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 | Copyright (C) 2011-2014 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 "ThermoParcel.H"
28 
29 #include "HeatTransferModel.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  TIntegrator_.reset
46  (
48  (
49  "T",
50  this->solution().integrationSchemes()
51  ).ptr()
52  );
53 
54  this->subModelProperties().lookup("radiation") >> radiation_;
55 
56  if (radiation_)
57  {
58  radAreaP_.reset
59  (
61  (
62  IOobject
63  (
64  this->name() + ":radAreaP",
65  this->db().time().timeName(),
66  this->db(),
67  IOobject::READ_IF_PRESENT,
68  IOobject::AUTO_WRITE
69  ),
70  this->mesh(),
71  dimensionedScalar("zero", dimArea, 0.0)
72  )
73  );
74 
75  radT4_.reset
76  (
78  (
79  IOobject
80  (
81  this->name() + ":radT4",
82  this->db().time().timeName(),
83  this->db(),
84  IOobject::READ_IF_PRESENT,
85  IOobject::AUTO_WRITE
86  ),
87  this->mesh(),
89  )
90  );
91 
92  radAreaPT4_.reset
93  (
95  (
96  IOobject
97  (
98  this->name() + ":radAreaPT4",
99  this->db().time().timeName(),
100  this->db(),
101  IOobject::READ_IF_PRESENT,
102  IOobject::AUTO_WRITE
103  ),
104  this->mesh(),
106  (
107  "zero",
109  0.0
110  )
111  )
112  );
113  }
114 }
115 
116 
117 template<class CloudType>
119 {
120  CloudType::cloudReset(c);
121 
122  heatTransferModel_.reset(c.heatTransferModel_.ptr());
123  TIntegrator_.reset(c.TIntegrator_.ptr());
124 
125  radiation_ = c.radiation_;
126 }
127 
128 
129 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
130 
131 template<class CloudType>
133 (
134  const word& cloudName,
135  const volScalarField& rho,
136  const volVectorField& U,
137  const dimensionedVector& g,
138  const SLGThermo& thermo,
139  bool readFields
140 )
141 :
142  CloudType
143  (
144  cloudName,
145  rho,
146  U,
147  thermo.thermo().mu(),
148  g,
149  false
150  ),
151  thermoCloud(),
152  cloudCopyPtr_(NULL),
153  constProps_(this->particleProperties()),
154  thermo_(thermo),
155  T_(thermo.thermo().T()),
156  p_(thermo.thermo().p()),
157  heatTransferModel_(NULL),
158  TIntegrator_(NULL),
159  radiation_(false),
160  radAreaP_(NULL),
161  radT4_(NULL),
162  radAreaPT4_(NULL),
163  hsTrans_
164  (
166  (
167  IOobject
168  (
169  this->name() + ":hsTrans",
170  this->db().time().timeName(),
171  this->db(),
172  IOobject::READ_IF_PRESENT,
173  IOobject::AUTO_WRITE
174  ),
175  this->mesh(),
176  dimensionedScalar("zero", dimEnergy, 0.0)
177  )
178  ),
179  hsCoeff_
180  (
182  (
183  IOobject
184  (
185  this->name() + ":hsCoeff",
186  this->db().time().timeName(),
187  this->db(),
188  IOobject::READ_IF_PRESENT,
189  IOobject::AUTO_WRITE
190  ),
191  this->mesh(),
193  )
194  )
195 {
196  if (this->solution().active())
197  {
198  setModels();
199 
200  if (readFields)
201  {
202  parcelType::readFields(*this);
203  }
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  thermoCloud(),
222  cloudCopyPtr_(NULL),
223  constProps_(c.constProps_),
224  thermo_(c.thermo_),
225  T_(c.T()),
226  p_(c.p()),
227  heatTransferModel_(c.heatTransferModel_->clone()),
228  TIntegrator_(c.TIntegrator_->clone()),
229  radiation_(c.radiation_),
230  radAreaP_(NULL),
231  radT4_(NULL),
232  radAreaPT4_(NULL),
233  hsTrans_
234  (
236  (
237  IOobject
238  (
239  this->name() + ":hsTrans",
240  this->db().time().timeName(),
241  this->db(),
242  IOobject::NO_READ,
243  IOobject::NO_WRITE,
244  false
245  ),
246  c.hsTrans()
247  )
248  ),
249  hsCoeff_
250  (
252  (
253  IOobject
254  (
255  this->name() + ":hsCoeff",
256  this->db().time().timeName(),
257  this->db(),
258  IOobject::NO_READ,
259  IOobject::NO_WRITE,
260  false
261  ),
262  c.hsCoeff()
263  )
264  )
265 {
266  if (radiation_)
267  {
268  radAreaP_.reset
269  (
271  (
272  IOobject
273  (
274  this->name() + ":radAreaP",
275  this->db().time().timeName(),
276  this->db(),
277  IOobject::NO_READ,
278  IOobject::NO_WRITE,
279  false
280  ),
281  c.radAreaP()
282  )
283  );
284 
285  radT4_.reset
286  (
288  (
289  IOobject
290  (
291  this->name() + ":radT4",
292  this->db().time().timeName(),
293  this->db(),
294  IOobject::NO_READ,
295  IOobject::NO_WRITE,
296  false
297  ),
298  c.radT4()
299  )
300  );
301 
302  radAreaPT4_.reset
303  (
305  (
306  IOobject
307  (
308  this->name() + ":radAreaPT4",
309  this->db().time().timeName(),
310  this->db(),
311  IOobject::NO_READ,
312  IOobject::NO_WRITE,
313  false
314  ),
315  c.radAreaPT4()
316  )
317  );
318  }
319 }
320 
321 
322 template<class CloudType>
324 (
325  const fvMesh& mesh,
326  const word& name,
328 )
329 :
330  CloudType(mesh, name, c),
331  thermoCloud(),
332  cloudCopyPtr_(NULL),
333  constProps_(),
334  thermo_(c.thermo()),
335  T_(c.T()),
336  p_(c.p()),
337  heatTransferModel_(NULL),
338  TIntegrator_(NULL),
339  radiation_(false),
340  radAreaP_(NULL),
341  radT4_(NULL),
342  radAreaPT4_(NULL),
343  hsTrans_(NULL),
344  hsCoeff_(NULL)
345 {}
346 
347 
348 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
349 
350 template<class CloudType>
352 {}
353 
354 
355 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
356 
357 template<class CloudType>
359 (
360  parcelType& parcel,
361  const scalar lagrangianDt
362 )
363 {
364  CloudType::setParcelThermoProperties(parcel, lagrangianDt);
365 
366  parcel.T() = constProps_.T0();
367  parcel.Cp() = constProps_.Cp0();
368 }
369 
370 
371 template<class CloudType>
373 (
374  parcelType& parcel,
375  const scalar lagrangianDt,
376  const bool fullyDescribed
377 )
378 {
379  CloudType::checkParcelProperties(parcel, lagrangianDt, fullyDescribed);
380 }
381 
382 
383 template<class CloudType>
385 {
386  cloudCopyPtr_.reset
387  (
388  static_cast<ThermoCloud<CloudType>*>
389  (
390  clone(this->name() + "Copy").ptr()
391  )
392  );
393 }
394 
395 
396 template<class CloudType>
398 {
399  cloudReset(cloudCopyPtr_());
400  cloudCopyPtr_.clear();
401 }
402 
403 
404 template<class CloudType>
406 {
407  CloudType::resetSourceTerms();
408  hsTrans_->field() = 0.0;
409  hsCoeff_->field() = 0.0;
410 
411  if (radiation_)
412  {
413  radAreaP_->field() = 0.0;
414  radT4_->field() = 0.0;
415  radAreaPT4_->field() = 0.0;
416  }
417 }
418 
419 
420 template<class CloudType>
422 (
423  const ThermoCloud<CloudType>& cloudOldTime
424 )
425 {
426  CloudType::relaxSources(cloudOldTime);
427 
428  this->relax(hsTrans_(), cloudOldTime.hsTrans(), "h");
429  this->relax(hsCoeff_(), cloudOldTime.hsCoeff(), "h");
430 
431  if (radiation_)
432  {
433  this->relax(radAreaP_(), cloudOldTime.radAreaP(), "radiation");
434  this->relax(radT4_(), cloudOldTime.radT4(), "radiation");
435  this->relax(radAreaPT4_(), cloudOldTime.radAreaPT4(), "radiation");
436  }
437 }
438 
439 
440 template<class CloudType>
442 {
443  CloudType::scaleSources();
444 
445  this->scale(hsTrans_(), "h");
446  this->scale(hsCoeff_(), "h");
447 
448  if (radiation_)
449  {
450  this->scale(radAreaP_(), "radiation");
451  this->scale(radT4_(), "radiation");
452  this->scale(radAreaPT4_(), "radiation");
453  }
454 }
455 
456 
457 template<class CloudType>
459 {
460  CloudType::preEvolve();
461 
462  this->pAmbient() = thermo_.thermo().p().average().value();
463 }
464 
465 
466 template<class CloudType>
468 {
469  if (this->solution().canEvolve())
470  {
471  typename parcelType::template
472  TrackingData<ThermoCloud<CloudType> > td(*this);
473 
474  this->solve(td);
475  }
476 }
477 
478 
479 template<class CloudType>
481 {
482  typedef typename particle::TrackingData<ThermoCloud<CloudType> > tdType;
483 
484  tdType td(*this);
485 
486  Cloud<parcelType>::template autoMap<tdType>(td, mapper);
487 
488  this->updateMesh();
489 }
490 
491 
492 template<class CloudType>
494 {
495  CloudType::info();
496 
497  Info<< " Temperature min/max = " << Tmin() << ", " << Tmax()
498  << endl;
499 }
500 
501 
502 // ************************************************************************* //
Foam::ThermoCloud::evolve
void evolve()
Evolve the cloud.
Definition: ThermoCloud.C:467
Foam::IOobject
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
Foam::thermoCloud
Virtual abstract base class for templated ThermoCloud.
Definition: thermoCloud.H:48
Foam::solution
Selector class for relaxation factors, solver type and solution.
Definition: solution.H:48
relax
p relax()
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::compressible::New
autoPtr< BasicCompressibleTurbulenceModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const typename BasicCompressibleTurbulenceModel::transportModel &transport, const word &propertiesName)
Definition: turbulentFluidThermoModel.C:36
Foam::dimensioned::T
dimensioned< Type > T() const
Return transpose.
Foam::dimLength
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:50
Foam::SLGThermo
Thermo package for (S)olids (L)iquids and (G)ases Takes reference to thermo package,...
Definition: SLGThermo.H:62
Foam::dimEnergy
const dimensionSet dimEnergy
Foam::ThermoCloud::scaleSources
void scaleSources()
Apply scaling to (transient) cloud sources.
Definition: ThermoCloud.C:441
thermo
Basic thermodynamics type based on the use of fitting functions for cp, h, s obtained from the templa...
g
const dimensionedVector & g
Definition: setRegionFluidFields.H:33
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::readFields
This function object reads fields from the time directories and adds them to the mesh database for fu...
Definition: readFields.H:104
Foam::HeatTransferModel
Templated heat transfer model class.
Definition: ThermoCloud.H:53
U
U
Definition: pEqn.H:46
Foam::ThermoCloud::~ThermoCloud
virtual ~ThermoCloud()
Destructor.
Definition: ThermoCloud.C:351
Foam::ThermoCloud::restoreState
void restoreState()
Reset the current cloud to the previously stored state.
Definition: ThermoCloud.C:397
solve
rhoEqn solve()
Foam::pow4
dimensionedScalar pow4(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:98
Foam::dimArea
const dimensionSet dimArea(sqr(dimLength))
Definition: dimensionSets.H:57
Foam::ThermoCloud::radAreaP
DimensionedField< scalar, volMesh > & radAreaP()
Radiation sum of parcel projected areas [m2].
Definition: ThermoCloudI.H:102
Foam::ThermoCloud::cloudReset
void cloudReset(ThermoCloud< CloudType > &c)
Reset state of cloud.
Definition: ThermoCloud.C:118
Foam::ThermoCloud::hsTrans
DimensionedField< scalar, volMesh > & hsTrans()
Sensible enthalpy transfer [J/kg].
Definition: ThermoCloudI.H:192
Foam::Info
messageStream Info
Foam::ThermoCloud::radT4
DimensionedField< scalar, volMesh > & radT4()
Radiation sum of parcel temperature^4 [K4].
Definition: ThermoCloudI.H:132
Foam::dimensionedScalar
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Definition: dimensionedScalarFwd.H:41
Foam::ThermoCloud::resetSourceTerms
void resetSourceTerms()
Reset the cloud source terms.
Definition: ThermoCloud.C:405
Foam::ThermoCloud::setParcelThermoProperties
void setParcelThermoProperties(parcelType &parcel, const scalar lagrangianDt)
Set parcel thermo properties.
Definition: ThermoCloud.C:359
Foam::CloudType
DSMCCloud< dsmcParcel > CloudType
Definition: makeDSMCParcelBinaryCollisionModels.C:36
Foam::ThermoCloud::radAreaPT4
DimensionedField< scalar, volMesh > & radAreaPT4()
Radiation sum of parcel projected area*temperature^4 [m2K4].
Definition: ThermoCloudI.H:162
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
Foam::dimensioned
Generic dimensioned Type class.
Definition: dimensionedScalarFwd.H:41
ThermoCloud.H
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
Foam::ThermoCloud::autoMap
virtual void autoMap(const mapPolyMesh &)
Remap the cells of particles corresponding to the.
Definition: ThermoCloud.C:480
rho
rho
Definition: pEqn.H:3
Foam::sqr
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Definition: dimensionedSymmTensor.C:49
Foam::ThermoCloud::checkParcelProperties
void checkParcelProperties(parcelType &parcel, const scalar lagrangianDt, const bool fullyDescribed)
Check parcel properties.
Definition: ThermoCloud.C:373
Foam::ThermoCloud::setModels
void setModels()
Set cloud sub-models.
Definition: ThermoCloud.C:34
Foam::ThermoCloud::ThermoCloud
ThermoCloud(const ThermoCloud &)
Disallow default bitwise copy construct.
Foam::ThermoCloud::info
void info()
Print cloud information.
Definition: ThermoCloud.C:493
Foam::ThermoCloud
Templated base class for thermodynamic cloud.
Definition: ThermoCloud.H:60
readFields
void readFields(const boolList &haveMesh, const fvMesh &mesh, const autoPtr< fvMeshSubset > &subsetterPtr, IOobjectList &allObjects, PtrList< GeoField > &fields)
Definition: redistributePar.C:589
Foam::Cloud
Base cloud calls templated on particle type.
Definition: Cloud.H:52
HeatTransferModel.H
timeName
word timeName
Definition: getTimeIndex.H:3
cloudName
const word cloudName(propsDict.lookup("cloudName"))
Foam::dimTemperature
const dimensionSet dimTemperature(0, 0, 0, 1, 0, 0, 0)
Definition: dimensionSets.H:52
Foam::mapPolyMesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
Foam::constant::universal::c
const dimensionedScalar c
Speed of light in a vacuum.
Foam::ThermoCloud::relaxSources
void relaxSources(const ThermoCloud< CloudType > &cloudOldTime)
Apply relaxation to (steady state) cloud sources.
Definition: ThermoCloud.C:422
Foam::DSMCCloud::parcelType
ParcelType parcelType
Type of parcel the cloud was instantiated for.
Definition: DSMCCloud.H:217
Foam::ThermoCloud::hsCoeff
DimensionedField< scalar, volMesh > & hsCoeff()
Return coefficient for carrier phase hs equation.
Definition: ThermoCloudI.H:208
ThermoParcel.H
Foam::GeometricField
Generic GeometricField class.
Definition: surfaceFieldsFwd.H:52
Foam::ThermoCloud::storeState
void storeState()
Store the current cloud state.
Definition: ThermoCloud.C:384
Foam::particle::TrackingData
Definition: particle.H:94
Foam::ThermoCloud::preEvolve
void preEvolve()
Pre-evolve.
Definition: ThermoCloud.C:458
Foam::name
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:51