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 | Copyright (C) 2011-2016 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 "IOdictionary.H"
43 #include "autoPtr.H"
44 #include "runTimeSelectionTables.H"
45 
46 #include "PtrList.H"
47 #include "SLGThermo.H"
48 
49 #include "phasePropertiesList.H"
50 
51 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 
53 namespace Foam
54 {
55 
56 /*---------------------------------------------------------------------------*\
57  Class CompositionModel Declaration
58 \*---------------------------------------------------------------------------*/
59 
60 template<class CloudType>
61 class CompositionModel
62 :
63  public CloudSubModelBase<CloudType>
64 {
65  // Private data
66 
67  //- Reference to the thermo database
68  const SLGThermo& thermo_;
69 
70  //- List of phase properties
71  phasePropertiesList phaseProps_;
72 
73 
74 public:
75 
76  //- Runtime type information
77  TypeName("compositionModel");
78 
79  //- Declare runtime constructor selection table
81  (
82  autoPtr,
84  dictionary,
85  (
86  const dictionary& dict,
88  ),
89  (dict, owner)
90  );
91 
92 
93  // Constructors
94 
95  //- Construct null from owner
97 
98  //- Construct from dictionary
100  (
101  const dictionary& dict,
102  CloudType& owner,
103  const word& type
104  );
105 
106  //- Construct copy
107  CompositionModel(const CompositionModel<CloudType>& cm);
108 
109  //- Construct and return a clone
110  virtual autoPtr<CompositionModel<CloudType>> clone() const = 0;
111 
112 
113  //- Destructor
114  virtual ~CompositionModel();
115 
116 
117  //- Selector
118  static autoPtr<CompositionModel<CloudType>> New
119  (
120  const dictionary& dict,
121  CloudType& owner
122  );
123 
124 
125  // Member Functions
126 
127  // Access
128 
129  //- Return the thermo database
130  const SLGThermo& thermo() const;
131 
132 
133  // Composition lists
134 
135  //- Return the carrier components (wrapper function)
136  const basicSpecieMixture& carrier() const;
137 
138  //- Return the global (additional) liquids
139  const liquidMixtureProperties& liquids() const;
140 
141  //- Return the global (additional) solids
142  const solidMixtureProperties& solids() const;
143 
144  //- Return the list of phase properties
145  const phasePropertiesList& phaseProps() const;
146 
147  //- Return the number of phases
148  label nPhase() const;
149 
150 
151  // Phase properties
152 
153  //- Return the list of phase type names
154  // If only 1 phase, return the component names of that phase
155  const wordList& phaseTypes() const;
156 
157  //- Return the list of state labels (s), (l), (g) etc.
158  const wordList& stateLabels() const;
159 
160  //- Return the list of component names for phaseI
161  const wordList& componentNames(const label phaseI) const;
162 
163  //- Return global id of component cmptName in carrier thermo
165  (
166  const word& cmptName,
167  const bool allowNotFound = false
168  ) const;
169 
170  //- Return local id of component cmptName in phase phaseI
171  label localId
172  (
173  const label phaseI,
174  const word& cmptName,
175  const bool allowNotFound = false
176  ) const;
177 
178  //- Return carrier id of component given local id
180  (
181  const label phaseI,
182  const label id,
183  const bool allowNotFound = false
184  ) const;
185 
186  //- Return the list of phase phaseI mass fractions
187  const scalarField& Y0(const label phaseI) const;
188 
189  //- Return the list of phase phaseI volume fractions fractions
190  // based on supplied mass fractions Y
191  scalarField X(const label phaseI, const scalarField& Y) const;
192 
193 
194  // Mixture properties
195 
196  //- Return the list of mixture mass fractions
197  // If only 1 phase, return component fractions of that phase
198  virtual const scalarField& YMixture0() const = 0;
199 
200  // Indices of gas, liquid and solid phases in phase properties
201  // list - returns -1 if not applicable
202 
203  //- Gas id
204  virtual label idGas() const = 0;
205 
206  //- Liquid id
207  virtual label idLiquid() const = 0;
208 
209  //- Solid id
210  virtual label idSolid() const = 0;
211 
212 
213  // Evaluation
214 
215  //- Return total enthalpy for the phase phaseI
216  virtual scalar H
217  (
218  const label phaseI,
219  const scalarField& Y,
220  const scalar p,
221  const scalar T
222  ) const;
223 
224  //- Return sensible enthalpy for the phase phaseI
225  virtual scalar Hs
226  (
227  const label phaseI,
228  const scalarField& Y,
229  const scalar p,
230  const scalar T
231  ) const;
232 
233  //- Return chemical enthalpy for the phase phaseI
234  virtual scalar Hc
235  (
236  const label phaseI,
237  const scalarField& Y,
238  const scalar p,
239  const scalar T
240  ) const;
241 
242  //- Return specific heat caoacity for the phase phaseI
243  virtual scalar Cp
244  (
245  const label phaseI,
246  const scalarField& Y,
247  const scalar p,
248  const scalar T
249  ) const;
250 
251  //- Return latent heat for the phase phaseI
252  virtual scalar L
253  (
254  const label phaseI,
255  const scalarField& Y,
256  const scalar p,
257  const scalar T
258  ) const;
259 };
260 
261 
262 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
263 
264 } // End namespace Foam
265 
266 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
268 #define makeCompositionModel(CloudType) \
269  \
270  typedef Foam::CloudType::reactingCloudType reactingCloudType; \
271  defineNamedTemplateTypeNameAndDebug \
272  ( \
273  Foam::CompositionModel<reactingCloudType>, \
274  0 \
275  ); \
276  namespace Foam \
277  { \
278  defineTemplateRunTimeSelectionTable \
279  ( \
280  CompositionModel<reactingCloudType>, \
281  dictionary \
282  ); \
283  }
284 
286 #define makeCompositionModelType(SS, CloudType) \
287  \
288  typedef Foam::CloudType::reactingCloudType reactingCloudType; \
289  defineNamedTemplateTypeNameAndDebug(Foam::SS<reactingCloudType>, 0); \
290  \
291  Foam::CompositionModel<reactingCloudType>:: \
292  adddictionaryConstructorToTable<Foam::SS<reactingCloudType>> \
293  add##SS##CloudType##reactingCloudType##ConstructorToTable_;
294 
295 
296 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
297 
298 #ifdef NoRepository
299  #include "CompositionModel.C"
300 #endif
301 
302 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
303 
304 #endif
305 
306 // ************************************************************************* //
declareRunTimeSelectionTable(autoPtr, CompositionModel, dictionary,(const dictionary &dict, CloudType &owner),(dict, owner))
Declare runtime constructor selection table.
virtual scalar L(const label phaseI, const scalarField &Y, const scalar p, const scalar T) const
Return latent heat for the phase phaseI.
virtual const scalarField & YMixture0() const =0
Return the list of mixture mass fractions.
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
DSMCCloud< dsmcParcel > CloudType
const SLGThermo & thermo() const
Return the thermo database.
const phasePropertiesList & phaseProps() const
Return the list of phase properties.
CompositionModel(CloudType &owner)
Construct null from owner.
virtual label idSolid() const =0
Solid id.
const scalarField & Y0(const label phaseI) const
Return the list of phase phaseI mass fractions.
scalarField X(const label phaseI, const scalarField &Y) const
Return the list of phase phaseI volume fractions fractions.
virtual scalar Hs(const label phaseI, const scalarField &Y, const scalar p, const scalar T) const
Return sensible enthalpy for the phase phaseI.
label localToCarrierId(const label phaseI, const label id, const bool allowNotFound=false) const
Return carrier id of component given local id.
virtual scalar H(const label phaseI, const scalarField &Y, const scalar p, const scalar T) const
Return total enthalpy for the phase phaseI.
TypeName("compositionModel")
Runtime type information.
virtual scalar Cp(const label phaseI, const scalarField &Y, const scalar p, const scalar T) const
Return specific heat caoacity for the phase phaseI.
const dictionary & dict() const
Return const access to the cloud dictionary.
Definition: subModelBase.C:110
const CloudType & owner() const
Return const access to the owner cloud.
const wordList & phaseTypes() const
Return the list of phase type names.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
virtual label idLiquid() const =0
Liquid id.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
fileName::Type type(const fileName &, const bool followLink=true)
Return the file type: DIRECTORY or FILE.
Definition: POSIX.C:485
List< word > wordList
A List of words.
Definition: fileName.H:54
label nPhase() const
Return the number of phases.
static autoPtr< CompositionModel< CloudType > > New(const dictionary &dict, CloudType &owner)
Selector.
PtrList< volScalarField > & Y
virtual ~CompositionModel()
Destructor.
Macros to ease declaration of run-time selection tables.
label localId(const label phaseI, const word &cmptName, const bool allowNotFound=false) const
Return local id of component cmptName in phase phaseI.
virtual label idGas() const =0
Gas id.
volScalarField & p
const wordList & stateLabels() const
Return the list of state labels (s), (l), (g) etc.
virtual scalar Hc(const label phaseI, const scalarField &Y, const scalar p, const scalar T) const
Return chemical enthalpy for the phase phaseI.
const basicSpecieMixture & carrier() const
Return the carrier components (wrapper function)
virtual autoPtr< CompositionModel< CloudType > > clone() const =0
Construct and return a clone.
const wordList & componentNames(const label phaseI) const
Return the list of component names for phaseI.
label carrierId(const word &cmptName, const bool allowNotFound=false) const
Return global id of component cmptName in carrier thermo.
Namespace for OpenFOAM.
const liquidMixtureProperties & liquids() const
Return the global (additional) liquids.
const solidMixtureProperties & solids() const
Return the global (additional) solids.