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 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "SLGThermo.H"
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34  defineTypeNameAndDebug(SLGThermo, 0);
35 }
36 
37 
38 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
39 
41 :
43  (
44  IOobject
45  (
46  SLGThermo::typeName,
47  mesh.polyMesh::instance(),
48  mesh
49  )
50  ),
51  thermo_(thermo),
52  carrier_(nullptr),
53  liquids_(nullptr),
54  solids_(nullptr)
55 {
56  Info<< "Creating component thermo properties:" << endl;
57 
58  if (isA<basicSpecieMixture>(thermo))
59  {
60  basicSpecieMixture& mcThermo =
61  dynamic_cast<basicSpecieMixture&>(thermo);
62  carrier_ = &mcThermo;
63 
64  Info<< " multi-component carrier - " << mcThermo.species().size()
65  << " species" << endl;
66  }
67  else
68  {
69  Info<< " single component carrier" << endl;
70  }
71 
72  if (thermo.found("liquids"))
73  {
74  liquids_ = liquidMixtureProperties::New(thermo.subDict("liquids"));
75  Info<< " liquids - " << liquids_->components().size()
76  << " components" << endl;
77  }
78  else
79  {
80  Info<< " no liquid components" << endl;
81  }
82 
83  if (thermo.found("solids"))
84  {
85  solids_ = solidMixtureProperties::New(thermo.subDict("solids"));
86  Info<< " solids - " << solids_->components().size()
87  << " components" << endl;
88  }
89  else
90  {
91  Info<< " no solid components" << endl;
92  }
93 }
94 
95 
96 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
97 
99 {}
100 
101 
102 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
103 
105 {
106  return thermo_;
107 }
108 
109 
111 {
112  if (carrier_ == nullptr)
113  {
115  << "carrier requested, but object is not allocated"
116  << abort(FatalError);
117  }
118 
119  return *carrier_;
120 }
121 
122 
124 {
125  if (!liquids_.valid())
126  {
128  << "liquids requested, but object is not allocated"
129  << abort(FatalError);
130  }
131 
132  return *liquids_;
133 }
134 
135 
137 {
138  if (!solids_.valid())
139  {
141  << "solids requested, but object is not allocated"
142  << abort(FatalError);
143  }
144 
145  return *solids_;
146 }
147 
148 
150 (
151  const word& cmptName,
152  bool allowNotfound
153 ) const
154 {
155  forAll(carrier().species(), i)
156  {
157  if (cmptName == carrier_->species()[i])
158  {
159  return i;
160  }
161  }
162 
163  if (!allowNotfound)
164  {
166  << "Unknown carrier component " << cmptName
167  << ". Valid carrier components are:" << nl
168  << carrier_->species() << exit(FatalError);
169  }
170 
171  return -1;
172 }
173 
174 
176 (
177  const word& cmptName,
178  bool allowNotfound
179 ) const
180 {
181  forAll(liquids().components(), i)
182  {
183  if (cmptName == liquids_->components()[i])
184  {
185  return i;
186  }
187  }
188 
189  if (!allowNotfound)
190  {
192  << "Unknown liquid component " << cmptName << ". Valid liquids are:"
193  << nl << liquids_->components() << exit(FatalError);
194  }
195 
196  return -1;
197 }
198 
199 
201 (
202  const word& cmptName,
203  bool allowNotfound
204 ) const
205 {
206  forAll(solids().components(), i)
207  {
208  if (cmptName == solids_->components()[i])
209  {
210  return i;
211  }
212  }
213 
214  if (!allowNotfound)
215  {
217  << "Unknown solid component " << cmptName << ". Valid solids are:"
218  << nl << solids_->components() << exit(FatalError);
219  }
220 
221  return -1;
222 }
223 
224 
226 {
227  return (carrier_ != nullptr);
228 }
229 
230 
232 {
233  return liquids_.valid();
234 }
235 
236 
238 {
239  return solids_.valid();
240 }
241 
242 
243 // ************************************************************************* //
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:104
Foam::SLGThermo::~SLGThermo
virtual ~SLGThermo()
Destructor.
Definition: SLGThermo.C:98
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::SLGThermo::thermo
const fluidThermo & thermo() const
Return reference to the thermo database.
Definition: SLGThermo.C:104
Foam::basicSpecieMixture
Specialization of basicMultiComponentMixture for a mixture consisting of a number for molecular speci...
Definition: basicSpecieMixture.H:54
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:225
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:136
Foam::solidMixtureProperties
A mixture of solids.
Definition: solidMixtureProperties.H:69
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:337
SLGThermo.H
Foam::liquidMixtureProperties::New
static autoPtr< liquidMixtureProperties > New(const dictionary &)
Select construct from dictionary.
Definition: liquidMixtureProperties.C:91
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:290
Foam::label
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:62
Foam::SLGThermo::liquids
const liquidMixtureProperties & liquids() const
Return reference to the global (additional) liquids.
Definition: SLGThermo.C:123
Foam::Info
messageStream Info
Information stream (uses stdout - output is on the master only)
Foam::SLGThermo::carrier
const basicSpecieMixture & carrier() const
Return reference to the gaseous components.
Definition: SLGThermo.C:110
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:84
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:137
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:176
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:67
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:355
Foam::liquidMixtureProperties
A mixture of liquids.
Definition: liquidMixtureProperties.H:68
Foam::nl
constexpr char nl
Definition: Ostream.H:372
Foam::SLGThermo::carrierId
label carrierId(const word &cmptName, bool allowNotFound=false) const
Index of carrier component.
Definition: SLGThermo.C:150
Foam::SLGThermo::hasLiquids
bool hasLiquids() const
Thermo database has liquid components flag.
Definition: SLGThermo.C:231
Foam::SLGThermo::SLGThermo
SLGThermo(const fvMesh &mesh, fluidThermo &thermo)
Construct from mesh.
Definition: SLGThermo.C:40
Foam::SLGThermo::hasSolids
bool hasSolids() const
Thermo database has solid components flag.
Definition: SLGThermo.C:237
Foam::SLGThermo::solidId
label solidId(const word &cmptName, bool allowNotFound=false) const
Index of solid component.
Definition: SLGThermo.C:201
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)