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

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