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 | Copyright (C) 2011-2015 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_(NULL),
51  liquids_(NULL),
52  solids_(NULL)
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_ == NULL)
111  {
113  (
114  "const Foam::basicSpecieMixture& "
115  "Foam::SLGThermo::carrier() const"
116  ) << "carrier requested, but object is not allocated"
117  << abort(FatalError);
118  }
119 
120  return *carrier_;
121 }
122 
123 
125 {
126  if (!liquids_.valid())
127  {
129  (
130  "const Foam::liquidMixtureProperties& "
131  "Foam::SLGThermo::liquids() const"
132  ) << "liquids requested, but object is not allocated"
133  << abort(FatalError);
134  }
135 
136  return liquids_();
137 }
138 
139 
141 {
142  if (!solids_.valid())
143  {
145  (
146  "const Foam::solidMixtureProperties& "
147  "Foam::SLGThermo::solids() const"
148  ) << "solids requested, but object is not allocated"
149  << abort(FatalError);
150  }
151 
152  return solids_();
153 }
154 
155 
157 (
158  const word& cmptName,
159  bool allowNotfound
160 ) const
161 {
162  forAll(carrier().species(), i)
163  {
164  if (cmptName == carrier_->species()[i])
165  {
166  return i;
167  }
168  }
169 
170  if (!allowNotfound)
171  {
173  (
174  "Foam::label Foam::SLGThermo::carrierId(const word&, bool) const"
175  ) << "Unknown carrier component " << cmptName
176  << ". Valid carrier components are:" << nl
177  << carrier_->species() << exit(FatalError);
178  }
179 
180  return -1;
181 }
182 
183 
185 (
186  const word& cmptName,
187  bool allowNotfound
188 ) const
189 {
190  forAll(liquids().components(), i)
191  {
192  if (cmptName == liquids_->components()[i])
193  {
194  return i;
195  }
196  }
197 
198  if (!allowNotfound)
199  {
201  (
202  "Foam::label Foam::SLGThermo::liquidId(const word&, bool) const"
203  ) << "Unknown liquid component " << cmptName << ". Valid liquids are:"
204  << nl << liquids_->components() << exit(FatalError);
205  }
206 
207  return -1;
208 }
209 
210 
212 (
213  const word& cmptName,
214  bool allowNotfound
215 ) const
216 {
217  forAll(solids().components(), i)
218  {
219  if (cmptName == solids_->components()[i])
220  {
221  return i;
222  }
223  }
224 
225  if (!allowNotfound)
226  {
228  (
229  "Foam::label Foam::SLGThermo::solidId(const word&, bool) const"
230  ) << "Unknown solid component " << cmptName << ". Valid solids are:"
231  << nl << solids_->components() << exit(FatalError);
232  }
233 
234  return -1;
235 }
236 
237 
239 {
240  return (carrier_ != NULL);
241 }
242 
243 
245 {
246  return liquids_.valid();
247 }
248 
249 
251 {
252  return solids_.valid();
253 }
254 
255 
256 // ************************************************************************* //
label solidId(const word &cmptName, bool allowNotFound=false) const
Index of solid component.
Definition: SLGThermo.C:212
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:306
const basicSpecieMixture & carrier() const
Return reference to the gaseous components.
Definition: SLGThermo.C:108
static autoPtr< liquidMixtureProperties > New(const dictionary &)
Select construct from dictionary.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
A class for handling words, derived from string.
Definition: word.H:59
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
const fluidThermo & thermo() const
Return reference to the thermo database.
Definition: SLGThermo.C:102
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:76
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
SLGThermo(const fvMesh &mesh, fluidThermo &thermo)
Construct from mesh.
Definition: SLGThermo.C:38
static autoPtr< solidMixtureProperties > New(const dictionary &)
Select construct from dictionary.
messageStream Info
dynamicFvMesh & mesh
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Definition: dictionary.C:638
Namespace for OpenFOAM.
Thermo package for (S)olids (L)iquids and (G)ases Takes reference to thermo package, and provides:
Definition: SLGThermo.H:62
static const char nl
Definition: Ostream.H:260
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
#define forAll(list, i)
Definition: UList.H:421
const solidMixtureProperties & solids() const
Return reference to the global (additional) solids.
Definition: SLGThermo.C:140
errorManip< error > abort(error &err)
Definition: errorManip.H:131
Fundamental fluid thermodynamic properties.
Definition: fluidThermo.H:49
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:314
virtual ~SLGThermo()
Destructor.
Definition: SLGThermo.C:96
bool hasLiquids() const
Thermo database has liquid components flag.
Definition: SLGThermo.C:244
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:60
error FatalError
bool hasSolids() const
Thermo database has solid components flag.
Definition: SLGThermo.C:250
bool hasMultiComponentCarrier() const
Thermo database has multi-component carrier flag.
Definition: SLGThermo.C:238
const speciesTable & species() const
Return the table of species.
Specialization of basicMultiComponentMixture for a mixture consisting of a number for molecular speci...
Basic thermodynamics type based on the use of fitting functions for cp, h, s obtained from the templa...
label carrierId(const word &cmptName, bool allowNotFound=false) const
Index of carrier component.
Definition: SLGThermo.C:157
const liquidMixtureProperties & liquids() const
Return reference to the global (additional) liquids.
Definition: SLGThermo.C:124
defineTypeNameAndDebug(combustionModel, 0)
label liquidId(const word &cmptName, bool allowNotFound=false) const
Index of liquid component.
Definition: SLGThermo.C:185