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

KinematicParcel.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) 1991-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::KinematicParcel
00026 
00027 Description
00028     Kinematic parcel class with one/two-way coupling with the continuous
00029     phase.
00030 
00031     Sub-models include:
00032     - drag
00033     - turbulent dispersion
00034     - wall interactions
00035 
00036 SourceFiles
00037     KinematicParcelI.H
00038     KinematicParcel.C
00039     KinematicParcelIO.C
00040 
00041 \*---------------------------------------------------------------------------*/
00042 
00043 #ifndef KinematicParcel_H
00044 #define KinematicParcel_H
00045 
00046 #include <lagrangian/Particle.H>
00047 #include <OpenFOAM/IOstream.H>
00048 #include <OpenFOAM/autoPtr.H>
00049 #include <finiteVolume/interpolationCellPoint.H>
00050 #include <OpenFOAM/contiguous.H>
00051 
00052 #include <lagrangianIntermediate/KinematicCloud_.H>
00053 
00054 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00055 
00056 namespace Foam
00057 {
00058 
00059 template<class ParcelType>
00060 class KinematicParcel;
00061 
00062 // Forward declaration of friend functions
00063 
00064 template<class ParcelType>
00065 Ostream& operator<<
00066 (
00067     Ostream&,
00068     const KinematicParcel<ParcelType>&
00069 );
00070 
00071 /*---------------------------------------------------------------------------*\
00072                          Class KinematicParcel Declaration
00073 \*---------------------------------------------------------------------------*/
00074 
00075 template<class ParcelType>
00076 class KinematicParcel
00077 :
00078     public Particle<ParcelType>
00079 {
00080 public:
00081 
00082     //- Class to hold kinematic particle constant properties
00083     class constantProperties
00084     {
00085         // Private data
00086 
00087             //- Constant properties dictionary
00088             const dictionary dict_;
00089 
00090             //- Minimum density [kg/m3]
00091             const scalar rhoMin_;
00092 
00093             //- Particle density [kg/m3] (constant)
00094             const scalar rho0_;
00095 
00096             //- Minimum particle mass [kg]
00097             const scalar minParticleMass_;
00098 
00099 
00100     public:
00101 
00102         //- Constructor
00103         constantProperties(const dictionary& parentDict);
00104 
00105         // Member functions
00106 
00107             //- Return const access to the constant properties dictionary
00108             inline const dictionary& dict() const;
00109 
00110             //- Return const access to the minimum density
00111             inline scalar rhoMin() const;
00112 
00113             //- Return const access to the particle density
00114             inline scalar rho0() const;
00115 
00116             //- Return const access to the minimum particle mass
00117             inline scalar minParticleMass() const;
00118     };
00119 
00120 
00121     //- Class used to pass kinematic tracking data to the trackToFace function
00122     class trackData
00123     :
00124         public Particle<ParcelType>::trackData
00125     {
00126         // Private data
00127 
00128             //- Reference to the cloud containing this particle
00129             KinematicCloud<ParcelType>& cloud_;
00130 
00131             //- Particle constant properties
00132             const constantProperties& constProps_;
00133 
00134 
00135             // Interpolators for continuous phase fields
00136 
00137                 //- Density interpolator
00138                 const interpolation<scalar>& rhoInterp_;
00139 
00140                 //- Velocity interpolator
00141                 const interpolation<vector>& UInterp_;
00142 
00143                 //- Dynamic viscosity interpolator
00144                 const interpolation<scalar>& muInterp_;
00145 
00146             //- Local gravitational or other body-force acceleration
00147             const vector& g_;
00148 
00149 
00150    public:
00151 
00152         // Constructors
00153 
00154            //- Construct from components
00155            inline trackData
00156             (
00157                 KinematicCloud<ParcelType>& cloud,
00158                 const constantProperties& constProps,
00159                 const interpolation<scalar>& rhoInterp,
00160                 const interpolation<vector>& UInterp,
00161                 const interpolation<scalar>& muInterp,
00162                 const vector& g
00163             );
00164 
00165 
00166         // Member functions
00167 
00168             //- Return access to the owner cloud
00169             inline KinematicCloud<ParcelType>& cloud();
00170 
00171             //- Return const access to the constant properties
00172             inline const constantProperties& constProps() const;
00173 
00174             //- Return conat access to the interpolator for continuous
00175             //  phase density field
00176             inline const interpolation<scalar>& rhoInterp() const;
00177 
00178             //- Return conat access to the interpolator for continuous
00179             //  phase velocity field
00180             inline const interpolation<vector>& UInterp() const;
00181 
00182             //- Return conat access to the interpolator for continuous
00183             //  phase dynamic viscosity field
00184             inline const interpolation<scalar>& muInterp() const;
00185 
00186             // Return const access to the gravitational acceleration vector
00187             inline const vector& g() const;
00188     };
00189 
00190 
00191 protected:
00192 
00193     // Protected data
00194 
00195         // Parcel properties
00196 
00197             //- Active flag - tracking inactive when active = false
00198             bool active_;
00199 
00200             //- Parcel type id
00201             label typeId_;
00202 
00203             //- Number of particles in Parcel
00204             scalar nParticle_;
00205 
00206             //- Diameter [m]
00207             scalar d_;
00208 
00209             //- Velocity of Parcel [m/s]
00210             vector U_;
00211 
00212             //- Density [kg/m3]
00213             scalar rho_;
00214 
00215             //- Time spent in turbulent eddy [s]
00216             scalar tTurb_;
00217 
00218             //- Turbulent velocity fluctuation [m/s]
00219             vector UTurb_;
00220 
00221 
00222         // Cell-based quantities
00223 
00224             //- Density [kg/m3]
00225             scalar rhoc_;
00226 
00227             //- Velocity [m/s]
00228             vector Uc_;
00229 
00230             //- Viscosity [Pa.s]
00231             scalar muc_;
00232 
00233 
00234     // Protected member functions
00235 
00236         //- Calculate new particle velocity
00237         template<class TrackData>
00238         const vector calcVelocity
00239         (
00240             TrackData& td,
00241             const scalar dt,           // timestep
00242             const label cellI,         // owner cell
00243             const scalar Re,           // Reynolds number
00244             const scalar mu,           // local carrier viscosity
00245             const scalar d,            // diameter
00246             const vector& U,           // velocity
00247             const scalar rho,          // density
00248             const scalar mass,         // mass
00249             const vector& Su,          // explicit particle momentum source
00250             vector& dUTrans            // momentum transfer to carrier
00251         ) const;
00252 
00253 
00254 public:
00255 
00256     // Static data members
00257 
00258         //- String representation of properties
00259         static string propHeader;
00260 
00261         //- Runtime type information
00262         TypeName("KinematicParcel");
00263 
00264 
00265     friend class Cloud<ParcelType>;
00266 
00267 
00268     // Constructors
00269 
00270         //- Construct from owner, position, and cloud owner
00271         //  Other properties initialised as null
00272         inline KinematicParcel
00273         (
00274             KinematicCloud<ParcelType>& owner,
00275             const vector& position,
00276             const label cellI
00277         );
00278 
00279         //- Construct from components
00280         inline KinematicParcel
00281         (
00282             KinematicCloud<ParcelType>& owner,
00283             const vector& position,
00284             const label cellI,
00285             const label typeId,
00286             const scalar nParticle0,
00287             const scalar d0,
00288             const vector& U0,
00289             const constantProperties& constProps
00290         );
00291 
00292         //- Construct from Istream
00293         KinematicParcel
00294         (
00295             const Cloud<ParcelType>& c,
00296             Istream& is,
00297             bool readFields = true
00298         );
00299 
00300         //- Construct as a copy
00301         KinematicParcel(const KinematicParcel& p);
00302 
00303         //- Construct and return a clone
00304         autoPtr<KinematicParcel> clone() const
00305         {
00306             return autoPtr<KinematicParcel>(new KinematicParcel(*this));
00307         }
00308 
00309 
00310     // Member Functions
00311 
00312         // Access
00313 
00314             //- Return const access to active flag
00315             inline bool active() const;
00316 
00317             //- Return const access to type id
00318             inline label typeId() const;
00319 
00320             //- Return const access to number of particles
00321             inline scalar nParticle() const;
00322 
00323             //- Return const access to diameter
00324             inline scalar d() const;
00325 
00326             //- Return const access to velocity
00327             inline const vector& U() const;
00328 
00329             //- Return const access to density
00330             inline scalar rho() const;
00331 
00332             //- Return const access to time spent in turbulent eddy
00333             inline scalar tTurb() const;
00334 
00335             //- Return const access to turbulent velocity fluctuation
00336             inline const vector& UTurb() const;
00337 
00338 
00339         // Edit
00340 
00341             //- Return const access to active flag
00342             inline bool& active();
00343 
00344             //- Return access to type id
00345             inline label typeId();
00346 
00347             //- Return access to number of particles
00348             inline scalar& nParticle();
00349 
00350             //- Return access to diameter
00351             inline scalar& d();
00352 
00353             //- Return access to velocity
00354             inline vector& U();
00355 
00356             //- Return access to density
00357             inline scalar& rho();
00358 
00359             //- Return access to time spent in turbulent eddy
00360             inline scalar& tTurb();
00361 
00362             //- Return access to turbulent velocity fluctuation
00363             inline vector& UTurb();
00364 
00365 
00366         // Helper functions
00367 
00368             //- The nearest distance to a wall that
00369             //  the particle can be in the n direction
00370             inline scalar wallImpactDistance(const vector& n) const;
00371 
00372             //- Return the index of the face to be used in the interpolation
00373             //  routine
00374             inline label faceInterpolation() const;
00375 
00376             //- Cell owner mass
00377             inline scalar massCell(const label cellI) const;
00378 
00379             //- Particle mass
00380             inline scalar mass() const;
00381 
00382             //- Particle volume
00383             inline scalar volume() const;
00384 
00385             //- Particle volume for a given diameter
00386             inline scalar volume(const scalar d) const;
00387 
00388             //- Particle projected area
00389             inline scalar areaP() const;
00390 
00391             //- Projected area for given diameter
00392             inline scalar areaP(const scalar d) const;
00393 
00394             //- Particle surface area
00395             inline scalar areaS() const;
00396 
00397             //- Surface area for given diameter
00398             inline scalar areaS(const scalar d) const;
00399 
00400             //- Reynolds number
00401             inline scalar Re
00402             (
00403                 const vector& U,        // particle velocity
00404                 const scalar d,         // particle diameter
00405                 const scalar rhoc,      // carrier density
00406                 const scalar muc        // carrier dynamic viscosity
00407             ) const;
00408 
00409 
00410         // Main calculation loop
00411 
00412             //- Set cell values
00413             template<class TrackData>
00414             void setCellValues
00415             (
00416                 TrackData& td,
00417                 const scalar dt,
00418                 const label cellI
00419             );
00420 
00421             //- Correct cell values using latest transfer information
00422             template<class TrackData>
00423             void cellValueSourceCorrection
00424             (
00425                 TrackData& td,
00426                 const scalar dt,
00427                 const label cellI
00428             );
00429 
00430             //- Update parcel properties over the time interval
00431             template<class TrackData>
00432             void calc
00433             (
00434                 TrackData& td,
00435                 const scalar dt,
00436                 const label cellI
00437             );
00438 
00439 
00440         // Tracking
00441 
00442             //- Move the parcel
00443             template<class TrackData>
00444             bool move(TrackData& td);
00445 
00446 
00447         // Patch interactions
00448 
00449             //- Overridable function to handle the particle hitting a patch
00450             //  Executed before other patch-hitting functions
00451             template<class TrackData>
00452             bool hitPatch
00453             (
00454                 const polyPatch& p,
00455                 TrackData& td,
00456                 const label patchI
00457             );
00458 
00459 
00460             //- Overridable function to handle the particle hitting a patch
00461             //  Executed before other patch-hitting functions without trackData
00462             bool hitPatch
00463             (
00464                 const polyPatch& p,
00465                 int& td,
00466                 const label patchI
00467             );
00468 
00469 
00470             //- Overridable function to handle the particle hitting a
00471             //  processorPatch
00472             template<class TrackData>
00473             void hitProcessorPatch
00474             (
00475                 const processorPolyPatch&,
00476                 TrackData& td
00477             );
00478 
00479             //- Overridable function to handle the particle hitting a
00480             //  processorPatch without trackData
00481             void hitProcessorPatch
00482             (
00483                 const processorPolyPatch&,
00484                 int&
00485             );
00486 
00487             //- Overridable function to handle the particle hitting a wallPatch
00488             template<class TrackData>
00489             void hitWallPatch
00490             (
00491                 const wallPolyPatch&,
00492                 TrackData& td
00493             );
00494 
00495             //- Overridable function to handle the particle hitting a wallPatch
00496             //  without trackData
00497             void hitWallPatch
00498             (
00499                 const wallPolyPatch&,
00500                 int&
00501             );
00502 
00503             //- Overridable function to handle the particle hitting a polyPatch
00504             template<class TrackData>
00505             void hitPatch
00506             (
00507                 const polyPatch&,
00508                 TrackData& td
00509             );
00510 
00511             //- Overridable function to handle the particle hitting a polyPatch
00512             //- without trackData
00513             void hitPatch
00514             (
00515                 const polyPatch&,
00516                 int&
00517             );
00518 
00519             //- Transform the physical properties of the particle
00520             //  according to the given transformation tensor
00521             void transformProperties(const tensor& T);
00522 
00523             //- Transform the physical properties of the particle
00524             //  according to the given separation vector
00525             void transformProperties(const vector& separation);
00526 
00527 
00528         // I-O
00529 
00530             //- Read
00531             static void readFields(Cloud<ParcelType>& c);
00532 
00533             //- Write
00534             static void writeFields(const Cloud<ParcelType>& c);
00535 
00536 
00537     // Ostream Operator
00538 
00539         friend Ostream& operator<< <ParcelType>
00540         (
00541             Ostream&,
00542             const KinematicParcel<ParcelType>&
00543         );
00544 };
00545 
00546 
00547 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00548 
00549 } // End namespace Foam
00550 
00551 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00552 
00553 #include <lagrangianIntermediate/KinematicParcelI.H>
00554 
00555 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00556 
00557 #define defineParcelTypeNameAndDebug(Type, DebugSwitch)                       \
00558     template<>                                                                \
00559     const Foam::word KinematicParcel<Type>::typeName(#Type);                  \
00560     template<>                                                                \
00561     int KinematicParcel<Type>::debug                                          \
00562     (                                                                         \
00563         Foam::debug::debugSwitch(#Type, DebugSwitch)                          \
00564     );
00565 
00566 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00567 
00568 #ifdef NoRepository
00569     #include <lagrangianIntermediate/KinematicParcel.C>
00570 #endif
00571 
00572 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00573 
00574 #endif
00575 
00576 // ************************ vim: set sw=4 sts=4 et: ************************ //
00577 
00578 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines