basicThermoTemplates.C
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) 2012-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
27\*---------------------------------------------------------------------------*/
28
29#include "basicThermo.H"
30
31// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
32
33template<class Thermo, class ThermoConstructTable>
34typename ThermoConstructTable::mapped_type
35Foam::basicThermo::getThermoOrDie
36(
37 const dictionary& thermoTypeDict,
38 ThermoConstructTable& thermoTable,
39 const word& thermoTypeName,
40 const wordList& cmptNames
41)
42{
43 // Lookup the thermo package
44
45 auto ctorIter = thermoTable.cfind(thermoTypeName);
46
47 // Print error message if package not found in the table
48 if (!ctorIter.found())
49 {
51 (
52 thermoTypeDict,
53 Thermo::typeName,
54 word::null, // Suppress long name? Just output dictionary (above)
55 thermoTable
56 );
57
59 (
61 cmptNames,
62 thermoTable.sortedToc()
63 ) << exit(FatalIOError);
64
65 // return nullptr;
66 }
67
68 return ctorIter.val();
69}
70
71
72template<class Thermo, class ThermoConstructTable>
73typename ThermoConstructTable::mapped_type
74Foam::basicThermo::getThermoOrDie
75(
76 const dictionary& thermoDict,
77 ThermoConstructTable& thermoTable
78)
79{
80 const dictionary* dictptr = thermoDict.findDict("thermoType");
81
82 if (dictptr)
83 {
84 const auto& thermoTypeDict = *dictptr;
85
86 const wordList* cmptHeaderPtr = &(wordList::null());
87
88 // Thermo package name, constructed from components
89 const word thermoTypeName
90 (
91 basicThermo::makeThermoName(thermoTypeDict, cmptHeaderPtr)
92 );
93
94 Info<< "Selecting thermodynamics package " << thermoTypeDict << endl;
95
96 return getThermoOrDie<Thermo, ThermoConstructTable>
97 (
98 thermoTypeDict,
99 thermoTable,
100 thermoTypeName,
101 *cmptHeaderPtr
102 );
103 }
104 else
105 {
106 const word thermoTypeName(thermoDict.get<word>("thermoType"));
107
108 Info<< "Selecting thermodynamics package " << thermoTypeName << endl;
109
110 auto ctorIter = thermoTable.cfind(thermoTypeName);
111
112 if (!ctorIter.found())
113 {
115 (
117 Thermo::typeName,
118 thermoTypeName,
119 thermoTable
120 ) << exit(FatalIOError);
121 }
122
123 return ctorIter.val();
124 }
125}
126
127
128// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
129
130template<class Thermo>
132(
133 const fvMesh& mesh,
134 const word& phaseName
135)
136{
138 (
140 (
141 phasePropertyName(dictName, phaseName),
142 mesh.time().constant(),
143 mesh,
146 false
147 )
148 );
149
150 auto* ctorPtr = getThermoOrDie<Thermo>
151 (
153 *(Thermo::fvMeshConstructorTablePtr_)
154 );
155
156 return autoPtr<Thermo>(ctorPtr(mesh, phaseName));
157}
158
159
160template<class Thermo>
162(
163 const fvMesh& mesh,
164 const dictionary& dict,
165 const word& phaseName
166)
167{
168 auto* ctorPtr = getThermoOrDie<Thermo>
169 (
170 dict,
171 *(Thermo::dictionaryConstructorTablePtr_)
172 );
173
174 return autoPtr<Thermo>(ctorPtr(mesh, dict, phaseName));
175}
176
177
178template<class Thermo>
180(
181 const fvMesh& mesh,
182 const word& phaseName,
183 const word& dictName
184)
185{
187 (
189 (
190 dictName,
191 mesh.time().constant(),
192 mesh,
195 false
196 )
197 );
198
199 auto* ctorPtr = getThermoOrDie<Thermo>
200 (
202 *(Thermo::fvMeshDictPhaseConstructorTablePtr_)
203 );
204
205 return autoPtr<Thermo>(ctorPtr(mesh, phaseName, dictName));
206}
207
208
209// ************************************************************************* //
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:57
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
@ MUST_READ_IF_MODIFIED
Definition: IOobject.H:180
static const List< word > & null()
Return a null List.
Definition: ListI.H:109
const word & constant() const
Return constant name.
Definition: TimePathsI.H:96
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
Definition: Time.C:717
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
static Ostream & printThermoNames(Ostream &os, const wordList &cmptNames, const wordList &thermoNames)
Print (filtered) table of thermo names, splits on " ,<>".
Definition: basicThermo.C:75
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
dictionary * findDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX)
Find and return a sub-dictionary pointer if present.
Definition: dictionaryI.H:127
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:290
A class for handling words, derived from Foam::string.
Definition: word.H:68
static const word null
An empty word.
Definition: word.H:80
const dictionary & thermoDict
Definition: EEqn.H:16
dynamicFvMesh & mesh
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
Definition: error.H:478
const word dictName("faMeshDefinition")
List< word > wordList
A List of words.
Definition: fileName.H:63
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
IOerror FatalIOError
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
dictionary dict