1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 Templated injection model class.
31 The injection model nominally describes the parcel:
35 In this case, the fullyDescribed() flag should be set to 0 (false). When
36 the parcel is then added to the cloud, the remaining properties are
37 populated using values supplied in the constant properties.
39 If, however, all of a parcel's properties are described in the model, the
40 fullDescribed() flag should be set to 1 (true).
47 \*---------------------------------------------------------------------------*/
49 #ifndef InjectionModel_H
50 #define InjectionModel_H
52 #include "IOdictionary.H"
54 #include "runTimeSelectionTables.H"
56 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
61 /*---------------------------------------------------------------------------*\
62 Class InjectionModel Declaration
63 \*---------------------------------------------------------------------------*/
65 template<class CloudType>
72 //- Parcel basis representation options
73 // i.e constant number of particles OR constant mass per parcel
85 //- The cloud dictionary
86 const dictionary& dict_;
88 //- Reference to the owner cloud class
91 //- The coefficients dictionary
92 const dictionary coeffDict_;
95 // Private member functions
97 //- Read injector properties from previous run (if applicable)
100 //- Write injector properties
108 //- Convenience typedef for parcel type
109 typedef typename CloudType::parcelType parcelType;
111 // Global injection properties
113 //- Start of injection [s]
116 //- Total volume of particles introduced by this injector [m^3]
117 // - scaled to ensure massTotal is achieved
120 //- Total mass to inject [kg]
123 //- Total mass injected to date [kg]
124 scalar massInjected_;
129 //- Number of injections counter
132 //- Running counter of total number of parcels added
133 label parcelsAddedTotal_;
136 // Injection properties per Lagrangian time step
138 //- Parcel basis enumeration
139 parcelBasis parcelBasis_;
141 //- Continuous phase time at start of injection time step [s]
144 //- Time at start of injection time step [s]
148 // Protected member functions
150 //- Number of parcels to introduce over the time step relative to SOI
151 virtual label parcelsToInject
157 //- Volume of parcels to introduce over the time step relative to SOI
158 virtual scalar volumeToInject
164 //- Additional flag to identify whether or not injection of parcelI is
166 virtual bool validInjection(const label parcelI) = 0;
168 //- Determine properties for next time step/injection interval
169 virtual void prepareForNextTimeStep
176 //- Find the cell that contains the supplied position
177 // Will modify position slightly towards the owner cell centroid to
178 // ensure that it lies in a cell and not edge/face
179 virtual void findCellAtPosition(label& cellI, vector& position);
181 //- Set number of particles to inject given parcel properties
182 virtual scalar setNumberOfParticles
186 const scalar diameter,
190 //- Post injection checks
191 virtual void postInjectCheck(const label parcelsAdded);
196 //- Runtime type information
197 TypeName("InjectionModel");
199 //- Declare runtime constructor selection table
200 declareRunTimeSelectionTable
206 const dictionary& dict,
215 //- Construct null from owner
216 InjectionModel(CloudType& owner);
218 //- Construct from dictionary
221 const dictionary& dict,
228 virtual ~InjectionModel();
232 static autoPtr<InjectionModel<CloudType> > New
234 const dictionary& dict,
241 //- Return the owner cloud dictionary
242 inline const dictionary& dict() const;
244 //- Return const access the owner cloud object
245 inline const CloudType& owner() const;
247 //- Return non-const access the owner cloud object for manipulation
248 inline CloudType& owner();
250 //- Return the coefficients dictionary
251 inline const dictionary& coeffDict() const;
256 //- Flag to indicate whether model activates injection model
257 virtual bool active() const = 0;
260 // Global information
262 //- Return the start-of-injection time
263 inline scalar timeStart() const;
265 //- Return the total volume to be injected across the event
266 inline scalar volumeTotal() const;
268 //- Return mass of particles to introduce
269 inline scalar massTotal() const;
271 //- Return mass of particles injected (cumulative)
272 inline scalar massInjected() const;
274 //- Return the end-of-injection time
275 virtual scalar timeEnd() const = 0;
279 //- Return the number of injections
280 inline label nInjections() const;
282 //- Return the total number parcels added
283 inline label parcelsAddedTotal() const;
286 // Per-injection event functions
288 //- Main injection loop
289 template<class TrackData>
290 void inject(TrackData& td);
293 // Injection geometry
295 //- Set the injection position and owner cell
296 virtual void setPositionAndCell
299 const label nParcels,
305 //- Set the parcel properties
306 virtual void setProperties
309 const label nParcels,
311 typename CloudType::parcelType& parcel
314 //- Flag to identify whether model fully describes the parcel
315 virtual bool fullyDescribed() const = 0;
319 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
321 } // End namespace Foam
323 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
325 #define makeInjectionModel(CloudType) \
327 defineNamedTemplateTypeNameAndDebug(InjectionModel<CloudType>, 0); \
329 defineTemplateRunTimeSelectionTable(InjectionModel<CloudType>, dictionary);
332 #define makeInjectionModelType(SS, CloudType, ParcelType) \
334 defineNamedTemplateTypeNameAndDebug(SS<CloudType<ParcelType> >, 0); \
336 InjectionModel<CloudType<ParcelType> >:: \
337 adddictionaryConstructorToTable<SS<CloudType<ParcelType> > > \
338 add##SS##CloudType##ParcelType##ConstructorToTable_;
341 #define makeInjectionModelThermoType(SS, CloudType, ParcelType, ThermoType) \
343 defineNamedTemplateTypeNameAndDebug \
345 SS<CloudType<ParcelType<ThermoType> > >, \
349 InjectionModel<CloudType<ParcelType<ThermoType> > >:: \
350 adddictionaryConstructorToTable \
351 <SS<CloudType<ParcelType<ThermoType> > > > \
352 add##SS##CloudType##ParcelType##ThermoType##ConstructorToTable_;
356 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
358 #include "InjectionModelI.H"
360 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
363 # include "InjectionModel.C"
366 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
370 // ************************************************************************* //