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