Commit ca2ad803 authored by Henry's avatar Henry
Browse files

Thermodynamics: Completed dictionary based selection mechanisms for all thermodynamic packages

Rationalised "make" macros to reduce code duplication
Removed solid phase radiation properties
Updated tutorials appropriately
parent 88050abc
......@@ -46,7 +46,7 @@ temperatureThermoBaffleFvPatchScalarField
turbulentTemperatureCoupledBaffleMixedFvPatchScalarField(p, iF),
owner_(false),
baffle_(),
solidThermoType_("undefined"),
solidThermoType_(new primitiveEntry("thermoType", "undefined")),
dict_(dictionary::null)
{}
......@@ -69,7 +69,7 @@ temperatureThermoBaffleFvPatchScalarField
),
owner_(ptf.owner_),
baffle_(ptf.baffle_),
solidThermoType_(ptf.solidThermoType_),
solidThermoType_(ptf.solidThermoType_().clone()),
dict_(ptf.dict_)
{}
......@@ -85,7 +85,7 @@ temperatureThermoBaffleFvPatchScalarField
turbulentTemperatureCoupledBaffleMixedFvPatchScalarField(p, iF, dict),
owner_(false),
baffle_(),
solidThermoType_(),
solidThermoType_(new primitiveEntry("thermoType", "undefined")),
dict_(dict)
{
if (!isA<mappedPatchBase>(patch().patch()))
......@@ -126,7 +126,7 @@ temperatureThermoBaffleFvPatchScalarField
Info << "Creating thermal baffle" << nbrMesh << endl;
baffle_.reset(baffle::New(thisMesh, dict).ptr());
owner_ = true;
dict.lookup("thermoType") >> solidThermoType_;
solidThermoType_ = dict.lookupEntry("thermoType", false, false).clone();
baffle_->rename(nbrMesh);
}
}
......@@ -142,7 +142,7 @@ temperatureThermoBaffleFvPatchScalarField
turbulentTemperatureCoupledBaffleMixedFvPatchScalarField(ptf, iF),
owner_(ptf.owner_),
baffle_(ptf.baffle_),
solidThermoType_(ptf.solidThermoType_),
solidThermoType_(ptf.solidThermoType_().clone()),
dict_(ptf.dict_)
{}
......@@ -219,8 +219,7 @@ void temperatureThermoBaffleFvPatchScalarField::write(Ostream& os) const
os.writeKeyword(word(thermoModel + "Coeffs"));
os << dict_.subDict(thermoModel + "Coeffs") << nl;
os.writeKeyword("thermoType") << solidThermoType_
<< token::END_STATEMENT << nl;
os << solidThermoType_() << nl;
os.writeKeyword("mixture");
os << dict_.subDict("mixture") << nl;
......
......@@ -140,7 +140,7 @@ class temperatureThermoBaffleFvPatchScalarField
autoPtr<regionModels::thermoBaffleModels::thermoBaffleModel> baffle_;
//- Solid thermo type
word solidThermoType_;
autoPtr<entry> solidThermoType_;
//- Dictionary
dictionary dict_;
......
......@@ -318,7 +318,13 @@ const tmp<volScalarField> thermoBaffle2D::Cp() const
const volScalarField& thermoBaffle2D::kappaRad() const
{
return thermo_->kappaRad();
// ***HGW return thermo_->kappaRad();
FatalErrorIn
(
"thermoBaffle2D::kappaRad()"
) << "not currently supported"
<< exit(FatalError);
return volScalarField::null();
}
......
basicThermo/basicThermo.C
fluidThermo/fluidThermo.C
psiThermo/psiThermo/psiThermo.C
psiThermo/hePsiThermo/hePsiThermos.C
psiThermo/psiThermo.C
psiThermo/psiThermos.C
rhoThermo/rhoThermo/rhoThermo.C
rhoThermo/heRhoThermo/heRhoThermos.C
rhoThermo/rhoThermo.C
rhoThermo/rhoThermos.C
derivedFvPatchFields/fixedEnergy/fixedEnergyFvPatchScalarField.C
derivedFvPatchFields/gradientEnergy/gradientEnergyFvPatchScalarField.C
......
......@@ -105,10 +105,22 @@ public:
// Selectors
//- Generic lookup for each of the related thermodynamics packages
template<class Thermo, class Table>
static typename Table::iterator lookupThermo
(
const dictionary& thermoDict,
Table* tablePtr
);
//- Generic New for each of the related thermodynamics packages
template<class Thermo>
static autoPtr<Thermo> New(const fvMesh&);
//- Generic New for each of the related thermodynamics packages
template<class Thermo>
static autoPtr<Thermo> New(const fvMesh&, const dictionary&);
//- Specialisation of the Generic New for basicThermo
static autoPtr<basicThermo> New(const fvMesh&);
......
......@@ -27,25 +27,13 @@ License
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
template<class Thermo>
Foam::autoPtr<Thermo> Foam::basicThermo::New
template<class Thermo, class Table>
typename Table::iterator Foam::basicThermo::lookupThermo
(
const fvMesh& mesh
const dictionary& thermoDict,
Table* tablePtr
)
{
IOdictionary thermoDict
(
IOobject
(
"thermophysicalProperties",
mesh.time().constant(),
mesh,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE,
false
)
);
word thermoTypeName;
if (thermoDict.isDict("thermoType"))
......@@ -76,16 +64,13 @@ Foam::autoPtr<Thermo> Foam::basicThermo::New
+ word(thermoTypeDict.lookup("specie")) + ">>,"
+ word(thermoTypeDict.lookup("energy")) + ">>>";
Info<< thermoTypeName << endl;
// Lookup the thermo package
typename Thermo::fvMeshConstructorTable::iterator cstrIter =
Thermo::fvMeshConstructorTablePtr_->find(thermoTypeName);
typename Table::iterator cstrIter = tablePtr->find(thermoTypeName);
// Print error message if package not found in the table
if (cstrIter == Thermo::fvMeshConstructorTablePtr_->end())
if (cstrIter == tablePtr->end())
{
FatalErrorIn(Thermo::typeName + "::New(const fvMesh&)")
FatalErrorIn(Thermo::typeName + "::New")
<< "Unknown " << Thermo::typeName << " type " << nl
<< "thermoType" << thermoTypeDict << nl << nl
<< "Valid " << Thermo::typeName << " types are:" << nl << nl;
......@@ -93,7 +78,7 @@ Foam::autoPtr<Thermo> Foam::basicThermo::New
// Get the list of all the suitable thermo packages available
wordList validThermoTypeNames
(
Thermo::fvMeshConstructorTablePtr_->sortedToc()
tablePtr->sortedToc()
);
// Build a table of the thermo packages constituent parts
......@@ -123,7 +108,7 @@ Foam::autoPtr<Thermo> Foam::basicThermo::New
FatalError<< exit(FatalError);
}
return autoPtr<Thermo>(cstrIter()(mesh));
return cstrIter;
}
else
{
......@@ -131,22 +116,69 @@ Foam::autoPtr<Thermo> Foam::basicThermo::New
Info<< "Selecting thermodynamics package " << thermoTypeName << endl;
typename Thermo::fvMeshConstructorTable::iterator cstrIter =
Thermo::fvMeshConstructorTablePtr_->find(thermoTypeName);
typename Table::iterator cstrIter = tablePtr->find(thermoTypeName);
if (cstrIter == Thermo::fvMeshConstructorTablePtr_->end())
if (cstrIter == tablePtr->end())
{
FatalErrorIn(Thermo::typeName + "::New(const fvMesh&)")
FatalErrorIn(Thermo::typeName + "::New")
<< "Unknown " << Thermo::typeName << " type "
<< thermoTypeName << nl << nl
<< "Valid " << Thermo::typeName << " types are:" << nl
<< Thermo::fvMeshConstructorTablePtr_->sortedToc() << nl
<< tablePtr->sortedToc() << nl
<< exit(FatalError);
}
return autoPtr<Thermo>(cstrIter()(mesh));
return cstrIter;
}
}
template<class Thermo>
Foam::autoPtr<Thermo> Foam::basicThermo::New
(
const fvMesh& mesh
)
{
IOdictionary thermoDict
(
IOobject
(
"thermophysicalProperties",
mesh.time().constant(),
mesh,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE,
false
)
);
typename Thermo::fvMeshConstructorTable::iterator cstrIter =
lookupThermo<Thermo, typename Thermo::fvMeshConstructorTable>
(
thermoDict,
Thermo::fvMeshConstructorTablePtr_
);
return autoPtr<Thermo>(cstrIter()(mesh));
}
template<class Thermo>
Foam::autoPtr<Thermo> Foam::basicThermo::New
(
const fvMesh& mesh,
const dictionary& dict
)
{
typename Thermo::dictionaryConstructorTable::iterator cstrIter =
lookupThermo<Thermo, typename Thermo::dictionaryConstructorTable>
(
dict,
Thermo::dictionaryConstructorTablePtr_
);
return autoPtr<Thermo>(cstrIter()(mesh, dict));
}
// ************************************************************************* //
......@@ -37,7 +37,7 @@ Description
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#define makeThermo(BaseThermo,Cthermo,Mixture,Transport,Type,Thermo,EqnOfState,Specie)\
#define makeThermoTypedefs(BaseThermo,Cthermo,Mixture,Transport,Type,Thermo,EqnOfState,Specie)\
\
typedef \
Transport \
......@@ -58,10 +58,8 @@ typedef \
typedef \
Cthermo \
< \
Mixture \
< \
Transport##Type##Thermo##EqnOfState##Specie \
> \
BaseThermo, \
Mixture<Transport##Type##Thermo##EqnOfState##Specie> \
> Cthermo##Mixture##Transport##Type##Thermo##EqnOfState##Specie; \
\
defineTemplateTypeNameAndDebugWithName \
......@@ -73,7 +71,22 @@ defineTemplateTypeNameAndDebugWithName \
+ ">>" \
).c_str(), \
0 \
); \
);
#define makeThermo(BaseThermo,Cthermo,Mixture,Transport,Type,Thermo,EqnOfState,Specie)\
\
makeThermoTypedefs \
( \
BaseThermo, \
Cthermo, \
Mixture, \
Transport, \
Type, \
Thermo, \
EqnOfState, \
Specie \
) \
\
addToRunTimeSelectionTable \
( \
......
......@@ -27,8 +27,8 @@ License
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class MixtureType>
void Foam::hePsiThermo<MixtureType>::calculate()
template<class BasicPsiThermo, class MixtureType>
void Foam::hePsiThermo<BasicPsiThermo, MixtureType>::calculate()
{
const scalarField& hCells = this->he_.internalField();
const scalarField& pCells = this->p_.internalField();
......@@ -101,10 +101,10 @@ void Foam::hePsiThermo<MixtureType>::calculate()
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class MixtureType>
Foam::hePsiThermo<MixtureType>::hePsiThermo(const fvMesh& mesh)
template<class BasicPsiThermo, class MixtureType>
Foam::hePsiThermo<BasicPsiThermo, MixtureType>::hePsiThermo(const fvMesh& mesh)
:
heThermo<psiThermo, MixtureType>(mesh)
heThermo<BasicPsiThermo, MixtureType>(mesh)
{
calculate();
......@@ -115,19 +115,19 @@ Foam::hePsiThermo<MixtureType>::hePsiThermo(const fvMesh& mesh)
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class MixtureType>
Foam::hePsiThermo<MixtureType>::~hePsiThermo()
template<class BasicPsiThermo, class MixtureType>
Foam::hePsiThermo<BasicPsiThermo, MixtureType>::~hePsiThermo()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class MixtureType>
void Foam::hePsiThermo<MixtureType>::correct()
template<class BasicPsiThermo, class MixtureType>
void Foam::hePsiThermo<BasicPsiThermo, MixtureType>::correct()
{
if (debug)
{
Info<< "entering hePsiThermo<MixtureType>::correct()" << endl;
Info<< "entering hePsiThermo<BasicPsiThermo, MixtureType>::correct()" << endl;
}
// force the saving of the old-time values
......@@ -137,7 +137,7 @@ void Foam::hePsiThermo<MixtureType>::correct()
if (debug)
{
Info<< "exiting hePsiThermo<MixtureType>::correct()" << endl;
Info<< "exiting hePsiThermo<BasicPsiThermo, MixtureType>::correct()" << endl;
}
}
......
......@@ -25,7 +25,7 @@ Class
Foam::hePsiThermo
Description
Enthalpy for a mixture based on compressibility
Energy for a mixture based on compressibility
SourceFiles
hePsiThermo.C
......@@ -47,10 +47,10 @@ namespace Foam
Class hePsiThermo Declaration
\*---------------------------------------------------------------------------*/
template<class MixtureType>
template<class BasicPsiThermo, class MixtureType>
class hePsiThermo
:
public heThermo<psiThermo, MixtureType>
public heThermo<BasicPsiThermo, MixtureType>
{
// Private Member Functions
......@@ -58,7 +58,7 @@ class hePsiThermo
void calculate();
//- Construct as copy (not implemented)
hePsiThermo(const hePsiThermo<MixtureType>&);
hePsiThermo(const hePsiThermo<BasicPsiThermo, MixtureType>&);
public:
......
......@@ -27,8 +27,8 @@ License
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class MixtureType>
void Foam::heRhoThermo<MixtureType>::calculate()
template<class BasicPsiThermo, class MixtureType>
void Foam::heRhoThermo<BasicPsiThermo, MixtureType>::calculate()
{
const scalarField& hCells = this->he().internalField();
const scalarField& pCells = this->p_.internalField();
......@@ -106,10 +106,10 @@ void Foam::heRhoThermo<MixtureType>::calculate()
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class MixtureType>
Foam::heRhoThermo<MixtureType>::heRhoThermo(const fvMesh& mesh)
template<class BasicPsiThermo, class MixtureType>
Foam::heRhoThermo<BasicPsiThermo, MixtureType>::heRhoThermo(const fvMesh& mesh)
:
heThermo<rhoThermo, MixtureType>(mesh)
heThermo<BasicPsiThermo, MixtureType>(mesh)
{
calculate();
}
......@@ -117,15 +117,15 @@ Foam::heRhoThermo<MixtureType>::heRhoThermo(const fvMesh& mesh)
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class MixtureType>
Foam::heRhoThermo<MixtureType>::~heRhoThermo()
template<class BasicPsiThermo, class MixtureType>
Foam::heRhoThermo<BasicPsiThermo, MixtureType>::~heRhoThermo()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class MixtureType>
void Foam::heRhoThermo<MixtureType>::correct()
template<class BasicPsiThermo, class MixtureType>
void Foam::heRhoThermo<BasicPsiThermo, MixtureType>::correct()
{
if (debug)
{
......
......@@ -25,7 +25,7 @@ Class
Foam::heRhoThermo
Description
Enthalpy for a mixture based on density
Energy for a mixture based on density
SourceFiles
heRhoThermo.C
......@@ -47,10 +47,10 @@ namespace Foam
Class heRhoThermo Declaration
\*---------------------------------------------------------------------------*/
template<class MixtureType>
template<class BasicPsiThermo, class MixtureType>
class heRhoThermo
:
public heThermo<rhoThermo, MixtureType>
public heThermo<BasicPsiThermo, MixtureType>
{
// Private Member Functions
......@@ -58,7 +58,7 @@ class heRhoThermo
void calculate();
//- Construct as copy (not implemented)
heRhoThermo(const heRhoThermo<MixtureType>&);
heRhoThermo(const heRhoThermo<BasicPsiThermo, MixtureType>&);
public:
......
......@@ -24,7 +24,6 @@ License
\*---------------------------------------------------------------------------*/
#include "chemistryModel.H"
#include "chemistrySolver.H"
#include "reactingMixture.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
......@@ -568,6 +567,8 @@ Foam::chemistryModel<CompType, ThermoType>::tc() const
);
scalarField& tc = ttc();
const scalarField& T = this->thermo().T();
const scalarField& p = this->thermo().p();
const label nReaction = reactions_.size();
......@@ -576,8 +577,8 @@ Foam::chemistryModel<CompType, ThermoType>::tc() const
forAll(rho, celli)
{
scalar rhoi = rho[celli];
scalar Ti = this->thermo().T()[celli];
scalar pi = this->thermo().p()[celli];
scalar Ti = T[celli];
scalar pi = p[celli];
scalarField c(nSpecie_);
scalar cSum = 0.0;
......@@ -716,11 +717,14 @@ void Foam::chemistryModel<CompType, ThermoType>::calculate()
this->thermo().rho()
);
const scalarField& T = this->thermo().T();
const scalarField& p = this->thermo().p();
forAll(rho, celli)
{
const scalar rhoi = rho[celli];
const scalar Ti = this->thermo().T()[celli];
const scalar pi = this->thermo().p()[celli];
const scalar Ti = T[celli];
const scalar pi = p[celli];
scalarField c(nSpecie_, 0.0);
for (label i=0; i<nSpecie_; i++)
......@@ -771,13 +775,16 @@ Foam::scalar Foam::chemistryModel<CompType, ThermoType>::solve
tmp<volScalarField> thc = this->thermo().hc();
const scalarField& hc = thc();
const scalarField& he = this->thermo().he();
const scalarField& T = this->thermo().T();
const scalarField& p = this->thermo().p();
forAll(rho, celli)
{
const scalar rhoi = rho[celli];
const scalar hi = this->thermo().he()[celli] + hc[celli];
const scalar pi = this->thermo().p()[celli];
scalar Ti = this->thermo().T()[celli];
const scalar hi = he[celli] + hc[celli];
const scalar pi = p[celli];
scalar Ti = T[celli];
scalarField c(nSpecie_, 0.0);
scalarField c0(nSpecie_, 0.0);
......
......@@ -25,7 +25,6 @@ License
#include "psiChemistryModel.H"
#include "fvMesh.H"
#include "Time.H"
/* * * * * * * * * * * * * * * private static data * * * * * * * * * * * * * */
......@@ -35,6 +34,7 @@ namespace Foam
defineRunTimeSelectionTable(psiChemistryModel, fvMesh);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::psiChemistryModel::psiChemistryModel
......
......@@ -25,7 +25,6 @@ License
#include "rhoChemistryModel.H"
#include "fvMesh.H"
#include "Time.H"
/* * * * * * * * * * * * * * * private static data * * * * * * * * * * * * * */
......@@ -35,6 +34,7 @@ namespace Foam
defineRunTimeSelectionTable(rhoChemistryModel, fvMesh);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::rhoChemistryModel::rhoChemistryModel
......