ReactingHeterogeneousCloud.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) 2018-2020 OpenCFD Ltd.
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 
30 
31 // * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * //
32 
33 template<class CloudType>
35 {
36  heterogeneousReactionModel_.reset
37  (
39  (
40  this->subModelProperties(),
41  *this
42  ).ptr()
43  );
44 }
45 
46 
47 template<class CloudType>
49 (
51 )
52 {
53  CloudType::cloudReset(c);
54  heterogeneousReactionModel_.reset(c.heterogeneousReactionModel_.ptr());
55 }
56 
57 
58 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
59 
60 template<class CloudType>
62 (
63  const word& cloudName,
64  const volScalarField& rho,
65  const volVectorField& U,
66  const dimensionedVector& g,
67  const SLGThermo& thermo,
68  bool readFields
69 )
70 :
71  CloudType(cloudName, rho, U, g, thermo, false),
73  cloudCopyPtr_(nullptr),
74  heterogeneousReactionModel_(nullptr)
75 {
76  if (this->solution().active())
77  {
78  setModels();
79 
80  if (readFields)
81  {
82  parcelType::readFields(*this, this->composition());
83  this->deleteLostParticles();
84  }
85  }
86 }
87 
88 
89 template<class CloudType>
91 (
92  ReactingHeterogeneousCloud<CloudType>& c,
93  const word& name
94 )
95 :
96  CloudType(c, name),
97  reactingHeterogeneousCloud(),
98  cloudCopyPtr_(nullptr),
99  heterogeneousReactionModel_(c.heterogeneousReactionModel_->clone())
100 {}
101 
102 
103 template<class CloudType>
105 (
106  const fvMesh& mesh,
107  const word& name,
109 )
110 :
111  CloudType(mesh, name, c),
113  cloudCopyPtr_(nullptr),
114  heterogeneousReactionModel_(c.heterogeneousReactionModel_->clone())
115 {}
116 
117 
118 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
119 
120 template<class CloudType>
122 (
123  parcelType& parcel,
124  const scalar lagrangianDt
125 )
126 {
127  CloudType::setParcelThermoProperties(parcel, lagrangianDt);
128  label idS = this->composition().idSolid();
129 
130  // Set initial particle composition. Overwrite thermoProperties from
131  // ReactingCloud
132  parcel.Y() = this->composition().Y0(idS);
133 
134  // Set initial progress to 0
135  parcel.F().setSize(heterogeneousReactionModel_->nF(), 0.0);
136 
137  // Set the parcel to combust
138  parcel.canCombust() = 1;
139 
140  // If rho0 was given in constProp use it. If not use the composition
141  // to set tho
142  if (this->constProps_.rho0() == -1)
143  {
144  const label idGas = this->composition().idGas();
145  const label idLiquid = this->composition().idLiquid();
146  const label idSolid = this->composition().idSolid();
147 
148  const scalarField& Ygas = this->composition().Y0(idGas);
149  const scalarField& Yliq = this->composition().Y0(idLiquid);
150  const scalarField& Ysol = this->composition().Y0(idSolid);
151 
152  const scalar p0 =
153  this->composition().thermo().thermo().p()[parcel.cell()];
154  const scalar T0 = this->constProps_.T0();
155 
156  parcel.rho() = this->composition().rho(Ygas, Yliq, Ysol, T0, p0);
157  }
158 }
159 
160 
161 template<class CloudType>
163 (
164  parcelType& parcel,
165  const scalar lagrangianDt,
166  const bool fullyDescribed
167 )
168 {
169  CloudType::checkParcelProperties(parcel, lagrangianDt, false);
170 
171  const label solId = this->composition().idSolid();
172  const label liqId = this->composition().idLiquid();
173  const label gasId = this->composition().idGas();
174 
175  // Check YMixture is pure solid
176  if
177  (
178  this->composition().YMixture0()[solId] != 1.0
179  || this->composition().YMixture0()[liqId] != 0.0
180  || this->composition().YMixture0()[gasId] != 0.0
181  )
182  {
184  << "The supplied composition must be : " << nl
185  << " YGasTot0 0 : " << nl
186  << " YLiquidTot0 0 : " << nl
187  << " YSolidTot0 1 : " << nl
188  << "This Cloud only works with pure solid particles."
189  << abort(FatalError);
190  }
191  if (this->composition().liquids().size() > 0)
192  {
194  << "The supplied composition has a liquid phase. " << nl
195  << "This Cloud only works with pure solid particles."
196  << abort(FatalError);
197  }
198 }
199 
200 
201 template<class CloudType>
203 {
204  cloudCopyPtr_.reset
205  (
206  static_cast<ReactingHeterogeneousCloud<CloudType>*>
207  (
208  clone(this->name() + "Copy").ptr()
209  )
210  );
211 }
212 
213 
214 template<class CloudType>
216 {
217  cloudReset(cloudCopyPtr_());
218  cloudCopyPtr_.clear();
219 }
220 
221 
222 template<class CloudType>
224 {
225  if (this->solution().canEvolve())
226  {
227  typename parcelType::trackingData td(*this);
228 
229  this->solve(*this, td);
230  }
231 }
232 
233 
234 template<class CloudType>
236 (
237  const mapPolyMesh& mapper
238 )
239 {
241 
242  this->updateMesh();
243 }
244 
245 
246 template<class CloudType>
248 {
249  CloudType::info();
250 
251  heterogeneousReactionModel_->info();
252 }
253 
254 
255 template<class CloudType>
257 {
259 }
260 
261 
262 template<class CloudType>
264 readObjects(const objectRegistry& obr)
265 {
266  CloudType::particleType::readObjects(*this, this->composition(), obr);
267 }
268 
269 
270 template<class CloudType>
272 writeObjects(objectRegistry& obr) const
273 {
274  CloudType::particleType::writeObjects(*this, this->composition(), obr);
275 }
276 
277 
278 // ************************************************************************* //
DSMCCloud< dsmcParcel > CloudType
virtual void autoMap(const mapPolyMesh &)
Remap the cells of particles corresponding to the.
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:598
basicSpecieMixture & composition
void setParcelThermoProperties(parcelType &parcel, const scalar lagrangianDt)
Set parcel thermo properties.
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:50
void restoreState()
Reset the current cloud to the previously stored state.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
Templated base class for reacting heterogeneous cloud.
Virtual abstract base class for templated ReactingCloud.
void storeState()
Store the current cloud state.
void cloudReset(ReactingHeterogeneousCloud< CloudType > &c)
Reset state of cloud.
CEqn solve()
virtual void writeObjects(objectRegistry &obr) const
Write particle fields as objects into the obr registry.
dynamicFvMesh & mesh
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition: exprTraits.C:127
void readFields(const typename GeoFieldType::Mesh &mesh, const IOobjectList &objects, const NameMatchPredicate &selectedFields, DynamicList< regIOobject *> &storedObjects)
Read the selected GeometricFields of the templated type and store on the objectRegistry.
const word cloudName(propsDict.get< word >("cloud"))
A class for handling words, derived from Foam::string.
Definition: word.H:63
void setModels()
Set cloud sub-models.
Thermo package for (S)olids (L)iquids and (G)ases Takes reference to thermo package, and provides:
Definition: SLGThermo.H:60
errorManip< error > abort(error &err)
Definition: errorManip.H:139
Base cloud calls templated on particle type.
Definition: Cloud.H:51
Basic thermodynamics type based on the use of fitting functions for cp, h, s obtained from the templa...
void writeFields(const fvMesh &mesh, const wordHashSet &selectedFields, const bool writeFaceFields)
const uniformDimensionedVectorField & g
void checkParcelProperties(parcelType &parcel, const scalar lagrangianDt, const bool fullyDescribed)
Check parcel properties.
U
Definition: pEqn.H:72
void info()
Print cloud information.
Base class for heterogeneous reacting models.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
const dimensionedScalar c
Speed of light in a vacuum.
virtual void writeFields() const
Write the field data for the cloud.
Selector class for relaxation factors, solver type and solution.
Definition: solution.H:92
Registry of regIOobjects.
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:67
const volScalarField & p0
Definition: EEqn.H:36
scalar T0
Definition: createFields.H:22
virtual void readObjects(const objectRegistry &obr)
Read particle fields as objects from the obr registry.