All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
parcelThermo.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-2021 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 "parcelThermo.H"
27 
28 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
29 
31 :
32  liquids_(nullptr),
33  solids_(nullptr)
34 {
35  Info<< "Creating component thermo properties:" << endl;
36 
37  if (carrierThermo.properties().found("liquids"))
38  {
40  (
41  carrierThermo.properties().subDict("liquids")
42  );
43  Info<< " liquids - " << liquids_->components().size()
44  << " components" << endl;
45  }
46  else
47  {
48  Info<< " no liquid components" << endl;
49  }
50 
51  if (carrierThermo.properties().found("solids"))
52  {
54  (
55  carrierThermo.properties().subDict("solids")
56  );
57  Info<< " solids - " << solids_->components().size()
58  << " components" << endl;
59  }
60  else
61  {
62  Info<< " no solid components" << endl;
63  }
64 }
65 
66 
68 :
69  liquids_(pThermo.liquids_, false),
70  solids_(pThermo.solids_, false)
71 {}
72 
73 
74 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
75 
77 {}
78 
79 
80 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
81 
83 {
84  if (!liquids_.valid())
85  {
87  << "liquids requested, but object is not allocated"
88  << abort(FatalError);
89  }
90 
91  return liquids_();
92 }
93 
94 
96 {
97  if (!solids_.valid())
98  {
100  << "solids requested, but object is not allocated"
101  << abort(FatalError);
102  }
103 
104  return solids_();
105 }
106 
107 
109 (
110  const word& cmptName,
111  bool allowNotfound
112 ) const
113 {
114  forAll(liquids().components(), i)
115  {
116  if (cmptName == liquids_->components()[i])
117  {
118  return i;
119  }
120  }
121 
122  if (!allowNotfound)
123  {
125  << "Unknown liquid component " << cmptName << ". Valid liquids are:"
126  << nl << liquids_->components() << exit(FatalError);
127  }
128 
129  return -1;
130 }
131 
132 
134 (
135  const word& cmptName,
136  bool allowNotfound
137 ) const
138 {
139  forAll(solids().components(), i)
140  {
141  if (cmptName == solids_->components()[i])
142  {
143  return i;
144  }
145  }
146 
147  if (!allowNotfound)
148  {
150  << "Unknown solid component " << cmptName << ". Valid solids are:"
151  << nl << solids_->components() << exit(FatalError);
152  }
153 
154  return -1;
155 }
156 
157 
158 // ************************************************************************* //
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:663
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
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:306
Thermo package for (S)olids (L)iquids and (G)ases Takes reference to thermo package, and provides:
Definition: parcelThermo.H:58
Info<< "Reading thermophysical properties\"<< endl;autoPtr< fluidReactionThermo > pThermo(fluidReactionThermo::New(mesh))
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Definition: dictionary.C:1002
label liquidId(const word &cmptName, bool allowNotFound=false) const
Index of liquid component.
Definition: parcelThermo.C:109
virtual const IOdictionary & properties() const =0
Properties dictionary.
static autoPtr< liquidMixtureProperties > New(const dictionary &)
Select construct from dictionary.
label solidId(const word &cmptName, bool allowNotFound=false) const
Index of solid component.
Definition: parcelThermo.C:134
A class for handling words, derived from string.
Definition: word.H:59
Base-class for fluid thermodynamic properties.
Definition: fluidThermo.H:53
const solidMixtureProperties & solids() const
Return reference to the global (additional) solids.
Definition: parcelThermo.C:95
errorManip< error > abort(error &err)
Definition: errorManip.H:131
static const char nl
Definition: Ostream.H:260
const liquidMixtureProperties & liquids() const
Return reference to the global (additional) liquids.
Definition: parcelThermo.C:82
messageStream Info
parcelThermo(const fluidThermo &carrierThermo)
Construct from carrier thermo.
Definition: parcelThermo.C:30
static autoPtr< solidMixtureProperties > New(const dictionary &)
Select construct from dictionary.
virtual ~parcelThermo()
Destructor.
Definition: parcelThermo.C:76