OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

DsmcParcel.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 2009-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Class
00026     Foam::DsmcParcel
00027 
00028 Description
00029     DSMC parcel class
00030 
00031 SourceFiles
00032     DsmcParcelI.H
00033     DsmcParcel.C
00034     DsmcParcelIO.C
00035 
00036 \*---------------------------------------------------------------------------*/
00037 
00038 #ifndef DsmcParcel_H
00039 #define DsmcParcel_H
00040 
00041 #include "Particle.H"
00042 #include "IOstream.H"
00043 #include "autoPtr.H"
00044 #include "contiguous.H"
00045 #include "mathematicalConstants.H"
00046 
00047 #include "DsmcCloud.H"
00048 
00049 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00050 
00051 namespace Foam
00052 {
00053 
00054 template<class ParcelType>
00055 class DsmcParcel;
00056 
00057 // Forward declaration of friend functions
00058 
00059 template<class ParcelType>
00060 Ostream& operator<<
00061 (
00062     Ostream&,
00063     const DsmcParcel<ParcelType>&
00064 );
00065 
00066 /*---------------------------------------------------------------------------*\
00067                          Class DsmcParcel Declaration
00068 \*---------------------------------------------------------------------------*/
00069 
00070 template<class ParcelType>
00071 class DsmcParcel
00072 :
00073     public Particle<ParcelType>
00074 {
00075 public:
00076 
00077     //- Class to hold DSMC particle constant properties
00078     class constantProperties
00079     {
00080         // Private data
00081 
00082             //- Particle mass [kg] (constant)
00083             scalar mass_;
00084 
00085             //- Particle hard sphere diameter [m] (constant)
00086             scalar d_;
00087 
00088             //- Internal degrees of freedom
00089             scalar internalDegreesOfFreedom_;
00090 
00091             //- Viscosity index
00092             scalar omega_;
00093 
00094 
00095     public:
00096 
00097         // Constrcutors
00098 
00099             //- Null constructor, allows List of constantProperties to be
00100             //  created before the contents is initialised
00101             inline constantProperties();
00102 
00103             //- Constructor from dictionary
00104             inline constantProperties(const dictionary& dict);
00105 
00106 
00107         // Member functions
00108 
00109             //- Return const access to the particle density
00110             inline scalar mass() const;
00111 
00112             //- Return const access to the minimum particle mass
00113             inline scalar d() const;
00114 
00115             //- Return the reference total collision cross section
00116             inline scalar sigmaT() const;
00117 
00118             //- Return the internalDegreesOfFreedom
00119             inline scalar internalDegreesOfFreedom() const;
00120 
00121             //- Return the viscosity index
00122             inline scalar omega() const;
00123 
00124     };
00125 
00126 
00127     //- Class used to pass kinematic tracking data to the trackToFace function
00128     class trackData
00129     :
00130         public Particle<ParcelType>::trackData
00131     {
00132         // Private data
00133 
00134             //- Reference to the cloud containing this particle
00135             DsmcCloud<ParcelType>& cloud_;
00136 
00137 
00138     public:
00139 
00140         // Constructors
00141 
00142             //- Construct from components
00143             inline trackData
00144             (
00145                 DsmcCloud<ParcelType>& cloud
00146             );
00147 
00148 
00149         // Member functions
00150 
00151             //- Return access to the owner cloud
00152             inline DsmcCloud<ParcelType>& cloud();
00153     };
00154 
00155 
00156 protected:
00157 
00158     // Protected member data
00159 
00160         // Parcel properties
00161 
00162             //- Velocity of Parcel [m/s]
00163             vector U_;
00164 
00165             //- Internal energy of the Parcel, covering all non-translational
00166             // degrees of freedom [J]
00167             scalar Ei_;
00168 
00169             //- Parcel type id
00170             label typeId_;
00171 
00172 
00173 public:
00174 
00175     //- Runtime type information
00176     TypeName("DsmcParcel");
00177 
00178     friend class Cloud<ParcelType>;
00179 
00180 
00181     // Constructors
00182 
00183         //- Construct from components
00184         inline DsmcParcel
00185         (
00186             DsmcCloud<ParcelType>& owner,
00187             const vector& position,
00188             const vector& U,
00189             const scalar Ei,
00190             const label celli,
00191             const label typeId
00192         );
00193 
00194         //- Construct from Istream
00195         DsmcParcel
00196         (
00197             const Cloud<ParcelType>& c,
00198             Istream& is,
00199             bool readFields = true
00200         );
00201 
00202         //- Construct and return a clone
00203         autoPtr<ParcelType> clone() const
00204         {
00205             return autoPtr<ParcelType>(new DsmcParcel<ParcelType>(*this));
00206         }
00207 
00208 
00209     // Member Functions
00210 
00211         // Access
00212 
00213             //- Return type id
00214             inline label typeId() const;
00215 
00216             //- Return const access to velocity
00217             inline const vector& U() const;
00218 
00219             //- Return const access to internal energy
00220             inline scalar Ei() const;
00221 
00222         // Edit
00223 
00224             //- Return access to velocity
00225             inline vector& U();
00226 
00227             //- Return access to internal energy
00228             inline scalar& Ei();
00229 
00230 
00231         // Main calculation loop
00232 
00233             // Tracking
00234 
00235                 //- Move the parcel
00236                 template<class TrackData>
00237                 bool move(TrackData& td);
00238 
00239 
00240         // Patch interactions
00241 
00242             //- Overridable function to handle the particle hitting a patch
00243             //  Executed before other patch-hitting functions
00244             template<class TrackData>
00245             bool hitPatch
00246             (
00247                 const polyPatch&,
00248                 TrackData& td,
00249                 const label patchI
00250             );
00251 
00252             //- Overridable function to handle the particle hitting a
00253             //  processorPatch
00254             template<class TrackData>
00255             void hitProcessorPatch
00256             (
00257                 const processorPolyPatch&,
00258                 TrackData& td
00259             );
00260 
00261             //- Overridable function to handle the particle hitting a
00262             //  processorPatch without trackData
00263             void hitProcessorPatch
00264             (
00265                 const processorPolyPatch&,
00266                 int&
00267             );
00268 
00269             //- Overridable function to handle the particle hitting a wallPatch
00270             template<class TrackData>
00271             void hitWallPatch
00272             (
00273                 const wallPolyPatch&,
00274                 TrackData& td
00275             );
00276 
00277             //- Overridable function to handle the particle hitting a wallPatch
00278             //  without trackData
00279             void hitWallPatch
00280             (
00281                 const wallPolyPatch&,
00282                 int&
00283             );
00284 
00285             //- Overridable function to handle the particle hitting a polyPatch
00286             template<class TrackData>
00287             void hitPatch
00288             (
00289                 const polyPatch&,
00290                 TrackData& td
00291             );
00292 
00293             //- Overridable function to handle the particle hitting a polyPatch
00294             //- without trackData
00295             void hitPatch
00296             (
00297                 const polyPatch&,
00298                 int&
00299             );
00300 
00301             //- Transform the physical properties of the particle
00302             //  according to the given transformation tensor
00303             void transformProperties(const tensor& T);
00304 
00305             //- Transform the physical properties of the particle
00306             //  according to the given separation vector
00307             void transformProperties(const vector& separation);
00308 
00309 
00310         // I-O
00311 
00312             static void readFields(DsmcCloud<ParcelType>& c);
00313 
00314             static void writeFields(const DsmcCloud<ParcelType>& c);
00315 
00316 
00317     // Ostream Operator
00318 
00319         friend Ostream& operator<< <ParcelType>
00320         (
00321             Ostream&,
00322             const DsmcParcel<ParcelType>&
00323         );
00324 };
00325 
00326 
00327 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00328 
00329 } // End namespace Foam
00330 
00331 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00332 
00333 #include "DsmcParcelI.H"
00334 
00335 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00336 
00337 #define defineParcelTypeNameAndDebug(Type, DebugSwitch)                       \
00338     template<>                                                                \
00339     const Foam::word DsmcParcel<Type>::typeName(#Type);                       \
00340     template<>                                                                \
00341     int DsmcParcel<Type>::debug                                               \
00342     (                                                                         \
00343         Foam::debug::debugSwitch(#Type, DebugSwitch)                          \
00344     );
00345 
00346 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00347 
00348 #ifdef NoRepository
00349     #include "DsmcParcel.C"
00350 #endif
00351 
00352 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00353 
00354 #endif
00355 
00356 // ************************************************************************* //
00357 
Copyright © 2000-2009 OpenCFD Ltd