improved calculate() method called from correct() in base class

This commit is contained in:
andy
2009-03-23 10:39:57 +00:00
parent 1c9390b59d
commit 3a76720e14
10 changed files with 80 additions and 66 deletions

View File

@ -50,12 +50,9 @@ namespace Foam
} }
} }
// Radiation solver iteration
Foam::label Foam::radiation::P1::iterRadId = pTraits<label>::one;
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
Foam::radiation::P1::P1(const volScalarField& T) Foam::radiation::P1::P1(const volScalarField& T)
: :
radiationModel(typeName, T), radiationModel(typeName, T),
@ -136,14 +133,8 @@ bool Foam::radiation::P1::read()
} }
void Foam::radiation::P1::correct() void Foam::radiation::P1::calculate()
{ {
if (!radiation_ || !(iterRadId == nFlowIterPerRadIter_))
{
iterRadId++;
return;
}
a_ = absorptionEmission_->a(); a_ = absorptionEmission_->a();
e_ = absorptionEmission_->e(); e_ = absorptionEmission_->e();
E_ = absorptionEmission_->E(); E_ = absorptionEmission_->E();
@ -171,8 +162,6 @@ void Foam::radiation::P1::correct()
== ==
- 4.0*(e_*radiation::sigmaSB*pow4(T_) + E_) - 4.0*(e_*radiation::sigmaSB*pow4(T_) + E_)
); );
iterRadId = pTraits<label>::one;
} }

View File

@ -59,7 +59,6 @@ class P1
: :
public radiationModel public radiationModel
{ {
// Private data // Private data
//- Incident radiation / [W/m2] //- Incident radiation / [W/m2]
@ -86,10 +85,6 @@ class P1
public: public:
// Static data members
static label iterRadId;
//- Runtime type information //- Runtime type information
TypeName("P1"); TypeName("P1");
@ -108,10 +103,10 @@ public:
// Edit // Edit
//- Update radiationSource varible //- Solve radiation equation(s)
void correct(); void calculate();
//- Read radiationProperties dictionary //- Read radiation properties dictionary
bool read(); bool read();

View File

@ -50,9 +50,6 @@ namespace Foam
} }
} }
// Radiation solver iterator counter
Foam::label Foam::radiation::fvDOM::iterRadId = pTraits<label>::one;
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -287,19 +284,13 @@ bool Foam::radiation::fvDOM::read()
} }
void Foam::radiation::fvDOM::correct() void Foam::radiation::fvDOM::calculate()
{ {
if (!radiation_ || !(iterRadId == nFlowIterPerRadIter_))
{
iterRadId++;
return;
}
absorptionEmission_->correct(a_, aj_); absorptionEmission_->correct(a_, aj_);
updateBlackBodyEmission(); updateBlackBodyEmission();
scalar maxResidual = 0; scalar maxResidual = 0.0;
label radIter = 0; label radIter = 0;
do do
{ {
@ -316,8 +307,6 @@ void Foam::radiation::fvDOM::correct()
} while(maxResidual > convergence_); } while(maxResidual > convergence_);
updateG(); updateG();
iterRadId = pTraits<label>::one;
} }

View File

@ -136,11 +136,6 @@ class fvDOM
public: public:
// Static data members
static label iterRadId;
//- Runtime type information //- Runtime type information
TypeName("fvDOM"); TypeName("fvDOM");
@ -159,10 +154,10 @@ public:
// Edit // Edit
//- Update radiation source variable //- Solve radiation equation(s)
void correct(); void calculate();
//- Read radiationProperties dictionary //- Read radiation properties dictionary
bool read(); bool read();
//- Update G and calculate total heat flux on boundary //- Update G and calculate total heat flux on boundary

View File

@ -117,7 +117,7 @@ Foam::radiation::radiativeIntensityRay::radiativeIntensityRay
{ {
IOobject IHeader IOobject IHeader
( (
"Ilambda_" + name(rayId) + "_" + name(i), "ILambda_" + name(rayId) + "_" + name(i),
mesh_.time().timeName(), mesh_.time().timeName(),
mesh_, mesh_,
IOobject::MUST_READ, IOobject::MUST_READ,

View File

@ -96,6 +96,9 @@ class radiativeIntensityRay
//- List of pointers to radiative intensity fields for given wavelengths //- List of pointers to radiative intensity fields for given wavelengths
PtrList<volScalarField> ILambda_; PtrList<volScalarField> ILambda_;
//- Global ray id - incremented in constructor
static label rayId;
// Private member functions // Private member functions
@ -108,11 +111,6 @@ class radiativeIntensityRay
public: public:
// Static data members
static label rayId;
// Constructors // Constructors
//- Construct form components //- Construct form components

View File

@ -50,10 +50,9 @@ namespace Foam
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
Foam::radiation::noRadiation::noRadiation(const volScalarField& T) Foam::radiation::noRadiation::noRadiation(const volScalarField& T)
: :
radiationModel(typeName, T) radiationModel(T)
{} {}
@ -71,7 +70,7 @@ bool Foam::radiation::noRadiation::read()
} }
void Foam::radiation::noRadiation::correct() void Foam::radiation::noRadiation::calculate()
{ {
// Do nothing // Do nothing
} }

View File

@ -54,7 +54,6 @@ class noRadiation
: :
public radiationModel public radiationModel
{ {
// Private member functions // Private member functions
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct
@ -76,7 +75,7 @@ public:
noRadiation(const volScalarField& T); noRadiation(const volScalarField& T);
// Destructor //- Destructor
virtual ~noRadiation(); virtual ~noRadiation();
@ -84,8 +83,8 @@ public:
// Edit // Edit
//- Update radiation source //- Solve radiation equation(s)
void correct(); void calculate();
//- Read radiationProperties dictionary //- Read radiationProperties dictionary
bool read(); bool read();

View File

@ -43,6 +43,30 @@ namespace Foam
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::radiation::radiationModel::radiationModel(const volScalarField& T)
:
IOdictionary
(
IOobject
(
"radiationProperties",
T.time().constant(),
T.mesh().objectRegistry::db(),
IOobject::MUST_READ,
IOobject::NO_WRITE
)
),
mesh_(T.mesh()),
time_(T.time()),
T_(T),
radiation_(false),
coeffs_(dictionary::null),
solverFreq_(0),
absorptionEmission_(NULL),
scatter_(NULL)
{}
Foam::radiation::radiationModel::radiationModel Foam::radiation::radiationModel::radiationModel
( (
const word& type, const word& type,
@ -60,14 +84,17 @@ Foam::radiation::radiationModel::radiationModel
IOobject::NO_WRITE IOobject::NO_WRITE
) )
), ),
T_(T),
mesh_(T.mesh()), mesh_(T.mesh()),
time_(T.time()),
T_(T),
radiation_(lookup("radiation")), radiation_(lookup("radiation")),
coeffs_(subDict(type + "Coeffs")), coeffs_(subDict(type + "Coeffs")),
nFlowIterPerRadIter_(readLabel(lookup("nFlowIterPerRadIter"))), solverFreq_(readLabel(lookup("solverFreq"))),
absorptionEmission_(absorptionEmissionModel::New(*this, mesh_)), absorptionEmission_(absorptionEmissionModel::New(*this, mesh_)),
scatter_(scatterModel::New(*this, mesh_)) scatter_(scatterModel::New(*this, mesh_))
{} {
solverFreq_ = max(1, solverFreq_);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * //
@ -94,6 +121,20 @@ bool Foam::radiation::radiationModel::read()
} }
void Foam::radiation::radiationModel::correct()
{
if (!radiation_)
{
return;
}
if ((time_.timeIndex() == 0) || (time_.timeIndex() % solverFreq_ == 0))
{
calculate();
}
}
Foam::tmp<Foam::fvScalarMatrix> Foam::radiation::radiationModel::Sh Foam::tmp<Foam::fvScalarMatrix> Foam::radiation::radiationModel::Sh
( (
basicThermo& thermo basicThermo& thermo

View File

@ -73,21 +73,24 @@ protected:
// Protected data // Protected data
//- Reference to the mesh database
const fvMesh& mesh_;
//- Reference to the time database
const Time& time_;
//- Reference to the temperature field //- Reference to the temperature field
const volScalarField& T_; const volScalarField& T_;
//- Reference to the mesh
const fvMesh& mesh_;
//- Model specific dictionary input parameters //- Model specific dictionary input parameters
Switch radiation_; Switch radiation_;
//- Radiation model dictionary //- Radiation model dictionary
dictionary coeffs_; dictionary coeffs_;
//- Number of iterations in the flow solver per radiation solver //- Radiation solver frequency - number flow solver iterations per
// iteration // radiation solver iteration
label nFlowIterPerRadIter_; label solverFreq_;
// References to the radiation sub-models // References to the radiation sub-models
@ -132,6 +135,9 @@ public:
// Constructors // Constructors
//- Null constructor
radiationModel(const volScalarField& T);
//- Construct from components //- Construct from components
radiationModel(const word& type, const volScalarField& T); radiationModel(const word& type, const volScalarField& T);
@ -142,7 +148,7 @@ public:
static autoPtr<radiationModel> New(const volScalarField& T); static autoPtr<radiationModel> New(const volScalarField& T);
// Destructor //- Destructor
virtual ~radiationModel(); virtual ~radiationModel();
@ -150,8 +156,11 @@ public:
// Edit // Edit
//- Main update/correction routine
virtual void correct();
//- Solve radiation equation(s) //- Solve radiation equation(s)
virtual void correct() = 0; virtual void calculate() = 0;
//- Read radiationProperties dictionary //- Read radiationProperties dictionary
virtual bool read() = 0; virtual bool read() = 0;