CompositionModel.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2021 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::CompositionModel
26 
27 Description
28  Templated reacting parcel composition model class
29  Consists of carrier species (via thermo package), and additional liquids
30  and solids
31 
32 SourceFiles
33  CompositionModel.C
34  CompositionModelNew.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef CompositionModel_H
39 #define CompositionModel_H
40 
41 #include "CloudSubModelBase.H"
42 #include "parcelThermo.H"
43 #include "basicSpecieMixture.H"
44 #include "phasePropertiesList.H"
45 #include "runTimeSelectionTables.H"
46 
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 
49 namespace Foam
50 {
51 
52 /*---------------------------------------------------------------------------*\
53  Class CompositionModel Declaration
54 \*---------------------------------------------------------------------------*/
55 
56 template<class CloudType>
57 class CompositionModel
58 :
59  public CloudSubModelBase<CloudType>
60 {
61  // Private Data
62 
63  //- Reference to thermophysical properties of the carrier fluid
64  const fluidThermo& carrierThermo_;
65 
66  //- Pointer to the multi-component carrier composition
67  const basicSpecieMixture* carrierMixture_;
68 
69  //- Reference to the thermo database
70  const parcelThermo& thermo_;
71 
72  //- List of phase properties
73  phasePropertiesList phaseProps_;
74 
75 
76 public:
77 
78  //- Runtime type information
79  TypeName("compositionModel");
80 
81  //- Declare runtime constructor selection table
83  (
84  autoPtr,
86  dictionary,
87  (
88  const dictionary& dict,
90  ),
91  (dict, owner)
92  );
93 
94 
95  // Constructors
96 
97  //- Construct null from owner
99 
100  //- Construct from dictionary
102  (
103  const dictionary& dict,
104  CloudType& owner,
105  const word& type
106  );
107 
108  //- Construct copy
110 
111  //- Construct and return a clone
112  virtual autoPtr<CompositionModel<CloudType>> clone() const = 0;
113 
114 
115  //- Destructor
116  virtual ~CompositionModel();
117 
118 
119  //- Selector
121  (
122  const dictionary& dict,
124  );
125 
126 
127  // Member Functions
128 
129  // Access
130 
131  //- Return the thermo database
132  const parcelThermo& thermo() const;
133 
134 
135  // Composition lists
136 
137  //- Return the carrier components (wrapper function)
138  const basicSpecieMixture& carrier() const;
139 
140  //- Return the global (additional) liquids
141  const liquidMixtureProperties& liquids() const;
142 
143  //- Return the global (additional) solids
144  const solidMixtureProperties& solids() const;
145 
146  //- Return the list of phase properties
147  const phasePropertiesList& phaseProps() const;
148 
149  //- Return the number of phases
150  label nPhase() const;
151 
152 
153  // Phase properties
154 
155  //- Return the list of phase type names
156  // If only 1 phase, return the component names of that phase
157  const wordList& phaseTypes() const;
158 
159  //- Return the list of state labels (s), (l), (g) etc.
160  const wordList& stateLabels() const;
161 
162  //- Return the list of component names for phaseI
163  const wordList& componentNames(const label phaseI) const;
164 
165  //- Return global id of component cmptName in carrier thermo
167  (
168  const word& cmptName,
169  const bool allowNotFound = false
170  ) const;
171 
172  //- Return local id of component cmptName in phase phaseI
173  label localId
174  (
175  const label phaseI,
176  const word& cmptName,
177  const bool allowNotFound = false
178  ) const;
179 
180  //- Return carrier id of component given local id
182  (
183  const label phaseI,
184  const label id,
185  const bool allowNotFound = false
186  ) const;
187 
188  //- Return the list of phase phaseI mass fractions
189  const scalarField& Y0(const label phaseI) const;
190 
191  //- Return the list of phase phaseI volume fractions fractions
192  // based on supplied mass fractions Y
193  scalarField X(const label phaseI, const scalarField& Y) const;
194 
195 
196  // Mixture properties
197 
198  //- Return the list of mixture mass fractions
199  // If only 1 phase, return component fractions of that phase
200  virtual const scalarField& YMixture0() const = 0;
201 
202  // Indices of gas, liquid and solid phases in phase properties
203  // list - returns -1 if not applicable
204 
205  //- Gas id
206  virtual label idGas() const = 0;
207 
208  //- Liquid id
209  virtual label idLiquid() const = 0;
210 
211  //- Solid id
212  virtual label idSolid() const = 0;
213 
214 
215  // Evaluation
216 
217  //- Return total enthalpy for the phase phaseI
218  virtual scalar H
219  (
220  const label phaseI,
221  const scalarField& Y,
222  const scalar p,
223  const scalar T
224  ) const;
225 
226  //- Return sensible enthalpy for the phase phaseI
227  virtual scalar Hs
228  (
229  const label phaseI,
230  const scalarField& Y,
231  const scalar p,
232  const scalar T
233  ) const;
234 
235  //- Return chemical enthalpy for the phase phaseI
236  virtual scalar Hc
237  (
238  const label phaseI,
239  const scalarField& Y,
240  const scalar p,
241  const scalar T
242  ) const;
243 
244  //- Return specific heat capacity for the phase phaseI
245  virtual scalar Cp
246  (
247  const label phaseI,
248  const scalarField& Y,
249  const scalar p,
250  const scalar T
251  ) const;
252 
253  //- Return latent heat for the phase phaseI
254  virtual scalar L
255  (
256  const label phaseI,
257  const scalarField& Y,
258  const scalar p,
259  const scalar T
260  ) const;
261 };
262 
263 
264 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
265 
266 } // End namespace Foam
267 
268 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
269 
270 #define makeCompositionModel(CloudType) \
271  \
272  typedef Foam::CloudType::thermoCloudType thermoCloudType; \
273  defineNamedTemplateTypeNameAndDebug \
274  ( \
275  Foam::CompositionModel<thermoCloudType>, \
276  0 \
277  ); \
278  namespace Foam \
279  { \
280  defineTemplateRunTimeSelectionTable \
281  ( \
282  CompositionModel<thermoCloudType>, \
283  dictionary \
284  ); \
285  }
286 
287 
288 #define makeCompositionModelType(SS, CloudType) \
289  \
290  typedef Foam::CloudType::thermoCloudType thermoCloudType; \
291  defineNamedTemplateTypeNameAndDebug(Foam::SS<thermoCloudType>, 0); \
292  \
293  Foam::CompositionModel<thermoCloudType>:: \
294  adddictionaryConstructorToTable<Foam::SS<thermoCloudType>> \
295  add##SS##CloudType##thermoCloudType##ConstructorToTable_;
296 
297 
298 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
299 
300 #ifdef NoRepository
301  #include "CompositionModel.C"
302 #endif
303 
304 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
305 
306 #endif
307 
308 // ************************************************************************* //
Base class for cloud sub-models.
const CloudType & owner() const
Return const access to the owner cloud.
Templated reacting parcel composition model class Consists of carrier species (via thermo package),...
const liquidMixtureProperties & liquids() const
Return the global (additional) liquids.
virtual label idLiquid() const =0
Liquid id.
scalarField X(const label phaseI, const scalarField &Y) const
Return the list of phase phaseI volume fractions fractions.
TypeName("compositionModel")
Runtime type information.
const parcelThermo & thermo() const
Return the thermo database.
virtual scalar H(const label phaseI, const scalarField &Y, const scalar p, const scalar T) const
Return total enthalpy for the phase phaseI.
const wordList & stateLabels() const
Return the list of state labels (s), (l), (g) etc.
CompositionModel(CloudType &owner)
Construct null from owner.
const phasePropertiesList & phaseProps() const
Return the list of phase properties.
const basicSpecieMixture & carrier() const
Return the carrier components (wrapper function)
virtual scalar L(const label phaseI, const scalarField &Y, const scalar p, const scalar T) const
Return latent heat for the phase phaseI.
virtual ~CompositionModel()
Destructor.
const wordList & componentNames(const label phaseI) const
Return the list of component names for phaseI.
label nPhase() const
Return the number of phases.
virtual scalar Hc(const label phaseI, const scalarField &Y, const scalar p, const scalar T) const
Return chemical enthalpy for the phase phaseI.
declareRunTimeSelectionTable(autoPtr, CompositionModel, dictionary,(const dictionary &dict, CloudType &owner),(dict, owner))
Declare runtime constructor selection table.
label localToCarrierId(const label phaseI, const label id, const bool allowNotFound=false) const
Return carrier id of component given local id.
virtual scalar Cp(const label phaseI, const scalarField &Y, const scalar p, const scalar T) const
Return specific heat capacity for the phase phaseI.
virtual const scalarField & YMixture0() const =0
Return the list of mixture mass fractions.
virtual scalar Hs(const label phaseI, const scalarField &Y, const scalar p, const scalar T) const
Return sensible enthalpy for the phase phaseI.
virtual label idSolid() const =0
Solid id.
virtual label idGas() const =0
Gas id.
static autoPtr< CompositionModel< CloudType > > New(const dictionary &dict, CloudType &owner)
Selector.
const solidMixtureProperties & solids() const
Return the global (additional) solids.
label localId(const label phaseI, const word &cmptName, const bool allowNotFound=false) const
Return local id of component cmptName in phase phaseI.
virtual autoPtr< CompositionModel< CloudType > > clone() const =0
Construct and return a clone.
label carrierId(const word &cmptName, const bool allowNotFound=false) const
Return global id of component cmptName in carrier thermo.
const scalarField & Y0(const label phaseI) const
Return the list of phase phaseI mass fractions.
const wordList & phaseTypes() const
Return the list of phase type names.
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:79
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
Specialisation of basicMixture for a mixture consisting of a number for molecular species.
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
Base-class for fluid thermodynamic properties.
Definition: fluidThermo.H:57
Thermo package for (S)olids (L)iquids and (G)ases Takes reference to thermo package,...
Definition: parcelThermo.H:59
Simple container for a list of phase properties.
const dictionary & dict() const
Return const access to the cloud dictionary.
Definition: subModelBase.C:110
A class for handling words, derived from string.
Definition: word.H:62
Namespace for OpenFOAM.
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
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488
Macros to ease declaration of run-time selection tables.
volScalarField & p
PtrList< volScalarField > & Y