SLGThermo.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) 2011-2016 OpenFOAM Foundation
9 Copyright (C) 2020 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 "SLGThermo.H"
30
31// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32
33namespace Foam
34{
36}
37
38
39// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
40
42:
44 (
46 (
47 SLGThermo::typeName,
48 mesh.polyMesh::instance(),
49 mesh
50 )
51 ),
52 thermo_(thermo),
53 carrier_(nullptr),
54 liquids_(nullptr),
55 solids_(nullptr)
56{
57 Info<< "Creating component thermo properties:" << endl;
58
59 if (isA<basicSpecieMixture>(thermo))
60 {
61 basicSpecieMixture& mcThermo =
62 dynamic_cast<basicSpecieMixture&>(thermo);
63 carrier_ = &mcThermo;
64
65 Info<< " multi-component carrier - " << mcThermo.species().size()
66 << " species" << endl;
67 }
68 else
69 {
70 Info<< " single component carrier" << endl;
71 }
72
73 if (thermo.found("liquids"))
74 {
75 liquids_ = liquidMixtureProperties::New(thermo.subDict("liquids"));
76 Info<< " liquids - " << liquids_->components().size()
77 << " components" << endl;
78 }
79 else
80 {
81 Info<< " no liquid components" << endl;
82 }
83
84 if (thermo.found("solids"))
85 {
86 solids_ = solidMixtureProperties::New(thermo.subDict("solids"));
87 Info<< " solids - " << solids_->components().size()
88 << " components" << endl;
89 }
90 else
91 {
92 Info<< " no solid components" << endl;
93 }
94}
95
96
97// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
98
100{}
101
102
103// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
104
106{
107 return thermo_;
108}
109
110
112{
113 if (carrier_ == nullptr)
114 {
116 << "carrier requested, but object is not allocated"
117 << abort(FatalError);
118 }
119
120 return *carrier_;
121}
122
123
125{
126 if (!liquids_)
127 {
129 << "liquids requested, but object is not allocated"
130 << abort(FatalError);
131 }
132
133 return *liquids_;
134}
135
136
138{
139 if (!solids_)
140 {
142 << "solids requested, but object is not allocated"
143 << abort(FatalError);
144 }
145
146 return *solids_;
147}
148
149
151(
152 const word& cmptName,
153 bool allowNotfound
154) const
155{
156 forAll(carrier().species(), i)
157 {
158 if (cmptName == carrier_->species()[i])
159 {
160 return i;
161 }
162 }
163
164 if (!allowNotfound)
165 {
167 << "Unknown carrier component " << cmptName
168 << ". Valid carrier components are:" << nl
169 << carrier_->species() << exit(FatalError);
170 }
171
172 return -1;
173}
174
175
177(
178 const word& cmptName,
179 bool allowNotfound
180) const
181{
182 forAll(liquids().components(), i)
183 {
184 if (cmptName == liquids_->components()[i])
185 {
186 return i;
187 }
188 }
189
190 if (!allowNotfound)
191 {
193 << "Unknown liquid component " << cmptName << ". Valid liquids are:"
194 << nl << liquids_->components() << exit(FatalError);
195 }
196
197 return -1;
198}
199
200
202(
203 const word& cmptName,
204 bool allowNotfound
205) const
206{
207 forAll(solids().components(), i)
208 {
209 if (cmptName == solids_->components()[i])
210 {
211 return i;
212 }
213 }
214
215 if (!allowNotfound)
216 {
218 << "Unknown solid component " << cmptName << ". Valid solids are:"
219 << nl << solids_->components() << exit(FatalError);
220 }
221
222 return -1;
223}
224
225
227{
228 return (carrier_ != nullptr);
229}
230
231
233{
234 return bool(liquids_);
235}
236
237
239{
240 return bool(solids_);
241}
242
243
244// ************************************************************************* //
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
Thermo package for (S)olids (L)iquids and (G)ases Takes reference to thermo package,...
Definition: SLGThermo.H:67
const liquidMixtureProperties & liquids() const
Return reference to the global (additional) liquids.
Definition: SLGThermo.C:124
label solidId(const word &cmptName, bool allowNotFound=false) const
Index of solid component.
Definition: SLGThermo.C:202
label liquidId(const word &cmptName, bool allowNotFound=false) const
Index of liquid component.
Definition: SLGThermo.C:177
const fluidThermo & thermo() const
Return reference to the thermo database.
Definition: SLGThermo.C:105
label carrierId(const word &cmptName, bool allowNotFound=false) const
Index of carrier component.
Definition: SLGThermo.C:151
const basicSpecieMixture & carrier() const
Return reference to the gaseous components.
Definition: SLGThermo.C:111
virtual ~SLGThermo()
Destructor.
Definition: SLGThermo.C:99
bool hasLiquids() const
Thermo database has liquid components flag.
Definition: SLGThermo.C:232
bool hasMultiComponentCarrier() const
Thermo database has multi-component carrier flag.
Definition: SLGThermo.C:226
const solidMixtureProperties & solids() const
Return reference to the global (additional) solids.
Definition: SLGThermo.C:137
bool hasSolids() const
Thermo database has solid components flag.
Definition: SLGThermo.C:238
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
Definition: Time.C:717
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
const speciesTable & species() const
Return the table of species.
Specialization of basicMultiComponentMixture for a mixture consisting of a number for molecular speci...
Fundamental fluid thermodynamic properties.
Definition: fluidThermo.H:56
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:76
Basic thermodynamics type based on the use of fitting functions for cp, h, s obtained from the templa...
A class for handling words, derived from Foam::string.
Definition: word.H:68
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition: className.H:121
bool
Definition: EEqn.H:20
dynamicFvMesh & mesh
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Namespace for OpenFOAM.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
errorManip< error > abort(error &err)
Definition: errorManip.H:144
error FatalError
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333