FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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