FreeFOAM The Cross-Platform CFD Toolkit
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) 2008-2010 OpenCFD Ltd.
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 
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() << nl << endl;
68  }
69  if (idLiquid_ < 0)
70  {
71  FatalErrorIn("Foam::SingleMixtureFraction<CloudType>::constructIds()")
72  << "No liquid phase found in phase list:" << nl
73  << this->phaseTypes() << nl << endl;
74  }
75  if (idSolid_ < 0)
76  {
77  FatalErrorIn("Foam::SingleMixtureFraction<CloudType>::constructIds()")
78  << "No solid phase found in phase list:" << nl
79  << this->phaseTypes() << nl << endl;
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" << nl
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_ << nl << exit(FatalError);
134  }
135 }
136 
137 
138 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
139 
140 template<class CloudType>
142 {}
143 
144 
145 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
146 
147 template<class CloudType>
148 const Foam::scalarField&
150 {
151  return this->phaseProps()[idGas_].Y();
152 }
153 
154 
155 template<class CloudType>
156 const Foam::scalarField&
158 {
159  return this->phaseProps()[idLiquid_].Y();
160 }
161 
162 
163 template<class CloudType>
164 const Foam::scalarField&
166 {
167  return this->phaseProps()[idSolid_].Y();
168 }
169 
170 
171 template<class CloudType>
172 const Foam::scalarField&
174 {
175  return YMixture0_;
176 }
177 
178 
179 template<class CloudType>
181 {
182  return idGas_;
183 }
184 
185 
186 template<class CloudType>
188 {
189  return idLiquid_;
190 }
191 
192 
193 template<class CloudType>
195 {
196  return idSolid_;
197 }
198 
199 
200 // ************************ vim: set sw=4 sts=4 et: ************************ //
201 
202