mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
STYLE: simplify read/write coding for some thermophysicalModels
This commit is contained in:
@ -49,9 +49,12 @@ void Foam::constAnIsoSolidTransport<Thermo>::constAnIsoSolidTransport::write
|
||||
{
|
||||
Thermo::write(os);
|
||||
|
||||
dictionary dict("transport");
|
||||
dict.add("kappa", kappa_);
|
||||
os << indent << dict.dictName() << dict;
|
||||
// Entries in dictionary format
|
||||
{
|
||||
os.beginBlock("transport");
|
||||
os.writeEntry("kappa", kappa_);
|
||||
os.endBlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -49,9 +49,12 @@ void Foam::constIsoSolidTransport<Thermo>::constIsoSolidTransport::write
|
||||
{
|
||||
Thermo::write(os);
|
||||
|
||||
dictionary dict("transport");
|
||||
dict.add("kappa", kappa_);
|
||||
os << indent << dict.dictName() << dict;
|
||||
// Entries in dictionary format
|
||||
{
|
||||
os.beginBlock("transport");
|
||||
os.writeEntry("kappa", kappa_);
|
||||
os.endBlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -35,15 +35,10 @@ Foam::exponentialSolidTransport<Thermo>::exponentialSolidTransport
|
||||
)
|
||||
:
|
||||
Thermo(dict),
|
||||
kappa0_(0.0),
|
||||
n0_(0.0),
|
||||
Tref_(0.0)
|
||||
{
|
||||
const dictionary& subDict = dict.subDict("transport");
|
||||
subDict.readEntry("kappa0", kappa0_);
|
||||
subDict.readEntry("n0", n0_);
|
||||
subDict.readEntry("Tref", Tref_);
|
||||
}
|
||||
kappa0_(dict.subDict("transport").get<scalar>("kappa0")),
|
||||
n0_(dict.subDict("transport").get<scalar>("n0")),
|
||||
Tref_(dict.subDict("transport").get<scalar>("Tref"))
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
@ -56,11 +51,14 @@ void Foam::exponentialSolidTransport<Thermo>::exponentialSolidTransport::write
|
||||
{
|
||||
Thermo::write(os);
|
||||
|
||||
dictionary dict("transport");
|
||||
dict.add("kappa0", kappa0_);
|
||||
dict.add("n0", n0_);
|
||||
dict.add("Tref", Tref_);
|
||||
os << indent << dict.dictName() << dict;
|
||||
// Entries in dictionary format
|
||||
{
|
||||
os.beginBlock("transport");
|
||||
os.writeEntry("kappa0", kappa0_);
|
||||
os.writeEntry("n0", n0_);
|
||||
os.writeEntry("Tref", Tref_);
|
||||
os.endBlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -35,15 +35,8 @@ Foam::polynomialSolidTransport<Thermo, PolySize>::polynomialSolidTransport
|
||||
)
|
||||
:
|
||||
Thermo(dict),
|
||||
kappaCoeffs_
|
||||
(
|
||||
dict.subDict("transport").lookup
|
||||
(
|
||||
"kappaCoeffs<" + Foam::name(PolySize) + '>'
|
||||
)
|
||||
)
|
||||
{
|
||||
}
|
||||
kappaCoeffs_(dict.subDict("transport").lookup(coeffsName("kappa")))
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
@ -53,14 +46,12 @@ void Foam::polynomialSolidTransport<Thermo, PolySize>::write(Ostream& os) const
|
||||
{
|
||||
Thermo::write(os);
|
||||
|
||||
dictionary dict("transport");
|
||||
|
||||
dict.add
|
||||
(
|
||||
word("kappaCoeffs<" + Foam::name(PolySize) + '>'),
|
||||
kappaCoeffs_
|
||||
);
|
||||
os << indent << dict.dictName() << dict;
|
||||
// Entries in dictionary format
|
||||
{
|
||||
os.beginBlock("transport");
|
||||
os.writeEntry(coeffsName("kappa"), kappaCoeffs_);
|
||||
os.endBlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -115,6 +115,12 @@ class polynomialSolidTransport
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Coeffs name. Eg, "kappaCoeffs<10>"
|
||||
inline static word coeffsName(const char* name)
|
||||
{
|
||||
return word(name + ("Coeffs<" + std::to_string(PolySize) + '>'));
|
||||
}
|
||||
|
||||
//- Construct from components
|
||||
inline polynomialSolidTransport
|
||||
(
|
||||
|
||||
@ -47,12 +47,15 @@ template<class Specie>
|
||||
void Foam::Boussinesq<Specie>::write(Ostream& os) const
|
||||
{
|
||||
Specie::write(os);
|
||||
dictionary dict("equationOfState");
|
||||
dict.add("rho0", rho0_);
|
||||
dict.add("T0", T0_);
|
||||
dict.add("beta", beta_);
|
||||
|
||||
os << indent << dict.dictName() << dict;
|
||||
// Entries in dictionary format
|
||||
{
|
||||
os.beginBlock("equationOfState");
|
||||
os.writeEntry("rho0", rho0_);
|
||||
os.writeEntry("T0", T0_);
|
||||
os.writeEntry("beta", beta_);
|
||||
os.endBlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -49,13 +49,15 @@ void Foam::adiabaticPerfectFluid<Specie>::write(Ostream& os) const
|
||||
{
|
||||
Specie::write(os);
|
||||
|
||||
dictionary dict("equationOfState");
|
||||
dict.add("p0", p0_);
|
||||
dict.add("rho0", rho0_);
|
||||
dict.add("gamma", gamma_);
|
||||
dict.add("B", B_);
|
||||
|
||||
os << indent << dict.dictName() << dict;
|
||||
// Entries in dictionary format
|
||||
{
|
||||
os.beginBlock("equationOfState");
|
||||
os.writeEntry("p0", p0_);
|
||||
os.writeEntry("rho0", rho0_);
|
||||
os.writeEntry("gamma", gamma_);
|
||||
os.writeEntry("B", B_);
|
||||
os.endBlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -37,13 +37,7 @@ template<class Specie, int PolySize>
|
||||
icoPolynomial<Specie, PolySize>::icoPolynomial(const dictionary& dict)
|
||||
:
|
||||
Specie(dict),
|
||||
rhoCoeffs_
|
||||
(
|
||||
dict.subDict("equationOfState").lookup
|
||||
(
|
||||
"rhoCoeffs<" + Foam::name(PolySize) + '>'
|
||||
)
|
||||
)
|
||||
rhoCoeffs_(dict.subDict("equationOfState").lookup(coeffsName("rho")))
|
||||
{}
|
||||
|
||||
|
||||
@ -54,14 +48,12 @@ void icoPolynomial<Specie, PolySize>::write(Ostream& os) const
|
||||
{
|
||||
Specie::write(os);
|
||||
|
||||
dictionary dict("equationOfState");
|
||||
dict.add
|
||||
(
|
||||
word("rhoCoeffs<" + Foam::name(PolySize) + '>'),
|
||||
rhoCoeffs_
|
||||
);
|
||||
|
||||
os << indent << dict.dictName() << dict;
|
||||
// Entries in dictionary format
|
||||
{
|
||||
os.beginBlock("equationOfState");
|
||||
os.writeEntry(coeffsName("rho"), rhoCoeffs_);
|
||||
os.endBlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -123,6 +123,15 @@ class icoPolynomial
|
||||
Polynomial<PolySize> rhoCoeffs_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Coeffs name. Eg, "rhoCoeffs<10>"
|
||||
inline static word coeffsName(const char* name)
|
||||
{
|
||||
return word(name + ("Coeffs<" + std::to_string(PolySize) + '>'));
|
||||
}
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
@ -45,10 +45,13 @@ template<class Specie>
|
||||
void Foam::incompressiblePerfectGas<Specie>::write(Ostream& os) const
|
||||
{
|
||||
Specie::write(os);
|
||||
dictionary dict("equationOfState");
|
||||
dict.add("pRef", pRef_);
|
||||
|
||||
os << indent << dict.dictName() << dict;
|
||||
// Entries in dictionary format
|
||||
{
|
||||
os.beginBlock("equationOfState");
|
||||
os.writeEntry("pRef", pRef_);
|
||||
os.endBlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -44,11 +44,13 @@ void Foam::linear<Specie>::write(Ostream& os) const
|
||||
{
|
||||
Specie::write(os);
|
||||
|
||||
dictionary dict("equationOfState");
|
||||
dict.add("psi", psi_);
|
||||
dict.add("rho0", rho0_);
|
||||
|
||||
os << indent << dict.dictName() << dict;
|
||||
// Entries in dictionary format
|
||||
{
|
||||
os.beginBlock("equationOfState");
|
||||
os.writeEntry("psi", psi_);
|
||||
os.writeEntry("rho0", rho0_);
|
||||
os.endBlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -44,11 +44,13 @@ void Foam::perfectFluid<Specie>::write(Ostream& os) const
|
||||
{
|
||||
Specie::write(os);
|
||||
|
||||
dictionary dict("equationOfState");
|
||||
dict.add("R", R_);
|
||||
dict.add("rho0", rho0_);
|
||||
|
||||
os << indent << dict.dictName() << dict;
|
||||
// Entries in dictionary format
|
||||
{
|
||||
os.beginBlock("equationOfState");
|
||||
os.writeEntry("R", R_);
|
||||
os.writeEntry("rho0", rho0_);
|
||||
os.endBlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -43,10 +43,12 @@ void Foam::rhoConst<Specie>::write(Ostream& os) const
|
||||
{
|
||||
Specie::write(os);
|
||||
|
||||
dictionary dict("equationOfState");
|
||||
dict.add("rho", rho_);
|
||||
|
||||
os << indent << dict.dictName() << dict;
|
||||
// Entries in dictionary format
|
||||
{
|
||||
os.beginBlock("equationOfState");
|
||||
os.writeEntry("rho", rho_);
|
||||
os.endBlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -39,7 +39,7 @@ namespace Foam
|
||||
Foam::specie::specie(const dictionary& dict)
|
||||
:
|
||||
name_(dict.dictName()),
|
||||
Y_(dict.subDict("specie").lookupOrDefault("massFraction", 1.0)),
|
||||
Y_(dict.subDict("specie").lookupOrDefault<scalar>("massFraction", 1)),
|
||||
molWeight_(dict.subDict("specie").get<scalar>("molWeight"))
|
||||
{}
|
||||
|
||||
@ -48,13 +48,13 @@ Foam::specie::specie(const dictionary& dict)
|
||||
|
||||
void Foam::specie::write(Ostream& os) const
|
||||
{
|
||||
dictionary dict("specie");
|
||||
if (Y_ != 1)
|
||||
// Entries in dictionary format
|
||||
{
|
||||
dict.add("massFraction", Y_);
|
||||
os.beginBlock("specie");
|
||||
os.writeEntryIfDifferent<scalar>("massFraction", 1, Y_);
|
||||
os.writeEntry("molWeight", molWeight_);
|
||||
os.endBlock();
|
||||
}
|
||||
dict.add("molWeight", molWeight_);
|
||||
os << indent << dict.dictName() << dict;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -44,10 +44,13 @@ void Foam::eConstThermo<EquationOfState>::write(Ostream& os) const
|
||||
{
|
||||
EquationOfState::write(os);
|
||||
|
||||
dictionary dict("thermodynamics");
|
||||
dict.add("Cv", Cv_);
|
||||
dict.add("Hf", Hf_);
|
||||
os << indent << dict.dictName() << dict;
|
||||
// Entries in dictionary format
|
||||
{
|
||||
os.beginBlock("thermodynamics");
|
||||
os.writeEntry("Cv", Cv_);
|
||||
os.writeEntry("Hf", Hf_);
|
||||
os.endBlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -44,10 +44,13 @@ void Foam::hConstThermo<EquationOfState>::write(Ostream& os) const
|
||||
{
|
||||
EquationOfState::write(os);
|
||||
|
||||
dictionary dict("thermodynamics");
|
||||
dict.add("Cp", Cp_);
|
||||
dict.add("Hf", Hf_);
|
||||
os << indent << dict.dictName() << dict;
|
||||
// Entries in dictionary format
|
||||
{
|
||||
os.beginBlock("thermodynamics");
|
||||
os.writeEntry("Cp", Cp_);
|
||||
os.writeEntry("Hf", Hf_);
|
||||
os.endBlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -37,13 +37,7 @@ Foam::hPolynomialThermo<EquationOfState, PolySize>::hPolynomialThermo
|
||||
EquationOfState(dict),
|
||||
Hf_(dict.subDict("thermodynamics").get<scalar>("Hf")),
|
||||
Sf_(dict.subDict("thermodynamics").get<scalar>("Sf")),
|
||||
CpCoeffs_
|
||||
(
|
||||
dict.subDict("thermodynamics").lookup
|
||||
(
|
||||
"CpCoeffs<" + Foam::name(PolySize) + '>'
|
||||
)
|
||||
),
|
||||
CpCoeffs_(dict.subDict("thermodynamics").lookup(coeffsName("Cp"))),
|
||||
hCoeffs_(),
|
||||
sCoeffs_()
|
||||
{
|
||||
@ -68,15 +62,14 @@ void Foam::hPolynomialThermo<EquationOfState, PolySize>::write
|
||||
{
|
||||
EquationOfState::write(os);
|
||||
|
||||
dictionary dict("thermodynamics");
|
||||
dict.add("Hf", Hf_);
|
||||
dict.add("Sf", Sf_);
|
||||
dict.add
|
||||
(
|
||||
word("CpCoeffs<" + Foam::name(PolySize) + '>'),
|
||||
CpCoeffs_
|
||||
);
|
||||
os << indent << dict.dictName() << dict;
|
||||
// Entries in dictionary format
|
||||
{
|
||||
os.beginBlock("thermodynamics");
|
||||
os.writeEntry("Hf", Hf_);
|
||||
os.writeEntry("Sf", Sf_);
|
||||
os.writeEntry(coeffsName("Cp"), CpCoeffs_);
|
||||
os.endBlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -148,6 +148,12 @@ class hPolynomialThermo
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Coeffs name. Eg, "CpCoeffs<10>"
|
||||
inline static word coeffsName(const char* name)
|
||||
{
|
||||
return word(name + ("Coeffs<" + std::to_string(PolySize) + '>'));
|
||||
}
|
||||
|
||||
//- Construct from components
|
||||
inline hPolynomialThermo
|
||||
(
|
||||
|
||||
@ -46,12 +46,15 @@ void Foam::hRefConstThermo<EquationOfState>::write(Ostream& os) const
|
||||
{
|
||||
EquationOfState::write(os);
|
||||
|
||||
dictionary dict("thermodynamics");
|
||||
dict.add("Cp", Cp_);
|
||||
dict.add("Hf", Hf_);
|
||||
dict.add("Tref", Tref_);
|
||||
dict.add("Href", Href_);
|
||||
os << indent << dict.dictName() << dict;
|
||||
// Entries in dictionary format
|
||||
{
|
||||
os.beginBlock("thermodynamics");
|
||||
os.writeEntry("Cp", Cp_);
|
||||
os.writeEntry("Hf", Hf_);
|
||||
os.writeEntry("Tref", Tref_);
|
||||
os.writeEntry("Href", Href_);
|
||||
os.endBlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -93,13 +93,16 @@ void Foam::janafThermo<EquationOfState>::write(Ostream& os) const
|
||||
lowCpCoeffs[coefLabel] = lowCpCoeffs_[coefLabel]/this->R();
|
||||
}
|
||||
|
||||
dictionary dict("thermodynamics");
|
||||
dict.add("Tlow", Tlow_);
|
||||
dict.add("Thigh", Thigh_);
|
||||
dict.add("Tcommon", Tcommon_);
|
||||
dict.add("highCpCoeffs", highCpCoeffs);
|
||||
dict.add("lowCpCoeffs", lowCpCoeffs);
|
||||
os << indent << dict.dictName() << dict;
|
||||
// Entries in dictionary format
|
||||
{
|
||||
os.beginBlock("thermodynamics");
|
||||
os.writeEntry("Tlow", Tlow_);
|
||||
os.writeEntry("Thigh", Thigh_);
|
||||
os.writeEntry("Tcommon", Tcommon_);
|
||||
os.writeEntry("highCpCoeffs", highCpCoeffs);
|
||||
os.writeEntry("lowCpCoeffs", lowCpCoeffs);
|
||||
os.endBlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -35,20 +35,8 @@ Foam::logPolynomialTransport<Thermo, PolySize>::logPolynomialTransport
|
||||
)
|
||||
:
|
||||
Thermo(dict),
|
||||
muCoeffs_
|
||||
(
|
||||
dict.subDict("transport").lookup
|
||||
(
|
||||
"muLogCoeffs<" + Foam::name(PolySize) + '>'
|
||||
)
|
||||
),
|
||||
kappaCoeffs_
|
||||
(
|
||||
dict.subDict("transport").lookup
|
||||
(
|
||||
"kappaLogCoeffs<" + Foam::name(PolySize) + '>'
|
||||
)
|
||||
)
|
||||
muCoeffs_(dict.subDict("transport").lookup(coeffsName("mu"))),
|
||||
kappaCoeffs_(dict.subDict("transport").lookup(coeffsName("kappa")))
|
||||
{}
|
||||
|
||||
|
||||
@ -64,16 +52,8 @@ void Foam::logPolynomialTransport<Thermo, PolySize>::write(Ostream& os) const
|
||||
// Entries in dictionary format
|
||||
{
|
||||
os.beginBlock("transport");
|
||||
os.writeEntry
|
||||
(
|
||||
word("muLogCoeffs<" + Foam::name(PolySize) + '>'),
|
||||
muCoeffs_
|
||||
);
|
||||
os.writeEntry
|
||||
(
|
||||
word("kappaLogCoeffs<" + Foam::name(PolySize) + '>'),
|
||||
kappaCoeffs_
|
||||
);
|
||||
os.writeEntry(coeffsName("mu"), muCoeffs_);
|
||||
os.writeEntry(coeffsName("kappa"), kappaCoeffs_);
|
||||
os.endBlock();
|
||||
}
|
||||
|
||||
|
||||
@ -139,6 +139,12 @@ class logPolynomialTransport
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Coeffs name. Eg, "muLogCoeffs<10>"
|
||||
inline static word coeffsName(const char* name)
|
||||
{
|
||||
return word(name + ("LogCoeffs<" + std::to_string(PolySize) + '>'));
|
||||
}
|
||||
|
||||
//- Construct from components
|
||||
inline logPolynomialTransport
|
||||
(
|
||||
|
||||
@ -35,20 +35,8 @@ Foam::polynomialTransport<Thermo, PolySize>::polynomialTransport
|
||||
)
|
||||
:
|
||||
Thermo(dict),
|
||||
muCoeffs_
|
||||
(
|
||||
dict.subDict("transport").lookup
|
||||
(
|
||||
"muCoeffs<" + Foam::name(PolySize) + '>'
|
||||
)
|
||||
),
|
||||
kappaCoeffs_
|
||||
(
|
||||
dict.subDict("transport").lookup
|
||||
(
|
||||
"kappaCoeffs<" + Foam::name(PolySize) + '>'
|
||||
)
|
||||
)
|
||||
muCoeffs_(dict.subDict("transport").lookup(coeffsName("mu"))),
|
||||
kappaCoeffs_(dict.subDict("transport").lookup(coeffsName("kappa")))
|
||||
{}
|
||||
|
||||
|
||||
@ -64,16 +52,8 @@ void Foam::polynomialTransport<Thermo, PolySize>::write(Ostream& os) const
|
||||
// Entries in dictionary format
|
||||
{
|
||||
os.beginBlock("transport");
|
||||
os.writeEntry
|
||||
(
|
||||
word("muCoeffs<" + Foam::name(PolySize) + '>'),
|
||||
muCoeffs_
|
||||
);
|
||||
os.writeEntry
|
||||
(
|
||||
word("kappaCoeffs<" + Foam::name(PolySize) + '>'),
|
||||
kappaCoeffs_
|
||||
);
|
||||
os.writeEntry(coeffsName("mu"), muCoeffs_);
|
||||
os.writeEntry(coeffsName("kappa"), kappaCoeffs_);
|
||||
os.endBlock();
|
||||
}
|
||||
|
||||
|
||||
@ -128,6 +128,12 @@ class polynomialTransport
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Coeffs name. Eg, "muCoeffs<10>"
|
||||
inline static word coeffsName(const char* name)
|
||||
{
|
||||
return word(name + ("Coeffs<" + std::to_string(PolySize) + '>'));
|
||||
}
|
||||
|
||||
//- Construct from components
|
||||
inline polynomialTransport
|
||||
(
|
||||
|
||||
Reference in New Issue
Block a user