SLGThermo.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "SLGThermo.H"
27 
28 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
29 
30 namespace Foam
31 {
32  defineTypeNameAndDebug(SLGThermo, 0);
33 }
34 
35 
36 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
37 
39 :
41  (
42  IOobject
43  (
44  SLGThermo::typeName,
45  mesh.polyMesh::instance(),
46  mesh
47  )
48  ),
49  thermo_(thermo),
50  carrier_(nullptr),
51  liquids_(nullptr),
52  solids_(nullptr)
53 {
54  Info<< "Creating component thermo properties:" << endl;
55 
56  if (isA<basicSpecieMixture>(thermo))
57  {
58  basicSpecieMixture& mcThermo =
59  dynamic_cast<basicSpecieMixture&>(thermo);
60  carrier_ = &mcThermo;
61 
62  Info<< " multi-component carrier - " << mcThermo.species().size()
63  << " species" << endl;
64  }
65  else
66  {
67  Info<< " single component carrier" << endl;
68  }
69 
70  if (thermo.found("liquids"))
71  {
72  liquids_ = liquidMixtureProperties::New(thermo.subDict("liquids"));
73  Info<< " liquids - " << liquids_->components().size()
74  << " components" << endl;
75  }
76  else
77  {
78  Info<< " no liquid components" << endl;
79  }
80 
81  if (thermo.found("solids"))
82  {
83  solids_ = solidMixtureProperties::New(thermo.subDict("solids"));
84  Info<< " solids - " << solids_->components().size()
85  << " components" << endl;
86  }
87  else
88  {
89  Info<< " no solid components" << endl;
90  }
91 }
92 
93 
94 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
95 
97 {}
98 
99 
100 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
101 
103 {
104  return thermo_;
105 }
106 
107 
109 {
110  if (carrier_ == nullptr)
111  {
113  << "carrier requested, but object is not allocated"
114  << abort(FatalError);
115  }
116 
117  return *carrier_;
118 }
119 
120 
122 {
123  if (!liquids_.valid())
124  {
126  << "liquids requested, but object is not allocated"
127  << abort(FatalError);
128  }
129 
130  return liquids_();
131 }
132 
133 
135 {
136  if (!solids_.valid())
137  {
139  << "solids requested, but object is not allocated"
140  << abort(FatalError);
141  }
142 
143  return solids_();
144 }
145 
146 
148 (
149  const word& cmptName,
150  bool allowNotfound
151 ) const
152 {
153  forAll(carrier().species(), i)
154  {
155  if (cmptName == carrier_->species()[i])
156  {
157  return i;
158  }
159  }
160 
161  if (!allowNotfound)
162  {
164  << "Unknown carrier component " << cmptName
165  << ". Valid carrier components are:" << nl
166  << carrier_->species() << exit(FatalError);
167  }
168 
169  return -1;
170 }
171 
172 
174 (
175  const word& cmptName,
176  bool allowNotfound
177 ) const
178 {
179  forAll(liquids().components(), i)
180  {
181  if (cmptName == liquids_->components()[i])
182  {
183  return i;
184  }
185  }
186 
187  if (!allowNotfound)
188  {
190  << "Unknown liquid component " << cmptName << ". Valid liquids are:"
191  << nl << liquids_->components() << exit(FatalError);
192  }
193 
194  return -1;
195 }
196 
197 
199 (
200  const word& cmptName,
201  bool allowNotfound
202 ) const
203 {
204  forAll(solids().components(), i)
205  {
206  if (cmptName == solids_->components()[i])
207  {
208  return i;
209  }
210  }
211 
212  if (!allowNotfound)
213  {
215  << "Unknown solid component " << cmptName << ". Valid solids are:"
216  << nl << solids_->components() << exit(FatalError);
217  }
218 
219  return -1;
220 }
221 
222 
224 {
225  return (carrier_ != nullptr);
226 }
227 
228 
230 {
231  return liquids_.valid();
232 }
233 
234 
236 {
237  return solids_.valid();
238 }
239 
240 
241 // ************************************************************************* //
bool hasSolids() const
Thermo database has solid components flag.
Definition: SLGThermo.C:235
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:431
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:428
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
error FatalError
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
virtual ~SLGThermo()
Destructor.
Definition: SLGThermo.C:96
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:163
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:256
const speciesTable & species() const
Return the table of species.
bool hasMultiComponentCarrier() const
Thermo database has multi-component carrier flag.
Definition: SLGThermo.C:223
rhoReactionThermo & thermo
Definition: createFields.H:28
Specialization of basicMultiComponentMixture for a mixture consisting of a number for molecular speci...
const solidMixtureProperties & solids() const
Return reference to the global (additional) solids.
Definition: SLGThermo.C:134
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Definition: dictionary.C:692
static autoPtr< liquidMixtureProperties > New(const dictionary &)
Select construct from dictionary.
dynamicFvMesh & mesh
A class for handling words, derived from string.
Definition: word.H:59
Fundamental fluid thermodynamic properties.
Definition: fluidThermo.H:49
const liquidMixtureProperties & liquids() const
Return reference to the global (additional) liquids.
Definition: SLGThermo.C:121
Thermo package for (S)olids (L)iquids and (G)ases Takes reference to thermo package, and provides:
Definition: SLGThermo.H:62
errorManip< error > abort(error &err)
Definition: errorManip.H:131
static const char nl
Definition: Ostream.H:265
defineTypeNameAndDebug(combustionModel, 0)
const basicSpecieMixture & carrier() const
Return reference to the gaseous components.
Definition: SLGThermo.C:108
label liquidId(const word &cmptName, bool allowNotFound=false) const
Index of liquid component.
Definition: SLGThermo.C:174
label carrierId(const word &cmptName, bool allowNotFound=false) const
Index of carrier component.
Definition: SLGThermo.C:148
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:65
messageStream Info
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
bool hasLiquids() const
Thermo database has liquid components flag.
Definition: SLGThermo.C:229
static autoPtr< solidMixtureProperties > New(const dictionary &)
Select construct from dictionary.
SLGThermo(const fvMesh &mesh, fluidThermo &thermo)
Construct from mesh.
Definition: SLGThermo.C:38
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:92
Namespace for OpenFOAM.
label solidId(const word &cmptName, bool allowNotFound=false) const
Index of solid component.
Definition: SLGThermo.C:199
const fluidThermo & thermo() const
Return reference to the thermo database.
Definition: SLGThermo.C:102