greyMeanSolidAbsorptionEmission.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) 2015 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 
31 #include "unitConversion.H"
33 
34 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
38  namespace radiation
39  {
40  defineTypeNameAndDebug(greyMeanSolidAbsorptionEmission, 0);
41 
43  (
44  absorptionEmissionModel,
45  greyMeanSolidAbsorptionEmission,
46  dictionary
47  );
48  }
49 }
50 
51 // * * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * //
52 
53 Foam::tmp<Foam::scalarField> Foam::radiation::
54 greyMeanSolidAbsorptionEmission::X(const word specie) const
55 {
56  const volScalarField& T = thermo_.T();
57  const volScalarField& p = thermo_.p();
58 
59  tmp<scalarField> tXj(new scalarField(T.primitiveField().size(), Zero));
60  scalarField& Xj = tXj.ref();
61 
62  tmp<scalarField> tRhoInv(new scalarField(T.primitiveField().size(), Zero));
63  scalarField& rhoInv = tRhoInv.ref();
64 
65  forAll(mixture_.Y(), specieI)
66  {
67  const scalarField& Yi = mixture_.Y()[specieI];
68 
69  forAll(rhoInv, iCell)
70  {
71  rhoInv[iCell] +=
72  Yi[iCell]/mixture_.rho(specieI, p[iCell], T[iCell]);
73  }
74  }
75  const scalarField& Yj = mixture_.Y(specie);
76  const label mySpecieI = mixture_.species().find(specie);
77  forAll(Xj, iCell)
78  {
79  Xj[iCell] = Yj[iCell]/mixture_.rho(mySpecieI, p[iCell], T[iCell]);
80  }
81 
82  return (Xj/rhoInv);
83 }
84 
85 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
86 
89 (
90  const dictionary& dict,
91  const fvMesh& mesh
92 )
93 :
95  coeffsDict_((dict.optionalSubDict(typeName + "Coeffs"))),
96  thermo_(mesh.lookupObject<solidThermo>(basicThermo::dictName)),
97  speciesNames_(0),
98  mixture_(dynamic_cast<const basicSpecieMixture&>(thermo_)),
99  solidData_(mixture_.Y().size())
100 {
101  if (!isA<basicSpecieMixture>(thermo_))
102  {
104  << "Model requires a multi-component thermo package"
105  << abort(FatalError);
106  }
107 
108  label nFunc = 0;
109  const dictionary& functionDicts = dict.optionalSubDict(typeName + "Coeffs");
110 
111  for (const entry& dEntry : functionDicts)
112  {
113  if (!dEntry.isDict()) // safety
114  {
115  continue;
116  }
117 
118  const word& key = dEntry.keyword();
119  const dictionary& dict = dEntry.dict();
120 
121  if (!mixture_.contains(key))
122  {
124  << " specie: " << key << " is not found in the solid mixture"
125  << nl
126  << " specie is the mixture are:" << mixture_.species() << nl
127  << nl << endl;
128  }
129  speciesNames_.insert(key, nFunc);
130 
131  dict.readEntry("absorptivity", solidData_[nFunc][absorptivity]);
132  dict.readEntry("emissivity", solidData_[nFunc][emissivity]);
133 
134  nFunc++;
135  }
136 }
137 
138 
139 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
140 
142 Foam::radiation::greyMeanSolidAbsorptionEmission::
143 calc(const label propertyId) const
144 {
145  tmp<volScalarField> ta
146  (
147  new volScalarField
148  (
149  IOobject
150  (
151  "a",
152  mesh().time().timeName(),
153  mesh(),
156  ),
157  mesh(),
160  )
161  );
162 
163  scalarField& a = ta.ref().primitiveFieldRef();
164 
165  forAllConstIters(speciesNames_, iter)
166  {
167  if (mixture_.contains(iter.key()))
168  {
169  a += solidData_[iter.val()][propertyId]*X(iter.key());
170  }
171  }
172 
173  ta.ref().correctBoundaryConditions();
174  return ta;
175 }
176 
177 
180 (
181  const label bandI
182 ) const
183 {
184  return calc(emissivity);
185 }
186 
187 
190 (
191  const label bandI
192 ) const
193 {
194  return calc(absorptivity);
195 }
196 
197 // ************************************************************************* //
dictionary dict
Abstract base-class for fluid and solid thermodynamic properties.
Definition: basicThermo.H:59
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
greyMeanSolidAbsorptionEmission(const dictionary &dict, const fvMesh &mesh)
Construct from components.
Unit conversion functions.
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:50
const word dictName("faMeshDefinition")
defineTypeNameAndDebug(cloudAbsorptionEmission, 0)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
const speciesTable & species() const
Return the table of species.
virtual const volScalarField & T() const
Temperature [K].
Definition: basicThermo.C:613
const dictionary & dict() const
Reference to the dictionary.
virtual scalar rho(const label speciei, const scalar p, const scalar T) const =0
Density [kg/m3].
Ignore writing from objectRegistry::writeObject()
const dimensionSet dimless
Dimensionless.
Specialization of basicMultiComponentMixture for a mixture consisting of a number for molecular speci...
Model to supply absorption and emission coefficients for radiation modelling.
PtrList< volScalarField > & Y()
Return the mass-fraction fields.
Macros for easy insertion into run-time selection tables.
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
virtual volScalarField & p()
Pressure [Pa].
Definition: basicThermo.C:601
tmp< volScalarField > eCont(const label bandI=0) const
Emission coefficient for continuous phase.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:81
bool insert(const Key &key, const T &obj)
Copy insert a new entry, not overwriting existing entries.
Definition: HashTableI.H:152
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 dictionary & optionalSubDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary, otherwise return this dictionary.
Definition: dictionary.C:560
dynamicFvMesh & mesh
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
errorManip< error > abort(error &err)
Definition: errorManip.H:139
Fundamental solid thermodynamic properties.
Definition: solidThermo.H:48
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
#define WarningInFunction
Report a warning using Foam::Warning.
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:50
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
Definition: foamGltfBase.H:103
PtrList< volScalarField > & Y
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
addToRunTimeSelectionTable(absorptionEmissionModel, cloudAbsorptionEmission, dictionary)
Nothing to be read.
tmp< volScalarField > aCont(const label bandI=0) const
Absorption coefficient for continuous phase.
bool contains(const word &specieName) const
Does the mixture include this specie?
volScalarField & p
A class for managing temporary objects.
Definition: HashPtrTable.H:50
label find(const word &val) const
Find index of the value (searches the hash).
static const word & extrapolatedCalculatedType() noexcept
The type name for extrapolatedCalculated patch fields combines zero-gradient and calculated.
Definition: fvPatchField.H:213
autoPtr< radiation::radiationModel > radiation(radiation::radiationModel::New(T))
Namespace for OpenFOAM.
forAllConstIters(mixture.phases(), phase)
Definition: pEqn.H:28
A keyword and a list of tokens is an &#39;entry&#39;.
Definition: entry.H:63
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:127