basicThermo.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-2017 OpenFOAM Foundation
9 Copyright (C) 2017-2021 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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
27Class
28 Foam::basicThermo
29
30Description
31 Abstract base-class for fluid and solid thermodynamic properties
32
33 An important concept is that the thermo can share an existing T
34 (similar to p) in which case it will not try to update it. This gets
35 triggered purely on construction order - the first one to register
36 T is responsible for updating it. Note that the mechanism also means
37 that if multiple thermos are running on the same mesh, only the first one
38 will update the temperature. The behaviour can be overridden using the
39 'updateT' dictionary entry.
40
41SourceFiles
42 basicThermo.C
43
44\*---------------------------------------------------------------------------*/
45
46#ifndef basicThermo_H
47#define basicThermo_H
48
49#include "volFields.H"
50#include "typeInfo.H"
51#include "IOdictionary.H"
52#include "autoPtr.H"
53#include "wordIOList.H"
54
55// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
56
57namespace Foam
58{
59
60/*---------------------------------------------------------------------------*\
61 Class basicThermo Declaration
62\*---------------------------------------------------------------------------*/
64class basicThermo
65:
66 public IOdictionary
67{
68 // Private Data
69
70 //- Components names/order
71 static const wordList componentHeader4;
72
73 //- Components names/order
74 static const wordList componentHeader7;
75
76
77 // Private Member Functions
78
79 //- Construct name of thermo package from dictionary components
80 static word makeThermoName
81 (
82 const dictionary& dict,
83 const wordList*& cmptHeaderPtr
84 );
85
86 //- Look up field from registry or construct and store
87 static volScalarField& lookupOrConstruct
88 (
89 const fvMesh& mesh,
90 const word& fieldName,
91 bool& isOwner
92 );
93
94 //- Generic lookup for thermodynamics package thermoTypeName
95 // \return constructor pointer, or FatalError
96 template<class Thermo, class ThermoConstructTable>
97 static typename ThermoConstructTable::mapped_type
98 getThermoOrDie
99 (
100 const dictionary& thermoTypeDict,
101 ThermoConstructTable& thermoTable,
102 const word& thermoTypeName,
103 const wordList& cmptNames
104 );
105
106 //- Generic lookup for each of the related thermodynamics packages
107 // \return constructor pointer, or FatalError
108 template<class Thermo, class ThermoConstructTable>
109 static typename ThermoConstructTable::mapped_type
110 getThermoOrDie
111 (
112 const dictionary& thermoDict,
113 ThermoConstructTable& thermoTable
114 );
115
116
117protected:
118
119 // Protected Data
120
121 //- Phase-name
122 const word& phaseName_;
123
124 //- Pressure created and stored by this instance
125 bool pOwner_;
126
127 //- Temperature created and stored by this instance
128 bool TOwner_;
129
130 //- Include dpdt term in the enthalpy equation?
131 bool dpdt_;
132
133
134 // Fields
135
136 //- Pressure [Pa]
138
139 //- Temperature [K]
141
142 //- Laminar thermal diffusivity [kg/m/s]
144
145
146 // Protected Member Functions
147
148 //- Return the enthalpy/internal energy field boundary types
149 //- by interrogating the temperature field boundary types
151
152 //- Return the enthalpy/internal energy field boundary base types
153 //- by interrogating the temperature field boundary types
155
156 //- No copy construct
157 basicThermo(const basicThermo&) = delete;
158
159
160public:
161
162 //- Runtime type information
163 TypeName("basicThermo");
164
165
166 //- Declare run-time constructor selection table
168 (
169 autoPtr,
171 fvMesh,
172 (const fvMesh& mesh, const word& phaseName),
173 (mesh, phaseName)
174 );
175
176
177 //- Declare run-time constructor selection table for dictionary based
179 (
180 autoPtr,
182 fvMeshDictPhase,
183 (const fvMesh& mesh, const word& phaseName, const word& dictName),
184 (mesh, phaseName, dictName)
185 );
186
187
188 // Constructors
189
190 //- Construct from mesh and phase name
192 (
193 const fvMesh&,
194 const word& phaseName
195 );
196
197 //- Construct from mesh, dictionary and phase name
199 (
200 const fvMesh&,
201 const dictionary&,
202 const word& phaseName
203 );
204
205 //- Construct from mesh, phase name and explicit naming of the
206 //- dictionary (so it can be shared amongst phases).
208 (
209 const fvMesh&,
210 const word& phaseName,
211 const word& dictionaryName
212 );
213
214
215 // Selectors
216
217 //- Generic New for each of the related thermodynamics packages
218 template<class Thermo>
219 static autoPtr<Thermo> New
220 (
221 const fvMesh&,
222 const word& phaseName=word::null
223 );
224
225 //- Generic New for each of the related thermodynamics packages
226 template<class Thermo>
227 static autoPtr<Thermo> New
228 (
229 const fvMesh&,
230 const dictionary&,
231 const word& phaseName=word::null
232 );
233
234 //- Generic New for each of the related thermodynamics packages
235 template<class Thermo>
236 static autoPtr<Thermo> New
237 (
238 const fvMesh&,
239 const word& phaseName,
240 const word& dictName
241 );
242
243 //- Specialisation of the Generic New for basicThermo
245 (
246 const fvMesh&,
247 const word& phaseName=word::null
248 );
249
250
251 //- Destructor
252 virtual ~basicThermo();
253
254
255 // Member Functions
257 static const word dictName;
260 (
261 const word& name,
262 const word& phaseName
263 )
264 {
265 return IOobject::groupName(name, phaseName);
266 }
268 word phasePropertyName(const word& name) const
269 {
271 }
272
273 static const basicThermo& lookupThermo(const fvPatchScalarField& pf);
274
275 //- Print (filtered) table of thermo names, splits on \c " ,<>"
277 (
278 Ostream& os,
279 const wordList& cmptNames,
280 const wordList& thermoNames
281 );
282
283 //- Check that the thermodynamics package is consistent
284 // with energy forms supported by the application
285 void validate
286 (
287 const string& app,
288 const word&
289 ) const;
290
291 //- Check that the thermodynamics package is consistent
292 // with energy forms supported by the application
293 void validate
294 (
295 const string& app,
296 const word&,
297 const word&
298 ) const;
299
300 //- Check that the thermodynamics package is consistent
301 // with energy forms supported by the application
302 void validate
303 (
304 const string& app,
305 const word&,
306 const word&,
307 const word&
308 ) const;
309
310 //- Check that the thermodynamics package is consistent
311 // with energy forms supported by the application
312 void validate
313 (
314 const string& app,
315 const word&,
316 const word&,
317 const word&,
318 const word&
319 ) const;
320
321 //- Split thermo package name into a list of components names
322 // Splits on \c " ,<>"
323 // \return empty list if the split name does not have the
324 // expected number of components (non-zero).
326 (
327 const std::string& thermoName,
328 const int nExpectedCmpts
329 );
330
331 //- Update properties
332 virtual void correct() = 0;
333
334 //- Return the name of the thermo physics
335 virtual word thermoName() const = 0;
336
337 //- Return true if the equation of state is incompressible
338 // i.e. rho != f(p)
339 virtual bool incompressible() const = 0;
340
341 //- Return true if the equation of state is isochoric
342 // i.e. rho = const
343 virtual bool isochoric() const = 0;
344
345 //- True if dpdt term should be included in enthalpy equation
346 bool dpdt() const noexcept
347 {
348 return dpdt_;
349 }
350
351 //- True if T should be updated
352 bool updateT() const noexcept
353 {
354 return TOwner_;
355 }
356
357
358 // Access to thermodynamic state variables
359
360 //- Pressure [Pa]
361 // Non-const access allowed for transport equations
362 virtual volScalarField& p();
363
364 //- Pressure [Pa]
365 virtual const volScalarField& p() const;
366
367 //- Density [kg/m^3]
368 virtual tmp<volScalarField> rho() const = 0;
369
370 //- Density for patch [kg/m^3]
371 virtual tmp<scalarField> rho(const label patchi) const = 0;
372
373 //- Enthalpy/Internal energy [J/kg]
374 // Non-const access allowed for transport equations
375 virtual volScalarField& he() = 0;
376
377 //- Enthalpy/Internal energy [J/kg]
378 virtual const volScalarField& he() const = 0;
379
380 //- Enthalpy/Internal energy
381 // for given pressure and temperature [J/kg]
382 virtual tmp<volScalarField> he
383 (
384 const volScalarField& p,
385 const volScalarField& T
386 ) const = 0;
387
388 //- Enthalpy/Internal energy for cell-set [J/kg]
389 virtual tmp<scalarField> he
390 (
391 const scalarField& p,
392 const scalarField& T,
393 const labelList& cells
394 ) const = 0;
395
396 //- Enthalpy/Internal energy for patch [J/kg]
397 virtual tmp<scalarField> he
398 (
399 const scalarField& p,
400 const scalarField& T,
401 const label patchi
402 ) const = 0;
403
404 //- Chemical enthalpy [J/kg]
405 virtual tmp<volScalarField> hc() const = 0;
406
407 //- Temperature from enthalpy/internal energy for cell-set
408 virtual tmp<scalarField> THE
409 (
410 const scalarField& h,
411 const scalarField& p,
412 const scalarField& T0, // starting temperature
413 const labelList& cells
414 ) const = 0;
415
416 //- Temperature from enthalpy/internal energy for patch
417 virtual tmp<scalarField> THE
418 (
419 const scalarField& h,
420 const scalarField& p,
421 const scalarField& T0, // starting temperature
422 const label patchi
423 ) const = 0;
424
425
426 // Fields derived from thermodynamic state variables
427
428 //- Temperature [K]
429 virtual const volScalarField& T() const;
430
431 //- Temperature [K]
432 // Non-const access allowed for transport equations
433 virtual volScalarField& T();
434
435 //- Heat capacity at constant pressure [J/kg/K]
436 virtual tmp<volScalarField> Cp() const = 0;
437
438 //- Heat capacity at constant pressure for patch [J/kg/K]
439 virtual tmp<scalarField> Cp
440 (
441 const scalarField& p,
442 const scalarField& T,
443 const label patchi
444 ) const = 0;
445
446 //- Heat capacity using pressure and temperature [J/kg/K]
447 virtual tmp<scalarField> Cp
448 (
449 const scalarField& p,
450 const scalarField& T,
451 const labelList& cells
452 ) const = 0;
453
454 //- Heat capacity at constant volume [J/kg/K]
455 virtual tmp<volScalarField> Cv() const = 0;
456
457 //- Heat capacity at constant volume for patch [J/kg/K]
458 virtual tmp<scalarField> Cv
459 (
460 const scalarField& p,
461 const scalarField& T,
462 const label patchi
463 ) const = 0;
464
465 //- Density from pressure and temperature from EoS
467 (
468 const scalarField& p,
469 const scalarField& T,
470 const labelList& cells
471 ) const = 0;
472
473 //- Gamma = Cp/Cv []
474 virtual tmp<volScalarField> gamma() const = 0;
475
476 //- Gamma = Cp/Cv for patch []
477 virtual tmp<scalarField> gamma
478 (
479 const scalarField& p,
480 const scalarField& T,
481 const label patchi
482 ) const = 0;
483
484 //- Heat capacity at constant pressure/volume [J/kg/K]
485 virtual tmp<volScalarField> Cpv() const = 0;
486
487 //- Heat capacity at constant pressure/volume for patch [J/kg/K]
488 virtual tmp<scalarField> Cpv
489 (
490 const scalarField& p,
491 const scalarField& T,
492 const label patchi
493 ) const = 0;
494
495 //- Heat capacity ratio []
496 virtual tmp<volScalarField> CpByCpv() const = 0;
497
498 //- Heat capacity ratio for patch []
500 (
501 const scalarField& p,
502 const scalarField& T,
503 const label patchi
504 ) const = 0;
505
506 //- Molecular weight [kg/kmol]
507 virtual tmp<volScalarField> W() const = 0;
508
509
510 // Access to transport state variables
511
512 //- Thermal diffusivity for enthalpy of mixture [kg/m/s]
513 virtual const volScalarField& alpha() const;
514
515 //- Thermal diffusivity for enthalpy of mixture for patch [kg/m/s]
516 virtual const scalarField& alpha
517 (
518 const label patchi
519 ) const;
520
521
522 // Fields derived from transport state variables
523
524 //- Thermal diffusivity for temperature of mixture [J/m/s/K]
525 virtual tmp<volScalarField> kappa() const = 0;
526
527 //- Thermal diffusivity for temperature
528 // of mixture for patch [J/m/s/K]
529 virtual tmp<scalarField> kappa
530 (
531 const label patchi
532 ) const = 0;
533
534 //- Thermal diffusivity for energy of mixture [kg/m/s]
535 virtual tmp<volScalarField> alphahe() const = 0;
536
537 //- Thermal diffusivity for energy of mixture for patch [kg/m/s]
538 virtual tmp<scalarField> alphahe(const label patchi) const = 0;
539
540 //- Effective thermal diffusivity for temperature
541 // of mixture [J/m/s/K]
543 (
544 const volScalarField&
545 ) const = 0;
546
547 //- Effective thermal diffusivity for temperature
548 // of mixture for patch [J/m/s/K]
550 (
551 const scalarField& alphat,
552 const label patchi
553 ) const = 0;
554
555 //- Effective thermal diffusivity of mixture [kg/m/s]
557 (
558 const volScalarField& alphat
559 ) const = 0;
560
561 //- Effective thermal diffusivity of mixture for patch [kg/m/s]
563 (
564 const scalarField& alphat,
565 const label patchi
566 ) const = 0;
567
568
569 //- Read thermophysical properties dictionary
570 virtual bool read();
571};
572
573
574// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
575
576} // End namespace Foam
577
578// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
579
580#ifdef NoRepository
581 #include "basicThermoTemplates.C"
582#endif
583
584// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
585
586#endif
587
588// ************************************************************************* //
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:57
static word groupName(StringType base, const word &group)
Create dot-delimited name.group string.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
const word & name() const
Abstract base-class for fluid and solid thermodynamic properties.
Definition: basicThermo.H:66
virtual word thermoName() const =0
Return the name of the thermo physics.
static Ostream & printThermoNames(Ostream &os, const wordList &cmptNames, const wordList &thermoNames)
Print (filtered) table of thermo names, splits on " ,<>".
Definition: basicThermo.C:75
static const basicThermo & lookupThermo(const fvPatchScalarField &pf)
Definition: basicThermo.C:454
virtual const volScalarField & he() const =0
Enthalpy/Internal energy [J/kg].
bool dpdt_
Include dpdt term in the enthalpy equation?
Definition: basicThermo.H:130
virtual tmp< scalarField > THE(const scalarField &h, const scalarField &p, const scalarField &T0, const labelList &cells) const =0
Temperature from enthalpy/internal energy for cell-set.
virtual tmp< volScalarField > W() const =0
Molecular weight [kg/kmol].
virtual tmp< scalarField > rhoEoS(const scalarField &p, const scalarField &T, const labelList &cells) const =0
Density from pressure and temperature from EoS.
virtual tmp< scalarField > CpByCpv(const scalarField &p, const scalarField &T, const label patchi) const =0
Heat capacity ratio for patch [].
virtual tmp< volScalarField > kappa() const =0
Thermal diffusivity for temperature of mixture [J/m/s/K].
virtual const volScalarField & T() const
Temperature [K].
Definition: basicThermo.C:622
virtual tmp< scalarField > Cv(const scalarField &p, const scalarField &T, const label patchi) const =0
Heat capacity at constant volume for patch [J/kg/K].
virtual tmp< volScalarField > alphaEff(const volScalarField &alphat) const =0
Effective thermal diffusivity of mixture [kg/m/s].
virtual tmp< scalarField > alphaEff(const scalarField &alphat, const label patchi) const =0
Effective thermal diffusivity of mixture for patch [kg/m/s].
virtual tmp< volScalarField > alphahe() const =0
Thermal diffusivity for energy of mixture [kg/m/s].
wordList heBoundaryTypes()
Definition: basicThermo.C:198
virtual volScalarField & p()
Pressure [Pa].
Definition: basicThermo.C:610
virtual tmp< volScalarField > Cpv() const =0
Heat capacity at constant pressure/volume [J/kg/K].
word phasePropertyName(const word &name) const
Definition: basicThermo.H:267
virtual tmp< volScalarField > rho() const =0
Density [kg/m^3].
virtual tmp< scalarField > he(const scalarField &p, const scalarField &T, const label patchi) const =0
Enthalpy/Internal energy for patch [J/kg].
static word phasePropertyName(const word &name, const word &phaseName)
Definition: basicThermo.H:259
wordList heBoundaryBaseTypes()
Definition: basicThermo.C:164
static const word dictName
Definition: basicThermo.H:256
bool updateT() const noexcept
True if T should be updated.
Definition: basicThermo.H:351
virtual tmp< scalarField > THE(const scalarField &h, const scalarField &p, const scalarField &T0, const label patchi) const =0
Temperature from enthalpy/internal energy for patch.
bool dpdt() const noexcept
True if dpdt term should be included in enthalpy equation.
Definition: basicThermo.H:345
virtual void correct()=0
Update properties.
bool pOwner_
Pressure created and stored by this instance.
Definition: basicThermo.H:124
bool TOwner_
Temperature created and stored by this instance.
Definition: basicThermo.H:127
virtual bool incompressible() const =0
Return true if the equation of state is incompressible.
volScalarField & p_
Pressure [Pa].
Definition: basicThermo.H:136
virtual tmp< scalarField > rho(const label patchi) const =0
Density for patch [kg/m^3].
virtual tmp< scalarField > Cp(const scalarField &p, const scalarField &T, const labelList &cells) const =0
Heat capacity using pressure and temperature [J/kg/K].
basicThermo(const basicThermo &)=delete
No copy construct.
static autoPtr< Thermo > New(const fvMesh &, const word &phaseName, const word &dictName)
Generic New for each of the related thermodynamics packages.
virtual volScalarField & he()=0
Enthalpy/Internal energy [J/kg].
virtual tmp< volScalarField > CpByCpv() const =0
Heat capacity ratio [].
const word & phaseName_
Phase-name.
Definition: basicThermo.H:121
virtual tmp< volScalarField > Cv() const =0
Heat capacity at constant volume [J/kg/K].
virtual tmp< volScalarField > gamma() const =0
Gamma = Cp/Cv [].
virtual tmp< scalarField > alphahe(const label patchi) const =0
Thermal diffusivity for energy of mixture for patch [kg/m/s].
volScalarField & T_
Temperature [K].
Definition: basicThermo.H:139
static autoPtr< Thermo > New(const fvMesh &, const word &phaseName=word::null)
Generic New for each of the related thermodynamics packages.
virtual bool isochoric() const =0
Return true if the equation of state is isochoric.
virtual tmp< scalarField > he(const scalarField &p, const scalarField &T, const labelList &cells) const =0
Enthalpy/Internal energy for cell-set [J/kg].
void validate(const string &app, const word &) const
Check that the thermodynamics package is consistent.
Definition: basicThermo.C:486
TypeName("basicThermo")
Runtime type information.
virtual tmp< scalarField > Cp(const scalarField &p, const scalarField &T, const label patchi) const =0
Heat capacity at constant pressure for patch [J/kg/K].
static autoPtr< Thermo > New(const fvMesh &, const dictionary &, const word &phaseName=word::null)
Generic New for each of the related thermodynamics packages.
declareRunTimeSelectionTable(autoPtr, basicThermo, fvMeshDictPhase,(const fvMesh &mesh, const word &phaseName, const word &dictName),(mesh, phaseName, dictName))
Declare run-time constructor selection table for dictionary based.
virtual ~basicThermo()
Destructor.
Definition: basicThermo.C:437
static wordList splitThermoName(const std::string &thermoName, const int nExpectedCmpts)
Split thermo package name into a list of components names.
Definition: basicThermo.C:580
virtual tmp< volScalarField > hc() const =0
Chemical enthalpy [J/kg].
virtual tmp< volScalarField > Cp() const =0
Heat capacity at constant pressure [J/kg/K].
virtual const volScalarField & alpha() const
Thermal diffusivity for enthalpy of mixture [kg/m/s].
Definition: basicThermo.C:634
virtual tmp< scalarField > gamma(const scalarField &p, const scalarField &T, const label patchi) const =0
Gamma = Cp/Cv for patch [].
virtual tmp< scalarField > Cpv(const scalarField &p, const scalarField &T, const label patchi) const =0
Heat capacity at constant pressure/volume for patch [J/kg/K].
declareRunTimeSelectionTable(autoPtr, basicThermo, fvMesh,(const fvMesh &mesh, const word &phaseName),(mesh, phaseName))
Declare run-time constructor selection table.
virtual bool read()
Read thermophysical properties dictionary.
Definition: basicThermo.C:646
volScalarField alpha_
Laminar thermal diffusivity [kg/m/s].
Definition: basicThermo.H:142
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
A class for managing temporary objects.
Definition: tmp.H:65
A class for handling words, derived from Foam::string.
Definition: word.H:68
const dictionary & thermoDict
Definition: EEqn.H:16
dynamicFvMesh & mesh
OBJstream os(runTime.globalPath()/outputName)
const cellShapeList & cells
kappaEff
Definition: TEqn.H:10
Namespace for OpenFOAM.
const direction noexcept
Definition: Scalar.H:223
#define declareRunTimeSelectionTable(ptrWrapper, baseType, argNames, argList, parList)
Declare a run-time selection (variables and adder classes)
dictionary dict
volScalarField & h
scalar T0
Definition: createFields.H:22
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73