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

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