SingleMixtureFraction.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 "SingleMixtureFraction.H"
27 
28 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
29 
30 template<class CloudType>
32 {
33  forAll(this->phaseProps(), phaseI)
34  {
35  switch (this->phaseProps()[phaseI].phase())
36  {
37  case phaseProperties::GAS:
38  {
39  idGas_ = phaseI;
40  break;
41  }
42  case phaseProperties::LIQUID:
43  {
44  idLiquid_ = phaseI;
45  break;
46  }
47  case phaseProperties::SOLID:
48  {
49  idSolid_ = phaseI;
50  break;
51  }
52  default:
53  {
55  (
56  "void Foam::SingleMixtureFraction<CloudType>::"
57  "constructIds()"
58  ) << "Unknown phase enumeration" << nl << abort(FatalError);
59  }
60  }
61  }
62 
63  if (idGas_ < 0)
64  {
65  FatalErrorIn("Foam::SingleMixtureFraction<CloudType>::constructIds()")
66  << "No gas phase found in phase list:" << nl
67  << this->phaseTypes() << exit(FatalError);
68  }
69  if (idLiquid_ < 0)
70  {
71  FatalErrorIn("Foam::SingleMixtureFraction<CloudType>::constructIds()")
72  << "No liquid phase found in phase list:" << nl
73  << this->phaseTypes() << exit(FatalError);
74  }
75  if (idSolid_ < 0)
76  {
77  FatalErrorIn("Foam::SingleMixtureFraction<CloudType>::constructIds()")
78  << "No solid phase found in phase list:" << nl
79  << this->phaseTypes() << exit(FatalError);
80  }
81 }
82 
83 
84 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
85 
86 template<class CloudType>
88 (
89  const dictionary& dict,
90  CloudType& owner
91 )
92 :
93  CompositionModel<CloudType>(dict, owner, typeName),
94 
95  idGas_(-1),
96  idLiquid_(-1),
97  idSolid_(-1),
98 
99  YMixture0_(3)
100 {
101  constructIds();
102 
103  if (this->phaseProps().size() != 3)
104  {
106  (
107  "Foam::SingleMixtureFraction<CloudType>::"
108  "SingleMixtureFraction"
109  "("
110  "const dictionary&, "
111  "CloudType&"
112  ")"
113  ) << "Incorrect numebr of phases: " << nl
114  << " Please specify 1 gas, 1 liquid and 1 solid"
115  << exit(FatalError);
116  }
117 
118  this->coeffDict().lookup("YGasTot0") >> YMixture0_[idGas_];
119  this->coeffDict().lookup("YLiquidTot0") >> YMixture0_[idLiquid_];
120  this->coeffDict().lookup("YSolidTot0") >> YMixture0_[idSolid_];
121 
122  if (mag(sum(YMixture0_) - 1.0) > SMALL)
123  {
125  (
126  "Foam::SingleMixtureFraction<CloudType>::"
127  "SingleMixtureFraction"
128  "("
129  "const dictionary&, "
130  "CloudType&"
131  ")"
132  ) << "Sum of phases should be 1. Phase fractions:" << nl
133  << YMixture0_ << exit(FatalError);
134  }
135 }
136 
137 
138 template<class CloudType>
140 (
142 )
143 :
145  idGas_(cm.idGas_),
146  idLiquid_(cm.idLiquid_),
147  idSolid_(cm.idSolid_),
148  YMixture0_(cm.YMixture0_)
149 {}
150 
151 
152 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
153 
154 template<class CloudType>
156 {}
157 
158 
159 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
160 
161 template<class CloudType>
162 const Foam::scalarField&
164 {
165  return YMixture0_;
166 }
167 
168 
169 template<class CloudType>
171 {
172  return idGas_;
173 }
174 
175 
176 template<class CloudType>
178 {
179  return idLiquid_;
180 }
181 
182 
183 template<class CloudType>
185 {
186  return idSolid_;
187 }
188 
189 
190 // ************************************************************************* //
virtual label idGas() const
Gas id.
virtual label idSolid() const
Solid id.
dimensioned< scalar > mag(const dimensioned< Type > &)
Templated parcel multi-phase, multi-component class.
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
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
virtual label idLiquid() const
Liquid id.
virtual ~SingleMixtureFraction()
Destructor.
dictionary dict
static const char nl
Definition: Ostream.H:260
SingleMixtureFraction(const dictionary &dict, CloudType &owner)
Construct from dictionary.
#define forAll(list, i)
Definition: UList.H:421
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
errorManip< error > abort(error &err)
Definition: errorManip.H:131
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:314
virtual const scalarField & YMixture0() const
Return the list of mixture mass fractions.
error FatalError
Templated reacting parcel composition model class Consists of carrier species (via thermo package)...
Definition: ReactingCloud.H:52
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:68