InjectionModel.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
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
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::InjectionModel
26 
27 Description
28  Templated injection model class.
29 
30  The injection model nominally describes the parcel:
31  - position
32  - diameter
33  - velocity
34  In this case, the fullyDescribed() flag should be set to 0 (false). When
35  the parcel is then added to the cloud, the remaining properties are
36  populated using values supplied in the constant properties.
37 
38  If, however, all of a parcel's properties are described in the model, the
39  fullDescribed() flag should be set to 1 (true).
40 
41 
42 SourceFiles
43  InjectionModel.C
44  InjectionModelNew.C
45 
46 \*---------------------------------------------------------------------------*/
47 
48 #ifndef InjectionModel_H
49 #define InjectionModel_H
50 
51 #include "IOdictionary.H"
52 #include "autoPtr.H"
53 #include "runTimeSelectionTables.H"
54 #include "CloudSubModelBase.H"
55 #include "vector.H"
56 #include "TimeDataEntry.H"
57 
58 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
59 
60 namespace Foam
61 {
62 
63 /*---------------------------------------------------------------------------*\
64  Class InjectionModel Declaration
65 \*---------------------------------------------------------------------------*/
66 
67 template<class CloudType>
68 class InjectionModel
69 :
70  public CloudSubModelBase<CloudType>
71 {
72 public:
73 
74  //- Convenience typedef for parcelType
75  typedef typename CloudType::parcelType parcelType;
76 
77 
78  // Enumerations
79 
80  //- Parcel basis representation options
81  // i.e constant number of particles OR constant mass per parcel
82  enum parcelBasis
83  {
86  pbFixed
87  };
88 
89 
90 protected:
91 
92  // Protected data
93 
94  // Global injection properties
95 
96  //- Start of injection [s]
97  scalar SOI_;
98 
99  //- Total volume of particles introduced by this injector [m^3]
100  // - scaled to ensure massTotal is achieved
101  scalar volumeTotal_;
102 
103  //- Total mass to inject [kg]
104  scalar massTotal_;
105 
106  //- Mass flow rate profile for steady calculations
108 
109  //- Total mass injected to date [kg]
110  scalar massInjected_;
111 
112 
113  // Counters
114 
115  //- Number of injections counter
117 
118  //- Running counter of total number of parcels added
120 
121 
122  // Injection properties per Lagrangian time step
123 
124  //- Parcel basis enumeration
126 
127  //- nParticle to assign to parcels when the 'fixed' basis
128  // is selected
129  scalar nParticleFixed_;
130 
131  //- Continuous phase time at start of injection time step [s]
132  scalar time0_;
133 
134  //- Time at start of injection time step [s]
135  scalar timeStep0_;
136 
137  //- Volume that should have been injected, but would lead to
138  // less than 1 particle per parcel
139  scalar delayedVolume_;
140 
141  //- Optional injector ID
143 
144 
145  // Protected Member Functions
146 
147  //- Additional flag to identify whether or not injection of parcelI is
148  // permitted
149  virtual bool validInjection(const label parcelI) = 0;
150 
151  //- Determine properties for next time step/injection interval
152  virtual bool prepareForNextTimeStep
153  (
154  const scalar time,
155  label& newParcels,
156  scalar& newVolumeFraction
157  );
158 
159  //- Find the cell that contains the supplied position
160  // Will modify position slightly towards the owner cell centroid to
161  // ensure that it lies in a cell and not edge/face
162  virtual bool findCellAtPosition
163  (
164  label& cellI,
165  label& tetFaceI,
166  label& tetPtI,
167  vector& position,
168  bool errorOnNotFound = true
169  );
170 
171  //- Set number of particles to inject given parcel properties
172  virtual scalar setNumberOfParticles
173  (
174  const label parcels,
175  const scalar volumeFraction,
176  const scalar diameter,
177  const scalar rho
178  );
179 
180  //- Post injection checks
181  virtual void postInjectCheck
182  (
183  const label parcelsAdded,
184  const scalar massAdded
185  );
186 
187 
188 public:
189 
190  //- Runtime type information
191  TypeName("injectionModel");
192 
193  //- Declare runtime constructor selection table
195  (
196  autoPtr,
198  dictionary,
199  (
200  const dictionary& dict,
201  CloudType& owner,
202  const word& modelType
203  ),
204  (dict, owner, modelType)
205  );
206 
207 
208  // Constructors
209 
210  //- Construct null from owner
212 
213  //- Construct from dictionary
215  (
216  const dictionary& dict,
217  CloudType& owner,
218  const word& modelName,
219  const word& modelType
220  );
221 
222  //- Construct copy
224 
225  //- Construct and return a clone
226  virtual autoPtr<InjectionModel<CloudType> > clone() const = 0;
227 
228 
229  //- Destructor
230  virtual ~InjectionModel();
231 
232 
233  // Selectors
234 
235  //- Selector with lookup from dictionary
237  (
238  const dictionary& dict,
240  );
241 
242  //- Selector with name and type
244  (
245  const dictionary& dict,
246  const word& modelName,
247  const word& modelType,
249  );
250 
251 
252  // Member Functions
253 
254  // Mapping
255 
256  //- Update mesh
257  virtual void updateMesh();
258 
259 
260  // Global information
261 
262  //- Return the start-of-injection time
263  inline scalar timeStart() const;
264 
265  //- Return the total volume to be injected across the event
266  inline scalar volumeTotal() const;
267 
268  //- Return mass of particles to introduce
269  inline scalar massTotal() const;
270 
271  //- Return mass of particles injected (cumulative)
272  inline scalar massInjected() const;
273 
274  //- Return the end-of-injection time
275  virtual scalar timeEnd() const = 0;
276 
277  //- Number of parcels to introduce relative to SOI
278  virtual label parcelsToInject
279  (
280  const scalar time0,
281  const scalar time1
282  ) = 0;
283 
284  //- Volume of parcels to introduce relative to SOI
285  virtual scalar volumeToInject
286  (
287  const scalar time0,
288  const scalar time1
289  ) = 0;
290 
291  //- Return the average parcel mass over the injection period
292  virtual scalar averageParcelMass();
293 
294 
295  // Counters
296 
297  //- Return the number of injections
298  inline label nInjections() const;
299 
300  //- Return the total number parcels added
301  inline label parcelsAddedTotal() const;
302 
303 
304  // Per-injection event functions
305 
306  //- Main injection loop
307  template<class TrackData>
308  void inject(TrackData& td);
309 
310  //- Main injection loop - steady-state
311  template<class TrackData>
312  void injectSteadyState(TrackData& td, const scalar trackTime);
313 
314 
315  // Injection geometry
316 
317  //- Set the injection position and owner cell, tetFace and tetPt
318  virtual void setPositionAndCell
319  (
320  const label parcelI,
321  const label nParcels,
322  const scalar time,
323  vector& position,
324  label& cellOwner,
325  label& tetFaceI,
326  label& tetPtI
327  ) = 0;
328 
329  //- Set the parcel properties
330  virtual void setProperties
331  (
332  const label parcelI,
333  const label nParcels,
334  const scalar time,
335  parcelType& parcel
336  ) = 0;
337 
338  //- Flag to identify whether model fully describes the parcel
339  virtual bool fullyDescribed() const = 0;
340 
341 
342  // I-O
343 
344  //- Write injection info to stream
345  virtual void info(Ostream& os);
346 };
347 
348 
349 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
350 
351 } // End namespace Foam
352 
353 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
354 
355 #define makeInjectionModel(CloudType) \
356  \
357  typedef Foam::CloudType::kinematicCloudType kinematicCloudType; \
358  defineNamedTemplateTypeNameAndDebug \
359  ( \
360  Foam::InjectionModel<kinematicCloudType>, \
361  0 \
362  ); \
363  \
364  namespace Foam \
365  { \
366  defineTemplateRunTimeSelectionTable \
367  ( \
368  InjectionModel<kinematicCloudType>, \
369  dictionary \
370  ); \
371  }
372 
373 
374 #define makeInjectionModelType(SS, CloudType) \
375  \
376  typedef Foam::CloudType::kinematicCloudType kinematicCloudType; \
377  defineNamedTemplateTypeNameAndDebug(Foam::SS<kinematicCloudType>, 0); \
378  \
379  Foam::InjectionModel<kinematicCloudType>:: \
380  adddictionaryConstructorToTable<Foam::SS<kinematicCloudType> > \
381  add##SS##CloudType##kinematicCloudType##ConstructorToTable_;
382 
383 
384 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
385 
386 #include "InjectionModelI.H"
387 
388 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
389 
390 #ifdef NoRepository
391 # include "InjectionModel.C"
392 #endif
393 
394 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
395 
396 #endif
397 
398 // ************************************************************************* //
Foam::InjectionModel::validInjection
virtual bool validInjection(const label parcelI)=0
Additional flag to identify whether or not injection of parcelI is.
Foam::InjectionModel::massTotal
scalar massTotal() const
Return mass of particles to introduce.
Definition: InjectionModelI.H:45
Foam::InjectionModel::info
virtual void info(Ostream &os)
Write injection info to stream.
Definition: InjectionModel.C:645
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::InjectionModel::parcelsAddedTotal
label parcelsAddedTotal() const
Return the total number parcels added.
Definition: InjectionModelI.H:66
Foam::InjectionModel::InjectionModel
InjectionModel(CloudType &owner)
Construct null from owner.
Definition: InjectionModel.C:253
Foam::InjectionModel::updateMesh
virtual void updateMesh()
Update mesh.
Definition: InjectionModel.C:389
InjectionModelI.H
Foam::InjectionModel
Templated injection model class.
Definition: InjectionModel.H:67
Foam::CloudSubModelBase
Base class for cloud sub-models.
Definition: CloudSubModelBase.H:49
Foam::InjectionModel::prepareForNextTimeStep
virtual bool prepareForNextTimeStep(const scalar time, label &newParcels, scalar &newVolumeFraction)
Determine properties for next time step/injection interval.
Definition: InjectionModel.C:37
Foam::CloudSubModelBase::owner
const CloudType & owner() const
Return const access to the owner cloud.
Definition: CloudSubModelBase.C:103
Foam::InjectionModel::massInjected_
scalar massInjected_
Total mass injected to date [kg].
Definition: InjectionModel.H:109
Foam::InjectionModel::parcelsToInject
virtual label parcelsToInject(const scalar time0, const scalar time1)=0
Number of parcels to introduce relative to SOI.
Foam::InjectionModel::setNumberOfParticles
virtual scalar setNumberOfParticles(const label parcels, const scalar volumeFraction, const scalar diameter, const scalar rho)
Set number of particles to inject given parcel properties.
Definition: InjectionModel.C:178
Foam::subModelBase::modelName
const word & modelName() const
Return const access to the name of the sub-model.
Definition: subModelBase.C:104
Foam::InjectionModel::delayedVolume_
scalar delayedVolume_
Volume that should have been injected, but would lead to.
Definition: InjectionModel.H:138
Foam::InjectionModel::volumeTotal_
scalar volumeTotal_
Total volume of particles introduced by this injector [m^3].
Definition: InjectionModel.H:100
Foam::InjectionModel::timeStep0_
scalar timeStep0_
Time at start of injection time step [s].
Definition: InjectionModel.H:134
Foam::InjectionModel::injectorID_
label injectorID_
Optional injector ID.
Definition: InjectionModel.H:141
Foam::TimeDataEntry< scalar >
Foam::InjectionModel::nInjections
label nInjections() const
Return the number of injections.
Definition: InjectionModelI.H:59
Foam::InjectionModel::timeStart
scalar timeStart() const
Return the start-of-injection time.
Definition: InjectionModelI.H:31
Foam::InjectionModel::massFlowRate_
TimeDataEntry< scalar > massFlowRate_
Mass flow rate profile for steady calculations.
Definition: InjectionModel.H:106
Foam::InjectionModel::fullyDescribed
virtual bool fullyDescribed() const =0
Flag to identify whether model fully describes the parcel.
Foam::InjectionModel::pbNumber
@ pbNumber
Definition: InjectionModel.H:83
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::subModelBase::dict
const dictionary & dict() const
Return const access to the cloud dictionary.
Definition: subModelBase.C:110
CloudSubModelBase.H
Foam::InjectionModel::clone
virtual autoPtr< InjectionModel< CloudType > > clone() const =0
Construct and return a clone.
Foam::InjectionModel::massInjected
scalar massInjected() const
Return mass of particles injected (cumulative)
Definition: InjectionModelI.H:52
Foam::InjectionModel::parcelBasis
parcelBasis
Parcel basis representation options.
Definition: InjectionModel.H:81
Foam::InjectionModel::time0_
scalar time0_
Continuous phase time at start of injection time step [s].
Definition: InjectionModel.H:131
Foam::InjectionModel::volumeToInject
virtual scalar volumeToInject(const scalar time0, const scalar time1)=0
Volume of parcels to introduce relative to SOI.
Foam::DSMCCloud
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:68
Foam::InjectionModel::postInjectCheck
virtual void postInjectCheck(const label parcelsAdded, const scalar massAdded)
Post injection checks.
Definition: InjectionModel.C:221
Foam::InjectionModel::averageParcelMass
virtual scalar averageParcelMass()
Return the average parcel mass over the injection period.
Definition: InjectionModel.C:396
TimeDataEntry.H
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::InjectionModel::massTotal_
scalar massTotal_
Total mass to inject [kg].
Definition: InjectionModel.H:103
Foam::InjectionModel::pbMass
@ pbMass
Definition: InjectionModel.H:84
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::InjectionModel::inject
void inject(TrackData &td)
Main injection loop.
Definition: InjectionModel.C:414
Foam::InjectionModel::parcelsAddedTotal_
label parcelsAddedTotal_
Running counter of total number of parcels added.
Definition: InjectionModel.H:118
Foam::subModelBase::modelType
const word & modelType() const
Return const access to the sub-model type.
Definition: subModelBase.C:122
rho
rho
Definition: pEqn.H:3
IOdictionary.H
Foam::autoPtr
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
Foam::InjectionModel::findCellAtPosition
virtual bool findCellAtPosition(label &cellI, label &tetFaceI, label &tetPtI, vector &position, bool errorOnNotFound=true)
Find the cell that contains the supplied position.
Definition: InjectionModel.C:93
runTimeSelectionTables.H
Macros to ease declaration of run-time selection tables.
Foam::InjectionModel::parcelType
CloudType::parcelType parcelType
Convenience typedef for parcelType.
Definition: InjectionModel.H:74
Foam::Vector< scalar >
Foam::InjectionModel::pbFixed
@ pbFixed
Definition: InjectionModel.H:85
Foam::InjectionModel::~InjectionModel
virtual ~InjectionModel()
Destructor.
Definition: InjectionModel.C:382
Foam::InjectionModel::SOI_
scalar SOI_
Start of injection [s].
Definition: InjectionModel.H:96
vector.H
Foam::InjectionModel::setProperties
virtual void setProperties(const label parcelI, const label nParcels, const scalar time, parcelType &parcel)=0
Set the parcel properties.
Foam::InjectionModel::volumeTotal
scalar volumeTotal() const
Return the total volume to be injected across the event.
Definition: InjectionModelI.H:38
Foam::DSMCCloud::parcelType
ParcelType parcelType
Type of parcel the cloud was instantiated for.
Definition: DSMCCloud.H:217
Foam::InjectionModel::declareRunTimeSelectionTable
declareRunTimeSelectionTable(autoPtr, InjectionModel, dictionary,(const dictionary &dict, CloudType &owner, const word &modelType),(dict, owner, modelType))
Declare runtime constructor selection table.
Foam::InjectionModel::timeEnd
virtual scalar timeEnd() const =0
Return the end-of-injection time.
Foam::InjectionModel::TypeName
TypeName("injectionModel")
Runtime type information.
Foam::InjectionModel::nInjections_
label nInjections_
Number of injections counter.
Definition: InjectionModel.H:115
Foam::InjectionModel::New
static autoPtr< InjectionModel< CloudType > > New(const dictionary &dict, CloudType &owner)
Selector with lookup from dictionary.
Definition: InjectionModelNew.C:33
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::InjectionModel::parcelBasis_
parcelBasis parcelBasis_
Parcel basis enumeration.
Definition: InjectionModel.H:124
InjectionModel.C
Foam::InjectionModel::injectSteadyState
void injectSteadyState(TrackData &td, const scalar trackTime)
Main injection loop - steady-state.
Definition: InjectionModel.C:544
Foam::InjectionModel::nParticleFixed_
scalar nParticleFixed_
nParticle to assign to parcels when the 'fixed' basis
Definition: InjectionModel.H:128
Foam::InjectionModel::setPositionAndCell
virtual void setPositionAndCell(const label parcelI, const label nParcels, const scalar time, vector &position, label &cellOwner, label &tetFaceI, label &tetPtI)=0
Set the injection position and owner cell, tetFace and tetPt.
autoPtr.H