ThermoCloud.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-2017 OpenFOAM Foundation
9  Copyright (C) 2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "ThermoCloud.H"
30 #include "ThermoParcel.H"
31 
32 #include "HeatTransferModel.H"
33 
34 // * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
35 
36 template<class CloudType>
38 {
39  heatTransferModel_.reset
40  (
42  (
43  this->subModelProperties(),
44  *this
45  ).ptr()
46  );
47 
48  TIntegrator_.reset
49  (
51  (
52  "T",
53  this->solution().integrationSchemes()
54  ).ptr()
55  );
56 
57  this->subModelProperties().readEntry("radiation", radiation_);
58 
59  if (radiation_)
60  {
61  radAreaP_.reset
62  (
64  (
65  IOobject
66  (
67  this->name() + ":radAreaP",
68  this->db().time().timeName(),
69  this->db(),
70  IOobject::READ_IF_PRESENT,
71  IOobject::AUTO_WRITE
72  ),
73  this->mesh(),
75  )
76  );
77 
78  radT4_.reset
79  (
81  (
82  IOobject
83  (
84  this->name() + ":radT4",
85  this->db().time().timeName(),
86  this->db(),
87  IOobject::READ_IF_PRESENT,
88  IOobject::AUTO_WRITE
89  ),
90  this->mesh(),
92  )
93  );
94 
95  radAreaPT4_.reset
96  (
98  (
99  IOobject
100  (
101  this->name() + ":radAreaPT4",
102  this->db().time().timeName(),
103  this->db(),
104  IOobject::READ_IF_PRESENT,
105  IOobject::AUTO_WRITE
106  ),
107  this->mesh(),
109  )
110  );
111  }
112 }
113 
114 
115 template<class CloudType>
117 {
118  CloudType::cloudReset(c);
119 
120  heatTransferModel_.reset(c.heatTransferModel_.ptr());
121  TIntegrator_.reset(c.TIntegrator_.ptr());
122 
123  radiation_ = c.radiation_;
124 }
125 
126 
127 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
128 
129 template<class CloudType>
131 (
132  const word& cloudName,
133  const volScalarField& rho,
134  const volVectorField& U,
135  const dimensionedVector& g,
136  const SLGThermo& thermo,
137  bool readFields
138 )
139 :
140  CloudType
141  (
142  cloudName,
143  rho,
144  U,
145  thermo.thermo().mu(),
146  g,
147  false
148  ),
149  thermoCloud(),
150  cloudCopyPtr_(nullptr),
151  constProps_(this->particleProperties()),
152  thermo_(thermo),
153  T_(thermo.thermo().T()),
154  p_(thermo.thermo().p()),
155  heatTransferModel_(nullptr),
156  TIntegrator_(nullptr),
157  radiation_(false),
158  radAreaP_(nullptr),
159  radT4_(nullptr),
160  radAreaPT4_(nullptr),
161  hsTrans_
162  (
164  (
165  IOobject
166  (
167  this->name() + ":hsTrans",
168  this->db().time().timeName(),
169  this->db(),
170  IOobject::READ_IF_PRESENT,
171  IOobject::AUTO_WRITE
172  ),
173  this->mesh(),
175  )
176  ),
177  hsCoeff_
178  (
180  (
181  IOobject
182  (
183  this->name() + ":hsCoeff",
184  this->db().time().timeName(),
185  this->db(),
186  IOobject::READ_IF_PRESENT,
187  IOobject::AUTO_WRITE
188  ),
189  this->mesh(),
191  )
192  )
193 {
194  if (this->solution().active())
195  {
196  setModels();
197 
198  if (readFields)
199  {
200  parcelType::readFields(*this);
201  this->deleteLostParticles();
202  }
203  }
204 
205  if (this->solution().resetSourcesOnStartup())
206  {
207  resetSourceTerms();
208  }
209 }
210 
211 
212 template<class CloudType>
214 (
216  const word& name
217 )
218 :
219  CloudType(c, name),
220  thermoCloud(),
221  cloudCopyPtr_(nullptr),
222  constProps_(c.constProps_),
223  thermo_(c.thermo_),
224  T_(c.T()),
225  p_(c.p()),
226  heatTransferModel_(c.heatTransferModel_->clone()),
227  TIntegrator_(c.TIntegrator_->clone()),
228  radiation_(c.radiation_),
229  radAreaP_(nullptr),
230  radT4_(nullptr),
231  radAreaPT4_(nullptr),
232  hsTrans_
233  (
235  (
236  IOobject
237  (
238  this->name() + ":hsTrans",
239  this->db().time().timeName(),
240  this->db(),
241  IOobject::NO_READ,
242  IOobject::NO_WRITE,
243  false
244  ),
245  c.hsTrans()
246  )
247  ),
248  hsCoeff_
249  (
251  (
252  IOobject
253  (
254  this->name() + ":hsCoeff",
255  this->db().time().timeName(),
256  this->db(),
257  IOobject::NO_READ,
258  IOobject::NO_WRITE,
259  false
260  ),
261  c.hsCoeff()
262  )
263  )
264 {
265  if (radiation_)
266  {
267  radAreaP_.reset
268  (
270  (
271  IOobject
272  (
273  this->name() + ":radAreaP",
274  this->db().time().timeName(),
275  this->db(),
276  IOobject::NO_READ,
277  IOobject::NO_WRITE,
278  false
279  ),
280  c.radAreaP()
281  )
282  );
283 
284  radT4_.reset
285  (
287  (
288  IOobject
289  (
290  this->name() + ":radT4",
291  this->db().time().timeName(),
292  this->db(),
293  IOobject::NO_READ,
294  IOobject::NO_WRITE,
295  false
296  ),
297  c.radT4()
298  )
299  );
300 
301  radAreaPT4_.reset
302  (
304  (
305  IOobject
306  (
307  this->name() + ":radAreaPT4",
308  this->db().time().timeName(),
309  this->db(),
310  IOobject::NO_READ,
311  IOobject::NO_WRITE,
312  false
313  ),
314  c.radAreaPT4()
315  )
316  );
317  }
318 }
319 
320 
321 template<class CloudType>
323 (
324  const fvMesh& mesh,
325  const word& name,
327 )
328 :
329  CloudType(mesh, name, c),
330  thermoCloud(),
331  cloudCopyPtr_(nullptr),
332  constProps_(),
333  thermo_(c.thermo()),
334  T_(c.T()),
335  p_(c.p()),
336  heatTransferModel_(nullptr),
337  TIntegrator_(nullptr),
338  radiation_(false),
339  radAreaP_(nullptr),
340  radT4_(nullptr),
341  radAreaPT4_(nullptr),
342  hsTrans_(nullptr),
343  hsCoeff_(nullptr)
344 {}
345 
346 
347 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
348 
349 template<class CloudType>
351 (
352  parcelType& parcel,
353  const scalar lagrangianDt
354 )
355 {
356  CloudType::setParcelThermoProperties(parcel, lagrangianDt);
357 
358  parcel.T() = constProps_.T0();
359  parcel.Cp() = constProps_.Cp0();
360 }
361 
362 
363 template<class CloudType>
365 (
366  parcelType& parcel,
367  const scalar lagrangianDt,
368  const bool fullyDescribed
369 )
370 {
371  CloudType::checkParcelProperties(parcel, lagrangianDt, fullyDescribed);
372 }
373 
374 
375 template<class CloudType>
377 {
378  cloudCopyPtr_.reset
379  (
380  static_cast<ThermoCloud<CloudType>*>
381  (
382  clone(this->name() + "Copy").ptr()
383  )
384  );
385 }
386 
387 
388 template<class CloudType>
390 {
391  cloudReset(cloudCopyPtr_());
392  cloudCopyPtr_.clear();
393 }
394 
395 
396 template<class CloudType>
398 {
399  CloudType::resetSourceTerms();
400  hsTrans_->field() = 0.0;
401  hsCoeff_->field() = 0.0;
402 
403  if (radiation_)
404  {
405  radAreaP_->field() = 0.0;
406  radT4_->field() = 0.0;
407  radAreaPT4_->field() = 0.0;
408  }
409 }
410 
411 
412 template<class CloudType>
414 (
415  const ThermoCloud<CloudType>& cloudOldTime
416 )
417 {
418  CloudType::relaxSources(cloudOldTime);
419 
420  this->relax(hsTrans_(), cloudOldTime.hsTrans(), "h");
421  this->relax(hsCoeff_(), cloudOldTime.hsCoeff(), "h");
422 
423  if (radiation_)
424  {
425  this->relax(radAreaP_(), cloudOldTime.radAreaP(), "radiation");
426  this->relax(radT4_(), cloudOldTime.radT4(), "radiation");
427  this->relax(radAreaPT4_(), cloudOldTime.radAreaPT4(), "radiation");
428  }
429 }
430 
431 
432 template<class CloudType>
434 {
435  CloudType::scaleSources();
436 
437  this->scale(hsTrans_(), "h");
438  this->scale(hsCoeff_(), "h");
439 
440  if (radiation_)
441  {
442  this->scale(radAreaP_(), "radiation");
443  this->scale(radT4_(), "radiation");
444  this->scale(radAreaPT4_(), "radiation");
445  }
446 }
447 
448 
449 template<class CloudType>
451 (
452  const typename parcelType::trackingData& td
453 )
454 {
455  CloudType::preEvolve(td);
456 
457  this->pAmbient() = thermo_.thermo().p().average().value();
458 }
459 
460 
461 template<class CloudType>
463 {
464  if (this->solution().canEvolve())
465  {
466  typename parcelType::trackingData td(*this);
467 
468  this->solve(*this, td);
469  }
470 }
471 
472 
473 template<class CloudType>
475 {
477 
478  this->updateMesh();
479 }
480 
481 
482 template<class CloudType>
484 {
485  CloudType::info();
486 
487  Info<< " Temperature min/max = " << Tmin() << ", " << Tmax()
488  << endl;
489 }
490 
491 
492 // ************************************************************************* //
Foam::ThermoCloud::evolve
void evolve()
Evolve the cloud.
Definition: ThermoCloud.C:462
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
Foam::thermoCloud
Virtual abstract base class for templated ThermoCloud.
Definition: thermoCloud.H:50
Foam::solution
Selector class for relaxation factors, solver type and solution.
Definition: solution.H:55
cloudName
const word cloudName(propsDict.get< word >("cloud"))
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::dimLength
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:52
Foam::SLGThermo
Thermo package for (S)olids (L)iquids and (G)ases Takes reference to thermo package,...
Definition: SLGThermo.H:64
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
Foam::dimEnergy
const dimensionSet dimEnergy
Foam::ThermoCloud::scaleSources
void scaleSources()
Apply scaling to (transient) cloud sources.
Definition: ThermoCloud.C:433
thermo
Basic thermodynamics type based on the use of fitting functions for cp, h, s obtained from the templa...
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::Cloud::parcelType
ParticleType parcelType
Parcels are just particles.
Definition: Cloud.H:117
rho
rho
Definition: readInitialConditions.H:88
Foam::dimensioned::T
dimensioned< Type > T() const
Return transpose.
Definition: dimensionedSphericalTensor.C:38
solve
CEqn solve()
Foam::HeatTransferModel
Templated class to calculate the fluid-particle heat transfer coefficients based on a specified Nusse...
Definition: ThermoCloud.H:59
Foam::ThermoCloud::restoreState
void restoreState()
Reset the current cloud to the previously stored state.
Definition: ThermoCloud.C:389
Foam::pow4
dimensionedScalar pow4(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:100
Foam::dimArea
const dimensionSet dimArea(sqr(dimLength))
Definition: dimensionSets.H:59
Foam::ThermoCloud::cloudReset
void cloudReset(ThermoCloud< CloudType > &c)
Reset state of cloud.
Definition: ThermoCloud.C:116
Foam::ThermoCloud::preEvolve
void preEvolve(const typename parcelType::trackingData &td)
Pre-evolve.
Definition: ThermoCloud.C:451
Foam::Info
messageStream Info
Information stream (stdout output on master, null elsewhere)
Foam::ThermoCloud::radAreaPT4
volScalarField::Internal & radAreaPT4()
Radiation sum of parcel projected area*temperature^4 [m2K4].
Definition: ThermoCloudI.H:165
Foam::dimensionedScalar
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Definition: dimensionedScalarFwd.H:42
Foam::ThermoCloud::hsCoeff
volScalarField::Internal & hsCoeff()
Return coefficient for carrier phase hs equation.
Definition: ThermoCloudI.H:211
Foam::ThermoCloud::resetSourceTerms
void resetSourceTerms()
Reset the cloud source terms.
Definition: ThermoCloud.C:397
Foam::ThermoCloud::setParcelThermoProperties
void setParcelThermoProperties(parcelType &parcel, const scalar lagrangianDt)
Set parcel thermo properties.
Definition: ThermoCloud.C:351
Foam::CloudType
DSMCCloud< dsmcParcel > CloudType
Definition: makeDSMCParcelBinaryCollisionModels.C:38
timeName
word timeName
Definition: getTimeIndex.H:3
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::dimensioned< vector >
ThermoCloud.H
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
g
const uniformDimensionedVectorField & g
Definition: createFluidFields.H:26
Foam::ThermoCloud::autoMap
virtual void autoMap(const mapPolyMesh &)
Remap the cells of particles corresponding to the.
Definition: ThermoCloud.C:474
Foam::readFields
void readFields(const typename GeoFieldType::Mesh &mesh, const IOobjectList &objects, const wordHashSet &selectedFields, LIFOStack< regIOobject * > &storedObjects)
Read the selected GeometricFields of the templated type.
Definition: ReadFieldsTemplates.C:312
Foam::New
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
Definition: DimensionedFieldReuseFunctions.H:105
U
U
Definition: pEqn.H:72
Foam::sqr
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Definition: dimensionedSymmTensor.C:51
Foam::ThermoCloud::checkParcelProperties
void checkParcelProperties(parcelType &parcel, const scalar lagrangianDt, const bool fullyDescribed)
Check parcel properties.
Definition: ThermoCloud.C:365
Foam::ThermoCloud::setModels
void setModels()
Set cloud sub-models.
Definition: ThermoCloud.C:37
Foam::ThermoCloud::info
void info()
Print cloud information.
Definition: ThermoCloud.C:483
Foam::ThermoCloud
Templated base class for thermodynamic cloud.
Definition: ThermoCloud.H:66
Foam::Cloud
Base cloud calls templated on particle type.
Definition: Cloud.H:55
HeatTransferModel.H
Foam::ThermoCloud::radT4
volScalarField::Internal & radT4()
Radiation sum of parcel temperature^4 [K4].
Definition: ThermoCloudI.H:135
Foam::dimTemperature
const dimensionSet dimTemperature(0, 0, 0, 1, 0, 0, 0)
Definition: dimensionSets.H:54
Foam::mapPolyMesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:161
Foam::constant::universal::c
const dimensionedScalar c
Speed of light in a vacuum.
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
Foam::ThermoCloud::relaxSources
void relaxSources(const ThermoCloud< CloudType > &cloudOldTime)
Apply relaxation to (steady state) cloud sources.
Definition: ThermoCloud.C:414
ThermoParcel.H
Foam::GeometricField< scalar, fvPatchField, volMesh >
Foam::ThermoCloud::storeState
void storeState()
Store the current cloud state.
Definition: ThermoCloud.C:376
Foam::ThermoCloud::radAreaP
volScalarField::Internal & radAreaP()
Radiation sum of parcel projected areas [m2].
Definition: ThermoCloudI.H:105
Foam::ThermoCloud::hsTrans
volScalarField::Internal & hsTrans()
Sensible enthalpy transfer [J/kg].
Definition: ThermoCloudI.H:195
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54
relax
UEqn relax()