SingleMixtureFraction.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-2020 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  << "Unknown phase enumeration" << nl << abort(FatalError);
56  }
57  }
58  }
59 
60  if (idGas_ < 0)
61  {
63  << "No gas phase found in phase list:" << nl
64  << this->phaseTypes() << exit(FatalError);
65  }
66  if (idLiquid_ < 0)
67  {
69  << "No liquid phase found in phase list:" << nl
70  << this->phaseTypes() << exit(FatalError);
71  }
72  if (idSolid_ < 0)
73  {
75  << "No solid phase found in phase list:" << nl
76  << this->phaseTypes() << exit(FatalError);
77  }
78 }
79 
80 
81 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
82 
83 template<class CloudType>
85 (
86  const dictionary& dict,
87  CloudType& owner
88 )
89 :
90  CompositionModel<CloudType>(dict, owner, typeName),
91 
92  idGas_(-1),
93  idLiquid_(-1),
94  idSolid_(-1),
95 
96  YMixture0_(3)
97 {
98  constructIds();
99 
100  if (this->phaseProps().size() != 3)
101  {
103  << "Incorrect number of phases: " << nl
104  << " Please specify 1 gas, 1 liquid and 1 solid"
105  << exit(FatalError);
106  }
107 
108  this->coeffDict().lookup("YGasTot0") >> YMixture0_[idGas_];
109  this->coeffDict().lookup("YLiquidTot0") >> YMixture0_[idLiquid_];
110  this->coeffDict().lookup("YSolidTot0") >> YMixture0_[idSolid_];
111 
112  if (mag(sum(YMixture0_) - 1.0) > small)
113  {
115  << "Sum of phases should be 1. Phase fractions:" << nl
116  << YMixture0_ << exit(FatalError);
117  }
118 }
119 
120 
121 template<class CloudType>
123 (
125 )
126 :
128  idGas_(cm.idGas_),
129  idLiquid_(cm.idLiquid_),
130  idSolid_(cm.idSolid_),
131  YMixture0_(cm.YMixture0_)
132 {}
133 
134 
135 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
136 
137 template<class CloudType>
139 {}
140 
141 
142 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
143 
144 template<class CloudType>
145 const Foam::scalarField&
147 {
148  return YMixture0_;
149 }
150 
151 
152 template<class CloudType>
154 {
155  return idGas_;
156 }
157 
158 
159 template<class CloudType>
161 {
162  return idLiquid_;
163 }
164 
165 
166 template<class CloudType>
168 {
169  return idSolid_;
170 }
171 
172 
173 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
Templated reacting parcel composition model class Consists of carrier species (via thermo package),...
const phasePropertiesList & phaseProps() const
Return the list of phase properties.
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:80
Templated parcel multi-phase, multi-component class.
virtual const scalarField & YMixture0() const
Return the list of mixture mass fractions.
virtual ~SingleMixtureFraction()
Destructor.
SingleMixtureFraction(const dictionary &dict, CloudType &owner)
Construct from dictionary.
virtual label idGas() const
Gas id.
virtual label idLiquid() const
Liquid id.
virtual label idSolid() const
Solid id.
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:710
const dictionary & coeffDict() const
Return const access to the coefficients dictionary.
Definition: subModelBase.C:128
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
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
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
errorManip< error > abort(error &err)
Definition: errorManip.H:131
dimensioned< scalar > mag(const dimensioned< Type > &)
error FatalError
static const char nl
Definition: Ostream.H:266
dictionary dict