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 -------------------------------------------------------------------------------
11 License
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 
33 namespace Foam
34 {
35  defineTypeNameAndDebug(SLGThermo, 0);
36 }
37 
38 
39 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
40 
42 :
44  (
45  IOobject
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 
150 Foam::label Foam::SLGThermo::carrierId
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 
176 Foam::label Foam::SLGThermo::liquidId
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 
201 Foam::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 
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 // ************************************************************************* //
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
Foam::SLGThermo::~SLGThermo
virtual ~SLGThermo()
Destructor.
Definition: SLGThermo.C:99
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::SLGThermo::thermo
const fluidThermo & thermo() const
Return reference to the thermo database.
Definition: SLGThermo.C:105
Foam::basicSpecieMixture
Specialization of basicMultiComponentMixture for a mixture consisting of a number for molecular speci...
Definition: basicSpecieMixture.H:58
Foam::SLGThermo
Thermo package for (S)olids (L)iquids and (G)ases Takes reference to thermo package,...
Definition: SLGThermo.H:64
Foam::SLGThermo::hasMultiComponentCarrier
bool hasMultiComponentCarrier() const
Thermo database has multi-component carrier flag.
Definition: SLGThermo.C:226
Foam::basicMultiComponentMixture::species
const speciesTable & species() const
Return the table of species.
Definition: basicMultiComponentMixtureI.H:29
Foam::fluidThermo
Fundamental fluid thermodynamic properties.
Definition: fluidThermo.H:52
thermo
Basic thermodynamics type based on the use of fitting functions for cp, h, s obtained from the templa...
Foam::SLGThermo::solids
const solidMixtureProperties & solids() const
Return reference to the global (additional) solids.
Definition: SLGThermo.C:137
Foam::solidMixtureProperties
A mixture of solids.
Definition: solidMixtureProperties.H:69
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
SLGThermo.H
Foam::liquidMixtureProperties::New
static autoPtr< liquidMixtureProperties > New(const dictionary &)
Select construct from dictionary.
Definition: liquidMixtureProperties.C:92
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::SLGThermo::liquids
const liquidMixtureProperties & liquids() const
Return reference to the global (additional) liquids.
Definition: SLGThermo.C:124
Foam::Info
messageStream Info
Information stream (stdout output on master, null elsewhere)
Foam::SLGThermo::carrier
const basicSpecieMixture & carrier() const
Return reference to the gaseous components.
Definition: SLGThermo.C:111
Foam::FatalError
error FatalError
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:144
Foam::solidMixtureProperties::New
static autoPtr< solidMixtureProperties > New(const dictionary &)
Select construct from dictionary.
Definition: solidMixtureProperties.C:80
Foam::SLGThermo::liquidId
label liquidId(const word &cmptName, bool allowNotFound=false) const
Index of liquid component.
Definition: SLGThermo.C:177
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::regIOobject
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:73
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Foam::liquidMixtureProperties
A mixture of liquids.
Definition: liquidMixtureProperties.H:68
Foam::nl
constexpr char nl
Definition: Ostream.H:404
Foam::SLGThermo::carrierId
label carrierId(const word &cmptName, bool allowNotFound=false) const
Index of carrier component.
Definition: SLGThermo.C:151
Foam::SLGThermo::hasLiquids
bool hasLiquids() const
Thermo database has liquid components flag.
Definition: SLGThermo.C:232
bool
bool
Definition: EEqn.H:20
Foam::SLGThermo::SLGThermo
SLGThermo(const fvMesh &mesh, fluidThermo &thermo)
Construct from mesh.
Definition: SLGThermo.C:41
Foam::SLGThermo::hasSolids
bool hasSolids() const
Thermo database has solid components flag.
Definition: SLGThermo.C:238
Foam::SLGThermo::solidId
label solidId(const word &cmptName, bool allowNotFound=false) const
Index of solid component.
Definition: SLGThermo.C:202
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)