coding updates/corrections - first pass

This commit is contained in:
andy
2009-03-20 13:40:39 +00:00
parent 97de9529af
commit 4b2f7812e8
29 changed files with 1143 additions and 929 deletions

View File

@ -24,7 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "GreyDiffusiveRadiationMixedFvPatchScalarField.H"
#include "greyDiffusiveRadiationMixedFvPatchScalarField.H"
#include "addToRunTimeSelectionTable.H"
#include "fvPatchFieldMapper.H"
#include "volFields.H"
@ -37,15 +37,15 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::radiation::GreyDiffusiveRadiationMixedFvPatchField::
GreyDiffusiveRadiationMixedFvPatchField
Foam::radiation::greyDiffusiveRadiationMixedFvPatchScalarField::
greyDiffusiveRadiationMixedFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF
)
:
mixedFvPatchScalarField(p, iF),
TName_("undefined"),
TName_("undefinedT"),
emissivity_(0.0),
myRayIndex_(0),
myWaveLengthIndex_(0),
@ -59,10 +59,10 @@ GreyDiffusiveRadiationMixedFvPatchField
}
Foam::radiation::GreyDiffusiveRadiationMixedFvPatchField::
GreyDiffusiveRadiationMixedFvPatchField
Foam::radiation::greyDiffusiveRadiationMixedFvPatchScalarField::
greyDiffusiveRadiationMixedFvPatchScalarField
(
const GreyDiffusiveRadiationMixedFvPatchField& ptf,
const greyDiffusiveRadiationMixedFvPatchScalarField& ptf,
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const fvPatchFieldMapper& mapper
@ -78,8 +78,8 @@ GreyDiffusiveRadiationMixedFvPatchField
{}
Foam::radiation::GreyDiffusiveRadiationMixedFvPatchField::
GreyDiffusiveRadiationMixedFvPatchField
Foam::radiation::greyDiffusiveRadiationMixedFvPatchScalarField::
greyDiffusiveRadiationMixedFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
@ -117,10 +117,10 @@ GreyDiffusiveRadiationMixedFvPatchField
}
Foam::radiation::GreyDiffusiveRadiationMixedFvPatchField::
GreyDiffusiveRadiationMixedFvPatchField
Foam::radiation::greyDiffusiveRadiationMixedFvPatchScalarField::
greyDiffusiveRadiationMixedFvPatchScalarField
(
const GreyDiffusiveRadiationMixedFvPatchField& ptf
const greyDiffusiveRadiationMixedFvPatchScalarField& ptf
)
:
mixedFvPatchScalarField(ptf),
@ -133,10 +133,10 @@ GreyDiffusiveRadiationMixedFvPatchField
{}
Foam::radiation::GreyDiffusiveRadiationMixedFvPatchField::
GreyDiffusiveRadiationMixedFvPatchField
Foam::radiation::greyDiffusiveRadiationMixedFvPatchScalarField::
greyDiffusiveRadiationMixedFvPatchScalarField
(
const GreyDiffusiveRadiationMixedFvPatchField& ptf,
const greyDiffusiveRadiationMixedFvPatchScalarField& ptf,
const DimensionedField<scalar, volMesh>& iF
)
:
@ -153,17 +153,18 @@ GreyDiffusiveRadiationMixedFvPatchField
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::radiation::GreyDiffusiveRadiationMixedFvPatchField::autoMap
void Foam::radiation::greyDiffusiveRadiationMixedFvPatchScalarField::autoMap
(
const fvPatchFieldMapper& m
)
{
scalarField::autoMap(m);
qr_.automap(m);
}
void Foam::radiation::GreyDiffusiveRadiationMixedFvPatchField::rmap
void Foam::radiation::greyDiffusiveRadiationMixedFvPatchScalarField::rmap
(
const fvPatchScalarField& ptf,
const labelList& addr
@ -171,12 +172,15 @@ void Foam::radiation::GreyDiffusiveRadiationMixedFvPatchField::rmap
{
mixedFvPatchScalarField::rmap(ptf, addr);
// const GreyDiffusiveRadiationMixedFvPatchField& mrptf =
refCast<const GreyDiffusiveRadiationMixedFvPatchField>(ptf);
const greyDiffusiveRadiationMixedFvPatchScalarField& gdrpsf =
refCast<const greyDiffusiveRadiationMixedFvPatchScalarField>(ptf);
qr_.rmap(gdrpsf.qr_, addr);
}
void Foam::radiation::GreyDiffusiveRadiationMixedFvPatchField::updateCoeffs()
void Foam::radiation::greyDiffusiveRadiationMixedFvPatchScalarField::
updateCoeffs()
{
if (this->updated())
{
@ -187,28 +191,31 @@ void Foam::radiation::GreyDiffusiveRadiationMixedFvPatchField::updateCoeffs()
patch().lookupPatchField<volScalarField, scalar>(TName_);
const radiationModel& rad =
db().lookupObject<radiationModel>("radiationProperties");
db().lookupObject<radiationModel>("radiationProperties");
const fvDOM& Dom(refCast<const fvDOM>(rad));
const fvDOM& dom = refCast<const fvDOM>(rad);
const label patchi = patch().index();
if(Dom.lambdaj() == 1)
if (dom.lambdaj() == 1)
{
if (myRayIsInit_ == -1)
{
for(label i=0; i < Dom.Ni() ; i++)
for (label i=0; i < Dom.Ni() ; i++)
{
for(label j=0; j < Dom.lambdaj() ; j++)
for (label j=0; j < dom.lambdaj() ; j++)
{
const volScalarField& radiationField =
Dom.RadIntRayiLambdaj(i,j);
if (&(radiationField.internalField()) ==
&dimensionedInternalField())
dom.RadIntRayiLambdaj(i,j);
if
(
&(radiationField.internalField())
== &dimensionedInternalField()
)
{
myRayIndex_ = i;
myWaveLengthIndex_ = j;
myRayIsInit_ = 0.;
myRayIsInit_ = 0.0;
break;
}
}
@ -220,7 +227,7 @@ void Foam::radiation::GreyDiffusiveRadiationMixedFvPatchField::updateCoeffs()
FatalErrorIn
(
"Foam::radiation::"
"GreyDiffusiveRadiationMixedFvPatchField::"
"greyDiffusiveRadiationMixedFvPatchScalarField::"
"updateCoeffs"
) << " a grey boundary condition is used with a non-grey"
<< "absorption model"
@ -229,22 +236,21 @@ void Foam::radiation::GreyDiffusiveRadiationMixedFvPatchField::updateCoeffs()
vectorField n = patch().Sf()/patch().magSf();
scalarField& Iw = *(this);
scalarField& Iw = *this;
qr_ = Iw *(-n & Dom.RadIntRay(myRayIndex_).Di());
qr_ = Iw*(-n & dom.RadIntRay(myRayIndex_).Di());
Dom.RadIntRay(myRayIndex_).add(qr_,patchi);
dom.RadIntRay(myRayIndex_).add(qr_,patchi);
forAll(Iw, faceI)
{
scalar Ir = 0.0;
for(label i=0; i < Dom.Ni() ; i++) //
for (label i=0; i < dom.Ni(); i++)
{
const vector& si = Dom.RadIntRay(i).Si();
const vector& si = dom.RadIntRay(i).Si();
const scalarField& Iface = Dom.RadIntRay(i).Ilambdaj
const scalarField& Iface = dom.RadIntRay(i).Ilambdaj
(
myWaveLengthIndex_
).boundaryField()[patch().index()];
@ -253,12 +259,12 @@ void Foam::radiation::GreyDiffusiveRadiationMixedFvPatchField::updateCoeffs()
if (InOut < 0.) // qin into the wall
{
const vector& di = Dom.RadIntRay(i).Di();
const vector& di = dom.RadIntRay(i).Di();
Ir += Iface[faceI]*mag(n[faceI] & di);
}
}
const vector& mySi = Dom.RadIntRay(myRayIndex_).Si();
const vector& mySi = dom.RadIntRay(myRayIndex_).Si();
scalar InOut = -n[faceI] & mySi;
@ -266,9 +272,12 @@ void Foam::radiation::GreyDiffusiveRadiationMixedFvPatchField::updateCoeffs()
{
refGrad()[faceI] = 0.0;
valueFraction()[faceI] = 1.0;
refValue()[faceI] = ((1. - emissivity_) * Ir +
emissivity_*radiation::sigmaSB.value()*pow4(Tp[faceI])) /
Foam::mathematicalConstant::pi;
refValue()[faceI] =
(
Ir*(1.0 - emissivity_)
+ emissivity_*radiation::sigmaSB.value()*pow4(Tp[faceI])
)
/mathematicalConstant::pi;
}
else if (InOut < 0.) //direction into the wall
@ -283,13 +292,14 @@ void Foam::radiation::GreyDiffusiveRadiationMixedFvPatchField::updateCoeffs()
}
void Foam::radiation::GreyDiffusiveRadiationMixedFvPatchField::write(Ostream&
os) const
void Foam::radiation::greyDiffusiveRadiationMixedFvPatchScalarField::write
(
Ostream& os
) const
{
fvPatchScalarField::write(os);
os.writeKeyword("T") << TName_ << token::END_STATEMENT << nl;
os.writeKeyword("emissivity") << emissivity_ << token::END_STATEMENT << nl;
writeEntry("value", os);
}
@ -303,7 +313,7 @@ namespace radiation
makePatchTypeField
(
fvPatchScalarField,
GreyDiffusiveRadiationMixedFvPatchField
greyDiffusiveRadiationMixedFvPatchScalarField
);
}
}

View File

@ -23,18 +23,18 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::WideBandDiffusiveRadiationMixedFvPatchField
Foam::greyDiffusiveRadiationMixedFvPatchScalarField
Description
Radiation temperature specified
SourceFiles
WideBandDiffusiveRadiationMixedFvPatchField.C
greyDiffusiveRadiationMixedFvPatchScalarField.C
\*---------------------------------------------------------------------------*/
#ifndef WideBandDiffusiveRadiationMixedFvPatchField_H
#define WideBandDiffusiveRadiationMixedFvPatchField_H
#ifndef greyDiffusiveRadiationMixedFvPatchScalarField_H
#define greyDiffusiveRadiationMixedFvPatchScalarField_H
#include "mixedFvPatchFields.H"
@ -45,14 +45,13 @@ namespace Foam
namespace radiation
{
/*---------------------------------------------------------------------------*\
Class WideBandDiffusiveRadiationMixedFvPatchField Declaration
Class greyDiffusiveRadiationMixedFvPatchScalarField Declaration
\*---------------------------------------------------------------------------*/
class WideBandDiffusiveRadiationMixedFvPatchField
class greyDiffusiveRadiationMixedFvPatchScalarField
:
public mixedFvPatchScalarField
{
// Private data
//- Name of temperature field
@ -67,49 +66,50 @@ class WideBandDiffusiveRadiationMixedFvPatchField
//- Direction index
label myWaveLengthIndex_;
//- Init ray flag
//- Initialise ray flag
label myRayIsInit_;
//- Radiative heat flux on walls.
//- Radiative heat flux on walls
scalarField qr_;
public:
//- Runtime type information
TypeName("WideBandDiffusiveRadiation");
TypeName("greyDiffusiveRadiation");
// Constructors
//- Construct from patch and internal field
WideBandDiffusiveRadiationMixedFvPatchField
greyDiffusiveRadiationMixedFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&
);
//- Construct from patch, internal field and dictionary
WideBandDiffusiveRadiationMixedFvPatchField
greyDiffusiveRadiationMixedFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const dictionary&
);
//- Construct by mapping given GreyDiffusiveRadiationMixedFvPatchField
// onto a new patch
WideBandDiffusiveRadiationMixedFvPatchField
//- Construct by mapping given a
// greyDiffusiveRadiationMixedFvPatchScalarField onto a new patch
greyDiffusiveRadiationMixedFvPatchScalarField
(
const WideBandDiffusiveRadiationMixedFvPatchField&,
const greyDiffusiveRadiationMixedFvPatchScalarField&,
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const fvPatchFieldMapper&
);
//- Construct as copy
WideBandDiffusiveRadiationMixedFvPatchField
greyDiffusiveRadiationMixedFvPatchScalarField
(
const WideBandDiffusiveRadiationMixedFvPatchField&
const greyDiffusiveRadiationMixedFvPatchScalarField&
);
//- Construct and return a clone
@ -117,14 +117,14 @@ public:
{
return tmp<fvPatchScalarField>
(
new WideBandDiffusiveRadiationMixedFvPatchField(*this)
new greyDiffusiveRadiationMixedFvPatchScalarField(*this)
);
}
//- Construct as copy setting internal field reference
WideBandDiffusiveRadiationMixedFvPatchField
greyDiffusiveRadiationMixedFvPatchScalarField
(
const WideBandDiffusiveRadiationMixedFvPatchField&,
const greyDiffusiveRadiationMixedFvPatchScalarField&,
const DimensionedField<scalar, volMesh>&
);
@ -136,7 +136,7 @@ public:
{
return tmp<fvPatchScalarField>
(
new WideBandDiffusiveRadiationMixedFvPatchField(*this, iF)
new greyDiffusiveRadiationMixedFvPatchScalarField(*this, iF)
);
}
@ -145,13 +145,13 @@ public:
// Access
//- Return the temperature field name
//- Return the temperature field name
const word& TName() const
{
return TName_;
}
//- Return reference to the temperature field name to allow
//- Return reference to the temperature field name to allow
// adjustment
word& TName()
{
@ -170,14 +170,14 @@ public:
return emissivity_;
}
//- Return heat flux on the boundary
const scalarField& qr() const
{
return qr_;
}
// Mapping functions
// Mapping functions
//- Map (and resize as needed) from self given a mapping object
virtual void autoMap

View File

@ -35,11 +35,10 @@ License
#include "radiationConstants.H"
#include "mathematicalConstants.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::radiation::WideBandDiffusiveRadiationMixedFvPatchField::
WideBandDiffusiveRadiationMixedFvPatchField
Foam::radiation::wideBandDiffusiveRadiationMixedFvPatchScalarField::
wideBandDiffusiveRadiationMixedFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF
@ -51,7 +50,7 @@ WideBandDiffusiveRadiationMixedFvPatchField
myRayIndex_(0),
myWaveLengthIndex_(0),
myRayIsInit_(-1),
qr_(0)
qr_(p.size(), 0.0)
{
refValue() = 0.0;
refGrad() = 0.0;
@ -60,10 +59,10 @@ WideBandDiffusiveRadiationMixedFvPatchField
}
Foam::radiation::WideBandDiffusiveRadiationMixedFvPatchField::
WideBandDiffusiveRadiationMixedFvPatchField
Foam::radiation::wideBandDiffusiveRadiationMixedFvPatchScalarField::
wideBandDiffusiveRadiationMixedFvPatchScalarField
(
const WideBandDiffusiveRadiationMixedFvPatchField& ptf,
const wideBandDiffusiveRadiationMixedFvPatchScalarField& ptf,
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const fvPatchFieldMapper& mapper
@ -79,8 +78,8 @@ WideBandDiffusiveRadiationMixedFvPatchField
{}
Foam::radiation::WideBandDiffusiveRadiationMixedFvPatchField::
WideBandDiffusiveRadiationMixedFvPatchField
Foam::radiation::wideBandDiffusiveRadiationMixedFvPatchScalarField::
wideBandDiffusiveRadiationMixedFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
@ -93,17 +92,16 @@ WideBandDiffusiveRadiationMixedFvPatchField
myRayIndex_(0),
myWaveLengthIndex_(0),
myRayIsInit_(-1),
qr_(0)
qr_(p.size(), 0.0)
{
const scalarField& Tp =
patch().lookupPatchField<volScalarField, scalar>(TName_);
refValue() = emissivity_*4.0*radiation::sigmaSB.value()*pow4(Tp) /
Foam::mathematicalConstant::pi;
refValue() =
emissivity_*4.0*radiation::sigmaSB.value()*pow4(Tp)
/Foam::mathematicalConstant::pi;
refGrad() = 0.0;
qr_.setSize(p.size());
if (dict.found("value"))
{
fvPatchScalarField::operator=
@ -118,10 +116,10 @@ WideBandDiffusiveRadiationMixedFvPatchField
}
Foam::radiation::WideBandDiffusiveRadiationMixedFvPatchField::
WideBandDiffusiveRadiationMixedFvPatchField
Foam::radiation::wideBandDiffusiveRadiationMixedFvPatchScalarField::
wideBandDiffusiveRadiationMixedFvPatchScalarField
(
const WideBandDiffusiveRadiationMixedFvPatchField& ptf
const wideBandDiffusiveRadiationMixedFvPatchScalarField& ptf
)
:
mixedFvPatchScalarField(ptf),
@ -134,10 +132,10 @@ WideBandDiffusiveRadiationMixedFvPatchField
{}
Foam::radiation::WideBandDiffusiveRadiationMixedFvPatchField::
WideBandDiffusiveRadiationMixedFvPatchField
Foam::radiation::wideBandDiffusiveRadiationMixedFvPatchScalarField::
wideBandDiffusiveRadiationMixedFvPatchScalarField
(
const WideBandDiffusiveRadiationMixedFvPatchField& ptf,
const wideBandDiffusiveRadiationMixedFvPatchScalarField& ptf,
const DimensionedField<scalar, volMesh>& iF
)
:
@ -148,23 +146,23 @@ WideBandDiffusiveRadiationMixedFvPatchField
myWaveLengthIndex_(ptf.myWaveLengthIndex_),
myRayIsInit_(ptf.myRayIsInit_),
qr_(ptf.qr_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::radiation::WideBandDiffusiveRadiationMixedFvPatchField::autoMap
void Foam::radiation::wideBandDiffusiveRadiationMixedFvPatchScalarField::autoMap
(
const fvPatchFieldMapper& m
)
{
scalarField::autoMap(m);
qr_.automap(m);
}
void Foam::radiation::WideBandDiffusiveRadiationMixedFvPatchField::rmap
void Foam::radiation::wideBandDiffusiveRadiationMixedFvPatchScalarField::rmap
(
const fvPatchScalarField& ptf,
const labelList& addr
@ -172,14 +170,15 @@ void Foam::radiation::WideBandDiffusiveRadiationMixedFvPatchField::rmap
{
mixedFvPatchScalarField::rmap(ptf, addr);
// const GreyDiffusiveRadiationMixedFvPatchField& mrptf =
refCast<const WideBandDiffusiveRadiationMixedFvPatchField>(ptf);
const wideBandDiffusiveRadiationMixedFvPatchScalarField& wbdrpsf =
refCast<const wideBandDiffusiveRadiationMixedFvPatchScalarField>(ptf);
qr_.rmap(wbdrpsf.qr_, addr);
}
void
Foam::radiation::WideBandDiffusiveRadiationMixedFvPatchField::updateCoeffs
()
void Foam::radiation::wideBandDiffusiveRadiationMixedFvPatchScalarField::
updateCoeffs()
{
if (this->updated())
{
@ -187,24 +186,27 @@ Foam::radiation::WideBandDiffusiveRadiationMixedFvPatchField::updateCoeffs
}
const radiationModel& rad =
db().lookupObject<radiationModel>("radiationProperties");
db().lookupObject<radiationModel>("radiationProperties");
const fvDOM& Dom(refCast<const fvDOM>(rad));
const fvDOM& dom(refCast<const fvDOM>(rad));
const label patchi = patch().index();
if(Dom.lambdaj() > 1)
if (dom.lambdaj() > 1)
{
if (myRayIsInit_ == -1)
{
for(label i=0; i < Dom.Ni() ; i++)
for (label i=0; i < dom.Ni() ; i++)
{
for(label j=0; j < Dom.lambdaj() ; j++)
for (label j=0; j < dom.lambdaj() ; j++)
{
const volScalarField& radiationField =
Dom.RadIntRayiLambdaj(i,j);
if (&(radiationField.internalField()) ==
&dimensionedInternalField())
dom.RadIntRayiLambdaj(i,j);
if
(
&(radiationField.internalField())
==&dimensionedInternalField()
)
{
myRayIndex_ = i;
myWaveLengthIndex_ = j;
@ -220,7 +222,7 @@ Foam::radiation::WideBandDiffusiveRadiationMixedFvPatchField::updateCoeffs
FatalErrorIn
(
"Foam::radiation::"
"WideBandDiffusiveRadiationMixedFvPatchScalarField::"
"wideBandDiffusiveRadiationMixedFvPatchScalarField::"
"updateCoeffs"
) << " a Non-grey boundary condition is used with a grey"
<< "absorption model"
@ -229,24 +231,23 @@ Foam::radiation::WideBandDiffusiveRadiationMixedFvPatchField::updateCoeffs
vectorField n = patch().Sf()/patch().magSf();
scalarField& Iw = *(this);
scalarField& Iw = *this;
qr_ = Iw *(-n & Dom.RadIntRay(myRayIndex_).Di());
qr_ = Iw*(-n & dom.RadIntRay(myRayIndex_).Di());
Dom.RadIntRay(myRayIndex_).add(qr_,patchi);
dom.RadIntRay(myRayIndex_).add(qr_,patchi);
const scalarField Eb =
Dom.blackBody().bj(myWaveLengthIndex_).boundaryField()[patchi];
dom.blackBody().bj(myWaveLengthIndex_).boundaryField()[patchi];
forAll(Iw, faceI)
{
scalar Ir = 0.0;
for(label i=0; i < Dom.Ni() ; i++) //
for(label i=0; i < dom.Ni(); i++)
{
const vector& si = Dom.RadIntRay(i).Si();
const vector& si = dom.RadIntRay(i).Si();
const scalarField& Iface = Dom.RadIntRay(i).Ilambdaj
const scalarField& Iface = dom.RadIntRay(i).Ilambdaj
(
myWaveLengthIndex_
).boundaryField()[patch().index()];
@ -255,13 +256,12 @@ Foam::radiation::WideBandDiffusiveRadiationMixedFvPatchField::updateCoeffs
if (InOut < 0.) // qin into the wall
{
const vector& di = Dom.RadIntRay(i).Di();
const vector& di = dom.RadIntRay(i).Di();
Ir = Ir + Iface[faceI]*mag(n[faceI] & di);
}
}
const vector& mySi = Dom.RadIntRay(myRayIndex_).Si();
const vector& mySi = dom.RadIntRay(myRayIndex_).Si();
scalar InOut = -n[faceI] & mySi;
@ -269,8 +269,12 @@ Foam::radiation::WideBandDiffusiveRadiationMixedFvPatchField::updateCoeffs
{
refGrad()[faceI] = 0.0;
valueFraction()[faceI] = 1.0;
refValue()[faceI] = ((1. - emissivity_) * Ir +
emissivity_* Eb[faceI]) / Foam::mathematicalConstant::pi;
refValue()[faceI] =
(
Ir*(1.0 - emissivity_)
+ emissivity_* Eb[faceI]
)
/mathematicalConstant::pi;
}
else if (InOut < 0.) //direction into the wall
{
@ -284,7 +288,7 @@ Foam::radiation::WideBandDiffusiveRadiationMixedFvPatchField::updateCoeffs
}
void Foam::radiation::WideBandDiffusiveRadiationMixedFvPatchField::write
void Foam::radiation::wideBandDiffusiveRadiationMixedFvPatchScalarField::write
(
Ostream& os
) const
@ -305,7 +309,7 @@ namespace radiation
makePatchTypeField
(
fvPatchScalarField,
WideBandDiffusiveRadiationMixedFvPatchField
wideBandDiffusiveRadiationMixedFvPatchScalarField
);
}
}

View File

@ -23,18 +23,18 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::GreyDiffusiveRadiationMixedFvPatchField
Foam::wideBandDiffusiveRadiationMixedFvPatchScalarField
Description
Radiation temperature specified
SourceFiles
GreyDiffusiveRadiationMixedFvPatchField.C
wideBandDiffusiveRadiationMixedFvPatchScalarField.C
\*---------------------------------------------------------------------------*/
#ifndef GreyDiffusiveRadiationMixedFvPatchField_H
#define GreyDiffusiveRadiationMixedFvPatchField_H
#ifndef wideBandDiffusiveRadiationMixedFvPatchScalarField_H
#define wideBandDiffusiveRadiationMixedFvPatchScalarField_H
#include "mixedFvPatchFields.H"
@ -45,14 +45,13 @@ namespace Foam
namespace radiation
{
/*---------------------------------------------------------------------------*\
Class GreyDiffusiveRadiationMixedFvPatchField Declaration
Class wideBandDiffusiveRadiationMixedFvPatchScalarField Declaration
\*---------------------------------------------------------------------------*/
class GreyDiffusiveRadiationMixedFvPatchField
class wideBandDiffusiveRadiationMixedFvPatchScalarField
:
public mixedFvPatchScalarField
{
// Private data
//- Name of temperature field
@ -73,23 +72,24 @@ class GreyDiffusiveRadiationMixedFvPatchField
//- Radiative heat flux on walls.
scalarField qr_;
public:
//- Runtime type information
TypeName("GreyDiffusiveRadiation");
TypeName("wideBandDiffusiveRadiation");
// Constructors
//- Construct from patch and internal field
GreyDiffusiveRadiationMixedFvPatchField
wideBandDiffusiveRadiationMixedFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&
);
//- Construct from patch, internal field and dictionary
GreyDiffusiveRadiationMixedFvPatchField
wideBandDiffusiveRadiationMixedFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
@ -98,18 +98,18 @@ public:
//- Construct by mapping given GreyDiffusiveRadiationMixedFvPatchField
// onto a new patch
GreyDiffusiveRadiationMixedFvPatchField
wideBandDiffusiveRadiationMixedFvPatchScalarField
(
const GreyDiffusiveRadiationMixedFvPatchField&,
const wideBandDiffusiveRadiationMixedFvPatchScalarField&,
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const fvPatchFieldMapper&
);
//- Construct as copy
GreyDiffusiveRadiationMixedFvPatchField
wideBandDiffusiveRadiationMixedFvPatchScalarField
(
const GreyDiffusiveRadiationMixedFvPatchField&
const wideBandDiffusiveRadiationMixedFvPatchScalarField&
);
//- Construct and return a clone
@ -117,14 +117,14 @@ public:
{
return tmp<fvPatchScalarField>
(
new GreyDiffusiveRadiationMixedFvPatchField(*this)
new wideBandDiffusiveRadiationMixedFvPatchScalarField(*this)
);
}
//- Construct as copy setting internal field reference
GreyDiffusiveRadiationMixedFvPatchField
wideBandDiffusiveRadiationMixedFvPatchScalarField
(
const GreyDiffusiveRadiationMixedFvPatchField&,
const wideBandDiffusiveRadiationMixedFvPatchScalarField&,
const DimensionedField<scalar, volMesh>&
);
@ -136,7 +136,7 @@ public:
{
return tmp<fvPatchScalarField>
(
new GreyDiffusiveRadiationMixedFvPatchField(*this, iF)
new wideBandDiffusiveRadiationMixedFvPatchScalarField(*this, iF)
);
}
@ -145,13 +145,13 @@ public:
// Access
//- Return the temperature field name
//- Return the temperature field name
const word& TName() const
{
return TName_;
}
//- Return reference to the temperature field name to allow
//- Return reference to the temperature field name to allow
// adjustment
word& TName()
{
@ -170,14 +170,14 @@ public:
return emissivity_;
}
//- Return heat flux on the boundary
const scalarField& qr() const
{
return qr_;
}
// Mapping functions
// Mapping functions
//- Map (and resize as needed) from self given a mapping object
virtual void autoMap

View File

@ -101,8 +101,7 @@ public:
// Destructor
~P1();
virtual ~P1();
// Member functions

View File

@ -27,14 +27,8 @@ License
#include "absorptionCoeffs.H"
#include "IOstreams.H"
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * //
Foam::radiation::absorptionCoeffs::~absorptionCoeffs()
{}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::radiation::absorptionCoeffs::absorptionCoeffs(Istream& is)
:
Tcommon_(readScalar(is)),
@ -42,38 +36,36 @@ Foam::radiation::absorptionCoeffs::absorptionCoeffs(Istream& is)
Thigh_(readScalar(is)),
invTemp_(readBool(is))
{
for
(
label coefLabel=0;
absorptionCoeffs::nCoeffs_;
coefLabel++
)
for (label coefLabel=0; absorptionCoeffs::nCoeffs_; coefLabel++)
{
is >> highACoeffs_[coefLabel];
}
for
(
label coefLabel=0;
absorptionCoeffs::nCoeffs_;
coefLabel++
)
for (label coefLabel=0; absorptionCoeffs::nCoeffs_; coefLabel++)
{
is >> lowACoeffs_[coefLabel];
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * //
Foam::radiation::absorptionCoeffs::~absorptionCoeffs()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::radiation::absorptionCoeffs::checkT(const scalar T) const
{
if (T < Tlow_ || T > Thigh_)
if (T < Tlow_ || T > Thigh_)
{
FatalErrorIn
(
"absCoeffs::checkT(const scalar T) const"
) << "attempt to use absCoeff"
" out of temperature range "
<< Tlow_ << " -> " << Thigh_ << "; T = " << T
<< abort(FatalError);
"absorptionCoeffs::checkT(const scalar T) const"
) << "attempt to use absCoeff out of temperature range:" << nl
<< " " << Tlow_ << " -> " << Thigh_ << "; T = " << T
<< nl << abort(FatalError);
}
}
@ -96,6 +88,7 @@ Foam::radiation::absorptionCoeffs::coeffs
}
}
void Foam::radiation::absorptionCoeffs::init
(
const dictionary& dict
@ -109,4 +102,6 @@ void Foam::radiation::absorptionCoeffs::init
dict.lookup("loTcoeffs") >> lowACoeffs_;
dict.lookup("hiTcoeffs") >> highACoeffs_;
}
// ************************************************************************* //

View File

@ -40,6 +40,7 @@ SourceFiles
#include "List.H"
#include "IOstreams.H"
#include "IOdictionary.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
@ -47,29 +48,33 @@ namespace radiation
{
/*---------------------------------------------------------------------------*\
Class absorptionCoeffs Declaration
Class absorptionCoeffs Declaration
\*---------------------------------------------------------------------------*/
class absorptionCoeffs
{
public:
// Public data members
static const int nCoeffs_ = 6;
typedef FixedList<scalar, nCoeffs_> coeffArray;
private:
// Private data
// Temperature limits of applicability of functions
scalar Tcommon_;
scalar Tlow_;
scalar Tcommon_;
scalar Thigh_;
scalar Tlow_;
// Polynomio using inverse temperatures
scalar Thigh_;
// Polynomial using inverse temperatures
bool invTemp_;
coeffArray highACoeffs_;
@ -93,26 +98,28 @@ public:
absorptionCoeffs()
{}
// Destructor
~absorptionCoeffs();
~absorptionCoeffs();
// member functions
// Member functions
//- Return the coefficients corresponding to the given temperature
const coeffArray& coeffs(const scalar T) const;
// Init from a dictionary
// Initialise from a dictionary
void init(const dictionary&);
// Init from an Istram
// Initialise from an Istream
inline void init(Istream&)
{
absorptionCoeffs(Istream);
absorptionCoeffs(Istream);
}
// Acces Functions
inline bool invTemp() const
{
return invTemp_;
@ -142,12 +149,15 @@ public:
{
return lowACoeffs_;
}
};
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
} // End namespace radiation
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -24,7 +24,6 @@ License
\*---------------------------------------------------------------------------*/
#include "blackBodyEmission.H"
#include "dimensionedConstants.H"
@ -37,14 +36,15 @@ Foam::radiation::blackBodyEmission::blackBodyEmission
label lambdaj,
const volScalarField& T
)
:blackBodyEmissiveTable_(fn, instance, T.mesh()),
C1_("C1",dimensionSet(1,4,3,0,0,0,0),3.7419e-16),
C2_("C2",dimensionSet(0,1,0,1,0,0,0),14.388e-6),
bj_(0),
T_(T)
:
blackBodyEmissiveTable_(fn, instance, T.mesh()),
C1_("C1",dimensionSet(1, 4, 3, 0, 0, 0, 0), 3.7419e-16),
C2_("C2",dimensionSet(0, 1, 0, 1, 0, 0, 0), 14.388e-6),
bj_(0),
T_(T)
{
bj_.setSize(lambdaj);
for(label i=0; i < lambdaj; i++)
for (label i=0; i < lambdaj; i++)
{
bj_.set
(
@ -66,21 +66,24 @@ T_(T)
}
}
// * * * * * * * Destructor * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::radiation::blackBodyEmission::~blackBodyEmission()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::scalar Foam::radiation::blackBodyEmission::flambdaT
(
const scalar lambdaT
) const
{
return blackBodyEmissiveTable_.LookUp(lambdaT*1e6)[1];
return blackBodyEmissiveTable_.LookUp(lambdaT*1.0e6)[1];
}
Foam::tmp<Foam::volScalarField>
Foam::radiation::blackBodyEmission::EbDeltaLambdaT
(
@ -125,7 +128,6 @@ Foam::radiation::blackBodyEmission::EbDeltaLambdaT
}
return Eb;
}
}
@ -139,5 +141,4 @@ void Foam::radiation::blackBodyEmission::correct
}
// ************************************************************************* //

View File

@ -33,6 +33,7 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef blackModyEmission_H
#define blackModyEmission_H
@ -42,6 +43,7 @@ SourceFiles
#include "radiationConstants.H"
#include "interpolationLookUpTable.H"
#include "Vector2D.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
@ -54,71 +56,82 @@ namespace radiation
class blackBodyEmission
{
// Private data
mutable interpolationLookUpTable<scalar> blackBodyEmissiveTable_;
scalar flambdaT(const scalar lambdaT) const;
mutable interpolationLookUpTable<scalar> blackBodyEmissiveTable_;
const dimensionedScalar C1_;
scalar flambdaT(const scalar lambdaT) const;
const dimensionedScalar C2_;
const dimensionedScalar C1_;
// Ptr List for enregy black body emission
PtrList<volScalarField> bj_;
const dimensionedScalar C2_;
// Ptr List for enregy black body emission
PtrList<volScalarField> bj_;
// Reference to the temperature field
const volScalarField& T_;
// T
const volScalarField& T_;
public:
// Constructors
blackBodyEmission
(
const fileName& fn,
const word& instance,
label lambdaj,
const volScalarField& T
);
//- Construct from components
blackBodyEmission
(
const fileName& fn,
const word& instance,
label lambdaj,
const volScalarField& T
);
// Destructor
~blackBodyEmission();
// - Spectral emission for the black body at T and lambda
inline dimensionedScalar EblambdaT
(
const dimensionedScalar T,
const scalar lambda
) const
{
return (C1_/(pow5(lambda)*(exp(C2_/(lambda*T))-1)));
}
// Member functions
// Integral Energy at T from lambda1 to lambda2
// Access
//- Black body spectrum
inline const volScalarField& bj(label i) const
{
return bj_[i];
}
//- Spectral emission for the black body at T and lambda
inline dimensionedScalar EblambdaT
(
const dimensionedScalar T,
const scalar lambda
) const
{
return (C1_/(pow5(lambda)*(exp(C2_/(lambda*T)) - 1)));
}
//- Integral energy at T from lambda1 to lambda2
tmp<Foam::volScalarField> EbDeltaLambdaT
(
const volScalarField& T,
const Vector2D<scalar>& band
) const;
tmp<Foam::volScalarField> EbDeltaLambdaT //dimensionedScalar
(
const volScalarField& T,
const Vector2D<scalar>& band
) const;
// Edit
// Update black body emission
void correct(label j, const Vector2D<scalar>& band);
// Acces members
// Black body spectrum
inline const volScalarField& bj(label i) const
{
return bj_[i];
}
};
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
} // End namespace radiation
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -53,9 +53,9 @@ namespace Foam
// Radiation solver iterator counter
Foam::label Foam::radiation::fvDOM::iterRadId = pTraits<label>::one;
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
Foam::radiation::fvDOM::fvDOM(const volScalarField& T)
:
radiationModel(typeName, T),
@ -134,25 +134,30 @@ Foam::radiation::fvDOM::fvDOM(const volScalarField& T)
aj_.setSize(lambdaj_);
if (mesh_.nSolutionD() == 3) //3D
{
RadIntRay_.setSize(4.* Nphi_* Ntheta_);
Ni_ = 4. * Nphi_ * Ntheta_;
scalar deltaPhi = mathematicalConstant::pi / (2. * Nphi_);
scalar deltaTheta = mathematicalConstant::pi / Ntheta_;
RadIntRay_.setSize(4.0*Nphi_*Ntheta_);
Ni_ = 4.0*Nphi_*Ntheta_;
scalar deltaPhi = mathematicalConstant::pi/(2.0*Nphi_);
scalar deltaTheta = mathematicalConstant::pi/Ntheta_;
label i = 0;
for(label n = 1 ; n <= Ntheta_ ; n++)
for (label n = 1 ; n <= Ntheta_ ; n++)
{
for(label m = 1 ; m <= 4*Nphi_ ; m++)
for (label m = 1 ; m <= 4*Nphi_ ; m++)
{
scalar thetai = (2.*n - 1.)*deltaTheta/2.;
scalar phii = (2.*m - 1.)*deltaPhi/2.;
scalar thetai = (2.0*n - 1.0)*deltaTheta/2.0;
scalar phii = (2.0*m - 1.0)*deltaPhi/2.0;
RadIntRay_.set
(
i,
new radiativeIntensityRay
(
phii, thetai, deltaPhi,
deltaTheta, lambdaj_, mesh_,
absorptionEmission_, blackBody_
phii,
thetai,
deltaPhi,
deltaTheta,
lambdaj_,
mesh_,
absorptionEmission_,
blackBody_
)
);
i++;
@ -163,23 +168,28 @@ Foam::radiation::fvDOM::fvDOM(const volScalarField& T)
{
if (mesh_.nSolutionD() == 2) //2D (X & Y)
{
scalar thetai = mathematicalConstant::pi/2.;
scalar thetai = mathematicalConstant::pi/2.0;
scalar deltaTheta = mathematicalConstant::pi;
RadIntRay_.setSize(4.* Nphi_);
Ni_ = 4. * Nphi_;
scalar deltaPhi = mathematicalConstant::pi / (2. * Nphi_);
RadIntRay_.setSize(4.0*Nphi_);
Ni_ = 4.0*Nphi_;
scalar deltaPhi = mathematicalConstant::pi/(2.0*Nphi_);
label i = 0;
for(label m = 1 ; m <= 4*Nphi_ ; m++)
for (label m = 1 ; m <= 4*Nphi_ ; m++)
{
scalar phii = (2.*m - 1.)*deltaPhi/2.;
scalar phii = (2.0*m - 1.0)*deltaPhi/2.0;
RadIntRay_.set
(
i,
new radiativeIntensityRay
(
phii, thetai, deltaPhi,
deltaTheta, lambdaj_, mesh_,
absorptionEmission_, blackBody_
phii,
thetai,
deltaPhi,
deltaTheta,
lambdaj_,
mesh_,
absorptionEmission_,
blackBody_
)
);
i++;
@ -187,23 +197,28 @@ Foam::radiation::fvDOM::fvDOM(const volScalarField& T)
}
else //1D (X)
{
scalar thetai = mathematicalConstant::pi/2.;
scalar thetai = mathematicalConstant::pi/2.0;
scalar deltaTheta = mathematicalConstant::pi;
RadIntRay_.setSize(2);
Ni_ = 2.;
Ni_ = 2.0;
scalar deltaPhi = mathematicalConstant::pi;
label i = 0;
for(label m = 1 ; m <= 2 ; m++)
for (label m = 1 ; m <= 2 ; m++)
{
scalar phii = (2*m - 1.)*deltaPhi/2.;
scalar phii = (2.0*m - 1.0)*deltaPhi/2.0;
RadIntRay_.set
(
i,
new radiativeIntensityRay
(
phii, thetai, deltaPhi,
deltaTheta, lambdaj_, mesh_,
absorptionEmission_, blackBody_
phii,
thetai,
deltaPhi,
deltaTheta,
lambdaj_,
mesh_,
absorptionEmission_,
blackBody_
)
);
i++;
@ -213,7 +228,7 @@ Foam::radiation::fvDOM::fvDOM(const volScalarField& T)
}
// Construct absorption for wave length
// Construct absorption for wave length
for(label i=0; i < lambdaj_; i++)
{
volScalarField* volPtr= new volScalarField
@ -233,6 +248,8 @@ Foam::radiation::fvDOM::fvDOM(const volScalarField& T)
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::radiation::fvDOM::~fvDOM()
@ -274,8 +291,8 @@ void Foam::radiation::fvDOM::correct()
label radIter = 0;
do
{
radIter ++;
for(label i = 0; i < Ni_; i++) //
radIter ++;
for (label i = 0; i < Ni_; i++)
{
maxResidual = 0;
scalar maxBandResidual = RadIntRay_[i].correct(this);
@ -284,13 +301,14 @@ void Foam::radiation::fvDOM::correct()
Info << "Radiation solver Iter: " << radIter << endl;
}while(maxResidual > convergenceCriterion);
} while(maxResidual > convergenceCriterion);
updateG();
iterRadId = pTraits<label>::one;
}
Foam::tmp<Foam::volScalarField> Foam::radiation::fvDOM::Rp() const
{
@ -327,27 +345,29 @@ Foam::radiation::fvDOM::Ru() const
return a*G - 4.0*E;
}
void Foam::radiation::fvDOM::updateBlackBodyEmission()
{
for(label j=0; j < lambdaj_; j++)
for (label j=0; j < lambdaj_; j++)
{
blackBody_.correct(j, absorptionEmission_->bands(j));
}
}
void Foam::radiation::fvDOM::updateG()
{
G_ = dimensionedScalar("zero",dimMass/pow3(dimTime), 0.0);
Qr_ = dimensionedScalar("zero",dimMass/pow3(dimTime), 0.0);
for(label i = 0; i < Ni_; i++)
for (label i = 0; i < Ni_; i++)
{
RadIntRay_[i].addIntensity();
G_ += RadIntRay_[i].I()* RadIntRay_[i].omegai();
Qr_ += RadIntRay_[i].Qri();
}
}
// ************************************************************************* //

View File

@ -27,25 +27,25 @@ Class
Description
Finite Volume Discrete Ordinary Method. It solves the RTE equation for n
directions in a participating media. It does not consider scatter.
Finite Volume Discrete Ordinary Method. Solves the RTE equation for n
directions in a participating media, not including scatter.
Available absorption models:
greyMeanAbsoprtionEmission
wideBandAbsorptionEmission
greyMeanAbsoprtionEmission
wideBandAbsorptionEmission
i.e. dictionary
fvDOMCoeffs
{
Nphi 1; // azimuthal angles in PI/2 on X-Y.(from Y to X)
Ntheta 2; // polar angles in P1 (from Z to X-Y plane)
convergence 1e-4; //convergence criteria for radiation iteration
convergence 1e-4; // convergence criteria for radiation iteration
}
nFlowIterPerRadIter 1; // Number of flow iterations per radiation
iteration
The total number of solid angles is 4 * Nphi * Ntheta.
The total number of solid angles is 4*Nphi*Ntheta.
In 1D the direction of the rays is X (Nphi and Ntheta are ignored)
In 2D the direction of the rays is on X-Y plane (only Nphi is considered)
@ -77,7 +77,6 @@ class fvDOM
:
public radiationModel
{
// Private data
//- Incident radiation [W/m2]
@ -131,14 +130,16 @@ class fvDOM
//- Update Black Body Emissiom
void updateBlackBodyEmission(void);
public:
// Static data members
static label iterRadId;
//- Runtime type information
TypeName("fvDOM");
TypeName("fvDOM");
// Constructors
@ -148,103 +149,74 @@ public:
// Destructor
~fvDOM();
virtual ~fvDOM();
// Member functions
// Edit
//- Update radiationSource varible
void correct();
//- Update radiation source variable
void correct();
//- Read radiationProperties dictionary
bool read();
//- Read radiationProperties dictionary
bool read();
//- Update G and calculate total heat flux on boundary
void updateG();
//- Update G and calculate total heat flux on boundary
void updateG();
//- Source term component (for power of T^4)
virtual tmp<volScalarField> Rp() const;
//- Source term component (for power of T^4)
virtual tmp<volScalarField> Rp() const;
//- Source term component (constant)
virtual tmp<DimensionedField<scalar, volMesh> > Ru() const;
//- Source term component (constant)
virtual tmp<DimensionedField<scalar, volMesh> > Ru() const;
// Access
//- Intensity Ray on i direction
inline const radiativeIntensityRay& RadIntRay(label i) const
{
return RadIntRay_[i];
}
//- Ray intensity in i direction
inline const radiativeIntensityRay& RadIntRay(label i) const;
//- Intensity Ray on i direction and j band-width
inline const volScalarField& RadIntRayiLambdaj
(
const label i,
const label j
) const
{
return RadIntRay_[i].Ilambdaj(j);
}
//- Ray intensity in i direction and j band-width
inline const volScalarField& RadIntRayiLambdaj
(
const label i,
const label j
) const;
//-Number of angles in theta
label Ntheta() const
{
return Ntheta_;
}
//- Number of angles in theta
inline label Ntheta() const;
//- Number of angles in phi
label Nphi() const
{
return Nphi_;
}
//- Number of angles in phi
inline label Nphi() const;
//- Number of directions
label Ni() const
{
return Ni_;
}
//- Number of directions
inline label Ni() const;
//- Number of wavelengths
inline const label& lambdaj() const
{
return lambdaj_;
}
//- Number of wavelengths
inline label lambdaj() const;
// Const access to a
inline const volScalarField& a() const
{
return a_;
}
// Const access to a
inline const volScalarField& a() const;
// Const access to aj
inline const volScalarField& aj(label i) const
{
return aj_[i];
}
// Const access to aj
inline const volScalarField& aj(label i) const;
// Const access to G
inline const volScalarField& G() const
{
return G_;
}
// Const access to G
inline const volScalarField& G() const;
// Const access to Qr
inline const volScalarField& Qr() const
{
return Qr_;
}
// Const access to Qr
inline const volScalarField& Qr() const;
// Const access to blavkBody
virtual const blackBodyEmission& blackBody() const
{
return blackBody_;
}
// Const access to blackBody
virtual const blackBodyEmission& blackBody() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "fvDOMI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace radiation

View File

@ -0,0 +1,102 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
inline const Foam::radiation::radiativeIntensityRay&
Foam::radiation::fvDOM::RadIntRay(label i) const
{
return RadIntRay_[i];
}
inline const Foam::volScalarField& Foam::radiation::fvDOM::RadIntRayiLambdaj
(
const label i,
const label j
) const
{
return RadIntRay_[i].Ilambdaj(j);
}
inline Foam::label Foam::radiation::fvDOM::Ntheta() const
{
return Ntheta_;
}
inline Foam::label Foam::radiation::fvDOM::Nphi() const
{
return Nphi_;
}
inline Foam::label Foam::radiation::fvDOM::Ni() const
{
return Ni_;
}
inline Foam::label Foam::radiation::fvDOM::lambdaj() const
{
return lambdaj_;
}
inline const Foam::volScalarField& Foam::radiation::fvDOM::a() const
{
return a_;
}
inline const Foam::volScalarField& Foam::radiation::fvDOM::aj
(
const label i
) const
{
return aj_[i];
}
inline const Foam::volScalarField& Foam::radiation::fvDOM::G() const
{
return G_;
}
inline const Foam::volScalarField& Foam::radiation::fvDOM::Qr() const
{
return Qr_;
}
virtual const Foam::radiation::blackBodyEmission&
Foam::radiation::fvDOM::blackBody() const
{
return blackBody_;
}
// ************************************************************************* //

View File

@ -26,65 +26,65 @@ License
#include "IFstream.H"
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
template <class Type>
Foam::label Foam::interpolationLookUpTable <Type>::index
(
const List<scalar>& indices,
const bool lastDim
const List<scalar>& indices,
const bool lastDim
) const
{
label totalindex = 0;
for(int i = 0;i < dim_.size()-1;i++)
for (int i = 0; i < dim_.size() - 1; i++)
{
label dim = 1;
for(int j = i + 1 ;j < dim_.size() ; j++)
{
dim *=(dim_[j]+1);
}
totalindex += Foam::min
(
Foam::max(label((indices[i]-min_[i])/delta_[i]),0),
dim_[i]
)*dim;
for (int j = i + 1; j < dim_.size(); j++)
{
dim *=(dim_[j]+1);
}
totalindex +=
dim
*min
(
max(label((indices[i] - min_[i])/delta_[i]), 0),
dim_[i]
);
}
if(lastDim)
{
label iLastdim = dim_.size() -1;
totalindex += Foam::min
(
Foam::max
(
label((indices[iLastdim]-min_[iLastdim])/delta_[iLastdim]),
0
),
dim_[iLastdim]
);
}
if (lastDim)
{
label iLastdim = dim_.size() - 1;
totalindex += Foam::min
(
max
(
label((indices[iLastdim] - min_[iLastdim])/delta_[iLastdim]),
0
),
dim_[iLastdim]
);
}
return totalindex;
}
template <class Type>
Foam::label Foam::interpolationLookUpTable <Type>::index
(
const scalar indice
) const
{
label i = 0;
label totalindex =
Foam::min
min
(
Foam::max
max
(
label((indice-min_[i])/delta_[i]),
label((indice - min_[i])/delta_[i]),
0
),
dim_[i]
@ -93,108 +93,110 @@ Foam::label Foam::interpolationLookUpTable <Type>::index
return totalindex;
}
template<class Type>
bool Foam::interpolationLookUpTable<Type>::checkRange
(
const scalar lookUpValue,
const label interfield
const scalar lookUpValue,
const label interfield
) const
{
if(lookUpValue >= min_[interfield] && lookUpValue <= max_[interfield])
{
return true;
}
else
{
return false;
}
if (lookUpValue >= min_[interfield] && lookUpValue <= max_[interfield])
{
return true;
}
else
{
return false;
}
}
template<class Type>
Foam::scalar Foam::interpolationLookUpTable<Type>::interpolate
(
const label lo,
const label hi,
const scalar lookUpValue, //Xi
const label ofield, // Yo , Delta Y
const label interfield // Delta X
const label lo,
const label hi,
const scalar lookUpValue,
const label ofield,
const label interfield
) const
{
if( List<scalarField>::operator[](interfield).operator[](hi)
!= List<scalarField>::operator[](interfield).operator[](lo))
if
(
List<scalarField>::operator[](interfield).operator[](hi)
!= List<scalarField>::operator[](interfield).operator[](lo)
)
{
scalar output
(
List<scalarField>::operator[](ofield).operator[](lo)
+ (
List<scalarField>::operator[](ofield).operator[](hi)
- List<scalarField>::operator[](ofield).operator[](lo)
)
* (
lookUpValue
- List<scalarField>::operator[](interfield).operator[](lo)
)
/(
List<scalarField>::operator[](interfield).operator[](hi)
- List<scalarField>::operator[](interfield).operator[](lo)
)
);
return output;
}
else
{
return List<scalarField>::operator[](ofield).operator[](lo);
}
scalar output
(
List<scalarField>::operator[](ofield).operator[](lo)
+ (
List<scalarField>::operator[](ofield).operator[](hi)
- List<scalarField>::operator[](ofield).operator[](lo)
)
*(
lookUpValue
- List<scalarField>::operator[](interfield).operator[](lo)
)
/(
List<scalarField>::operator[](interfield).operator[](hi)
- List<scalarField>::operator[](interfield).operator[](lo)
)
);
return output;
}
else
{
return List<scalarField>::operator[](ofield).operator[](lo);
}
}
template<class Type>
void Foam::interpolationLookUpTable<Type>::dimensionTable()
{
min_.setSize(entries_.size());
dim_.setSize(entries_.size());
delta_.setSize(entries_.size());
delta_.setSize(entries_.size());
max_.setSize(entries_.size());
entryIndices_.setSize(entries_.size());
outputIndices_.setSize(output_.size());
label index = 0;
label tableDim = 1;
entryIndices_.setSize(entries_.size());
outputIndices_.setSize(output_.size());
label index = 0;
label tableDim = 1;
forAll(entries_,i)
{
dim_[i] = readLabel(entries_[i].lookup("N"));
max_[i] = readScalar(entries_[i].lookup("max"));
min_[i] = readScalar(entries_[i].lookup("min"));
delta_[i] = (max_[i] - min_[i]) / dim_[i];
max_[i] = readScalar(entries_[i].lookup("max"));
min_[i] = readScalar(entries_[i].lookup("min"));
delta_[i] = (max_[i] - min_[i])/dim_[i];
tableDim *= (dim_[i] + 1);
fieldIndices_.insert(entries_[i].lookup("name"),index);
entryIndices_[i] = index;
index ++;
fieldIndices_.insert(entries_[i].lookup("name"),index);
entryIndices_[i] = index;
index++;
}
forAll(output_,i)
forAll(output_,i)
{
fieldIndices_.insert(output_[i].lookup("name"),index);
outputIndices_[i] = index;
index++;
}
fieldIndices_.insert(output_[i].lookup("name"),index);
outputIndices_[i] = index;
index++;
}
List<scalarField >& internal = *this;
List<scalarField>& internal = *this;
internal.setSize(entries_.size()+output_.size());
internal.setSize(entries_.size() + output_.size());
interpOutput_.setSize(entries_.size() + output_.size());
interpOutput_.setSize(entries_.size() + output_.size());
forAll(internal, i)
{
internal[i].setSize(tableDim);
}
forAll(internal, i)
{
internal[i].setSize(tableDim);
}
}
template<class Type>
void Foam::interpolationLookUpTable<Type>::readTable
(
@ -202,12 +204,12 @@ void Foam::interpolationLookUpTable<Type>::readTable
const fvMesh& mesh
)
{
IOdictionary control
IOdictionary control
(
IOobject
(
fileName_, //,
instance, //i,
fileName_,
instance,
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
@ -216,9 +218,9 @@ void Foam::interpolationLookUpTable<Type>::readTable
control.lookup("fields") >> entries_;
control.lookup("output") >> output_;
control.lookup("values") >> *this;
control.lookup("values") >> *this;
dimensionTable();
dimensionTable();
check();
@ -226,7 +228,7 @@ void Foam::interpolationLookUpTable<Type>::readTable
{
FatalErrorIn
(
"Foam::interpolationLookUpTable<Type>::readTable()"
"Foam::interpolationLookUpTable<Type>::readTable()"
) << "table is empty" << nl
<< exit(FatalError);
}
@ -238,7 +240,7 @@ void Foam::interpolationLookUpTable<Type>::readTable
template<class Type>
Foam::interpolationLookUpTable<Type>::interpolationLookUpTable()
:
List<scalarField >(),
List<scalarField >(),
fileName_("fileNameIsUndefined")
{}
@ -246,20 +248,20 @@ Foam::interpolationLookUpTable<Type>::interpolationLookUpTable()
template<class Type>
Foam::interpolationLookUpTable<Type>::interpolationLookUpTable
(
const fileName& fn, const word& instance, const fvMesh& mesh
const fileName& fn, const word& instance, const fvMesh& mesh
)
:
List<scalarField >(),
List<scalarField >(),
fileName_(fn),
dim_(0),
min_(0),
delta_(0.),
max_(0.),
entries_(0),
output_(0),
entryIndices_(0),
outputIndices_(0),
interpOutput_(0)
dim_(0),
min_(0),
delta_(0.0),
max_(0.0),
entries_(0),
output_(0),
entryIndices_(0),
outputIndices_(0),
interpOutput_(0)
{
readTable(instance, mesh);
}
@ -271,39 +273,40 @@ Foam::interpolationLookUpTable<Type>::interpolationLookUpTable
const interpolationLookUpTable& interpTable
)
:
List<scalarField >(interpTable),
List<scalarField >(interpTable),
fileName_(interpTable.fileName_),
entryIndices_(interpTable.entryIndices_),
outputIndices_(interpTable.outputIndices_),
dim_(interpTable.dim_),
min_(interpTable.min_),
delta_(interpTable.delta_),
max_(interpTable.max_),
entries_(0),
output_(0),
interpOutput_(interpTable.interpOutput_)
entryIndices_(interpTable.entryIndices_),
outputIndices_(interpTable.outputIndices_),
dim_(interpTable.dim_),
min_(interpTable.min_),
delta_(interpTable.delta_),
max_(interpTable.max_),
entries_(0),
output_(0),
interpOutput_(interpTable.interpOutput_)
{}
template<class Type>
Foam::interpolationLookUpTable<Type>::interpolationLookUpTable
(
const dictionary& dict
const dictionary& dict
)
:
List<scalarField >(),
List<scalarField >(),
fileName_(fileName(dict.lookup("fileName")).expand()),
dim_(0),
min_(.0),
delta_(.0),
max_(.0),
min_(0.0),
delta_(0.0),
max_(0.0),
entries_(dict.lookup("fields")),
output_(dict.lookup("output")),
entryIndices_(0),
outputIndices_(0),
output_(dict.lookup("output")),
entryIndices_(0),
outputIndices_(0),
fieldIndices_(0),
interpOutput_(0)
interpOutput_(0)
{
dimensionTable();
dimensionTable();
}
@ -312,27 +315,27 @@ Foam::interpolationLookUpTable<Type>::interpolationLookUpTable
template<class Type>
void Foam::interpolationLookUpTable<Type>::check() const
{
// check order in the first dimension.
scalar prevValue = List<scalarField >::operator[](0).operator[](0);
label dim = 1 ;
for(int j = 1 ;j < dim_.size() ; j++)
{
dim *=(dim_[j]+1);
}
for (int j = 1; j < dim_.size(); j++)
{
dim *=(dim_[j]+1);
}
for (label i = 1; i < dim_[0]; i++)
{
label index = i*dim;
const scalar currValue =
List<scalarField >::operator[](0).operator[](index);
List<scalarField >::operator[](0).operator[](index);
// avoid duplicate values (divide-by-zero error)
if (currValue <= prevValue)
{
FatalErrorIn
(
"Foam::interpolationLookUpTable<Type>::checkOrder() const"
"Foam::interpolationLookUpTable<Type>::checkOrder() const"
) << "out-of-order value: "
<< currValue << " at index " << index << nl
<< exit(FatalError);
@ -341,6 +344,7 @@ void Foam::interpolationLookUpTable<Type>::check() const
}
}
template<class Type>
void Foam::interpolationLookUpTable<Type>::write
(
@ -354,21 +358,21 @@ void Foam::interpolationLookUpTable<Type>::write
(
IOobject
(
fn, //,
instance, //i,
fn,
instance,
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
)
);
control.writeHeader(os) ;
control.writeHeader(os);
os.writeKeyword("fields");
os << entries_ << token::END_STATEMENT << nl;
os.writeKeyword("fields");
os << entries_ << token::END_STATEMENT << nl;
os.writeKeyword("output");
os << output_ << token::END_STATEMENT << nl;
os.writeKeyword("output");
os << output_ << token::END_STATEMENT << nl;
if (this->size() == 0)
{
@ -378,7 +382,7 @@ void Foam::interpolationLookUpTable<Type>::write
) << "table is empty" << nl
<< exit(FatalError);
}
os.writeKeyword("values");
os.writeKeyword("values");
os << *this << token::END_STATEMENT << nl;
}
@ -387,10 +391,7 @@ void Foam::interpolationLookUpTable<Type>::write
template<class Type>
Foam::scalarField&
Foam::interpolationLookUpTable<Type>::operator[]
(
const label i
)
Foam::interpolationLookUpTable<Type>::operator[](const label i)
{
label ii = i;
label n = this->size();
@ -399,41 +400,37 @@ Foam::interpolationLookUpTable<Type>::operator[]
{
FatalErrorIn
(
"Foam::interpolationLookUpTable<Type>::operator[]"
"(const label) const"
) << "table has (" << n << ") columns" << nl
"Foam::interpolationLookUpTable<Type>::operator[]"
"(const label) const"
) << "table has (" << n << ") columns" << nl
<< exit(FatalError);
}
else if (ii < 0)
{
FatalErrorIn
FatalErrorIn
(
"Foam::interpolationLookUpTable<Type>::operator[]"
"(const label) const"
) << "index (" << ii << ") underflow" << nl
"Foam::interpolationLookUpTable<Type>::operator[]"
"(const label) const"
) << "index (" << ii << ") underflow" << nl
<< exit(FatalError);
}
}
else if (ii > n)
{
FatalErrorIn
FatalErrorIn
(
"Foam::interpolationLookUpTable<Type>::operator[]"
"(const label) const"
) << "index (" << ii << ") overflow" << nl
"Foam::interpolationLookUpTable<Type>::operator[]"
"(const label) const"
) << "index (" << ii << ") overflow" << nl
<< exit(FatalError);
}
}
return List<scalarField >::operator[](ii);
return List<scalarField >::operator[](ii);
}
template<class Type>
const Foam::scalarField&
Foam::interpolationLookUpTable<Type>::operator[]
(
const label i
) const
Foam::interpolationLookUpTable<Type>::operator[](const label i) const
{
label ii = i;
label n = this->size();
@ -442,62 +439,45 @@ Foam::interpolationLookUpTable<Type>::operator[]
{
FatalErrorIn
(
"Foam::interpolationLookUpTable<Type>::operator[]"
"(const label) const"
) << "table has (" << n << ") columns" << nl
"Foam::interpolationLookUpTable<Type>::operator[]"
"(const label) const"
) << "table has (" << n << ") columns" << nl
<< exit(FatalError);
}
else if (ii < 0)
{
FatalErrorIn
FatalErrorIn
(
"Foam::interpolationLookUpTable<Type>::operator[]"
"(const label) const"
) << "index (" << ii << ") underflow" << nl
"Foam::interpolationLookUpTable<Type>::operator[]"
"(const label) const"
) << "index (" << ii << ") underflow" << nl
<< exit(FatalError);
}
}
else if (ii > n)
{
FatalErrorIn
FatalErrorIn
(
"Foam::interpolationLookUpTable<Type>::operator[]"
"(const label) const"
) << "index (" << ii << ") overflow" << nl
"Foam::interpolationLookUpTable<Type>::operator[]"
"(const label) const"
) << "index (" << ii << ") overflow" << nl
<< exit(FatalError);
}
}
return List<scalarField >::operator[](ii);
return List<scalarField >::operator[](ii);
}
template<class Type>
bool Foam::interpolationLookUpTable<Type>::found
(
const word& key
) const
bool Foam::interpolationLookUpTable<Type>::found(const word& fieldName) const
{
for
(
HashTable<label>::const_iterator iter = fieldIndices_.begin();
iter != fieldIndices_.end();
++iter
)
{
if (fieldIndices_.found(key))
{
return true;
};
}
return false;
return fieldIndices_.found(fieldName);
}
template<class Type>
const Foam::scalarList&
Foam::interpolationLookUpTable<Type>::LookUp
(
const scalar retvals
)
Foam::interpolationLookUpTable<Type>::lookUp(const scalar retvals)
{
const label lo = index(retvals);
findHi(lo, retvals);
@ -512,7 +492,6 @@ void Foam::interpolationLookUpTable<Type>::findHi
const scalar retvals
)
{
forAll(outputIndices_,j)
{
scalar tmp = 0;
@ -525,10 +504,10 @@ void Foam::interpolationLookUpTable<Type>::findHi
{
label dim = 1;
label hi = Foam::min(lo + dim,(*this)[0].size()-1);
label hi = Foam::min(lo + dim, (*this)[0].size() - 1);
tmp +=(interpolate(lo,hi,retvals,ofield,entryIndices_[i])
- baseValue);
tmp += interpolate(lo, hi, retvals, ofield, entryIndices_[i])
- baseValue;
}
interpOutput_[entryIndices_[i]] = retvals;
}
@ -536,5 +515,7 @@ void Foam::interpolationLookUpTable<Type>::findHi
tmp += baseValue;
interpOutput_[outputIndices_[j]] = tmp;
}
}
// ************************************************************************* //

View File

@ -29,7 +29,6 @@ Description
A list of lists. Interpolates based on the first dimension.
The values must be positive and monotonically increasing in each dimension
Note
- Accessing an empty list results in an error.
- Accessing a list with a single element always returns the same value.
@ -48,6 +47,7 @@ SourceFiles
#include "HashTable.H"
#include "IOdictionary.H"
#include "fvCFD.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
@ -60,12 +60,8 @@ namespace Foam
template<class Type>
class interpolationLookUpTable
:
public List<scalarField>
public List<scalarField>
{
public:
// Public data types
private:
// Private data
@ -73,71 +69,71 @@ private:
//- File name
fileName fileName_;
//- table dimensions
//- Table dimensions
List<label> dim_;
//- min on each dimension
//- Min on each dimension
List<scalar> min_;
//- deltas on each dimension
List<scalar> delta_;
//- Deltas on each dimension
List<scalar> delta_;
//- maximum on each dimension
//- Maximum on each dimension
List<scalar> max_;
//- entries dictionaries
//- Dictionary entries
List<dictionary> entries_;
//- output dictionaries
List<dictionary> output_;
//- Output dictionaries
List<dictionary> output_;
//- input Indeces from the Look Up Table
List<label> entryIndices_;
//- Input indices from the look up table
List<label> entryIndices_;
//- output Indeces from the Look Up Table
List<label> outputIndices_;
//- Output Indeces from the Look Up Table
List<label> outputIndices_;
//- field names and indices
HashTable<label> fieldIndices_;
//- Field names and indices
HashTable<label> fieldIndices_;
//- Output List containing input and interpolation values of outputs
List<scalar> interpOutput_;
//- Output list containing input and interpolation values of outputs
List<scalar> interpOutput_;
// Private Member Functions
//- Read the table of data from file
// Private Member Functions
//- Read the table of data from file
void readTable(const word& instance, const fvMesh& mesh);
//- Dimension Table from dictionaries input and output
void dimensionTable();
//- Dimension table from dictionaries input and output
void dimensionTable();
// Index table finding using scalarList
label index(const List<scalar>&, const bool lastDim=true) const;
//- Find table index by scalarList
label index(const List<scalar>&, const bool lastDim=true) const;
// Index table finding using scalar
//- Find table index by scalar
label index(const scalar) const;
//- check range of lookUpValue
bool checkRange(const scalar, const label) const;
//- Check range of lookup value
bool checkRange(const scalar, const label) const;
//- Interpolate function return an scalar
scalar interpolate
(
const label lo,
const label hi,
const scalar lookUpValue,
const label ofield,
const label interfield
) const;
//- Interpolate function return an scalar
scalar interpolate
(
const label lo,
const label hi,
const scalar lookUpValue,
const label ofield,
const label interfield
) const;
// Check list is monotonically increasing
// Check list is monotonically increasing
void check() const;
// find hi index, interpolate and populate interpOutput_
void findHi(const label lo, const scalar retvals);
public:
// Constructors
@ -156,18 +152,19 @@ public:
//- Construct from dictionary
interpolationLookUpTable(const dictionary& dict);
//- Construct copy
//- Construct copy
interpolationLookUpTable(const interpolationLookUpTable& interpTable);
// Member Functions
bool found(const word& key) const;
//- Return true if the filed exists in the table
bool found(const word& fieldName) const;
//- Return the output list given a single input scalar
const List<scalar>& LookUp(const scalar);
const List<scalar>& lookUp(const scalar);
//- Write Look Up Table to filename.
//- Write Look Up Table to filename.
void write
(
Ostream& os,
@ -177,54 +174,40 @@ public:
) const;
// Acces
// Access
inline label findFieldIndex(const word& field) const
{
return fieldIndices_[field];
}
//- Return the index of a field by name
inline label findFieldIndex(const word& fieldName) const;
inline const List<dictionary>& output() const
{
return output_;
}
//- Return const access to the output dictionaries
inline const List<dictionary>& output() const;
inline const List<dictionary>& entries() const
{
return entries_;
}
//- Return const access tp the dictionary entries
inline const List<dictionary>& entries() const;
inline const List<scalar>& min() const
{
return min_;
}
//- Return const access to the list of min dimensions
inline const List<scalar>& min() const;
inline const List<label>& dim() const
{
return dim_;
}
//- Return const access to the list of dimensions
inline const List<label>& dim() const;
inline const List<scalar>& delta() const
{
return delta_;
}
//- Return const access to the deltas in each dimension
inline const List<scalar>& delta() const;
//- Return const access to the list of max dimensions
inline const List<scalar>& max() const;
//- Return const access to the table name
inline const word tableName() const;
inline const List<scalar>& max() const
{
return max_;
}
inline const word tableName() const
{
return fileName_.name();
}
// Member Operators
//- Return an element of constant List<scalar, Type>
const scalarField& operator[](const label) const;
//- Return an element of List<scalar, Type>
scalarField & operator[](const label);
//- Return an element of List<scalar, Type>
scalarField& operator[](const label);
};

View File

@ -0,0 +1,93 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
template<class Type>
inline Foam::label
Foam::interpolationLookUpTable<Type>::findFieldIndex
(
const word& fieldName
) const
{
return fieldIndices_[fieldName];
}
template<class Type>
inline const Foam::List<Foam::dictionary>&
Foam::interpolationLookUpTable<Type>::output() const
{
return output_;
}
template<class Type>
inline const Foam::List<Foam::dictionary>&
Foam::interpolationLookUpTable<Type>::entries() const
{
return entries_;
}
template<class Type>
inline const Foam::List<Foam::scalar>&
Foam::interpolationLookUpTable<Type>::min() const
{
return min_;
}
template<class Type>
inline const Foam::List<Foam::label>&
Foam::interpolationLookUpTable<Type>::dim() const
{
return dim_;
}
template<class Type>
inline const Foam::List<Foam::scalar>&
Foam::interpolationLookUpTable<Type>::delta() const
{
return delta_;
}
template<class Type>
inline const Foam::List<Foam::scalar>&
Foam::interpolationLookUpTable<Type>::max() const
{
return max_;
}
template<class Type>
inline const Foam::word Foam::interpolationLookUpTable<Type>::tableName() const
{
return fileName_.name();
}
// ************************************************************************* //

View File

@ -36,10 +36,12 @@ License
#include "Vector2D.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
Foam::label Foam::radiation::radiativeIntensityRay::rayId = 0;
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Null constructor
Foam::radiation::radiativeIntensityRay::radiativeIntensityRay
(
scalar& phii,
@ -94,44 +96,49 @@ Foam::radiation::radiativeIntensityRay::~radiativeIntensityRay()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::radiation::radiativeIntensityRay::init
(
scalar phii, scalar thetai, scalar deltaPhi, scalar deltaTheta,
scalar lambdaj
const scalar phii,
const scalar thetai,
const scalar deltaPhi,
const scalar deltaTheta,
const scalar lambdaj
)
{
phii_ = phii;
thetai_ = thetai;
nLambdaj_ = lambdaj;
scalar sinTheta = Foam::sin(thetai);
scalar cosTheta = Foam::cos(thetai);
scalar sinPhi = Foam::sin(phii);
scalar cosPhi = Foam::cos(phii);
vector s = vector(sinTheta*sinPhi, sinTheta*cosPhi, cosTheta);
Si_ = (s);
thetai_ = thetai;
phii_ = phii;
omegai_ = 2. * Foam::sin(thetai)*Foam::sin(deltaTheta/2.)*deltaPhi;
Nlambdaj_ = (lambdaj);
Ilambdaj_.setSize(Nlambdaj_);
const vector& d = vector
Si_ = vector(sinTheta*sinPhi, sinTheta*cosPhi, cosTheta);
omegai_ = 2.0*Foam::sin(thetai)*Foam::sin(deltaTheta/2.0)*deltaPhi;
Ilambdaj_.setSize(nLambdaj_);
Di_ = vector
(
sinPhi * Foam::sin(0.5*deltaPhi) * (deltaTheta - Foam::cos(2.*thetai)
* Foam::sin(deltaTheta)) ,
cosPhi * Foam::sin(0.5*deltaPhi) * (deltaTheta - Foam::cos(2.*thetai)
* Foam::sin(deltaTheta)) ,
0.5 * deltaPhi * Foam::sin(2.*thetai) * Foam::sin(deltaTheta)
sinPhi
*Foam::sin(0.5*deltaPhi)
*(deltaTheta - Foam::cos(2.0*thetai)
*Foam::sin(deltaTheta)),
cosPhi
*Foam::sin(0.5*deltaPhi)
*(deltaTheta - Foam::cos(2.0*thetai)
*Foam::sin(deltaTheta)),
0.5*deltaPhi*Foam::sin(2.0*thetai)*Foam::sin(deltaTheta)
);
Di_ = (d);
forAll(Ilambdaj_, i)
{
IOobject header
(
"Ilambda_" + name(rayId) + "_"+ name(i),
"Ilambda_" + name(rayId) + "_" + name(i),
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ
);
// check if field exists and can be read
if (header.headerOk())
{
@ -188,16 +195,17 @@ void Foam::radiation::radiativeIntensityRay::init
rayId++;
}
Foam::scalar Foam::radiation::radiativeIntensityRay::correct
(
fvDOM* DomPtr
)
{
Qri_ = dimensionedScalar("zero",dimMass/pow3(dimTime), 0.0);
Qri_ = dimensionedScalar("zero", dimMass/pow3(dimTime), 0.0);
scalar maxResidual = 0.0;
for(label i = 0; i < Nlambdaj_; i++)
for(label i = 0; i < nLambdaj_; i++)
{
volScalarField k = DomPtr->aj(i);
@ -209,9 +217,10 @@ Foam::scalar Foam::radiation::radiativeIntensityRay::correct
fvScalarMatrix IiEq
(
fvm::div(Ji,Ilambdaj_[i],"div(Ji,Ii_h)")
fvm::div(Ji, Ilambdaj_[i], " div(Ji,Ii_h)")
+ fvm::Sp(k*omegai_, Ilambdaj_[i])
== k*omegai_*Ib + E
==
k*omegai_*Ib + E
);
IiEq.relax();
@ -228,23 +237,26 @@ Foam::scalar Foam::radiation::radiativeIntensityRay::correct
return maxResidual;
}
void Foam::radiation::radiativeIntensityRay::addIntensity()
{
I_ = dimensionedScalar("zero",dimMass/pow3(dimTime), 0.0);
I_ = dimensionedScalar("zero", dimMass/pow3(dimTime), 0.0);
for(label i = 0; i < Nlambdaj_; i++)
for (label i = 0; i < nLambdaj_; i++)
{
I_ += absEmmModel_.addRadInt(i, Ilambdaj_[i]);
I_ += absEmmModel_.addRadInt(i, Ilambdaj_[i]);
}
}
void Foam::radiation::radiativeIntensityRay::add
(
const scalarField & qr,
label patchI
const scalarField& qr,
const label patchI
) const
{
Qri_.boundaryField()[patchI] += qr;
Qri_.boundaryField()[patchI] += qr;
}
// ************************************************************************* //

View File

@ -45,54 +45,54 @@ namespace Foam
namespace radiation
{
/*---------------------------------------------------------------------------*\
Class radiativeIntensityRay Declaration
\*---------------------------------------------------------------------------*/
// Forward declaration of classes
class fvDOM;
/*---------------------------------------------------------------------------*\
Class radiativeIntensityRay Declaration
\*---------------------------------------------------------------------------*/
class radiativeIntensityRay
{
// Private data
//- absorptionEmissionModel
//- Absorption/emission model
const absorptionEmissionModel& absEmmModel_;
//- Temperature
//- Reference to the mesh
const fvMesh& mesh_;
// black Body
//- Black body
const blackBodyEmission& blackBody_;
//- Total Radiative Intensity on i direction / [W/m2]
//- Total radiative intensity in i direction / [W/m2]
volScalarField I_;
// - Total radiative heat flux on boundary on i direction
//- Total radiative heat flux on boundary in i direction
mutable volScalarField Qri_;
//- Direction i
vector Si_;
//- theta angle of direction i
//- Theta angle of direction i
scalar thetai_;
//- phi angle of direction i
//- Phi angle of direction i
scalar phii_;
//- solid angle
//- Solid angle of direction i
scalar omegai_;
//- Number of bands on i direction
label Nlambdaj_;
label nLambdaj_;
//- average vector inside the solid angle
//- Average vector inside the solid angle
vector Di_;
//- List of Pointers to Radiative Intensity wave-length
//- List of pointers to radiative intensity wave-length
PtrList<volScalarField> Ilambdaj_;
// Private member functions
//- Disallow default bitwise copy construct
@ -101,13 +101,14 @@ class radiativeIntensityRay
//- Disallow default bitwise assignment
void operator=(const radiativeIntensityRay&);
//- Integrate Intensity on this direction
// void IntegrateRadiativeIntensity(const label i);
public:
// Static data members
static label rayId;
// Constructors
//- Null constructor
@ -125,80 +126,88 @@ public:
// Destructor
~radiativeIntensityRay();
~radiativeIntensityRay();
// Member functions
// Edit
// Update radiative intensity on i direction
//- Update radiative intensity on i direction
scalar correct(fvDOM*);
// init the ray on i direction
//- Initialise the ray in i direction
void init
(
scalar phii, scalar thetai, scalar deltaPhi,scalar
deltaTheta, scalar lambda
const scalar phii,
const scalar thetai,
const scalar deltaPhi,
const scalar deltaTheta,
const scalar lambda
);
// add radiative heat flux on walls from the boundary patch
void add(const scalarField&, label) const;
//- Add radiative heat flux on walls from the boundary patch
void add(const scalarField&, const label) const;
// add Radiative intensities from all the bands
//- Add Radiative intensities from all the bands
void addIntensity();
// Access
//- Return Intensity on i direction
//- Return intensity in i direction
inline const volScalarField& I() const
{
return I_;
}
//- Return heat flux on boundary on i direction
//- Return heat flux on boundary in i direction
inline const volScalarField& Qri() const
{
return Qri_;
}
//- Return direction i
inline const vector Si() const
{
return Si_;
}
//- Return the average vector inside the solid angle
inline const vector Di() const
{
return Di_;
}
scalar lambdaj() const
//- Return the number of bands on i direction
scalar nLambdaj() const
{
return Nlambdaj_;
return nlambdaj_;
}
//- Return the phi angle of direction i
scalar phii() const
{
return phii_;
}
//- Return the theta angle of direction i
scalar thetai() const
{
return thetai_;
}
//- Return the solid angle of direction i
scalar omegai() const
{
return omegai_;
}
const volScalarField& Ilambdaj(label i) const
//- Return the list of pointers to radiative intensity wave-length
const volScalarField& Ilambdaj(const label i) const
{
return Ilambdaj_[i];
}
};

View File

@ -77,8 +77,7 @@ public:
// Destructor
~noRadiation();
virtual ~noRadiation();
// Member functions

View File

@ -28,7 +28,6 @@ Namespace
Description
Namespace for radiation modelling
Class
Foam::radiation::radiationModel
@ -58,6 +57,7 @@ namespace Foam
namespace radiation
{
// Forward declaration of classes
class absorptionEmissionModel;
class scatterModel;
@ -152,8 +152,7 @@ public:
// Destructor
virtual ~radiationModel();
virtual ~radiationModel();
// Member Functions

View File

@ -216,12 +216,13 @@ Foam::radiation::absorptionEmissionModel::EDisp(label i) const
);
}
Foam::label
Foam::radiation::absorptionEmissionModel::nBands() const
Foam::label Foam::radiation::absorptionEmissionModel::nBands() const
{
return pTraits<label>::one;
}
const Foam::Vector2D<Foam::scalar>&
Foam::radiation::absorptionEmissionModel::bands(label n) const
{
@ -229,11 +230,13 @@ Foam::radiation::absorptionEmissionModel::bands(label n) const
return Vector2D<scalar>::one;
}
bool Foam::radiation::absorptionEmissionModel::isGrey(void) const
bool Foam::radiation::absorptionEmissionModel::isGrey() const
{
return false;
}
Foam::tmp<Foam::volScalarField>
Foam::radiation::absorptionEmissionModel::addRadInt
(
@ -244,13 +247,16 @@ Foam::radiation::absorptionEmissionModel::addRadInt
return Ilambdaj;
}
void Foam::radiation::absorptionEmissionModel::correct
(
volScalarField& a,
PtrList<volScalarField>& aj
) const
{
a.internalField() = this->a();
aj[0].internalField() = a.internalField();
a.internalField() = this->a();
aj[0].internalField() = a.internalField();
}
// ************************************************************************* //

View File

@ -105,80 +105,85 @@ public:
//- Destructor
virtual ~absorptionEmissionModel();
virtual ~absorptionEmissionModel();
// Member Functions
// Access
//- Reference to the mesh
inline const fvMesh& mesh() const
{
return mesh_;
}
//- Reference to the dictionary
inline const dictionary& dict() const
{
return dict_;
}
// Absorption coefficient
//- Absorption coefficient (net)
virtual tmp<volScalarField> a(const label i = 0) const;
virtual tmp<volScalarField> a(const label bandI = 0) const;
//- Absorption coefficient for continuous phase
virtual tmp<volScalarField> aCont(const label i = 0) const;
virtual tmp<volScalarField> aCont(const label bandI = 0) const;
//- Absorption coefficient for dispersed phase
virtual tmp<volScalarField> aDisp(const label i = 0) const;
virtual tmp<volScalarField> aDisp(const label bandI = 0) const;
// Emission coefficient
//- Emission coefficient (net)
virtual tmp<volScalarField> e(const label i = 0) const;
virtual tmp<volScalarField> e(const label bandI = 0) const;
//- Return emission coefficient for continuous phase
virtual tmp<volScalarField> eCont(const label i = 0) const;
virtual tmp<volScalarField> eCont(const label bandI = 0) const;
//- Return emission coefficient for dispersed phase
virtual tmp<volScalarField> eDisp(const label i = 0) const;
virtual tmp<volScalarField> eDisp(const label bandI = 0) const;
// Emission contribution
//- Emission contribution (net)
virtual tmp<volScalarField> E(const label i = 0) const;
virtual tmp<volScalarField> E(const label bandI = 0) const;
//- Emission contribution for continuous phase
virtual tmp<volScalarField> ECont(const label i = 0) const;
virtual tmp<volScalarField> ECont(const label bandI = 0) const;
//- Emission contribution for dispersed phase
virtual tmp<volScalarField> EDisp(const label i = 0) const;
inline const fvMesh& mesh() const
{
return mesh_;
}
// Default for grey absorptionEmission model return 1
virtual label nBands() const;
// Default for grey absorptionEmission model return Vector2D::one
virtual const Vector2D<scalar>& bands
(
label n
) const;
// Is the absorptionEmission grey
virtual bool isGrey(void) const;
virtual tmp<volScalarField> EDisp(const label bandI = 0) const;
// Add radiative intensity fir ray i
virtual tmp<volScalarField> addRadInt
(
const label i,
const volScalarField& Ilambdaj
) const;
//- Const access to the number of bands - defaults to 1 for grey
// absorption/emission
virtual label nBands() const;
// Correct absorption coefficients
virtual void correct
(
volScalarField& a_,
PtrList<volScalarField>& aj_
) const ;
//- Const access to the bands - defaults to Vector2D::one for grey
// absorption/emission
virtual const Vector2D<scalar>& bands(label n) const;
//- Flag for whether the absorption/emission is for a grey gas
virtual bool isGrey(void) const;
//- Add radiative intensity fir ray i
virtual tmp<volScalarField> addRadInt
(
const label i,
const volScalarField& Ilambdaj
) const;
//- Correct absorption coefficients
virtual void correct
(
volScalarField& a,
PtrList<volScalarField>& aj
) const ;
};

View File

@ -53,7 +53,6 @@ class binaryAbsorptionEmission
:
public absorptionEmissionModel
{
// Private data
//- Coefficients dictionary
@ -83,8 +82,7 @@ public:
// Destructor
~binaryAbsorptionEmission();
virtual ~binaryAbsorptionEmission();
// Member Operators

View File

@ -70,7 +70,7 @@ Foam::radiation::constantAbsorptionEmission::~constantAbsorptionEmission()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::tmp<Foam::volScalarField>
Foam::radiation::constantAbsorptionEmission::aCont(label i) const
Foam::radiation::constantAbsorptionEmission::aCont(const label bandI) const
{
tmp<volScalarField> ta
(
@ -95,7 +95,7 @@ Foam::radiation::constantAbsorptionEmission::aCont(label i) const
Foam::tmp<Foam::volScalarField>
Foam::radiation::constantAbsorptionEmission::eCont(label i) const
Foam::radiation::constantAbsorptionEmission::eCont(const label bandI) const
{
tmp<volScalarField> te
(
@ -120,7 +120,7 @@ Foam::radiation::constantAbsorptionEmission::eCont(label i) const
Foam::tmp<Foam::volScalarField>
Foam::radiation::constantAbsorptionEmission::ECont(label i) const
Foam::radiation::constantAbsorptionEmission::ECont(const label bandI) const
{
tmp<volScalarField> tE
(

View File

@ -54,7 +54,6 @@ class constantAbsorptionEmission
:
public absorptionEmissionModel
{
// Private data
//- Absorption model dictionary
@ -87,8 +86,7 @@ public:
// Destructor
~constantAbsorptionEmission();
virtual ~constantAbsorptionEmission();
// Member Operators
@ -98,23 +96,24 @@ public:
// Absorption coefficient
//- Absorption coefficient for continuous phase
tmp<volScalarField> aCont(const label i = 0) const;
tmp<volScalarField> aCont(const label bandI = 0) const;
// Emission coefficient
//- Emission coefficient for continuous phase
tmp<volScalarField> eCont(const label i = 0) const;
tmp<volScalarField> eCont(const label bandI = 0) const;
// Emission contribution
//- Emission contribution for continuous phase
tmp<volScalarField> ECont(const label i = 0) const;
tmp<volScalarField> ECont(const label bandI = 0) const;
// Member Functions
inline bool isGrey(void) const
inline bool isGrey() const
{
return true;
}

View File

@ -57,10 +57,10 @@ Foam::radiation::greyMeanAbsorptionEmission::greyMeanAbsorptionEmission
coeffsDict_((dict.subDict(typeName + "Coeffs"))),
speciesNames_(0),
specieIndex_(0),
LookUpTable_
lookUpTable_
(
fileName(coeffsDict_.lookup("LookUpTableFileName")),
"constant",
fileName(coeffsDict_.lookup("lookUpTableFileName")),
mesh.time().constant(),
mesh
),
thermo_(mesh.db().lookupObject<basicThermo>("thermophysicalProperties")),
@ -69,7 +69,7 @@ Foam::radiation::greyMeanAbsorptionEmission::greyMeanAbsorptionEmission
{
Yj_.setSize(nSpecies_);
label nFunc = 0;
const dictionary& functionDicts = dict.subDict(typeName+"Coeffs");
const dictionary& functionDicts = dict.subDict(typeName + "Coeffs");
forAllConstIter(dictionary, functionDicts, iter)
{
@ -85,36 +85,34 @@ Foam::radiation::greyMeanAbsorptionEmission::greyMeanAbsorptionEmission
nFunc++;
}
// Check that all the species on the dictionary are present in the LookupTable
// and save the corresponding indexes of the LookupTable
// Check that all the species on the dictionary are present in the
// look-up table and save the corresponding indices of the look-up table
label j = 0;
forAllConstIter(HashTable<label>, speciesNames_, iter)
{
if(mesh.db().foundObject<volScalarField>("ft"))
if (mesh.db().foundObject<volScalarField>("ft"))
{
if(LookUpTable_.found(iter.key()))
if (lookUpTable_.found(iter.key()))
{
label index = LookUpTable_.findFieldIndex(iter.key());
label index = lookUpTable_.findFieldIndex(iter.key());
Info << "specie: " << iter.key() << " found on LookUpTable"
<< " with index: " << index << endl;
Info<< "specie: " << iter.key() << " found on look-up table "
<< " with index: " << index << endl;
specieIndex_[iter()] = index;
}
else if(mesh.db().foundObject<volScalarField>(iter.key()))
else if (mesh.db().foundObject<volScalarField>(iter.key()))
{
volScalarField& Y = const_cast<volScalarField&>
(mesh.db().lookupObject<volScalarField>(iter.key()));
Yj_.set
(
j,
&Y
);
specieIndex_[iter()] = 0.;
volScalarField& Y =
const_cast<volScalarField&>
(
mesh.db().lookupObject<volScalarField>(iter.key())
);
Yj_.set(j, &Y);
specieIndex_[iter()] = 0.0;
j++;
Info << "specie : " << iter.key() << " is being solved"
Info << "specie: " << iter.key() << " is being solved "
<< endl;
}
else
@ -123,10 +121,10 @@ Foam::radiation::greyMeanAbsorptionEmission::greyMeanAbsorptionEmission
(
"Foam::radiation::greyMeanAbsorptionEmission(const"
"dictionary& dict, const fvMesh& mesh)"
) << "specie : " << iter.key()
<< " is neither in Look Up Table : "
<< LookUpTable_.tableName()
<< " nor is being solved" <<nl
) << "specie: " << iter.key()
<< " is neither in look-up table: "
<< lookUpTable_.tableName()
<< " nor is being solved" << nl
<< exit(FatalError);
}
}
@ -136,7 +134,7 @@ Foam::radiation::greyMeanAbsorptionEmission::greyMeanAbsorptionEmission
(
"Foam::radiation::greyMeanAbsorptionEmission(const"
"dictionary& dict, const fvMesh& mesh)"
) << "specie ft is not present " <<nl
) << "specie ft is not present " << nl
<< exit(FatalError);
}
@ -152,12 +150,12 @@ Foam::radiation::greyMeanAbsorptionEmission::~greyMeanAbsorptionEmission()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::tmp<Foam::volScalarField>
Foam::radiation::greyMeanAbsorptionEmission::aCont(label iband) const
Foam::radiation::greyMeanAbsorptionEmission::aCont(const label bandI) const
{
const volScalarField& T = thermo_.T();
const volScalarField& p = thermo_.p();
const volScalarField& ft =
this->mesh().db().lookupObject<volScalarField>("ft");
this->mesh().db().lookupObject<volScalarField>("ft");
label nSpecies = speciesNames_.size();
@ -182,33 +180,38 @@ Foam::radiation::greyMeanAbsorptionEmission::aCont(label iband) const
forAll(a, i)
{
//
const List<scalar>& species = LookUpTable_.LookUp(ft[i]);
const List<scalar>& species = lookUpTable_.lookUp(ft[i]);
for(label n=0; n<nSpecies; n++)
for (label n=0; n<nSpecies; n++)
{
label l = 0;
scalar Yipi = 0;
if(specieIndex_[n] != 0)
if (specieIndex_[n] != 0)
{
//moles x pressure [atm]
Yipi = species[specieIndex_[n]]*p[i]*9.869231e-6;
}
else
{
Yipi = Yj_[l][i]; // mass fraction
// mass fraction
Yipi = Yj_[l][i];
l++;
}
const absorptionCoeffs::coeffArray& b = coeffs_[n].coeffs(T[i]);
scalar Ti = T[i];
if (coeffs_[n].invTemp()) //negative Temp exponents
// negative temperature exponents
if (coeffs_[n].invTemp())
{
Ti = 1./T[i];
}
a[i]+= Yipi*
(((((b[5]*Ti + b[4])*Ti + b[3])*Ti + b[2])*Ti + b[1])*Ti + b[0]);
a[i]+=
Yipi
*(
((((b[5]*Ti + b[4])*Ti + b[3])*Ti + b[2])*Ti + b[1])*Ti
+ b[0]
);
}
}
return ta;
@ -216,7 +219,7 @@ Foam::radiation::greyMeanAbsorptionEmission::aCont(label iband) const
Foam::tmp<Foam::volScalarField>
Foam::radiation::greyMeanAbsorptionEmission::eCont(label iband) const
Foam::radiation::greyMeanAbsorptionEmission::eCont(const label bandI) const
{
tmp<volScalarField> e
(
@ -240,7 +243,7 @@ Foam::radiation::greyMeanAbsorptionEmission::eCont(label iband) const
Foam::tmp<Foam::volScalarField>
Foam::radiation::greyMeanAbsorptionEmission::ECont(label iband) const
Foam::radiation::greyMeanAbsorptionEmission::ECont(const label bandI) const
{
tmp<volScalarField> E
(
@ -262,8 +265,8 @@ Foam::radiation::greyMeanAbsorptionEmission::ECont(label iband) const
if (mesh().db().foundObject<volScalarField>("hrr"))
{
const volScalarField& hrr =
mesh().db().lookupObject<volScalarField>("hrr");
E().internalField() = EhrrCoeff_ * hrr.internalField();
mesh().db().lookupObject<volScalarField>("hrr");
E().internalField() = EhrrCoeff_*hrr.internalField();
}
return E;

View File

@ -27,37 +27,37 @@ Class
Description
greyMeanAbsorptionEmission radiation absorption and emission coefficients
for continuous phase
for continuous phase
The coefficients for the species in the LookUpTable have to be specified
for use in moles x P [atm].i.e. (k[i] = species[i]*p*9.869231e-6).
The coefficients for the species in the Look up table have to be specified
for use in moles x P [atm], i.e. (k[i] = species[i]*p*9.869231e-6).
The coefficients for CO and soot or any other added are multiplied by the
respective mass fraction being solved.
respective mass fraction being solved
All the species in the dictionary need either to be in the Look up Table or
All the species in the dictionary need either to be in the look-up table or
being solved. Conversely, all the species solved do not need to be included
in the calculation of the absorption coefficient.
in the calculation of the absorption coefficient
The names of the species in the absorption dictionary must match exactly the
name in the Look Up table or the name of the field being solved.
name in the look-up table or the name of the field being solved
The look Up table ("SpeciesTable") file should be in constant
The look-up table ("speciesTable") file should be in constant
i.e. dictionary
LookUpTableFileName "SpeciesTable";
LookUpTableFileName "speciesTable";
EhrrCoeff 0.0;
CO2
CO2
{
Tcommon 300.; //Common Temp
invTemp true; //Is the polynomio using inverse temperature.
Tlow 300.; //Low Temp
Thigh 2500.; //Hight Temp
Tcommon 300.; // Common Temp
invTemp true; // Is the polynomial using inverse temperature?
Tlow 300.; // Low Temp
Thigh 2500.; // High Temp
loTcoeffs //coefss for T < Tcommon
loTcoeffs // coeffs for T < Tcommon
(
0 // a0 +
0 // a1*T +
@ -66,7 +66,7 @@ Description
0 // a4*T^(+/-)4 +
0 // a5*T^(+/-)5 +
);
hiTcoeffs //coefss for T > Tcommon
hiTcoeffs // coeffs for T > Tcommon
(
18.741
-121.31e3
@ -92,8 +92,6 @@ SourceFiles
#include "absorptionCoeffs.H"
#include "basicThermo.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
@ -109,9 +107,9 @@ class greyMeanAbsorptionEmission
:
public absorptionEmissionModel
{
public:
// Public data
// - Maximum number of species considered for absorptivity
static const int nSpecies_ = 5;
@ -119,21 +117,24 @@ public:
// Absorption Coefficients
absorptionCoeffs coeffs_[nSpecies_];
private:
// Private data
//- Absorption model dictionary
dictionary coeffsDict_;
// Hash table with species names
//- Hash table of species names
HashTable<label> speciesNames_;
// Indexes of species in the LookUpTable
FixedList<label,nSpecies_> specieIndex_;
// Indices of species in the look-up table
FixedList<label, nSpecies_> specieIndex_;
// Look-up table of species related to ft
mutable interpolationLookUpTable<scalar> lookUpTable_;
// Look Up table of species related to ft
mutable interpolationLookUpTable<scalar> LookUpTable_;
// Thermo
// Thermo package
const basicThermo& thermo_;
//- Emission constant coefficient
@ -145,7 +146,6 @@ private:
public:
//- Runtime type information
TypeName("greyMeanAbsorptionEmission");
@ -161,8 +161,7 @@ public:
// Destructor
~greyMeanAbsorptionEmission();
virtual ~greyMeanAbsorptionEmission();
// Member Operators
@ -172,23 +171,24 @@ public:
// Absorption coefficient
//- Absorption coefficient for continuous phase
tmp<volScalarField> aCont(const label i = 0) const;
tmp<volScalarField> aCont(const label bandI = 0) const;
// Emission coefficient
//- Emission coefficient for continuous phase
tmp<volScalarField> eCont(const label i = 0) const;
tmp<volScalarField> eCont(const label bandI = 0) const;
// Emission contribution
//- Emission contribution for continuous phase
tmp<volScalarField> ECont(const label i = 0) const;
tmp<volScalarField> ECont(const label bandI = 0) const;
// Member Functions
inline bool isGrey(void) const
inline bool isGrey() const
{
return true;
}

View File

@ -71,8 +71,7 @@ public:
// Destructor
~noAbsorptionEmission();
virtual ~noAbsorptionEmission();
};

View File

@ -57,10 +57,10 @@ Foam::radiation::wideBandAbsorptionEmission::wideBandAbsorptionEmission
coeffsDict_((dict.subDict(typeName + "Coeffs"))),
speciesNames_(0),
specieIndex_(0),
LookUpTable_
lookUpTable_
(
fileName(coeffsDict_.lookup("LookUpTableFileName")),
"constant",
fileName(coeffsDict_.lookup("lookUpTableFileName")),
mesh.time().constant(),
mesh
),
thermo_(mesh.db().lookupObject<basicThermo>("thermophysicalProperties")),
@ -84,7 +84,7 @@ Foam::radiation::wideBandAbsorptionEmission::wideBandAbsorptionEmission
totalWaveLength_ += (iBands_[nBand][1] - iBands_[nBand][0]);
label nSpec = 0;
const dictionary& SpecDicts = dict.subDict("species");
const dictionary& specDicts = dict.subDict("species");
forAllConstIter(dictionary, SpecDicts, iter)
{
const word& key = iter().keyword();
@ -101,42 +101,37 @@ Foam::radiation::wideBandAbsorptionEmission::wideBandAbsorptionEmission
"Foam::radiation::wideBandAbsorptionEmission(const"
"dictionary& dict, const fvMesh& mesh)"
) << "specie : " << key << "is not in all the bands"
<< nl
<< exit(FatalError);
<< nl << exit(FatalError);
}
}
coeffs_[nSpec][nBand].init(SpecDicts.subDict(key));
coeffs_[nSpec][nBand].init(specDicts.subDict(key));
nSpec++;
}
nBand++;
}
nBands_ = nBand;
/*
Check that all the species on the dictionary are present in the
LookupTable and save the corresponding indexes of the LookupTable
*/
// Check that all the species on the dictionary are present in the
// look-up table and save the corresponding indexes of the look-up table
label j = 0;
forAllConstIter(HashTable<label>, speciesNames_, iter)
{
if(LookUpTable_.found(iter.key()))
if (lookUpTable_.found(iter.key()))
{
label index = LookUpTable_.findFieldIndex(iter.key());
Info << "specie: " << iter.key() << " found in LookUpTable"
<< " with index: " << index << endl;
label index = lookUpTable_.findFieldIndex(iter.key());
Info<< "specie: " << iter.key() << " found in look-up table "
<< " with index: " << index << endl;
specieIndex_[iter()] = index;
}
else if
(mesh.db().foundObject<volScalarField>(iter.key()))
else if (mesh.db().foundObject<volScalarField>(iter.key()))
{
volScalarField& Y = const_cast<volScalarField&>
(mesh.db().lookupObject<volScalarField>(iter.key()));
(mesh.db().lookupObject<volScalarField>(iter.key()));
Yj_.set(j, &Y);
specieIndex_[iter()] = 0.;
specieIndex_[iter()] = 0.0;
j++;
Info << "specie : " << iter.key() << " is being solved" << endl;
}
@ -146,9 +141,9 @@ LookupTable and save the corresponding indexes of the LookupTable
(
"radiation::wideBandAbsorptionEmission(const"
"dictionary& dict, const fvMesh& mesh)"
) << "specie : " << iter.key()
<< " is neither in Look Up Table : "
<< LookUpTable_.tableName() <<" nor is being slved"
) << "specie : " << iter.key()
<< " is neither in look-up table : "
<< lookUpTable_.tableName() << " nor is being solved"
<< exit(FatalError);
}
}
@ -161,15 +156,16 @@ LookupTable and save the corresponding indexes of the LookupTable
Foam::radiation::wideBandAbsorptionEmission::~wideBandAbsorptionEmission()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::tmp<Foam::volScalarField>
Foam::radiation::wideBandAbsorptionEmission::aCont(label iband) const
Foam::radiation::wideBandAbsorptionEmission::aCont(const label bandI) const
{
const volScalarField& T = thermo_.T();
const volScalarField& p = thermo_.p();
const volScalarField& ft =
this->mesh().db().lookupObject<volScalarField>("ft");
this->mesh().db().lookupObject<volScalarField>("ft");
label nSpecies = speciesNames_.size();
@ -194,35 +190,40 @@ Foam::radiation::wideBandAbsorptionEmission::aCont(label iband) const
forAll(a, i)
{
const List<scalar>& species = lookUpTable_.lookUp(ft[i]);
const List<scalar>& species = LookUpTable_.LookUp(ft[i]);
for(label n=0; n<nSpecies; n++)
for (label n=0; n<nSpecies; n++)
{
label l = 0;
scalar Yipi = 0;
if(specieIndex_[n] != 0) //moles x pressure [atm]
if (specieIndex_[n] != 0)
{
// moles x pressure [atm]
Yipi = species[specieIndex_[n]]*p[i]*9.869231e-6;
}
else
{
Yipi = Yj_[l][i]; // mass fraction from species being solved
// mass fraction from species being solved
Yipi = Yj_[l][i];
l++;
}
scalar Ti = T[i];
const absorptionCoeffs::coeffArray& b =
coeffs_[n][iband].coeffs(T[i]);
coeffs_[n][bandI].coeffs(T[i]);
if (coeffs_[n][iband].invTemp())
if (coeffs_[n][bandI].invTemp())
{
Ti = 1./T[i];
}
a[i]+=Yipi*
(((((b[5]*Ti + b[4])*Ti + b[3])*Ti + b[2])*Ti + b[1])*Ti + b[0]);
a[i]+=
Yipi
*(
((((b[5]*Ti + b[4])*Ti + b[3])*Ti + b[2])*Ti + b[1])*Ti
+ b[0]
);
}
}
@ -231,7 +232,7 @@ Foam::radiation::wideBandAbsorptionEmission::aCont(label iband) const
Foam::tmp<Foam::volScalarField>
Foam::radiation::wideBandAbsorptionEmission::eCont(label iband) const
Foam::radiation::wideBandAbsorptionEmission::eCont(const label bandI) const
{
tmp<volScalarField> e
(
@ -255,7 +256,7 @@ Foam::radiation::wideBandAbsorptionEmission::eCont(label iband) const
Foam::tmp<Foam::volScalarField>
Foam::radiation::wideBandAbsorptionEmission::ECont(label iband) const
Foam::radiation::wideBandAbsorptionEmission::ECont(const label bandI) const
{
tmp<volScalarField> E
(
@ -277,12 +278,14 @@ Foam::radiation::wideBandAbsorptionEmission::ECont(label iband) const
if (mesh().db().foundObject<volScalarField>("hrr"))
{
const volScalarField& hrr =
mesh().db().lookupObject<volScalarField>("hrr");
E().internalField() = iEhrrCoeffs_[iband] * hrr.internalField() *
(iBands_[iband][1] - iBands_[iband][0])/totalWaveLength_;
mesh().db().lookupObject<volScalarField>("hrr");
E().internalField() =
iEhrrCoeffs_[bandI]
*hrr.internalField()
*(iBands_[bandI][1] - iBands_[bandI][0])
/totalWaveLength_;
}
return E;
}
@ -293,7 +296,7 @@ Foam::radiation::wideBandAbsorptionEmission::addRadInt
const volScalarField& Ilambdaj
) const
{
return Ilambdaj*(iBands_[i][1] - iBands_[i][0])/totalWaveLength_;
return Ilambdaj*(iBands_[i][1] - iBands_[i][0])/totalWaveLength_;
}
@ -303,16 +306,18 @@ void Foam::radiation::wideBandAbsorptionEmission::correct
PtrList<volScalarField>& aj
) const
{
a = dimensionedScalar("zero",dimless/dimLength, 0.0);
a = dimensionedScalar("zero", dimless/dimLength, 0.0);
for(label j = 0; j < nBands_; j++)
{
Info << "Calculating... absorption in band : " << j <<endl;
aj[j].internalField() = this->a(j);
Info << "Calculated absorption in band : " << j <<endl;
a.internalField() += aj[j].internalField() *
(iBands_[j][1] - iBands_[j][0])/totalWaveLength_;
}
for (label j = 0; j < nBands_; j++)
{
Info << "Calculating absorption in band: " << j <<endl;
aj[j].internalField() = this->a(j);
Info << "Calculated absorption in band: " << j <<endl;
a.internalField() +=
aj[j].internalField()
*(iBands_[j][1] - iBands_[j][0])
/totalWaveLength_;
}
}
// ************************************************************************* //

View File

@ -99,13 +99,10 @@ Description
}
SourceFiles
wideBandAbsorptionEmission.C
\*---------------------------------------------------------------------------*/
\*---------------------------------------------------------------------------*/
#ifndef wideBandAbsorptionEmission_H
#define wideBandAbsorptionEmission_H
@ -116,8 +113,6 @@ SourceFiles
#include "absorptionCoeffs.H"
#include "basicThermo.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
@ -133,20 +128,24 @@ class wideBandAbsorptionEmission
:
public absorptionEmissionModel
{
public:
// Public data
// - Maximum number of species considered for absorptivity
//- Maximum number of species considered for absorptivity
static const int nSpecies_ = 5;
// - Maximum number of bands
//- Maximum number of bands
static const int maxBands_ = 10;
// Absorption Coefficients
FixedList< FixedList<absorptionCoeffs, nSpecies_> , maxBands_> coeffs_;
//- Absorption coefficients
FixedList<FixedList<absorptionCoeffs, nSpecies_>, maxBands_> coeffs_;
private:
// Private data
//- Absorption model dictionary
dictionary coeffsDict_;
@ -162,10 +161,10 @@ private:
//- Proportion of the heat released rate emitted
FixedList<scalar, maxBands_ > iEhrrCoeffs_;
//- Look Up table of species related to ft
mutable interpolationLookUpTable<scalar> LookUpTable_;
//- Look-up table of species related to ft
mutable interpolationLookUpTable<scalar> lookUpTable_;
//- Thermo
//- Thermo package
const basicThermo& thermo_;
//- Bands
@ -174,9 +173,10 @@ private:
//- Pointer list of species being solved involved in the absorption
UPtrList<volScalarField> Yj_;
// Total wave lenght cover by the bands
// Total wave length covered by the bands
scalar totalWaveLength_;
public:
@ -195,32 +195,30 @@ public:
// Destructor
~wideBandAbsorptionEmission();
virtual ~wideBandAbsorptionEmission();
// Member Operators
// Member Functions
// Access
// Absorption coefficient
//- Absorption coefficient for continuous phase
tmp<volScalarField> aCont(const label i = 0) const;
tmp<volScalarField> aCont(const label bandI = 0) const;
// Emission coefficient
//- Emission coefficient for continuous phase
tmp<volScalarField> eCont(const label i = 0) const;
tmp<volScalarField> eCont(const label bandI = 0) const;
// Emission contribution
//- Emission contribution for continuous phase
tmp<volScalarField> ECont(const label i = 0) const;
tmp<volScalarField> ECont(const label bandI = 0) const;
// Member Functions
inline bool isGrey(void) const
{
@ -228,7 +226,7 @@ public:
}
// Number of bands
label nBands() const
inline label nBands() const
{
return nBands_;
}
@ -240,7 +238,7 @@ public:
}
// Add contribution of Ilambdaj to the total Radiative Intensity on
//direction i
// direction i
tmp<volScalarField> addRadInt
(
const label i,
@ -248,7 +246,6 @@ public:
) const;
void correct(volScalarField& a_, PtrList<volScalarField>& aj) const;
};