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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2015 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 "SingleMixtureFraction.H"
29 
30 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
31 
32 template<class CloudType>
34 {
35  forAll(this->phaseProps(), phaseI)
36  {
37  switch (this->phaseProps()[phaseI].phase())
38  {
39  case phaseProperties::GAS:
40  {
41  idGas_ = phaseI;
42  break;
43  }
44  case phaseProperties::LIQUID:
45  {
46  idLiquid_ = phaseI;
47  break;
48  }
49  case phaseProperties::SOLID:
50  {
51  idSolid_ = phaseI;
52  break;
53  }
54  default:
55  {
57  << "Unknown phase enumeration" << nl << abort(FatalError);
58  }
59  }
60  }
61 
62  if (idGas_ < 0)
63  {
65  << "No gas phase found in phase list:" << nl
66  << this->phaseTypes() << exit(FatalError);
67  }
68  if (idLiquid_ < 0)
69  {
71  << "No liquid phase found in phase list:" << nl
72  << this->phaseTypes() << exit(FatalError);
73  }
74  if (idSolid_ < 0)
75  {
77  << "No solid phase found in phase list:" << nl
78  << this->phaseTypes() << exit(FatalError);
79  }
80 }
81 
82 
83 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
84 
85 template<class CloudType>
87 (
88  const dictionary& dict,
89  CloudType& owner
90 )
91 :
92  CompositionModel<CloudType>(dict, owner, typeName),
93 
94  idGas_(-1),
95  idLiquid_(-1),
96  idSolid_(-1),
97 
98  YMixture0_(3)
99 {
100  constructIds();
101 
102  if (this->phaseProps().size() != 3)
103  {
105  << "Incorrect number of phases:" << nl
106  << " Please specify 1 gas, 1 liquid and 1 solid"
107  << exit(FatalError);
108  }
109 
110  this->coeffDict().readEntry("YGasTot0", YMixture0_[idGas_]);
111  this->coeffDict().readEntry("YLiquidTot0", YMixture0_[idLiquid_]);
112  this->coeffDict().readEntry("YSolidTot0", YMixture0_[idSolid_]);
113 
114  if (mag(sum(YMixture0_) - 1.0) > SMALL)
115  {
117  << "Sum of phases should be 1. Phase fractions:" << nl
118  << YMixture0_ << exit(FatalError);
119  }
120 }
121 
122 
123 template<class CloudType>
125 (
127 )
128 :
130  idGas_(cm.idGas_),
131  idLiquid_(cm.idLiquid_),
132  idSolid_(cm.idSolid_),
133  YMixture0_(cm.YMixture0_)
134 {}
135 
136 
137 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
138 
139 template<class CloudType>
141 {}
142 
143 
144 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
145 
146 template<class CloudType>
147 const Foam::scalarField&
149 {
150  return YMixture0_;
151 }
152 
153 
154 template<class CloudType>
156 {
157  return idGas_;
158 }
159 
160 
161 template<class CloudType>
163 {
164  return idLiquid_;
165 }
166 
167 
168 template<class CloudType>
170 {
171  return idSolid_;
172 }
173 
174 
175 // ************************************************************************* //
Foam::SingleMixtureFraction::idGas
virtual label idGas() const
Gas id.
Definition: SingleMixtureFraction.C:155
SingleMixtureFraction.H
Foam::SingleMixtureFraction
Templated parcel multi-phase, multi-component class.
Definition: SingleMixtureFraction.H:54
Foam::SingleMixtureFraction::idSolid
virtual label idSolid() const
Solid id.
Definition: SingleMixtureFraction.C:169
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::CompositionModel
Templated reacting parcel composition model class Consists of carrier species (via thermo package),...
Definition: ReactingCloud.H:58
Foam::Field< scalar >
Foam::SingleMixtureFraction::idLiquid
virtual label idLiquid() const
Liquid id.
Definition: SingleMixtureFraction.C:162
Foam::DSMCCloud
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:71
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::SingleMixtureFraction::YMixture0
virtual const scalarField & YMixture0() const
Return the list of mixture mass fractions.
Definition: SingleMixtureFraction.C:148
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:144
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::SingleMixtureFraction::~SingleMixtureFraction
virtual ~SingleMixtureFraction()
Destructor.
Definition: SingleMixtureFraction.C:140
Foam::SingleMixtureFraction::SingleMixtureFraction
SingleMixtureFraction(const dictionary &dict, CloudType &owner)
Construct from dictionary.
Definition: SingleMixtureFraction.C:87
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:381
Foam::nl
constexpr char nl
Definition: Ostream.H:385
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Foam::sum
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
Definition: DimensionedFieldFunctions.C:327