CompositionModel.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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::CompositionModel
29 
30 Group
31  grpLagrangianIntermediateCompositionSubModels
32 
33 Description
34  Templated reacting parcel composition model class
35  Consists of carrier species (via thermo package), and additional liquids
36  and solids
37 
38 SourceFiles
39  CompositionModel.C
40  CompositionModelNew.C
41 
42 \*---------------------------------------------------------------------------*/
43 
44 #ifndef CompositionModel_H
45 #define CompositionModel_H
46 
47 #include "CloudSubModelBase.H"
48 #include "IOdictionary.H"
49 #include "autoPtr.H"
50 #include "runTimeSelectionTables.H"
51 
52 #include "PtrList.H"
53 #include "SLGThermo.H"
54 
55 #include "phasePropertiesList.H"
56 
57 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
58 
59 namespace Foam
60 {
61 
62 /*---------------------------------------------------------------------------*\
63  Class CompositionModel Declaration
64 \*---------------------------------------------------------------------------*/
65 
66 template<class CloudType>
67 class CompositionModel
68 :
69  public CloudSubModelBase<CloudType>
70 {
71  // Private data
72 
73  //- Reference to the thermo database
74  const SLGThermo& thermo_;
75 
76  //- List of phase properties
77  phasePropertiesList phaseProps_;
78 
79 
80 public:
81 
82  //- Runtime type information
83  TypeName("compositionModel");
84 
85  //- Declare runtime constructor selection table
87  (
88  autoPtr,
90  dictionary,
91  (
92  const dictionary& dict,
93  CloudType& owner
94  ),
95  (dict, owner)
96  );
97 
98 
99  // Constructors
100 
101  //- Construct null from owner
102  CompositionModel(CloudType& owner);
103 
104  //- Construct from dictionary
106  (
107  const dictionary& dict,
108  CloudType& owner,
109  const word& type
110  );
111 
112  //- Construct copy
113  CompositionModel(const CompositionModel<CloudType>& cm);
114 
115  //- Construct and return a clone
116  virtual autoPtr<CompositionModel<CloudType>> clone() const = 0;
117 
118 
119  //- Destructor
120  virtual ~CompositionModel();
121 
122 
123  //- Selector
124  static autoPtr<CompositionModel<CloudType>> New
125  (
126  const dictionary& dict,
127  CloudType& owner
128  );
129 
130 
131  // Member Functions
132 
133  // Access
134 
135  //- Return the thermo database
136  const SLGThermo& thermo() const;
137 
138 
139  // Composition lists
140 
141  //- Return the carrier components (wrapper function)
142  const basicSpecieMixture& carrier() const;
143 
144  //- Return the global (additional) liquids
145  const liquidMixtureProperties& liquids() const;
146 
147  //- Return the global (additional) solids
148  const solidMixtureProperties& solids() const;
149 
150  //- Return the list of phase properties
151  const phasePropertiesList& phaseProps() const;
152 
153  //- Return the number of phases
154  label nPhase() const;
155 
156 
157  // Phase properties
158 
159  //- Return the list of phase type names
160  // If only 1 phase, return the component names of that phase
161  const wordList& phaseTypes() const;
162 
163  //- Return the list of state labels (s), (l), (g) etc.
164  const wordList& stateLabels() const;
165 
166  //- Return the list of component names for phaseI
167  const wordList& componentNames(const label phaseI) const;
168 
169  //- Return global id of component cmptName in carrier thermo
170  label carrierId
171  (
172  const word& cmptName,
173  const bool allowNotFound = false
174  ) const;
175 
176  //- Return local id of component cmptName in phase phaseI
177  label localId
178  (
179  const label phaseI,
180  const word& cmptName,
181  const bool allowNotFound = false
182  ) const;
183 
184  //- Return carrier id of component given local id
185  label localToCarrierId
186  (
187  const label phaseI,
188  const label id,
189  const bool allowNotFound = false
190  ) const;
191 
192  //- Return the list of phase phaseI mass fractions
193  const scalarField& Y0(const label phaseI) const;
194 
195  //- Return the list of phase phaseI volume fractions fractions
196  // based on supplied mass fractions Y
197  tmp<scalarField> X
198  (
199  const label phaseI,
200  const scalarField& Y
201  ) const;
202 
203 
204  // Mixture properties
205 
206  //- Return the list of mixture mass fractions
207  // If only 1 phase, return component fractions of that phase
208  virtual const scalarField& YMixture0() const = 0;
209 
210  // Indices of gas, liquid and solid phases in phase properties
211  // list - returns -1 if not applicable
212 
213  //- Gas id
214  virtual label idGas() const = 0;
215 
216  //- Liquid id
217  virtual label idLiquid() const = 0;
218 
219  //- Solid id
220  virtual label idSolid() const = 0;
221 
222 
223  // Evaluation
224 
225  //- Return total enthalpy for the phase phaseI
226  virtual scalar H
227  (
228  const label phaseI,
229  const scalarField& Y,
230  const scalar p,
231  const scalar T
232  ) const;
233 
234  //- Return sensible enthalpy for the phase phaseI
235  virtual scalar Hs
236  (
237  const label phaseI,
238  const scalarField& Y,
239  const scalar p,
240  const scalar T
241  ) const;
242 
243  //- Return chemical enthalpy for the phase phaseI
244  virtual scalar Hc
245  (
246  const label phaseI,
247  const scalarField& Y,
248  const scalar p,
249  const scalar T
250  ) const;
251 
252  //- Return specific heat capacity for the phase phaseI
253  virtual scalar Cp
254  (
255  const label phaseI,
256  const scalarField& Y,
257  const scalar p,
258  const scalar T
259  ) const;
260 
261  //- Return latent heat for the phase phaseI
262  virtual scalar L
263  (
264  const label phaseI,
265  const scalarField& Y,
266  const scalar p,
267  const scalar T
268  ) const;
269 
270  //- Return rho of the full composition
271  virtual scalar rho
272  (
273  const scalarField& Ygas,
274  const scalarField& Yliq,
275  const scalarField& Ysol,
276  const scalar T,
277  const scalar p
278  ) const;
279 };
280 
281 
282 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
283 
284 } // End namespace Foam
285 
286 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
287 
288 #define makeCompositionModel(CloudType) \
289  \
290  typedef Foam::CloudType::reactingCloudType reactingCloudType; \
291  defineNamedTemplateTypeNameAndDebug \
292  ( \
293  Foam::CompositionModel<reactingCloudType>, \
294  0 \
295  ); \
296  namespace Foam \
297  { \
298  defineTemplateRunTimeSelectionTable \
299  ( \
300  CompositionModel<reactingCloudType>, \
301  dictionary \
302  ); \
303  }
304 
305 
306 #define makeCompositionModelType(SS, CloudType) \
307  \
308  typedef Foam::CloudType::reactingCloudType reactingCloudType; \
309  defineNamedTemplateTypeNameAndDebug(Foam::SS<reactingCloudType>, 0); \
310  \
311  Foam::CompositionModel<reactingCloudType>:: \
312  adddictionaryConstructorToTable<Foam::SS<reactingCloudType>> \
313  add##SS##CloudType##reactingCloudType##ConstructorToTable_;
314 
315 
316 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
317 
318 #ifdef NoRepository
319  #include "CompositionModel.C"
320 #endif
321 
322 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
323 
324 #endif
325 
326 // ************************************************************************* //
Foam::scalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Definition: primitiveFieldsFwd.H:52
phasePropertiesList.H
Foam::CompositionModel::YMixture0
virtual const scalarField & YMixture0() const =0
Return the list of mixture mass fractions.
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::CompositionModel::Cp
virtual scalar Cp(const label phaseI, const scalarField &Y, const scalar p, const scalar T) const
Return specific heat capacity for the phase phaseI.
Definition: CompositionModel.C:443
Foam::CompositionModel::H
virtual scalar H(const label phaseI, const scalarField &Y, const scalar p, const scalar T) const
Return total enthalpy for the phase phaseI.
Definition: CompositionModel.C:283
Foam::CompositionModel::rho
virtual scalar rho(const scalarField &Ygas, const scalarField &Yliq, const scalarField &Ysol, const scalar T, const scalar p) const
Return rho of the full composition.
Definition: CompositionModel.C:544
Foam::CompositionModel::localId
label localId(const label phaseI, const word &cmptName, const bool allowNotFound=false) const
Return local id of component cmptName in phase phaseI.
Definition: CompositionModel.C:183
Foam::CompositionModel::localToCarrierId
label localToCarrierId(const label phaseI, const label id, const bool allowNotFound=false) const
Return carrier id of component given local id.
Definition: CompositionModel.C:204
Foam::CompositionModel::Hs
virtual scalar Hs(const label phaseI, const scalarField &Y, const scalar p, const scalar T) const
Return sensible enthalpy for the phase phaseI.
Definition: CompositionModel.C:337
SLGThermo.H
Foam::CompositionModel::Hc
virtual scalar Hc(const label phaseI, const scalarField &Y, const scalar p, const scalar T) const
Return chemical enthalpy for the phase phaseI.
Definition: CompositionModel.C:392
Foam::wordList
List< word > wordList
A List of words.
Definition: fileName.H:62
Foam::CompositionModel::idGas
virtual label idGas() const =0
Gas id.
Foam::CompositionModel::phaseProps
const phasePropertiesList & phaseProps() const
Return the list of phase properties.
Definition: CompositionModel.C:116
Foam::CompositionModel::Y0
const scalarField & Y0(const label phaseI) const
Return the list of phase phaseI mass fractions.
Definition: CompositionModel.C:226
Foam::CompositionModel::X
tmp< scalarField > X(const label phaseI, const scalarField &Y) const
Return the list of phase phaseI volume fractions fractions.
Definition: CompositionModel.C:236
CloudSubModelBase.H
Foam::T
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Definition: FieldFieldFunctions.C:58
Foam::CompositionModel::idSolid
virtual label idSolid() const =0
Solid id.
Foam::CloudType
DSMCCloud< dsmcParcel > CloudType
Definition: makeDSMCParcelBinaryCollisionModels.C:38
Foam::CompositionModel::liquids
const liquidMixtureProperties & liquids() const
Return the global (additional) liquids.
Definition: CompositionModel.C:100
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::CompositionModel::idLiquid
virtual label idLiquid() const =0
Liquid id.
Foam::CompositionModel::carrier
const basicSpecieMixture & carrier() const
Return the carrier components (wrapper function)
Definition: CompositionModel.C:92
Foam::CompositionModel::CompositionModel
CompositionModel(CloudType &owner)
Construct null from owner.
Definition: CompositionModel.C:34
Foam::CompositionModel::declareRunTimeSelectionTable
declareRunTimeSelectionTable(autoPtr, CompositionModel, dictionary,(const dictionary &dict, CloudType &owner),(dict, owner))
Declare runtime constructor selection table.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Y
PtrList< volScalarField > & Y
Definition: createFieldRefs.H:7
Foam::CompositionModel::componentNames
const wordList & componentNames(const label phaseI) const
Return the list of component names for phaseI.
Definition: CompositionModel.C:153
Foam::CompositionModel::solids
const solidMixtureProperties & solids() const
Return the global (additional) solids.
Definition: CompositionModel.C:108
Foam::CompositionModel::TypeName
TypeName("compositionModel")
Runtime type information.
Foam::CompositionModel::nPhase
label nPhase() const
Return the number of phases.
Definition: CompositionModel.C:123
IOdictionary.H
CompositionModel.C
Foam::CompositionModel::clone
virtual autoPtr< CompositionModel< CloudType > > clone() const =0
Construct and return a clone.
runTimeSelectionTables.H
Macros to ease declaration of run-time selection tables.
Foam::CompositionModel::thermo
const SLGThermo & thermo() const
Return the thermo database.
Definition: CompositionModel.C:84
Foam::CompositionModel::~CompositionModel
virtual ~CompositionModel()
Destructor.
Definition: CompositionModel.C:77
Foam::CompositionModel::New
static autoPtr< CompositionModel< CloudType > > New(const dictionary &dict, CloudType &owner)
Selector.
Definition: CompositionModelNew.C:36
Foam::CompositionModel::phaseTypes
const wordList & phaseTypes() const
Return the list of phase type names.
Definition: CompositionModel.C:130
Foam::type
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:590
Foam::CompositionModel::carrierId
label carrierId(const word &cmptName, const bool allowNotFound=false) const
Return global id of component cmptName in carrier thermo.
Definition: CompositionModel.C:161
PtrList.H
Foam::CompositionModel::L
virtual scalar L(const label phaseI, const scalarField &Y, const scalar p, const scalar T) const
Return latent heat for the phase phaseI.
Definition: CompositionModel.C:493
Foam::CompositionModel::stateLabels
const wordList & stateLabels() const
Return the list of state labels (s), (l), (g) etc.
Definition: CompositionModel.C:145
autoPtr.H