parallel running fixes
[OpenFOAM-1.6.x.git] / src / lagrangian / intermediate / submodels / Kinematic / InjectionModel / InjectionModel / InjectionModel.H
blobbd2521eff9d6159c9aea8c34797a487954bfe90c
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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
25 Class
26     Foam::InjectionModel
28 Description
29     Templated injection model class.
31     The injection model nominally describes the parcel:
32     - position
33     - diameter
34     - velocity
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).
43 SourceFiles
44     InjectionModel.C
45     NewInjectionModel.C
47 \*---------------------------------------------------------------------------*/
49 #ifndef InjectionModel_H
50 #define InjectionModel_H
52 #include "IOdictionary.H"
53 #include "autoPtr.H"
54 #include "runTimeSelectionTables.H"
56 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
58 namespace Foam
61 /*---------------------------------------------------------------------------*\
62                          Class InjectionModel Declaration
63 \*---------------------------------------------------------------------------*/
65 template<class CloudType>
66 class InjectionModel
68 public:
70     // Enumerations
72         //- Parcel basis representation options
73         //  i.e constant number of particles OR constant mass per parcel
74         enum parcelBasis
75         {
76             pbNumber,
77             pbMass
78         };
81 private:
83     // Private data
85         //- The cloud dictionary
86         const dictionary& dict_;
88         //- Reference to the owner cloud class
89         CloudType& owner_;
91         //- The coefficients dictionary
92         const dictionary coeffDict_;
95     // Private member functions
97         //- Read injector properties from previous run (if applicable)
98         void readProps();
100         //- Write injector properties
101         void writeProps();
104 protected:
106     // Protected data
108         //- Convenience typedef for parcel type
109         typedef typename CloudType::parcelType parcelType;
111         // Global injection properties
113             //- Start of injection [s]
114             const scalar SOI_;
116             //- Total volume of particles introduced by this injector [m^3]
117             //  - scaled to ensure massTotal is achieved
118             scalar volumeTotal_;
120             //- Total mass to inject [kg]
121             scalar massTotal_;
123             //- Total mass injected to date [kg]
124             scalar massInjected_;
127         // Counters
129             //- Number of injections counter
130             label nInjections_;
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]
142             scalar time0_;
144             //- Time at start of injection time step [s]
145             scalar timeStep0_;
148     // Protected member functions
150         //- Number of parcels to introduce over the time step relative to SOI
151         virtual label parcelsToInject
152         (
153             const scalar time0,
154             const scalar time1
155         ) const = 0;
157         //- Volume of parcels to introduce over the time step relative to SOI
158         virtual scalar volumeToInject
159         (
160             const scalar time0,
161             const scalar time1
162         ) const = 0;
164         //- Additional flag to identify whether or not injection of parcelI is
165         //  permitted
166         virtual bool validInjection(const label parcelI) = 0;
168         //- Determine properties for next time step/injection interval
169         virtual void prepareForNextTimeStep
170         (
171             const scalar time,
172             label& newParcels,
173             scalar& newVolume
174         );
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
183         (
184             const label parcels,
185             const scalar volume,
186             const scalar diameter,
187             const scalar rho
188         );
190         //- Post injection checks
191         virtual void postInjectCheck(const label parcelsAdded);
194 public:
196     //- Runtime type information
197     TypeName("InjectionModel");
199     //- Declare runtime constructor selection table
200     declareRunTimeSelectionTable
201     (
202         autoPtr,
203         InjectionModel,
204         dictionary,
205         (
206             const dictionary& dict,
207             CloudType& owner
208         ),
209         (dict, owner)
210     );
213     // Constructors
215         //- Construct null from owner
216         InjectionModel(CloudType& owner);
218         //- Construct from dictionary
219         InjectionModel
220         (
221             const dictionary& dict,
222             CloudType& owner,
223             const word& type
224         );
227     //- Destructor
228     virtual ~InjectionModel();
231     //- Selector
232     static autoPtr<InjectionModel<CloudType> > New
233     (
234         const dictionary& dict,
235         CloudType& owner
236     );
239     // Access
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;
254     // Member Functions
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;
277             // Counters
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
297             (
298                 const label parcelI,
299                 const label nParcels,
300                 const scalar time,
301                 vector& position,
302                 label& cellOwner
303             ) = 0;
305             //- Set the parcel properties
306             virtual void setProperties
307             (
308                 const label parcelI,
309                 const label nParcels,
310                 const scalar time,
311                 typename CloudType::parcelType& parcel
312             ) = 0;
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)                                         \
326                                                                               \
327     defineNamedTemplateTypeNameAndDebug(InjectionModel<CloudType>, 0);        \
328                                                                               \
329     defineTemplateRunTimeSelectionTable(InjectionModel<CloudType>, dictionary);
332 #define makeInjectionModelType(SS, CloudType, ParcelType)                     \
333                                                                               \
334     defineNamedTemplateTypeNameAndDebug(SS<CloudType<ParcelType> >, 0);       \
335                                                                               \
336     InjectionModel<CloudType<ParcelType> >::                                  \
337         adddictionaryConstructorToTable<SS<CloudType<ParcelType> > >          \
338             add##SS##CloudType##ParcelType##ConstructorToTable_;
341 #define makeInjectionModelThermoType(SS, CloudType, ParcelType, ThermoType)   \
342                                                                               \
343     defineNamedTemplateTypeNameAndDebug                                       \
344     (                                                                         \
345         SS<CloudType<ParcelType<ThermoType> > >,                              \
346         0                                                                     \
347     );                                                                        \
348                                                                               \
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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
362 #ifdef NoRepository
363 #   include "InjectionModel.C"
364 #endif
366 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
368 #endif
370 // ************************************************************************* //