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-------------------------------------------------------------------------------
11License
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
36namespace Foam
37{
38 namespace radiation
39 {
41
43 (
47 );
48 }
49}
50
51// * * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * //
52
54greyMeanSolidAbsorptionEmission::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
87Foam::radiation::greyMeanSolidAbsorptionEmission::
88greyMeanSolidAbsorptionEmission
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
142Foam::radiation::greyMeanSolidAbsorptionEmission::
143calc(const label propertyId) const
144{
146 (
148 (
150 (
151 "a",
152 mesh().time().timeName(),
153 mesh(),
156 ),
157 mesh(),
159 extrapolatedCalculatedFvPatchVectorField::typeName
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// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
bool insert(const Key &key, const T &obj)
Copy insert a new entry, not overwriting existing entries.
Definition: HashTableI.H:180
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
label find(const T &val, label pos=0) const
Find index of the first occurrence of the value.
Definition: UList.C:212
const speciesTable & species() const
Return the table of species.
bool contains(const word &specieName) const
Does the mixture include this specie?
Specialization of basicMultiComponentMixture for a mixture consisting of a number for molecular speci...
Abstract base-class for fluid and solid thermodynamic properties.
Definition: basicThermo.H:66
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
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:577
bool readEntry(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX, bool mandatory=true) const
A keyword and a list of tokens is an 'entry'.
Definition: entry.H:70
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
Model to supply absorption and emission coefficients for radiation modelling.
const dictionary & dict() const
Reference to the dictionary.
greyMeanSolidAbsorptionEmission radiation absorption and emission coefficients for solid mixture
tmp< volScalarField > eCont(const label bandI=0) const
Emission coefficient for continuous phase.
tmp< volScalarField > aCont(const label bandI=0) const
Absorption coefficient for continuous phase.
Fundamental solid thermodynamic properties.
Definition: solidThermo.H:55
A class for managing temporary objects.
Definition: tmp.H:65
A class for handling words, derived from Foam::string.
Definition: word.H:68
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition: className.H:121
volScalarField & p
PtrList< volScalarField > & Y
const volScalarField & T
dynamicFvMesh & mesh
autoPtr< radiation::radiationModel > radiation(radiation::radiationModel::New(T))
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
const word dictName("faMeshDefinition")
word timeName
Definition: getTimeIndex.H:3
#define WarningInFunction
Report a warning using Foam::Warning.
Namespace for OpenFOAM.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
const dimensionSet dimless
Dimensionless.
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:52
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
errorManip< error > abort(error &err)
Definition: errorManip.H:144
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
error FatalError
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333
#define forAllConstIters(container, iter)
Iterate across all elements of the container object with const access.
Definition: stdFoam.H:278
Unit conversion functions.