radiationModel.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) 2016-2021 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 "radiationModel.H"
31 #include "scatterModel.H"
32 #include "sootModel.H"
33 #include "fvmSup.H"
34 #include "basicThermo.H"
35 
36 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
37 
38 namespace Foam
39 {
40  namespace radiation
41  {
42  defineTypeNameAndDebug(radiationModel, 0);
43  defineRunTimeSelectionTable(radiationModel, T);
44  defineRunTimeSelectionTable(radiationModel, dictionary);
45  }
46 }
47 
49  "qrExt";
50 
52  "qprimaryRad";
53 
55  "qreflective";
56 
57 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
58 
59 Foam::IOobject Foam::radiation::radiationModel::createIOobject
60 (
61  const fvMesh& mesh
62 ) const
63 {
64  IOobject io
65  (
66  "radiationProperties",
67  mesh.time().constant(),
68  mesh,
71  );
72 
73  if (io.typeHeaderOk<IOdictionary>(true))
74  {
76  }
77  else
78  {
79  io.readOpt(IOobject::NO_READ);
80  }
81 
82  return io;
83 }
84 
85 
86 void Foam::radiation::radiationModel::initialise()
87 {
88  if (radiation_)
89  {
90  solverFreq_ = max(1, getOrDefault<label>("solverFreq", 1));
91 
92  if (this->found("absorptionEmissionModel"))
93  {
94  absorptionEmission_.reset
95  (
96  absorptionEmissionModel::New(*this, mesh_).ptr()
97  );
98  }
99 
100  if (this->found("scatterModel"))
101  {
102  scatter_.reset(scatterModel::New(*this, mesh_).ptr());
103  }
104 
105  if (this->found("sootModel"))
106  {
107  soot_.reset(sootModel::New(*this, mesh_).ptr());
108  }
109  }
110 }
111 
112 
113 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
114 
115 Foam::radiation::radiationModel::radiationModel(const volScalarField& T)
116 :
118  (
119  IOobject
120  (
121  "radiationProperties",
122  T.time().constant(),
123  T.mesh(),
124  IOobject::NO_READ,
125  IOobject::NO_WRITE
126  )
127  ),
128  mesh_(T.mesh()),
129  time_(T.time()),
130  T_(T),
131  radiation_(false),
132  coeffs_(),
133  solverFreq_(0),
134  firstIter_(true),
135  absorptionEmission_(nullptr),
136  scatter_(nullptr),
137  soot_(nullptr)
138 {}
139 
140 
141 Foam::radiation::radiationModel::radiationModel
142 (
143  const word& type,
144  const volScalarField& T
145 )
146 :
147  IOdictionary(createIOobject(T.mesh())),
148  mesh_(T.mesh()),
149  time_(T.time()),
150  T_(T),
151  radiation_(getOrDefault("radiation", true)),
152  coeffs_(subOrEmptyDict(type + "Coeffs")),
153  solverFreq_(1),
154  firstIter_(true),
155  absorptionEmission_(nullptr),
156  scatter_(nullptr),
157  soot_(nullptr)
158 {
159  if (readOpt() == IOobject::NO_READ)
160  {
161  radiation_ = false;
162  }
163 
164  initialise();
165 }
166 
167 
168 Foam::radiation::radiationModel::radiationModel
169 (
170  const word& type,
171  const dictionary& dict,
172  const volScalarField& T
173 )
174 :
176  (
177  IOobject
178  (
179  "radiationProperties",
180  T.time().constant(),
181  T.mesh(),
184  ),
185  dict
186  ),
187  mesh_(T.mesh()),
188  time_(T.time()),
189  T_(T),
190  radiation_(getOrDefault("radiation", true)),
191  coeffs_(subOrEmptyDict(type + "Coeffs")),
192  solverFreq_(1),
193  firstIter_(true),
194  absorptionEmission_(nullptr),
195  scatter_(nullptr),
196  soot_(nullptr)
197 {
198  initialise();
199 }
200 
201 
202 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * //
203 
205 {}
206 
207 
208 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
209 
211 {
212  if (regIOobject::read())
213  {
214  readEntry("radiation", radiation_);
215  coeffs_ = subOrEmptyDict(type() + "Coeffs");
216 
217  solverFreq_ = getOrDefault<label>("solverFreq", 1);
218  solverFreq_ = max(1, solverFreq_);
219 
220  return true;
221  }
222 
223  return false;
224 }
225 
226 
228 {
229  if (!radiation_)
230  {
231  return;
232  }
233 
234  if (firstIter_ || (time_.timeIndex() % solverFreq_ == 0))
235  {
236  calculate();
237  firstIter_ = false;
238  }
239 
240  if (soot_)
241  {
242  soot_->correct();
243  }
244 }
245 
246 
248 (
249  const basicThermo& thermo,
250  const volScalarField& he
251 ) const
252 {
253  const volScalarField Cpv(thermo.Cpv());
254  const volScalarField T3(pow3(T_));
255 
256  return
257  (
258  Ru()
259  - fvm::Sp(4.0*Rp()*T3/Cpv, he)
260  - Rp()*T3*(T_ - 4.0*he/Cpv)
261  );
262 }
263 
264 
266 (
267  const dimensionedScalar& rhoCp,
269 ) const
270 {
271  return
272  (
273  Ru()/rhoCp
274  - fvm::Sp(Rp()*pow3(T)/rhoCp, T)
275  );
276 }
277 
278 
280 (
283 ) const
284 {
285  return
286  (
287  Ru()/rhoCp.ref()
288  - fvm::Sp(Rp()*pow3(T)/rhoCp.ref(), T)
289  );
290 }
291 
292 
294 (
296 ) const
297 {
298  return
299  (
300  Ru()
301  - fvm::Sp(Rp()*pow3(T), T)
302  );
303 }
304 
305 
308 {
309  if (!absorptionEmission_)
310  {
312  << "Requested radiation absorptionEmission model, but model is "
313  << "not activate" << abort(FatalError);
314  }
315 
316  return *absorptionEmission_;
317 }
318 
319 
322 {
323  if (!soot_)
324  {
326  << "Requested radiation sootModel model, but model is "
327  << "not activate" << abort(FatalError);
328  }
329 
330  return *soot_;
331 }
332 
333 /*
334 const Foam::radiation::transmissivityModel&
335 Foam::radiation::radiationModel::transmissivity() const
336 {
337  if (!transmissivity_)
338  {
339  FatalErrorInFunction
340  << "Requested radiation sootModel model, but model is "
341  << "not activate" << abort(FatalError);
342  }
343 
344  return *transmissivity_;
345 }
346 */
347 
348 // ************************************************************************* //
Foam::IOobject::NO_WRITE
Definition: IOobject.H:195
Foam::IOdictionary
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:54
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
basicThermo.H
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::radiation::absorptionEmissionModel::New
static autoPtr< absorptionEmissionModel > New(const dictionary &dict, const fvMesh &mesh)
Selector.
Definition: absorptionEmissionModelNew.C:36
scatterModel.H
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::radiation::radiationModel::relfectedFluxName_
static const word relfectedFluxName_
Static name for reflected solar fluxes.
Definition: radiationModel.H:90
rhoCp
rhoCp
Definition: TEqn.H:3
Foam::radiation::radiationModel::primaryFluxName_
static const word primaryFluxName_
Static name for primary solar fluxes.
Definition: radiationModel.H:87
Foam::regIOobject::read
virtual bool read()
Read object.
Definition: regIOobjectRead.C:191
thermo
Basic thermodynamics type based on the use of fitting functions for cp, h, s obtained from the templa...
Foam::basicThermo
Abstract base-class for fluid and solid thermodynamic properties.
Definition: basicThermo.H:63
Foam::IOobject::IOobject
IOobject(const IOobject &)=default
Copy construct.
Foam::radiation::scatterModel::New
static autoPtr< scatterModel > New(const dictionary &dict, const fvMesh &mesh)
Definition: scatterModelNew.C:35
Foam::radiation::radiationModel::read
virtual bool read()=0
Read radiationProperties dictionary.
Definition: radiationModel.C:210
Foam::radiation::sootModel::New
static autoPtr< sootModel > New(const dictionary &dict, const fvMesh &mesh)
Selector.
Definition: sootModelNew.C:36
Foam::radiation::radiationModel::soot
const sootModel & soot() const
Access to soot Model.
Definition: radiationModel.C:321
Foam::fvm::Sp
tmp< fvMatrix< Type > > Sp(const volScalarField::Internal &, const GeometricField< Type, fvPatchField, volMesh > &)
Foam::pow3
dimensionedScalar pow3(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:89
Foam::T
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Definition: FieldFieldFunctions.C:58
Foam::radiation::radiationModel::~radiationModel
virtual ~radiationModel()
Destructor.
Definition: radiationModel.C:204
sootModel.H
Foam::IOdictionary::IOdictionary
IOdictionary(const IOobject &io, const dictionary *fallback=nullptr)
Definition: IOdictionary.C:37
Foam::max
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
radiation
autoPtr< radiation::radiationModel > radiation(radiation::radiationModel::New(T))
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::dimensioned< scalar >
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:144
Foam::radiation::radiationModel::ST
virtual tmp< fvScalarMatrix > ST(const dimensionedScalar &rhoCp, volScalarField &T) const
Temperature source term.
Definition: radiationModel.C:266
Foam::radiation::radiationModel::correct
virtual void correct()
Main update/correction routine.
Definition: radiationModel.C:227
Foam::radiation::radiationModel::absorptionEmission
const absorptionEmissionModel & absorptionEmission() const
Access to absorptionEmission model.
Definition: radiationModel.C:307
Foam::radiation::defineTypeNameAndDebug
defineTypeNameAndDebug(cloudAbsorptionEmission, 0)
fvmSup.H
Calculate the matrix for implicit and explicit sources.
found
bool found
Definition: TABSMDCalcMethod2.H:32
Foam::radiation::defineRunTimeSelectionTable
defineRunTimeSelectionTable(radiationModel, T)
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
he
volScalarField & he
Definition: YEEqn.H:52
absorptionEmissionModel.H
Foam::radiation::sootModel
Base class for soor models.
Definition: sootModel.H:55
Foam::radiation::radiationModel::Sh
virtual tmp< fvScalarMatrix > Sh(const basicThermo &thermo, const volScalarField &he) const
Energy source term.
Definition: radiationModel.C:248
Foam::type
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:590
Foam::IOobject::MUST_READ_IF_MODIFIED
Definition: IOobject.H:186
Foam::radiation::absorptionEmissionModel
Model to supply absorption and emission coefficients for radiation modelling.
Definition: absorptionEmissionModel.H:54
Foam::GeometricField< scalar, fvPatchField, volMesh >
Foam::IOobject::NO_READ
Definition: IOobject.H:188
constant
constant condensation/saturation model.
radiationModel.H
Foam::radiation::radiationModel::externalRadHeatFieldName_
static const word externalRadHeatFieldName_
Static name external radiative fluxes.
Definition: radiationModel.H:84
Foam::IOobject::MUST_READ
Definition: IOobject.H:185