FEATURE: Updates to fvDOM overhaul and constructor reorganisation. Author: Henrik Rusche. Merge: Dominik Christ.

This commit is contained in:
Dominik Christ 2015-04-27 13:37:18 +01:00
commit 450a48a19e
10 changed files with 506 additions and 183 deletions

View file

@ -39,13 +39,7 @@ namespace Foam
namespace radiation namespace radiation
{ {
defineTypeNameAndDebug(P1, 0); defineTypeNameAndDebug(P1, 0);
addToRadiationRunTimeSelectionTables(P1);
addToRunTimeSelectionTable
(
radiationModel,
P1,
dictionary
);
} }
} }
@ -122,6 +116,76 @@ Foam::radiation::P1::P1(const volScalarField& T)
{} {}
Foam::radiation::P1::P1(const dictionary& dict, const volScalarField& T)
:
radiationModel(typeName, dict, T),
G_
(
IOobject
(
"G",
mesh_.time().timeName(),
T.db(),
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh_
),
Qr_
(
IOobject
(
"Qr",
mesh_.time().timeName(),
T.db(),
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh_,
dimensionedScalar("Qr", dimMass/pow3(dimTime), 0.0)
),
a_
(
IOobject
(
"a",
mesh_.time().timeName(),
T.db(),
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh_,
dimensionedScalar("a", dimless/dimLength, 0.0)
),
e_
(
IOobject
(
"e",
mesh_.time().timeName(),
T.db(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
dimensionedScalar("a", dimless/dimLength, 0.0)
),
E_
(
IOobject
(
"E",
mesh_.time().timeName(),
T.db(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
dimensionedScalar("E", dimMass/dimLength/pow3(dimTime), 0.0)
)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::radiation::P1::~P1() Foam::radiation::P1::~P1()
@ -150,7 +214,9 @@ void Foam::radiation::P1::calculate()
a_ = absorptionEmission_->a(); a_ = absorptionEmission_->a();
e_ = absorptionEmission_->e(); e_ = absorptionEmission_->e();
E_ = absorptionEmission_->E(); E_ = absorptionEmission_->E();
const volScalarField sigmaEff = scatter_->sigmaEff(); const volScalarField sigmaEff(scatter_->sigmaEff());
const dimensionedScalar a0 ("a0", a_.dimensions(), ROOTVSMALL);
// Construct diffusion // Construct diffusion
const volScalarField gamma const volScalarField gamma
@ -163,7 +229,7 @@ void Foam::radiation::P1::calculate()
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE IOobject::NO_WRITE
), ),
1.0/(3.0*a_ + sigmaEff) 1.0/(3.0*a_ + sigmaEff + a0)
); );
// Solve G transport equation // Solve G transport equation
@ -210,10 +276,8 @@ Foam::radiation::P1::Ru() const
{ {
const DimensionedField<scalar, volMesh>& G = const DimensionedField<scalar, volMesh>& G =
G_.dimensionedInternalField(); G_.dimensionedInternalField();
const DimensionedField<scalar, volMesh> E = const DimensionedField<scalar, volMesh> E =
absorptionEmission_->ECont()().dimensionedInternalField(); absorptionEmission_->ECont()().dimensionedInternalField();
const DimensionedField<scalar, volMesh> a = const DimensionedField<scalar, volMesh> a =
absorptionEmission_->aCont()().dimensionedInternalField(); absorptionEmission_->aCont()().dimensionedInternalField();

View file

@ -96,6 +96,8 @@ public:
//- Construct from components //- Construct from components
P1(const volScalarField& T); P1(const volScalarField& T);
//- Construct from components
P1(const dictionary& dict, const volScalarField& T);
// Destructor // Destructor
virtual ~P1(); virtual ~P1();

View file

@ -38,62 +38,14 @@ namespace Foam
namespace radiation namespace radiation
{ {
defineTypeNameAndDebug(fvDOM, 0); defineTypeNameAndDebug(fvDOM, 0);
addToRadiationRunTimeSelectionTables(fvDOM);
addToRunTimeSelectionTable
(
radiationModel,
fvDOM,
dictionary
);
} }
} }
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::radiation::fvDOM::fvDOM(const volScalarField& T) void Foam::radiation::fvDOM::initialise()
:
radiationModel(typeName, T),
G_
(
IOobject
(
"G",
mesh().time().timeName(),
T.db(),
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh(),
dimensionedScalar("G", dimMass/pow3(dimTime), 0.0)
),
a_
(
IOobject
(
"a",
mesh().time().timeName(),
T.db(),
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh(),
dimensionedScalar("a", dimless/dimLength, 0.0)
),
nTheta_(readLabel(coeffs_.lookup("nTheta"))),
nPhi_(readLabel(coeffs_.lookup("nPhi"))),
nRay_(0),
nLambda_(absorptionEmission_->nBands()),
aLambda_(nLambda_),
blackBody_(nLambda_, T),
IRay_(0),
Qem_(nLambda_),
Qin_(nLambda_),
convergence_(coeffs_.lookupOrDefault<scalar>("convergence", 0.0)),
maxIter_(coeffs_.lookupOrDefault<label>("maxIter", 50)),
fvRayDiv_(nLambda_),
cacheDiv_(coeffs_.lookupOrDefault<bool>("cacheDiv", false)),
omegaMax_(0)
{ {
if (mesh().nSolutionD() == 3) //3D if (mesh().nSolutionD() == 3) //3D
{ {
@ -208,7 +160,7 @@ Foam::radiation::fvDOM::fvDOM(const volScalarField& T)
( (
"aLambda_" + Foam::name(lambdaI) , "aLambda_" + Foam::name(lambdaI) ,
mesh().time().timeName(), mesh().time().timeName(),
T.db(), T_.db(),
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE IOobject::NO_WRITE
), ),
@ -260,8 +212,7 @@ Foam::radiation::fvDOM::fvDOM(const volScalarField& T)
forAll(IRay_, rayId) forAll(IRay_, rayId)
{ {
const surfaceScalarField Ji(IRay_[rayId].dAve() & mesh().Sf()); const surfaceScalarField Ji(IRay_[rayId].dAve() & mesh().Sf());
volScalarField& iRayLambdaI = volScalarField& iRayLambdaI = IRay_[rayId].ILambda(lambdaI);
IRay_[rayId].ILambda(lambdaI);
fvRayDiv_[lambdaI].set fvRayDiv_[lambdaI].set
( (
@ -288,6 +239,194 @@ Foam::radiation::fvDOM::fvDOM(const volScalarField& T)
Info<< endl; Info<< endl;
} }
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::radiation::fvDOM::fvDOM(const volScalarField& T)
:
radiationModel(typeName, T),
G_
(
IOobject
(
"G",
mesh().time().timeName(),
T.db(),
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh(),
dimensionedScalar("G", dimMass/pow3(dimTime), 0.0)
),
Qr_
(
IOobject
(
"Qr",
mesh_.time().timeName(),
T.db(),
IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE
),
mesh_,
dimensionedScalar("Qr", dimMass/pow3(dimTime), 0.0)
),
a_
(
IOobject
(
"a",
mesh().time().timeName(),
T.db(),
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh(),
dimensionedScalar("a", dimless/dimLength, 0.0)
),
nTheta_(readLabel(coeffs_.lookup("nTheta"))),
nPhi_(readLabel(coeffs_.lookup("nPhi"))),
nRay_(0),
nLambda_(absorptionEmission_->nBands()),
aLambda_(nLambda_),
blackBody_(nLambda_, T),
IRay_(0),
Qem_(nLambda_),
Qin_(nLambda_),
convergence_(coeffs_.lookupOrDefault<scalar>("convergence", 0.0)),
maxIter_(coeffs_.lookupOrDefault<label>("maxIter", 50)),
fvRayDiv_(nLambda_),
cacheDiv_(coeffs_.lookupOrDefault<bool>("cacheDiv", false)),
omegaMax_(0)
{
initialise();
}
Foam::radiation::fvDOM::fvDOM(const word& type, const volScalarField& T)
:
radiationModel(type, T),
G_
(
IOobject
(
"G",
mesh().time().timeName(),
T.db(),
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh(),
dimensionedScalar("G", dimMass/pow3(dimTime), 0.0)
),
Qr_
(
IOobject
(
"Qr",
mesh_.time().timeName(),
T.db(),
IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE
),
mesh_,
dimensionedScalar("Qr", dimMass/pow3(dimTime), 0.0)
),
a_
(
IOobject
(
"a",
mesh().time().timeName(),
T.db(),
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh(),
dimensionedScalar("a", dimless/dimLength, 0.0)
),
nTheta_(readLabel(coeffs_.lookup("nTheta"))),
nPhi_(readLabel(coeffs_.lookup("nPhi"))),
nRay_(0),
nLambda_(absorptionEmission_->nBands()),
aLambda_(nLambda_),
blackBody_(nLambda_, T),
IRay_(0),
Qem_(nLambda_),
Qin_(nLambda_),
convergence_(coeffs_.lookupOrDefault<scalar>("convergence", 0.0)),
maxIter_(coeffs_.lookupOrDefault<label>("maxIter", 50)),
fvRayDiv_(nLambda_),
cacheDiv_(coeffs_.lookupOrDefault<bool>("cacheDiv", false)),
omegaMax_(0)
{
initialise();
}
Foam::radiation::fvDOM::fvDOM
(
const dictionary& dict,
const volScalarField& T
)
:
radiationModel(typeName, dict, T),
G_
(
IOobject
(
"G",
mesh().time().timeName(),
T.db(),
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh(),
dimensionedScalar("G", dimMass/pow3(dimTime), 0.0)
),
Qr_
(
IOobject
(
"Qr",
mesh_.time().timeName(),
T.db(),
IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE
),
mesh_,
dimensionedScalar("Qr", dimMass/pow3(dimTime), 0.0)
),
a_
(
IOobject
(
"a",
mesh().time().timeName(),
T.db(),
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh(),
dimensionedScalar("a", dimless/dimLength, 0.0)
),
nTheta_(readLabel(coeffs_.lookup("nTheta"))),
nPhi_(readLabel(coeffs_.lookup("nPhi"))),
nRay_(0),
nLambda_(absorptionEmission_->nBands()),
aLambda_(nLambda_),
blackBody_(nLambda_, T),
IRay_(0),
Qem_(nLambda_),
Qin_(nLambda_),
convergence_(coeffs_.lookupOrDefault<scalar>("convergence", 0.0)),
maxIter_(coeffs_.lookupOrDefault<label>("maxIter", 50)),
fvRayDiv_(nLambda_),
cacheDiv_(coeffs_.lookupOrDefault<bool>("cacheDiv", false)),
omegaMax_(0)
{
initialise();
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
@ -346,53 +485,6 @@ Foam::radiation::fvDOM::Qem() const
return tsumQem; return tsumQem;
} }
Foam::tmp<Foam::volScalarField::GeometricBoundaryField>
Foam::radiation::fvDOM::Qr() const
{
tmp<volScalarField::GeometricBoundaryField> tQr
(
new volScalarField::GeometricBoundaryField
(
mesh().boundary(),
mesh().V(), // Dummy internal field,
calculatedFvPatchScalarField::typeName
)
);
volScalarField::GeometricBoundaryField& Qr = tQr();
Qr = 0;
forAll(Qem_, lambdaI)
{
Qr += Qin(lambdaI);
Qr -= Qem(lambdaI);
}
return tQr;
}
Foam::tmp<Foam::volScalarField::GeometricBoundaryField>
Foam::radiation::fvDOM::Qr(scalar lambdaI) const
{
tmp<volScalarField::GeometricBoundaryField> tQr
(
new volScalarField::GeometricBoundaryField
(
mesh().boundary(),
mesh().V(), // Dummy internal field,
calculatedFvPatchScalarField::typeName
)
);
volScalarField::GeometricBoundaryField& Qr = tQr();
Qr = 0;
Qr += Qin(lambdaI);
Qr -= Qem(lambdaI);
return tQr;
}
bool Foam::radiation::fvDOM::read() bool Foam::radiation::fvDOM::read()
{ {
@ -562,12 +654,21 @@ void Foam::radiation::fvDOM::updateBlackBodyEmission()
void Foam::radiation::fvDOM::updateG() void Foam::radiation::fvDOM::updateG()
{ {
G_ = dimensionedScalar("zero",dimMass/pow3(dimTime), 0.0); G_ = dimensionedScalar("zero",dimMass/pow3(dimTime), 0.0);
Qr_ = dimensionedScalar("zero",dimMass/pow3(dimTime), 0.0);
forAll(IRay_, rayI) forAll(IRay_, rayI)
{ {
IRay_[rayI].addIntensity(); IRay_[rayI].addIntensity();
G_ += IRay_[rayI].I()*IRay_[rayI].omega(); G_ += IRay_[rayI].I()*IRay_[rayI].omega();
} }
forAll(Qr_.boundaryField(), patchI)
{
forAll(aLambda_, lambdaI)
{
Qr_.boundaryField()[patchI] += Qin_[lambdaI][patchI] - Qem_[lambdaI][patchI];
}
}
} }

View file

@ -80,6 +80,9 @@ class fvDOM
//- Incident radiation [W/m2] //- Incident radiation [W/m2]
volScalarField G_; volScalarField G_;
//- Total radiative heat flux [W/m2]
volScalarField Qr_;
//- Total absorption coefficient [1/m] //- Total absorption coefficient [1/m]
volScalarField a_; volScalarField a_;
@ -128,6 +131,9 @@ class fvDOM
// Private member functions // Private member functions
//- Initialise
void initialise();
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct
fvDOM(const fvDOM&); fvDOM(const fvDOM&);
@ -149,6 +155,12 @@ public:
//- Construct from components //- Construct from components
fvDOM(const volScalarField& T); fvDOM(const volScalarField& T);
//- Construct from components
fvDOM(const word& type, const volScalarField& T);
//- Construct from components
fvDOM(const dictionary& dict, const volScalarField& T);
//- Destructor //- Destructor
virtual ~fvDOM(); virtual ~fvDOM();
@ -156,41 +168,31 @@ public:
// Member functions // Member functions
//- Total incident radiative heat flux field // Edit
tmp<volScalarField::GeometricBoundaryField> Qin() const;
//- Total emitted radiative heat flux field //- Solve radiation equation(s)
tmp<volScalarField::GeometricBoundaryField> Qem() const; void calculate();
//- Total radiative heat flux as difference of Qem and Qin //- Read radiation properties dictionary
tmp<volScalarField::GeometricBoundaryField> Qr() const; virtual bool read();
//- Band-wise radiative heat flux as difference of Qem and Qin //- Update G and calculate total heat flux on boundary
tmp<volScalarField::GeometricBoundaryField> Qr(scalar lambda) const; void updateG();
//- Solve radiation equation(s) //- Set the rayId and lambdaId from by decomposing an intensity
void calculate(); // field name
void setRayIdLambdaId
(
const word& name,
label& rayId,
label& lambdaId
) const;
//- Read radiation properties dictionary //- Source term component (for power of T^4)
bool read(); virtual tmp<volScalarField> Rp() const;
//- Update G and calculate total heat flux on boundary //- Source term component (constant)
void updateG(); virtual tmp<DimensionedField<scalar, volMesh> > Ru() const;
//- Set the rayId and lambdaId from by decomposing an intensity
// field name
void setRayIdLambdaId
(
const word& name,
label& rayId,
label& lambdaId
) 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;
// Access // Access
@ -226,18 +228,27 @@ public:
//- Const access to incident radiation field //- Const access to incident radiation field
inline const volScalarField& G() const; inline const volScalarField& G() const;
//- Const access to total radiative heat flux field
inline const volScalarField& Qr() const;
//- Const access to band wise emitted radiative heat flux field //- Const access to band wise emitted radiative heat flux field
inline const volScalarField::GeometricBoundaryField& Qem inline const volScalarField::GeometricBoundaryField& Qem
( (
scalar lambda const label lambda
) const; ) const;
//- Const access to band wise incident radiative heat flux field //- Const access to band wise incident radiative heat flux field
inline const volScalarField::GeometricBoundaryField& Qin inline const volScalarField::GeometricBoundaryField& Qin
( (
scalar lambda const label lambda
) const; ) const;
//- Total incident radiative heat flux field
tmp<volScalarField::GeometricBoundaryField> Qin() const;
//- Total emitted radiative heat flux field
tmp<volScalarField::GeometricBoundaryField> Qem() const;
//- Const access to black body //- Const access to black body
inline const blackBodyEmission& blackBody() const; inline const blackBodyEmission& blackBody() const;

View file

@ -29,6 +29,7 @@ Foam::radiation::fvDOM::IRay(const label rayI) const
return IRay_[rayI]; return IRay_[rayI];
} }
inline const Foam::volScalarField& inline const Foam::volScalarField&
Foam::radiation::fvDOM::IRayLambda Foam::radiation::fvDOM::IRayLambda
( (
@ -85,34 +86,26 @@ inline const Foam::volScalarField& Foam::radiation::fvDOM::G() const
} }
inline const Foam::volScalarField& Foam::radiation::fvDOM::Qr() const
{
return Qr_;
}
inline const Foam::volScalarField::GeometricBoundaryField& inline const Foam::volScalarField::GeometricBoundaryField&
Foam::radiation::fvDOM::Qin(scalar lambdaI) const Foam::radiation::fvDOM::Qin(const label lambdaI) const
{ {
return Qin_[lambdaI]; return Qin_[lambdaI];
} }
/*
inline Foam::volScalarField::GeometricBoundaryField&
Foam::radiation::fvDOM::Qin(scalar lambdaI)
{
return Qin_[lambdaI];
}
*/
inline const Foam::volScalarField::GeometricBoundaryField& inline const Foam::volScalarField::GeometricBoundaryField&
Foam::radiation::fvDOM::Qem(scalar lambdaI) const Foam::radiation::fvDOM::Qem(const label lambdaI) const
{ {
return Qem_[lambdaI]; return Qem_[lambdaI];
} }
/*
inline Foam::volScalarField::GeometricBoundaryField&
Foam::radiation::fvDOM::Qem(scalar lambdaI)
{
return Qem_[lambdaI];
}
*/
inline const Foam::radiation::blackBodyEmission& inline const Foam::radiation::blackBodyEmission&
Foam::radiation::fvDOM::blackBody() const Foam::radiation::fvDOM::blackBody() const
{ {

View file

@ -36,13 +36,7 @@ namespace Foam
namespace radiation namespace radiation
{ {
defineTypeNameAndDebug(noRadiation, 0); defineTypeNameAndDebug(noRadiation, 0);
addToRadiationRunTimeSelectionTables(noRadiation);
addToRunTimeSelectionTable
(
radiationModel,
noRadiation,
dictionary
);
} }
} }
@ -55,6 +49,16 @@ Foam::radiation::noRadiation::noRadiation(const volScalarField& T)
{} {}
Foam::radiation::noRadiation::noRadiation
(
const dictionary& dict,
const volScalarField& T
)
:
radiationModel(T)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::radiation::noRadiation::~noRadiation() Foam::radiation::noRadiation::~noRadiation()

View file

@ -73,6 +73,9 @@ public:
//- Construct from components //- Construct from components
noRadiation(const volScalarField& T); noRadiation(const volScalarField& T);
//- Construct from components
noRadiation(const dictionary& dict, const volScalarField& T);
//- Destructor //- Destructor
virtual ~noRadiation(); virtual ~noRadiation();

View file

@ -40,7 +40,7 @@ autoPtr<radiationModel> radiationModel::New
const volScalarField& T const volScalarField& T
) )
{ {
word radiationModelTypeName; word modelType;
// Note: no need to register/keep radiationProperties since models read // Note: no need to register/keep radiationProperties since models read
// it themselves. // it themselves.
@ -59,27 +59,56 @@ autoPtr<radiationModel> radiationModel::New
); );
radiationPropertiesDict.lookup("radiationModel") radiationPropertiesDict.lookup("radiationModel")
>> radiationModelTypeName; >> modelType;
} }
Info<< "Selecting radiationModel " << radiationModelTypeName << endl; Info<< "Selecting radiationModel " << modelType << endl;
TConstructorTable::iterator cstrIter =
TConstructorTablePtr_->find(modelType);
if (cstrIter == TConstructorTablePtr_->end())
{
FatalErrorIn
(
"radiationModel::New(const volScalarField&)"
) << "Unknown radiationModel type " << modelType
<< nl << nl
<< "Valid radiationModel types are:" << nl
<< TConstructorTablePtr_->toc()
<< exit(FatalError);
}
return autoPtr<radiationModel>(cstrIter()(T));
}
autoPtr<radiationModel> radiationModel::New
(
const dictionary& dict,
const volScalarField& T
)
{
const word modelType(dict.lookup("radiationModel"));
Info<< "Selecting radiationModel " << modelType << endl;
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(radiationModelTypeName); dictionaryConstructorTablePtr_->find(modelType);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (cstrIter == dictionaryConstructorTablePtr_->end())
{ {
FatalErrorIn FatalErrorIn
( (
"radiationModel::New(const volScalarField&)" "radiationModel::New(const dictionary&, const volScalarField&)"
) << "Unknown radiationModel type " << radiationModelTypeName ) << "Unknown radiationModel type "
<< nl << nl << modelType << nl << nl
<< "Valid radiationModel types are:" << nl << "Valid radiationModel types are:" << nl
<< dictionaryConstructorTablePtr_->sortedToc() << dictionaryConstructorTablePtr_->toc()
<< exit(FatalError); << exit(FatalError);
} }
return autoPtr<radiationModel>(cstrIter()(T)); return autoPtr<radiationModel>(cstrIter()(dict, T));
} }

View file

@ -35,11 +35,28 @@ namespace Foam
namespace radiation namespace radiation
{ {
defineTypeNameAndDebug(radiationModel, 0); defineTypeNameAndDebug(radiationModel, 0);
defineRunTimeSelectionTable(radiationModel, T);
defineRunTimeSelectionTable(radiationModel, dictionary); defineRunTimeSelectionTable(radiationModel, dictionary);
} }
} }
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::radiation::radiationModel::initialise()
{
if (radiation_)
{
solverFreq_ = max(1, lookupOrDefault<label>("solverFreq", 1));
absorptionEmission_.reset
(
absorptionEmissionModel::New(*this, mesh_).ptr()
);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::radiation::radiationModel::radiationModel(const volScalarField& T) Foam::radiation::radiationModel::radiationModel(const volScalarField& T)
@ -89,10 +106,44 @@ Foam::radiation::radiationModel::radiationModel
radiation_(lookup("radiation")), radiation_(lookup("radiation")),
coeffs_(subDict(type + "Coeffs")), coeffs_(subDict(type + "Coeffs")),
solverFreq_(readLabel(lookup("solverFreq"))), solverFreq_(readLabel(lookup("solverFreq"))),
absorptionEmission_(absorptionEmissionModel::New(*this, mesh_)), absorptionEmission_(NULL),
scatter_(scatterModel::New(*this, mesh_)) scatter_(scatterModel::New(*this, mesh_))
{ {
solverFreq_ = max(1, solverFreq_); initialise();
}
Foam::radiation::radiationModel::radiationModel
(
const word& type,
const dictionary& dict,
const volScalarField& T
)
:
IOdictionary
(
IOobject
(
"radiationProperties",
T.time().constant(),
T.mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
dict
),
mesh_(T.mesh()),
time_(T.time()),
T_(T),
radiation_(lookup("radiation")),
coeffs_(subOrEmptyDict(type + "Coeffs")),
solverFreq_(1),
firstIter_(true),
absorptionEmission_(NULL),
scatter_(NULL)
{
initialise();
} }
@ -109,7 +160,10 @@ bool Foam::radiation::radiationModel::read()
if (regIOobject::read()) if (regIOobject::read())
{ {
lookup("radiation") >> radiation_; lookup("radiation") >> radiation_;
coeffs_ = subDict(type() + "Coeffs"); coeffs_ = subOrEmptyDict(type() + "Coeffs");
solverFreq_ = lookupOrDefault<label>("solverFreq", 1);
solverFreq_ = max(1, solverFreq_);
return true; return true;
} }
@ -127,9 +181,10 @@ void Foam::radiation::radiationModel::correct()
return; return;
} }
if (time_.timeIndex() % solverFreq_ == 0) if (firstIter_ || (time_.timeIndex() % solverFreq_ == 0))
{ {
calculate(); calculate();
firstIter_ = false;
} }
} }

View file

@ -35,6 +35,7 @@ Description
SourceFiles SourceFiles
radiationModel.C radiationModel.C
radiationModelNew.C
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -81,7 +82,7 @@ protected:
//- Reference to the temperature field //- Reference to the temperature field
const volScalarField& T_; const volScalarField& T_;
//- Model specific dictionary input parameters //- Radiation model on/off flag
Switch radiation_; Switch radiation_;
//- Radiation model dictionary //- Radiation model dictionary
@ -91,6 +92,9 @@ protected:
// radiation solver iteration // radiation solver iteration
label solverFreq_; label solverFreq_;
//- Flag to enable radiation model to be evaluated on first iteration
bool firstIter_;
// References to the radiation sub-models // References to the radiation sub-models
@ -105,6 +109,12 @@ private:
// Private Member Functions // Private Member Functions
//- Create IO object if dictionary is present
IOobject createIOobject(const fvMesh& mesh) const;
//- Initialise
void initialise();
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct
radiationModel(const radiationModel&); radiationModel(const radiationModel&);
@ -125,12 +135,24 @@ public:
( (
autoPtr, autoPtr,
radiationModel, radiationModel,
dictionary, T,
( (
const volScalarField& T const volScalarField& T
), ),
(T) (T)
); );
declareRunTimeSelectionTable
(
autoPtr,
radiationModel,
dictionary,
(
const dictionary& dict,
const volScalarField& T
),
(dict, T)
);
#endif #endif
// Constructors // Constructors
@ -141,11 +163,26 @@ public:
//- Construct from components //- Construct from components
radiationModel(const word& type, const volScalarField& T); radiationModel(const word& type, const volScalarField& T);
//- Construct from components
radiationModel
(
const word& type,
const dictionary& dict,
const volScalarField& T
);
// Selectors // Selectors
//- Return a reference to the selected radiation model //- Return a reference to the selected radiation model
static autoPtr<radiationModel> New(const volScalarField& T); static autoPtr<radiationModel> New(const volScalarField& T);
//- Return a reference to the selected radiation model
static autoPtr<radiationModel> New
(
const dictionary& dict,
const volScalarField& T
);
//- Destructor //- Destructor
@ -168,6 +205,12 @@ public:
// Access // Access
//- Radiation model on/off flag
const Switch radiation() const
{
return radiation_;
}
//- Const access to mesh //- Const access to mesh
const fvMesh& mesh() const const fvMesh& mesh() const
{ {
@ -188,6 +231,24 @@ public:
}; };
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#define addToRadiationRunTimeSelectionTables(model) \
\
addToRunTimeSelectionTable \
( \
radiationModel, \
model, \
dictionary \
); \
\
addToRunTimeSelectionTable \
( \
radiationModel, \
model, \
T \
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace radiation } // End namespace radiation