multiBandZoneAbsorptionEmission.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) 2015-2019 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 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35  namespace radiation
36  {
37  defineTypeNameAndDebug(multiBandZoneAbsorptionEmission, 0);
38 
40  (
41  absorptionEmissionModel,
42  multiBandZoneAbsorptionEmission,
43  dictionary
44  );
45  }
46 }
47 
48 
49 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
50 
53 (
54  const dictionary& dict,
55  const fvMesh& mesh
56 )
57 :
59  coeffsDict_(dict.subDict(typeName + "Coeffs")),
60  absCoeffs_(maxBands_),
61  emiCoeffs_(maxBands_),
62  nBands_(0),
63  zoneAbsorptivity_(),
64  zoneEmisivity_(),
65  zoneCells_()
66 {
67  coeffsDict_.readEntry("absorptivity", absCoeffs_);
68  coeffsDict_.readEntry("emissivity", emiCoeffs_);
69  nBands_ = absCoeffs_.size();
70 
71  const dictionary& zoneDict = coeffsDict_.subDict("zones");
72 
73  zoneDict.readEntry("absorptivity", zoneAbsorptivity_);
74  zoneDict.readEntry("emissivity", zoneEmisivity_);
75 
76  zoneCells_.setSize(zoneAbsorptivity_.size(), -1);
77 
78  label i = 0;
79  forAllConstIters(zoneAbsorptivity_, iter)
80  {
81  label zoneID = mesh.cellZones().findZoneID(iter.key());
82  if (zoneID == -1)
83  {
85  << "Cannot find cellZone " << iter.key() << endl
86  << "Valid cellZones are " << mesh.cellZones().names()
87  << exit(FatalError);
88  }
89  zoneCells_[i++] = zoneID;
90  }
91 
92 }
93 
94 
95 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
96 
99 {}
100 
101 
102 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
103 
106 (
107  const label bandI
108 ) const
109 {
111  (
112  new volScalarField
113  (
114  IOobject
115  (
116  "a",
117  mesh().time().timeName(),
118  mesh(),
121  ),
122  mesh(),
123  dimensionedScalar("a", dimless/dimLength, absCoeffs_[bandI])
124  )
125  );
126 
127  volScalarField& a = ta.ref();
128 
129  forAll(zoneCells_, zonei)
130  {
131  const cellZone& cZone = mesh().cellZones()[zoneCells_[zonei]];
132 
133  tmp<volScalarField> tzoneAbs(a*0.0);
134  volScalarField& zoneAbs = tzoneAbs.ref();
135 
136  const scalarList& abs = zoneAbsorptivity_.find(cZone.name())();
137 
138  forAll(cZone, i)
139  {
140  label cellId = cZone[i];
141  zoneAbs[cellId] = abs[bandI] - absCoeffs_[bandI];
142  }
143 
144  a += zoneAbs;
145  }
147  return ta;
148 }
149 
150 
153 (
154  const label bandI
155 ) const
156 {
158  (
159  new volScalarField
160  (
161  IOobject
162  (
163  "e",
164  mesh().time().timeName(),
165  mesh(),
168  ),
169  mesh(),
170  dimensionedScalar("e", dimless/dimLength, emiCoeffs_[bandI])
171  )
172  );
173 
174  volScalarField& e = te.ref();
175 
176  forAll(zoneCells_, zonei)
177  {
178  const cellZone& cZone = mesh().cellZones()[zoneCells_[zonei]];
179 
180  tmp<volScalarField> tzoneEm(e*0.0);
181  volScalarField& zoneEm = tzoneEm.ref();
182 
183  const scalarList& emi = zoneEmisivity_.find(cZone.name())();
184 
185  forAll(cZone, i)
186  {
187  label cellId = cZone[i];
188  zoneEm[cellId] = emi[bandI] - emiCoeffs_[bandI];
189  }
190  e += zoneEm;
191  }
192 
194  return te;
195 }
196 
197 
200 (
201  const label bandI
202 ) const
203 {
205  (
206  new volScalarField
207  (
208  IOobject
209  (
210  "E",
211  mesh().time().timeName(),
212  mesh(),
215  ),
216  mesh(),
218  )
219  );
220 
221  return E;
222 }
223 
224 
225 // ************************************************************************* //
dictionary dict
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:116
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:598
T & ref() const
Return non-const reference to the contents of a non-null managed pointer.
Definition: tmpI.H:235
defineTypeNameAndDebug(cloudAbsorptionEmission, 0)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
const fvMesh & mesh() const
Reference to the mesh.
Ignore writing from objectRegistry::writeObject()
const dimensionSet dimless
Dimensionless.
Model to supply absorption and emission coefficients for radiation modelling.
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
Definition: dictionary.C:441
Macros for easy insertion into run-time selection tables.
tmp< volScalarField > eCont(const label bandI) const
Emission coefficient.
tmp< volScalarField > aCont(const label bandI) const
Absorption coefficient.
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
bool readEntry(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX, IOobjectOption::readOption readOpt=IOobjectOption::MUST_READ) const
Find entry and assign to T val. FatalIOError if it is found and the number of tokens is incorrect...
word timeName
Definition: getTimeIndex.H:3
const dimensionedScalar e
Elementary charge.
Definition: createFields.H:11
void setSize(const label n)
Alias for resize()
Definition: List.H:316
dynamicFvMesh & mesh
label findZoneID(const word &zoneName) const
Find zone index by name, return -1 if not found.
Definition: ZoneMesh.C:629
multiBandZoneAbsorptionEmission(const dictionary &dict, const fvMesh &mesh)
Construct from components.
label find(const T &val) const
Find index of the first occurrence of the value.
Definition: UList.C:173
tmp< volScalarField > ECont(const label bandI) const
Emission contribution.
A subset of mesh cells.
Definition: cellZone.H:58
dimensionedScalar pow3(const dimensionedScalar &ds)
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:50
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
label cellId
addToRunTimeSelectionTable(absorptionEmissionModel, cloudAbsorptionEmission, dictionary)
const word & name() const noexcept
The zone name.
Nothing to be read.
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
Definition: dimensionSets.H:51
const cellZoneMesh & cellZones() const noexcept
Return cell zone mesh.
Definition: polyMesh.H:678
wordList names() const
A list of the zone names.
Definition: ZoneMesh.C:362
Internal & ref(const bool updateAccessTime=true)
Same as internalFieldRef()
const dimensionSet dimMass(1, 0, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:49
A class for managing temporary objects.
Definition: HashPtrTable.H:50
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:172
autoPtr< radiation::radiationModel > radiation(radiation::radiationModel::New(T))
Namespace for OpenFOAM.
forAllConstIters(mixture.phases(), phase)
Definition: pEqn.H:28
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:127