Loading...
Searching...
No Matches
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\*---------------------------------------------------------------------------*/
29#include "SLGThermo.H"
30
31// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32
33namespace Foam
36}
37
38
39// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
40
42:
44 (
46 (
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
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 * * * * * * * * * * * * * * * //
102
103// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
106{
107 return thermo_;
108}
109
110
112{
113 if (carrier_ == nullptr)
114 {
116 << "carrier requested, but object is not allocated"
118 }
119
120 return *carrier_;
121}
122
123
125{
126 if (!liquids_)
127 {
129 << "liquids requested, but object is not allocated"
131 }
132
133 return *liquids_;
134}
135
136
138{
139 if (!solids_)
140 {
142 << "solids requested, but object is not allocated"
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
201Foam::label Foam::SLGThermo::solidId
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
227{
228 return (carrier_ != nullptr);
229}
230
233{
234 return bool(liquids_);
235}
236
237
239{
240 return bool(solids_);
241}
242
243
244// ************************************************************************* //
if(maxValue - minValue< SMALL)
if(patchID !=-1)
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition IOobject.H:191
const fileName & instance() const noexcept
Read access to instance path component.
Definition IOobjectI.H:289
Thermo package for (S)olids (L)iquids and (G)ases Takes reference to thermo package,...
Definition SLGThermo.H:63
const liquidMixtureProperties & liquids() const
Return reference to the global (additional) liquids.
Definition SLGThermo.C:117
SLGThermo(const fvMesh &mesh, fluidThermo &thermo)
Construct from mesh.
Definition SLGThermo.C:34
label solidId(const word &cmptName, bool allowNotFound=false) const
Index of solid component.
Definition SLGThermo.C:195
label liquidId(const word &cmptName, bool allowNotFound=false) const
Index of liquid component.
Definition SLGThermo.C:170
const fluidThermo & thermo() const
Return reference to the thermo database.
Definition SLGThermo.C:98
label carrierId(const word &cmptName, bool allowNotFound=false) const
Index of carrier component.
Definition SLGThermo.C:144
const basicSpecieMixture & carrier() const
Return reference to the gaseous components.
Definition SLGThermo.C:104
virtual ~SLGThermo()
Destructor.
Definition SLGThermo.C:92
bool hasLiquids() const
Thermo database has liquid components flag.
Definition SLGThermo.C:225
bool hasMultiComponentCarrier() const
Thermo database has multi-component carrier flag.
Definition SLGThermo.C:219
const solidMixtureProperties & solids() const
Return reference to the global (additional) solids.
Definition SLGThermo.C:130
bool hasSolids() const
Thermo database has solid components flag.
Definition SLGThermo.C:231
void size(const label n)
Older name for setAddressableSize.
Definition UList.H:118
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:52
Mesh data needed to do the Finite Volume discretisation.
Definition fvMesh.H:85
Mesh consisting of general polyhedral cells.
Definition polyMesh.H:79
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition regIOobject.H:71
regIOobject(const IOobject &io, const bool isTimeObject=false)
Construct from IOobject. The optional flag adds special handling if the object is the top-level regIO...
Definition regIOobject.C:43
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:66
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition className.H:142
dynamicFvMesh & mesh
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition error.H:600
Namespace for OpenFOAM.
messageStream Info
Information stream (stdout output on master, null elsewhere).
const word GlobalIOList< Tuple2< scalar, vector > >::typeName("scalarVectorTable")
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
Definition typeInfo.H:87
errorManip< error > abort(error &err)
Definition errorManip.H:139
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition errorManip.H:125
constexpr char nl
The newline '\n' character (0x0a).
Definition Ostream.H:50
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299