FreeFOAM The Cross-Platform CFD Toolkit
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) 1991-2010 OpenCFD Ltd.
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  NewInjectionModel.C
45 
46 \*---------------------------------------------------------------------------*/
47 
48 #ifndef InjectionModel_H
49 #define InjectionModel_H
50 
51 #include <OpenFOAM/IOdictionary.H>
52 #include <OpenFOAM/autoPtr.H>
54 
55 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
56 
57 namespace Foam
58 {
59 
60 /*---------------------------------------------------------------------------*\
61  Class InjectionModel Declaration
62 \*---------------------------------------------------------------------------*/
63 
64 template<class CloudType>
66 {
67 public:
68 
69  // Enumerations
70 
71  //- Parcel basis representation options
72  // i.e constant number of particles OR constant mass per parcel
74  {
77  };
78 
79 
80 private:
81 
82  // Private data
83 
84  //- The cloud dictionary
85  const dictionary& dict_;
86 
87  //- Reference to the owner cloud class
88  CloudType& owner_;
89 
90  //- The coefficients dictionary
91  const dictionary coeffDict_;
92 
93 
94  // Private member functions
95 
96  //- Read injector properties from previous run (if applicable)
97  void readProps();
98 
99  //- Write injector properties
100  void writeProps();
101 
102 
103 protected:
104 
105  // Protected data
106 
107  //- Convenience typedef for parcel type
108  typedef typename CloudType::parcelType parcelType;
109 
110  // Global injection properties
111 
112  //- Start of injection [s]
113  const scalar SOI_;
114 
115  //- Total volume of particles introduced by this injector [m^3]
116  // - scaled to ensure massTotal is achieved
117  scalar volumeTotal_;
118 
119  //- Total mass to inject [kg]
120  scalar massTotal_;
121 
122  //- Total mass injected to date [kg]
124 
125 
126  // Counters
127 
128  //- Number of injections counter
130 
131  //- Running counter of total number of parcels added
133 
134 
135  // Injection properties per Lagrangian time step
136 
137  //- Parcel basis enumeration
139 
140  //- Continuous phase time at start of injection time step [s]
141  scalar time0_;
142 
143  //- Time at start of injection time step [s]
144  scalar timeStep0_;
145 
146 
147  // Protected member functions
148 
149  //- Number of parcels to introduce over the time step relative to SOI
150  virtual label parcelsToInject
151  (
152  const scalar time0,
153  const scalar time1
154  ) const = 0;
155 
156  //- Volume of parcels to introduce over the time step relative to SOI
157  virtual scalar volumeToInject
158  (
159  const scalar time0,
160  const scalar time1
161  ) const = 0;
162 
163  //- Additional flag to identify whether or not injection of parcelI is
164  // permitted
165  virtual bool validInjection(const label parcelI) = 0;
166 
167  //- Determine properties for next time step/injection interval
168  virtual void prepareForNextTimeStep
169  (
170  const scalar time,
171  label& newParcels,
172  scalar& newVolume
173  );
174 
175  //- Find the cell that contains the supplied position
176  // Will modify position slightly towards the owner cell centroid to
177  // ensure that it lies in a cell and not edge/face
178  virtual void findCellAtPosition(label& cellI, vector& position);
179 
180  //- Set number of particles to inject given parcel properties
181  virtual scalar setNumberOfParticles
182  (
183  const label parcels,
184  const scalar volume,
185  const scalar diameter,
186  const scalar rho
187  );
188 
189  //- Post injection checks
190  virtual void postInjectCheck
191  (
192  const label parcelsAdded,
193  const scalar massAdded
194  );
195 
196 
197 public:
198 
199  //- Runtime type information
200  TypeName("InjectionModel");
201 
202  //- Declare runtime constructor selection table
204  (
205  autoPtr,
207  dictionary,
208  (
209  const dictionary& dict,
210  CloudType& owner
211  ),
212  (dict, owner)
213  );
214 
215 
216  // Constructors
217 
218  //- Construct null from owner
219  InjectionModel(CloudType& owner);
220 
221  //- Construct from dictionary
223  (
224  const dictionary& dict,
225  CloudType& owner,
226  const word& type
227  );
228 
229 
230  //- Destructor
231  virtual ~InjectionModel();
232 
233 
234  //- Selector
236  (
237  const dictionary& dict,
238  CloudType& owner
239  );
240 
241 
242  // Access
243 
244  //- Return the owner cloud dictionary
245  inline const dictionary& dict() const;
246 
247  //- Return const access the owner cloud object
248  inline const CloudType& owner() const;
249 
250  //- Return non-const access the owner cloud object for manipulation
251  inline CloudType& owner();
252 
253  //- Return the coefficients dictionary
254  inline const dictionary& coeffDict() const;
255 
256 
257  // Member Functions
258 
259  //- Flag to indicate whether model activates injection model
260  virtual bool active() const = 0;
261 
262 
263  // Global information
264 
265  //- Return the start-of-injection time
266  inline scalar timeStart() const;
267 
268  //- Return the total volume to be injected across the event
269  inline scalar volumeTotal() const;
270 
271  //- Return mass of particles to introduce
272  inline scalar massTotal() const;
273 
274  //- Return mass of particles injected (cumulative)
275  inline scalar massInjected() const;
276 
277  //- Return the end-of-injection time
278  virtual scalar timeEnd() const = 0;
279 
280  // Counters
281 
282  //- Return the number of injections
283  inline label nInjections() const;
284 
285  //- Return the total number parcels added
286  inline label parcelsAddedTotal() const;
287 
288 
289  // Per-injection event functions
290 
291  //- Main injection loop
292  template<class TrackData>
293  void inject(TrackData& td);
294 
295 
296  // Injection geometry
297 
298  //- Set the injection position and owner cell
299  virtual void setPositionAndCell
300  (
301  const label parcelI,
302  const label nParcels,
303  const scalar time,
304  vector& position,
305  label& cellOwner
306  ) = 0;
307 
308  //- Set the parcel properties
309  virtual void setProperties
310  (
311  const label parcelI,
312  const label nParcels,
313  const scalar time,
314  typename CloudType::parcelType& parcel
315  ) = 0;
316 
317  //- Flag to identify whether model fully describes the parcel
318  virtual bool fullyDescribed() const = 0;
319 };
320 
321 
322 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
323 
324 } // End namespace Foam
325 
326 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
327 
328 #define makeInjectionModel(CloudType) \
329  \
330  defineNamedTemplateTypeNameAndDebug(InjectionModel<CloudType>, 0); \
331  \
332  defineTemplateRunTimeSelectionTable(InjectionModel<CloudType>, dictionary);
333 
334 
335 #define makeInjectionModelType(SS, CloudType, ParcelType) \
336  \
337  defineNamedTemplateTypeNameAndDebug(SS<CloudType<ParcelType> >, 0); \
338  \
339  InjectionModel<CloudType<ParcelType> >:: \
340  adddictionaryConstructorToTable<SS<CloudType<ParcelType> > > \
341  add##SS##CloudType##ParcelType##ConstructorToTable_;
342 
343 
344 #define makeInjectionModelThermoType(SS, CloudType, ParcelType, ThermoType) \
345  \
346  defineNamedTemplateTypeNameAndDebug \
347  ( \
348  SS<CloudType<ParcelType<ThermoType> > >, \
349  0 \
350  ); \
351  \
352  InjectionModel<CloudType<ParcelType<ThermoType> > >:: \
353  adddictionaryConstructorToTable \
354  <SS<CloudType<ParcelType<ThermoType> > > > \
355  add##SS##CloudType##ParcelType##ThermoType##ConstructorToTable_;
356 
357 
358 
359 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
360 
361 #include "InjectionModelI.H"
362 
363 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
364 
365 #ifdef NoRepository
367 #endif
368 
369 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
370 
371 #endif
372 
373 // ************************ vim: set sw=4 sts=4 et: ************************ //