ThermoCloud.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-2021 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 "ThermoCloud.H"
27 #include "integrationScheme.H"
28 #include "HeatTransferModel.H"
29 #include "CompositionModel.H"
30 
31 // * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
32 
33 template<class CloudType>
35 {
36  heatTransferModel_.reset
37  (
39  (
40  this->subModelProperties(),
41  *this
42  ).ptr()
43  );
44 
45  compositionModel_.reset
46  (
48  (
49  this->subModelProperties(),
50  *this
51  ).ptr()
52  );
53 
54  TIntegrator_.reset
55  (
57  (
58  "T",
59  this->solution().integrationSchemes()
60  ).ptr()
61  );
62 
63  if (this->solution().coupled())
64  {
65  this->subModelProperties().lookup("radiation") >> radiation_;
66  }
67 
68  if (radiation_)
69  {
70  radAreaP_.reset
71  (
73  (
74  IOobject
75  (
76  this->name() + ":radAreaP",
77  this->db().time().timeName(),
78  this->db(),
79  IOobject::READ_IF_PRESENT,
80  IOobject::AUTO_WRITE
81  ),
82  this->mesh(),
84  )
85  );
86 
87  radT4_.reset
88  (
90  (
91  IOobject
92  (
93  this->name() + ":radT4",
94  this->db().time().timeName(),
95  this->db(),
96  IOobject::READ_IF_PRESENT,
97  IOobject::AUTO_WRITE
98  ),
99  this->mesh(),
101  )
102  );
103 
104  radAreaPT4_.reset
105  (
107  (
108  IOobject
109  (
110  this->name() + ":radAreaPT4",
111  this->db().time().timeName(),
112  this->db(),
113  IOobject::READ_IF_PRESENT,
114  IOobject::AUTO_WRITE
115  ),
116  this->mesh(),
118  )
119  );
120  }
121 }
122 
123 
124 template<class CloudType>
126 {
127  CloudType::cloudReset(c);
128 
129  heatTransferModel_.reset(c.heatTransferModel_.ptr());
130  compositionModel_.reset(c.compositionModel_.ptr());
131 
132  TIntegrator_.reset(c.TIntegrator_.ptr());
133 
134  radiation_ = c.radiation_;
135 }
136 
137 
138 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
139 
140 template<class CloudType>
142 (
143  const word& cloudName,
144  const volScalarField& rho,
145  const volVectorField& U,
146  const dimensionedVector& g,
147  const fluidThermo& carrierThermo,
148  const bool readFields
149 )
150 :
151  CloudType(cloudName, rho, U, g, carrierThermo, false),
152  cloudCopyPtr_(nullptr),
153  constProps_(this->particleProperties()),
154  carrierThermo_(carrierThermo),
155  thermo_(carrierThermo_),
156  T_(carrierThermo.T()),
157  p_(carrierThermo.p()),
158  heatTransferModel_(nullptr),
159  compositionModel_(nullptr),
160  TIntegrator_(nullptr),
161  radiation_(false),
162  radAreaP_(nullptr),
163  radT4_(nullptr),
164  radAreaPT4_(nullptr),
165  hsTrans_
166  (
168  (
169  IOobject
170  (
171  this->name() + ":hsTrans",
172  this->db().time().timeName(),
173  this->db(),
174  IOobject::READ_IF_PRESENT,
175  IOobject::AUTO_WRITE
176  ),
177  this->mesh(),
179  )
180  ),
181  hsCoeff_
182  (
184  (
185  IOobject
186  (
187  this->name() + ":hsCoeff",
188  this->db().time().timeName(),
189  this->db(),
190  IOobject::READ_IF_PRESENT,
191  IOobject::AUTO_WRITE
192  ),
193  this->mesh(),
195  )
196  )
197 {
198  setModels();
199 
200  if (readFields)
201  {
202  parcelType::readFields(*this);
203  this->deleteLostParticles();
204  }
205 
206  if (this->solution().resetSourcesOnStartup())
207  {
208  resetSourceTerms();
209  }
210 }
211 
212 
213 template<class CloudType>
215 (
217  const word& name
218 )
219 :
220  CloudType(c, name),
221  cloudCopyPtr_(nullptr),
222  constProps_(c.constProps_),
223  carrierThermo_(c.carrierThermo_),
224  thermo_(c.thermo_),
225  T_(c.T()),
226  p_(c.p()),
227  heatTransferModel_(c.heatTransferModel_->clone()),
228  compositionModel_(c.compositionModel_->clone()),
229  TIntegrator_(c.TIntegrator_->clone()),
230  radiation_(c.radiation_),
231  radAreaP_(nullptr),
232  radT4_(nullptr),
233  radAreaPT4_(nullptr),
234  hsTrans_
235  (
237  (
238  IOobject
239  (
240  this->name() + ":hsTrans",
241  this->db().time().timeName(),
242  this->db(),
243  IOobject::NO_READ,
244  IOobject::NO_WRITE,
245  false
246  ),
247  c.hsTrans()
248  )
249  ),
250  hsCoeff_
251  (
253  (
254  IOobject
255  (
256  this->name() + ":hsCoeff",
257  this->db().time().timeName(),
258  this->db(),
259  IOobject::NO_READ,
260  IOobject::NO_WRITE,
261  false
262  ),
263  c.hsCoeff()
264  )
265  )
266 {
267  if (radiation_)
268  {
269  radAreaP_.reset
270  (
272  (
273  IOobject
274  (
275  this->name() + ":radAreaP",
276  this->db().time().timeName(),
277  this->db(),
278  IOobject::NO_READ,
279  IOobject::NO_WRITE,
280  false
281  ),
282  c.radAreaP()
283  )
284  );
285 
286  radT4_.reset
287  (
289  (
290  IOobject
291  (
292  this->name() + ":radT4",
293  this->db().time().timeName(),
294  this->db(),
295  IOobject::NO_READ,
296  IOobject::NO_WRITE,
297  false
298  ),
299  c.radT4()
300  )
301  );
302 
303  radAreaPT4_.reset
304  (
306  (
307  IOobject
308  (
309  this->name() + ":radAreaPT4",
310  this->db().time().timeName(),
311  this->db(),
312  IOobject::NO_READ,
313  IOobject::NO_WRITE,
314  false
315  ),
316  c.radAreaPT4()
317  )
318  );
319  }
320 }
321 
322 
323 template<class CloudType>
325 (
326  const fvMesh& mesh,
327  const word& name,
328  const ThermoCloud<CloudType>& c
329 )
330 :
331  CloudType(mesh, name, c),
332  cloudCopyPtr_(nullptr),
333  constProps_(),
334  carrierThermo_(c.carrierThermo_),
335  thermo_(c.thermo()),
336  T_(c.T()),
337  p_(c.p()),
338  heatTransferModel_(nullptr),
339  compositionModel_(nullptr),
340  TIntegrator_(nullptr),
341  radiation_(false),
342  radAreaP_(nullptr),
343  radT4_(nullptr),
344  radAreaPT4_(nullptr),
345  hsTrans_(nullptr),
346  hsCoeff_(nullptr)
347 {}
348 
349 
350 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
351 
352 template<class CloudType>
354 {}
355 
356 
357 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
358 
359 template<class CloudType>
361 (
362  parcelType& parcel,
363  const scalar lagrangianDt
364 )
365 {
366  CloudType::setParcelThermoProperties(parcel, lagrangianDt);
367 
368  parcel.T() = constProps_.T0();
369  parcel.Cp() = constProps_.Cp0();
370 }
371 
372 
373 template<class CloudType>
375 (
376  parcelType& parcel,
377  const scalar lagrangianDt,
378  const bool fullyDescribed
379 )
380 {
381  CloudType::checkParcelProperties(parcel, lagrangianDt, fullyDescribed);
382 }
383 
384 
385 template<class CloudType>
387 {
388  cloudCopyPtr_.reset
389  (
390  static_cast<ThermoCloud<CloudType>*>
391  (
392  clone(this->name() + "Copy").ptr()
393  )
394  );
395 }
396 
397 
398 template<class CloudType>
400 {
401  cloudReset(cloudCopyPtr_());
402  cloudCopyPtr_.clear();
403 }
404 
405 
406 template<class CloudType>
408 {
409  CloudType::resetSourceTerms();
410  hsTrans_->field() = 0.0;
411  hsCoeff_->field() = 0.0;
412 
413  if (radiation_)
414  {
415  radAreaP_->field() = 0.0;
416  radT4_->field() = 0.0;
417  radAreaPT4_->field() = 0.0;
418  }
419 }
420 
421 
422 template<class CloudType>
424 (
425  const ThermoCloud<CloudType>& cloudOldTime
426 )
427 {
428  CloudType::relaxSources(cloudOldTime);
429 
430  this->relax(hsTrans_(), cloudOldTime.hsTrans_(), "h");
431  this->relax(hsCoeff_(), cloudOldTime.hsCoeff_(), "h");
432 
433  if (radiation_)
434  {
435  this->relax(radAreaP_(), cloudOldTime.radAreaP(), "radiation");
436  this->relax(radT4_(), cloudOldTime.radT4(), "radiation");
437  this->relax(radAreaPT4_(), cloudOldTime.radAreaPT4(), "radiation");
438  }
439 }
440 
441 
442 template<class CloudType>
444 {
445  CloudType::scaleSources();
446 
447  this->scale(hsTrans_(), "h");
448  this->scale(hsCoeff_(), "h");
449 
450  if (radiation_)
451  {
452  this->scale(radAreaP_(), "radiation");
453  this->scale(radT4_(), "radiation");
454  this->scale(radAreaPT4_(), "radiation");
455  }
456 }
457 
458 
459 template<class CloudType>
461 {
462  CloudType::preEvolve();
463 
464  this->pAmbient() = carrierThermo_.p().average().value();
465 }
466 
467 
468 template<class CloudType>
470 {
471  if (this->solution().canEvolve())
472  {
473  typename parcelType::trackingData td(*this);
474 
475  this->solve(*this, td);
476  }
477 }
478 
479 
480 template<class CloudType>
482 {
484 
485  this->updateMesh();
486 }
487 
488 
489 template<class CloudType>
491 {
492  CloudType::info();
493 
494  Info<< " Temperature min/max = " << Tmin() << ", " << Tmax()
495  << endl;
496 }
497 
498 
499 template<class CloudType>
501 {
502  if (compositionModel_.valid())
503  {
504  CloudType::particleType::writeFields(*this, this->composition());
505  }
506  else
507  {
508  CloudType::particleType::writeFields(*this);
509  }
510 }
511 
512 
513 // ************************************************************************* //
autoPtr< integrationScheme > TIntegrator_
Temperature integration.
Definition: ThermoCloud.H:140
const fluidThermo & carrierThermo_
Thermophysical properties of the carrier fluid.
Definition: ThermoCloud.H:114
Switch radiation_
Include radiation.
Definition: ThermoCloud.H:146
const dimensionSet dimArea
DSMCCloud< dsmcParcel > CloudType
void setParcelThermoProperties(parcelType &parcel, const scalar lagrangianDt)
Set parcel thermo properties.
Definition: ThermoCloud.C:361
Templated heat transfer model class.
Definition: ThermoCloud.H:58
const parcelThermo thermo_
SLG thermodynamics package.
Definition: ThermoCloud.H:117
void readFields(const typename GeoFieldType::Mesh &mesh, const IOobjectList &objects, const HashSet< word > &selectedFields, LIFOStack< regIOobject *> &storedObjects)
Read the selected GeometricFields of the specified type.
Definition: ReadFields.C:244
basicSpecieMixture & composition
dimensionedSymmTensor sqr(const dimensionedVector &dv)
void restoreState()
Reset the current cloud to the previously stored state.
Definition: ThermoCloud.C:399
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
const volScalarField & p() const
Return const access to the carrier pressure field.
Definition: ThermoCloudI.H:80
autoPtr< volScalarField::Internal > hsTrans_
Sensible enthalpy transfer [J/kg].
Definition: ThermoCloud.H:161
volScalarField::Internal & radAreaPT4()
Radiation sum of parcel projected area*temperature^4 [m2K4].
Definition: ThermoCloudI.H:179
tmp< volScalarField::Internal > hsTrans() const
Return sensible enthalpy transfer [J/kg].
Definition: ThermoCloudI.H:209
void cloudReset(ThermoCloud< CloudType > &c)
Reset state of cloud.
Definition: ThermoCloud.C:125
void preEvolve()
Pre-evolve.
Definition: ThermoCloud.C:460
virtual volScalarField & p()=0
Pressure [Pa].
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
const dimensionSet dimLength
Templated base class for thermodynamic cloud.
Definition: ThermoCloud.H:76
parcelType::constantProperties constProps_
Thermo parcel constant properties.
Definition: ThermoCloud.H:108
volScalarField::Internal & radAreaP()
Radiation sum of parcel projected areas [m^2].
Definition: ThermoCloudI.H:119
volScalarField::Internal & radT4()
Radiation sum of parcel temperature^4 [K4].
Definition: ThermoCloudI.H:149
T clone(const T &t)
Definition: List.H:54
dynamicFvMesh & mesh
virtual void autoMap(const mapPolyMesh &)
Remap the cells of particles corresponding to the.
Definition: ThermoCloud.C:481
autoPtr< BasicCompressibleMomentumTransportModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const typename BasicCompressibleMomentumTransportModel::transportModel &transport)
A class for handling words, derived from string.
Definition: word.H:59
Base-class for fluid thermodynamic properties.
Definition: fluidThermo.H:53
ThermoCloud(const word &cloudName, const volScalarField &rho, const volVectorField &U, const dimensionedVector &g, const fluidThermo &carrierThermo, const bool readFields=true)
Construct given carrier fields and thermo.
Definition: ThermoCloud.C:142
word timeName
Definition: getTimeIndex.H:3
EaEqn relax()
Base cloud calls templated on particle type.
Definition: Cloud.H:52
ParcelType parcelType
Type of parcel the cloud was instantiated for.
Definition: DSMCCloud.H:221
const dimensionSet dimEnergy
const volScalarField & T() const
Return const access to the carrier temperature field.
Definition: ThermoCloudI.H:73
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
void checkParcelProperties(parcelType &parcel, const scalar lagrangianDt, const bool fullyDescribed)
Check parcel properties.
Definition: ThermoCloud.C:375
void resetSourceTerms()
Reset the cloud source terms.
Definition: ThermoCloud.C:407
virtual void writeFields() const
Write the field data for the cloud.
Definition: ThermoCloud.C:500
rhoEqn solve()
autoPtr< volScalarField::Internal > hsCoeff_
Coefficient for carrier phase hs equation [W/K].
Definition: ThermoCloud.H:164
void evolve()
Evolve the cloud.
Definition: ThermoCloud.C:469
virtual const volScalarField & T() const =0
Temperature [K].
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
void info()
Print cloud information.
Definition: ThermoCloud.C:490
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
dimensionedScalar pow4(const dimensionedScalar &ds)
void scaleSources()
Apply scaling to (transient) cloud sources.
Definition: ThermoCloud.C:443
messageStream Info
tmp< volScalarField::Internal > hsCoeff() const
Return coefficient for carrier phase hs equation.
Definition: ThermoCloudI.H:225
Selector class for relaxation factors, solver type and solution.
Definition: solution.H:48
const parcelThermo & thermo() const
Return const access to thermo package.
Definition: ThermoCloudI.H:66
autoPtr< HeatTransferModel< ThermoCloud< CloudType > > > heatTransferModel_
Heat transfer model.
Definition: ThermoCloud.H:130
Templated reacting parcel composition model class Consists of carrier species (via thermo package)...
Definition: ThermoCloud.H:61
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:92
void storeState()
Store the current cloud state.
Definition: ThermoCloud.C:386
void setModels()
Set cloud sub-models.
Definition: ThermoCloud.C:34
const dimensionSet dimTemperature
autoPtr< CompositionModel< ThermoCloud< CloudType > > > compositionModel_
Reacting composition model.
Definition: ThermoCloud.H:134
void relaxSources(const ThermoCloud< CloudType > &cloudOldTime)
Apply relaxation to (steady state) cloud sources.
Definition: ThermoCloud.C:424
virtual ~ThermoCloud()
Destructor.
Definition: ThermoCloud.C:353