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

InjectionModel.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::InjectionModel
00027 
00028 Description
00029     Templated injection model class.
00030 
00031     The injection model nominally describes the parcel:
00032     - position
00033     - diameter
00034     - velocity
00035     In this case, the fullyDescribed() flag should be set to 0 (false). When
00036     the parcel is then added to the cloud, the remaining properties are
00037     populated using values supplied in the constant properties.
00038 
00039     If, however, all of a parcel's properties are described in the model, the
00040     fullDescribed() flag should be set to 1 (true).
00041 
00042 
00043 SourceFiles
00044     InjectionModel.C
00045     NewInjectionModel.C
00046 
00047 \*---------------------------------------------------------------------------*/
00048 
00049 #ifndef InjectionModel_H
00050 #define InjectionModel_H
00051 
00052 #include "IOdictionary.H"
00053 #include "autoPtr.H"
00054 #include "runTimeSelectionTables.H"
00055 
00056 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00057 
00058 namespace Foam
00059 {
00060 
00061 /*---------------------------------------------------------------------------*\
00062                          Class InjectionModel Declaration
00063 \*---------------------------------------------------------------------------*/
00064 
00065 template<class CloudType>
00066 class InjectionModel
00067 {
00068 public:
00069 
00070     // Enumerations
00071 
00072         //- Parcel basis representation options
00073         //  i.e constant number of particles OR constant mass per parcel
00074         enum parcelBasis
00075         {
00076             pbNumber,
00077             pbMass
00078         };
00079 
00080 
00081 private:
00082 
00083     // Private data
00084 
00085         //- The cloud dictionary
00086         const dictionary& dict_;
00087 
00088         //- Reference to the owner cloud class
00089         CloudType& owner_;
00090 
00091         //- The coefficients dictionary
00092         const dictionary coeffDict_;
00093 
00094 
00095     // Private member functions
00096 
00097         //- Read injector properties from previous run (if applicable)
00098         void readProps();
00099 
00100         //- Write injector properties
00101         void writeProps();
00102 
00103 
00104 protected:
00105 
00106     // Protected data
00107 
00108         //- Convenience typedef for parcel type
00109         typedef typename CloudType::parcelType parcelType;
00110 
00111         // Global injection properties
00112 
00113             //- Start of injection [s]
00114             const scalar SOI_;
00115 
00116             //- Total volume of particles introduced by this injector [m^3]
00117             //  - scaled to ensure massTotal is achieved
00118             scalar volumeTotal_;
00119 
00120             //- Total mass to inject [kg]
00121             const scalar massTotal_;
00122 
00123             //- Total mass injected to date [kg]
00124             scalar massInjected_;
00125 
00126 
00127         // Counters
00128 
00129             //- Number of injections counter
00130             label nInjections_;
00131 
00132             //- Running counter of total number of parcels added
00133             label parcelsAddedTotal_;
00134 
00135 
00136         // Injection properties per Lagrangian time step
00137 
00138             //- Parcel basis enumeration
00139             parcelBasis parcelBasis_;
00140 
00141             //- Continuous phase time at start of injection time step [s]
00142             scalar time0_;
00143 
00144             //- Time at start of injection time step [s]
00145             scalar timeStep0_;
00146 
00147 
00148     // Protected member functions
00149 
00150         //- Number of parcels to introduce over the time step relative to SOI
00151         virtual label parcelsToInject
00152         (
00153             const scalar time0,
00154             const scalar time1
00155         ) const = 0;
00156 
00157         //- Volume of parcels to introduce over the time step relative to SOI
00158         virtual scalar volumeToInject
00159         (
00160             const scalar time0,
00161             const scalar time1
00162         ) const = 0;
00163 
00164         //- Additional flag to identify whether or not injection of parcelI is
00165         //  permitted
00166         virtual bool validInjection(const label parcelI) = 0;
00167 
00168         //- Determine properties for next time step/injection interval
00169         virtual void prepareForNextTimeStep
00170         (
00171             const scalar time,
00172             label& newParcels,
00173             scalar& newVolume
00174         );
00175 
00176         //- Find the cell that contains the supplied position
00177         //  Will modify position slightly towards the owner cell centroid to
00178         //  ensure that it lies in a cell and not edge/face
00179         virtual void findCellAtPosition(label& cellI, vector& position);
00180 
00181         //- Set number of particles to inject given parcel properties
00182         virtual scalar setNumberOfParticles
00183         (
00184             const label parcels,
00185             const scalar volume,
00186             const scalar diameter,
00187             const scalar rho
00188         );
00189 
00190         //- Post injection checks
00191         virtual void postInjectCheck(const label parcelsAdded);
00192 
00193 
00194 public:
00195 
00196     //- Runtime type information
00197     TypeName("InjectionModel");
00198 
00199     //- Declare runtime constructor selection table
00200     declareRunTimeSelectionTable
00201     (
00202         autoPtr,
00203         InjectionModel,
00204         dictionary,
00205         (
00206             const dictionary& dict,
00207             CloudType& owner
00208         ),
00209         (dict, owner)
00210     );
00211 
00212 
00213     // Constructors
00214 
00215         //- Construct null from owner
00216         InjectionModel(CloudType& owner);
00217 
00218         //- Construct from dictionary
00219         InjectionModel
00220         (
00221             const dictionary& dict,
00222             CloudType& owner,
00223             const word& type
00224         );
00225 
00226 
00227     //- Destructor
00228     virtual ~InjectionModel();
00229 
00230 
00231     //- Selector
00232     static autoPtr<InjectionModel<CloudType> > New
00233     (
00234         const dictionary& dict,
00235         CloudType& owner
00236     );
00237 
00238 
00239     // Access
00240 
00241         //- Return the owner cloud dictionary
00242         inline const dictionary& dict() const;
00243 
00244         //- Return const access the owner cloud object
00245         inline const CloudType& owner() const;
00246 
00247         //- Return non-const access the owner cloud object for manipulation
00248         inline CloudType& owner();
00249 
00250         //- Return the coefficients dictionary
00251         inline const dictionary& coeffDict() const;
00252 
00253 
00254     // Member Functions
00255 
00256         //- Flag to indicate whether model activates injection model
00257         virtual bool active() const = 0;
00258 
00259 
00260         // Global information
00261 
00262             //- Return the start-of-injection time
00263             inline scalar timeStart() const;
00264 
00265             //- Return the total volume to be injected across the event
00266             inline scalar volumeTotal() const;
00267 
00268             //- Return mass of particles to introduce
00269             inline scalar massTotal() const;
00270 
00271             //- Return mass of particles injected (cumulative)
00272             inline scalar massInjected() const;
00273 
00274             //- Return the end-of-injection time
00275             virtual scalar timeEnd() const = 0;
00276 
00277             // Counters
00278 
00279                 //- Return the number of injections
00280                 inline label nInjections() const;
00281 
00282                 //- Return the total number parcels added
00283                 inline label parcelsAddedTotal() const;
00284 
00285 
00286         // Per-injection event functions
00287 
00288             //- Main injection loop
00289             template<class TrackData>
00290             void inject(TrackData& td);
00291 
00292 
00293         // Injection geometry
00294 
00295             //- Set the injection position and owner cell
00296             virtual void setPositionAndCell
00297             (
00298                 const label parcelI,
00299                 const label nParcels,
00300                 const scalar time,
00301                 vector& position,
00302                 label& cellOwner
00303             ) = 0;
00304 
00305             //- Set the parcel properties
00306             virtual void setProperties
00307             (
00308                 const label parcelI,
00309                 const label nParcels,
00310                 const scalar time,
00311                 typename CloudType::parcelType& parcel
00312             ) = 0;
00313 
00314             //- Flag to identify whether model fully describes the parcel
00315             virtual bool fullyDescribed() const = 0;
00316 };
00317 
00318 
00319 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00320 
00321 } // End namespace Foam
00322 
00323 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00324 
00325 #define makeInjectionModel(CloudType)                                         \
00326                                                                               \
00327     defineNamedTemplateTypeNameAndDebug(InjectionModel<CloudType>, 0);        \
00328                                                                               \
00329     defineTemplateRunTimeSelectionTable(InjectionModel<CloudType>, dictionary);
00330 
00331 
00332 #define makeInjectionModelType(SS, CloudType, ParcelType)                     \
00333                                                                               \
00334     defineNamedTemplateTypeNameAndDebug(SS<CloudType<ParcelType> >, 0);       \
00335                                                                               \
00336     InjectionModel<CloudType<ParcelType> >::                                  \
00337         adddictionaryConstructorToTable<SS<CloudType<ParcelType> > >          \
00338             add##SS##CloudType##ParcelType##ConstructorToTable_;
00339 
00340 
00341 #define makeInjectionModelThermoType(SS, CloudType, ParcelType, ThermoType)   \
00342                                                                               \
00343     defineNamedTemplateTypeNameAndDebug                                       \
00344     (                                                                         \
00345         SS<CloudType<ParcelType<ThermoType> > >,                              \
00346         0                                                                     \
00347     );                                                                        \
00348                                                                               \
00349     InjectionModel<CloudType<ParcelType<ThermoType> > >::                     \
00350         adddictionaryConstructorToTable                                       \
00351         <SS<CloudType<ParcelType<ThermoType> > > >                            \
00352             add##SS##CloudType##ParcelType##ThermoType##ConstructorToTable_;
00353 
00354 
00355 
00356 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00357 
00358 #include "InjectionModelI.H"
00359 
00360 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00361 
00362 #ifdef NoRepository
00363 #   include "InjectionModel.C"
00364 #endif
00365 
00366 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00367 
00368 #endif
00369 
00370 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd