ENH: Added write(Ostream&) function and implemented across libspecie

This commit is contained in:
andy
2010-10-13 17:56:46 +01:00
parent a8a7b0a5b4
commit 0f3f3bc6b8
58 changed files with 579 additions and 129 deletions

View File

@ -53,6 +53,17 @@ icoPolynomial<PolySize>::icoPolynomial(const dictionary& dict)
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<int PolySize>
void icoPolynomial<PolySize>::write(Ostream& os) const
{
specie::write(os);
os.writeKeyword("rhoPolynomial") << rhoPolynomial_/this->W()
<< token::END_STATEMENT << nl;
}
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
template<int PolySize>

View File

@ -138,14 +138,22 @@ public:
// Member functions
//- Return density [kg/m^3]
inline scalar rho(scalar p, scalar T) const;
// Fundamental properties
//- Return compressibility rho/p [s^2/m^2]
inline scalar psi(scalar p, scalar T) const;
//- Return density [kg/m^3]
inline scalar rho(scalar p, scalar T) const;
//- Return compression factor []
inline scalar Z(scalar p, scalar T) const;
//- Return compressibility rho/p [s^2/m^2]
inline scalar psi(scalar p, scalar T) const;
//- Return compression factor []
inline scalar Z(scalar p, scalar T) const;
// I-O
//- Write to Ostream
void write(Ostream& os) const;
// Member operators

View File

@ -47,6 +47,14 @@ perfectGas::perfectGas(const dictionary& dict)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void perfectGas::write(Ostream& os) const
{
specie::write(os);
}
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
Ostream& operator<<(Ostream& os, const perfectGas& pg)

View File

@ -81,14 +81,22 @@ public:
// Member functions
//- Return density [kg/m^3]
inline scalar rho(scalar p, scalar T) const;
// Fundamental properties
//- Return compressibility rho/p [s^2/m^2]
inline scalar psi(scalar p, scalar T) const;
//- Return density [kg/m^3]
inline scalar rho(scalar p, scalar T) const;
//- Return compression factor []
inline scalar Z(scalar p, scalar T) const;
//- Return compressibility rho/p [s^2/m^2]
inline scalar psi(scalar p, scalar T) const;
//- Return compression factor []
inline scalar Z(scalar p, scalar T) const;
// I-O
//- Write to Ostream
void write(Ostream& os) const;
// Member operators

View File

@ -98,7 +98,7 @@ void Foam::IrreversibleReaction<ReactionThermo, ReactionRate>::write
) const
{
Reaction<ReactionThermo>::write(os);
os << token::SPACE << k_;
k_.write(os);
}

View File

@ -136,7 +136,8 @@ void Foam::NonEquilibriumReversibleReaction<ReactionThermo, ReactionRate>::write
) const
{
Reaction<ReactionThermo>::write(os);
os << token::SPACE << fk_ << token::SPACE << rk_;
fk_.write(os);
rk_.write(os);
}

View File

@ -26,6 +26,53 @@ License
#include "Reaction.H"
#include "DynamicList.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class ReactionThermo>
Foam::string Foam::Reaction<ReactionThermo>::reactionStr() const
{
OStringStream reaction;
for (label i = 0; i < lhs_.size(); i++)
{
if (i > 0)
{
reaction << " + ";
}
if (mag(lhs_[i].stoichCoeff - 1) > SMALL)
{
reaction << lhs_[i].stoichCoeff;
}
reaction << species_[lhs_[i].index];
if (mag(lhs_[i].exponent - lhs_[i].stoichCoeff) > SMALL)
{
reaction << "^" << lhs_[i].exponent;
}
}
reaction << " = ";
for (label i = 0; i < rhs_.size(); i++)
{
if (i > 0)
{
reaction << " + ";
}
if (mag(rhs_[i].stoichCoeff - 1) > SMALL)
{
reaction << rhs_[i].stoichCoeff;
}
reaction << species_[rhs_[i].index];
if (mag(rhs_[i].exponent - rhs_[i].stoichCoeff) > SMALL)
{
reaction << "^" << rhs_[i].exponent;
}
}
return reaction.str();
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class ReactionThermo>
@ -207,7 +254,7 @@ Foam::Reaction<ReactionThermo>::Reaction
ReactionThermo(*thermoDatabase[species[0]]),
species_(species)
{
setLRhs(IStringStream(dict.lookup("reaction"))());
setLRhs(dict.lookup("reaction"));
setThermo(thermoDatabase);
}
@ -305,55 +352,7 @@ Foam::Reaction<ReactionThermo>::New
template<class ReactionThermo>
void Foam::Reaction<ReactionThermo>::write(Ostream& os) const
{
os << type() << nl << " ";
forAll(lhs_, i)
{
const typename Reaction<ReactionThermo>::specieCoeffs& sc = lhs_[i];
if (sc.stoichCoeff != 1)
{
os << sc.stoichCoeff;
}
os << species_[sc.index];
if (sc.exponent != sc.stoichCoeff)
{
os << '^' << sc.exponent;
}
if (i < lhs_.size() - 1)
{
os << " + ";
}
}
os << " = ";
forAll(rhs_, i)
{
const typename Reaction<ReactionThermo>::specieCoeffs& sc = rhs_[i];
if (sc.stoichCoeff != 1)
{
os << sc.stoichCoeff;
}
os << species_[sc.index];
if (sc.exponent != sc.stoichCoeff)
{
os << '^' << sc.exponent;
}
if (i < rhs_.size() - 1)
{
os << " + ";
}
}
os << endl << " ";
os.writeKeyword("reaction") << reactionStr() << token::END_STATEMENT << nl;
}

View File

@ -124,7 +124,13 @@ private:
// Private Member Functions
//- Return string representation of reaction
string reactionStr() const;
//- Construct the left- and right-hand-side reaction coefficients
void setLRhs(Istream&);
//- Construct reaction thermo
void setThermo(const HashPtrTable<ReactionThermo>& thermoDatabase);
//- Disallow default bitwise assignment

View File

@ -53,7 +53,56 @@ Reaction<ReactionThermo>::rhs() const
template<class ReactionThermo>
inline Ostream& operator<<(Ostream& os, const Reaction<ReactionThermo>& r)
{
r.write(os);
os << r.type() << nl << " ";
forAll(r.lhs_, i)
{
const typename Reaction<ReactionThermo>::specieCoeffs& sc = r.lhs_[i];
if (sc.stoichCoeff != 1)
{
os << sc.stoichCoeff;
}
os << r.species_[sc.index];
if (sc.exponent != sc.stoichCoeff)
{
os << '^' << sc.exponent;
}
if (i < r.lhs_.size() - 1)
{
os << " + ";
}
}
os << " = ";
forAll(r.rhs_, i)
{
const typename Reaction<ReactionThermo>::specieCoeffs& sc = r.rhs_[i];
if (sc.stoichCoeff != 1)
{
os << sc.stoichCoeff;
}
os << r.species_[sc.index];
if (sc.exponent != sc.stoichCoeff)
{
os << '^' << sc.exponent;
}
if (i < r.rhs_.size() - 1)
{
os << " + ";
}
}
os << endl << " ";
return os;
}

View File

@ -120,4 +120,23 @@ bool Foam::ReactionList<ThermoType>::readReactionDict()
}
template<class ThermoType>
void Foam::ReactionList<ThermoType>::write(Ostream& os) const
{
os << "reactions" << nl;
os << token::BEGIN_BLOCK << incrIndent << nl;
forAllConstIter(typename SLPtrList<Reaction<ThermoType> >, *this, iter)
{
const Reaction<ThermoType>& r = iter();
os << indent << r.type() << nl
<< indent << token::BEGIN_BLOCK << incrIndent << nl;
r.write(os);
os << decrIndent << indent << token::END_BLOCK << nl;
}
os << decrIndent << token::END_BLOCK << nl;
}
// ************************************************************************* //

View File

@ -113,6 +113,9 @@ public:
//- Read reactions from dictionary
bool readReactionDict();
//- Write
void write(Ostream& os) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -123,7 +123,7 @@ void Foam::ReversibleReaction<ReactionThermo, ReactionRate>::write
) const
{
Reaction<ReactionThermo>::write(os);
os << token::SPACE << k_;
k_.write(os);
}

View File

@ -100,6 +100,9 @@ public:
const scalarField& c
) const;
//- Write to stream
inline void write(Ostream& os) const;
// Ostream Operator

View File

@ -89,6 +89,14 @@ inline Foam::scalar Foam::ArrheniusReactionRate::operator()
}
inline void Foam::ArrheniusReactionRate::write(Ostream& os) const
{
os.writeKeyword("A") << A_ << token::END_STATEMENT << nl;
os.writeKeyword("beta") << beta_ << token::END_STATEMENT << nl;
os.writeKeyword("Ta") << Ta_ << token::END_STATEMENT << nl;
}
inline Foam::Ostream& Foam::operator<<
(
Ostream& os,

View File

@ -116,6 +116,9 @@ public:
const scalarField& c
) const;
//- Write to stream
inline void write(Ostream& os) const;
// Ostream Operator

View File

@ -106,6 +106,20 @@ inline Foam::scalar Foam::ChemicallyActivatedReactionRate
}
template<class ReactionRate, class ChemicallyActivationFunction>
inline void Foam::ChemicallyActivatedReactionRate
<
ReactionRate,
ChemicallyActivationFunction
>::write(Ostream& os) const
{
k0_.write(os);
kInf_.write(os);
F_.write(os);
thirdBodyEfficiencies_.write(os);
}
template<class ReactionRate, class ChemicallyActivationFunction>
inline Foam::Ostream& Foam::operator<<
(

View File

@ -56,7 +56,7 @@ inline Ostream& operator<<
/*---------------------------------------------------------------------------*\
Class FallOffReactionRate Declaration
Class FallOffReactionRate Declaration
\*---------------------------------------------------------------------------*/
template<class ReactionRate, class FallOffFunction>
@ -113,6 +113,9 @@ public:
const scalarField& c
) const;
//- Write to stream
inline void write(Ostream& os) const;
// Ostream Operator

View File

@ -94,6 +94,19 @@ Foam::FallOffReactionRate<ReactionRate, FallOffFunction>::operator()
}
template<class ReactionRate, class FallOffFunction>
inline void Foam::FallOffReactionRate<ReactionRate, FallOffFunction>::write
(
Ostream& os
) const
{
k0_.write(os);
kInf_.write(os);
F_.write(os);
thirdBodyEfficiencies_.write(os);
}
template<class ReactionRate, class FallOffFunction>
inline Foam::Ostream& Foam::operator<<
(

View File

@ -103,6 +103,9 @@ public:
const scalarField& c
) const;
//- Write to stream
inline void write(Ostream& os) const;
// Ostream Operator

View File

@ -104,6 +104,15 @@ inline Foam::scalar Foam::JanevReactionRate::operator()
}
inline void Foam::JanevReactionRate::write(Ostream& os) const
{
os.writeKeyword("A") << A_ << nl;
os.writeKeyword("beta") << beta_ << nl;
os.writeKeyword("Ta") << Ta_ << nl;
os.writeKeyword("b") << b_ << nl;
}
inline Foam::Ostream& Foam::operator<<
(
Ostream& os,

View File

@ -44,7 +44,7 @@ namespace Foam
{
/*---------------------------------------------------------------------------*\
Class LandauTellerReactionRate Declaration
Class LandauTellerReactionRate Declaration
\*---------------------------------------------------------------------------*/
class LandauTellerReactionRate
@ -57,6 +57,7 @@ class LandauTellerReactionRate
scalar B_;
scalar C_;
public:
// Constructors
@ -101,6 +102,9 @@ public:
const scalarField& c
) const;
//- Write to stream
inline void write(Ostream& os) const;
// Ostream Operator

View File

@ -114,6 +114,16 @@ inline Foam::scalar Foam::LandauTellerReactionRate::operator()
}
inline void Foam::LandauTellerReactionRate::write(Ostream& os) const
{
os.writeKeyword("A") << A_ << token::END_STATEMENT << nl;
os.writeKeyword("beta") << beta_ << token::END_STATEMENT << nl;
os.writeKeyword("Ta") << Ta_ << token::END_STATEMENT << nl;
os.writeKeyword("B") << B_ << token::END_STATEMENT << nl;
os.writeKeyword("C") << C_ << token::END_STATEMENT << nl;
}
inline Foam::Ostream& Foam::operator<<
(
Ostream& os,

View File

@ -104,6 +104,9 @@ public:
const scalarField& c
) const;
//- Write to stream
inline void write(Ostream& os) const;
// Ostream Operator

View File

@ -110,6 +110,20 @@ inline Foam::scalar Foam::LangmuirHinshelwoodReactionRate::operator()
}
inline void Foam::LangmuirHinshelwoodReactionRate::write(Ostream& os) const
{
FixedList<Tuple2<scalar, scalar>, n_> coeffs;
forAll(coeffs, i)
{
coeffs[i].first() = A_[i];
coeffs[i].second() = Ta_[i];
}
os.writeKeyword("coeffs") << coeffs << nl;
}
inline Foam::Ostream& Foam::operator<<
(
Ostream& os,

View File

@ -49,7 +49,7 @@ Ostream& operator<<(Ostream&, const LindemannFallOffFunction&);
/*---------------------------------------------------------------------------*\
Class LindemannFallOffFunction Declaration
Class LindemannFallOffFunction Declaration
\*---------------------------------------------------------------------------*/
class LindemannFallOffFunction
@ -83,6 +83,9 @@ public:
const scalar Pr
) const;
//- Write to stream
inline void write(Ostream& os) const;
// Ostream Operator

View File

@ -52,6 +52,10 @@ inline Foam::scalar Foam::LindemannFallOffFunction::operator()
}
inline void Foam::LindemannFallOffFunction::write(Ostream& os) const
{}
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
inline Foam::Ostream& Foam::operator<<

View File

@ -49,7 +49,7 @@ Ostream& operator<<(Ostream&, const SRIFallOffFunction&);
/*---------------------------------------------------------------------------*\
Class SRIFallOffFunction Declaration
Class SRIFallOffFunction Declaration
\*---------------------------------------------------------------------------*/
class SRIFallOffFunction
@ -94,6 +94,9 @@ public:
const scalar Pr
) const;
//- Write to stream
inline void write(Ostream& os) const;
// Ostream Operator

View File

@ -77,6 +77,16 @@ inline Foam::scalar Foam::SRIFallOffFunction::operator()
}
inline void Foam::SRIFallOffFunction::write(Ostream& os) const
{
os.writeKeyword("a") << a_ << token::END_STATEMENT << nl;
os.writeKeyword("b") << b_ << token::END_STATEMENT << nl;
os.writeKeyword("c") << c_ << token::END_STATEMENT << nl;
os.writeKeyword("d") << d_ << token::END_STATEMENT << nl;
os.writeKeyword("e") << e_ << token::END_STATEMENT << nl;
}
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
inline Foam::Ostream& Foam::operator<<

View File

@ -49,7 +49,7 @@ Ostream& operator<<(Ostream&, const TroeFallOffFunction&);
/*---------------------------------------------------------------------------*\
Class TroeFallOffFunction Declaration
Class TroeFallOffFunction Declaration
\*---------------------------------------------------------------------------*/
class TroeFallOffFunction
@ -94,6 +94,9 @@ public:
const scalar Pr
) const;
//- Write to stream
inline void write(Ostream& os) const;
// Ostream Operator

View File

@ -86,6 +86,15 @@ inline Foam::scalar Foam::TroeFallOffFunction::operator()
}
inline void Foam::TroeFallOffFunction::write(Ostream& os) const
{
os.writeKeyword("alpha") << alpha_ << token::END_STATEMENT << nl;
os.writeKeyword("Tsss") << Tsss_ << token::END_STATEMENT << nl;
os.writeKeyword("Ts") << Ts_ << token::END_STATEMENT << nl;
os.writeKeyword("Tss") << Tss_ << token::END_STATEMENT << nl;
}
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
inline Foam::Ostream& Foam::operator<<

View File

@ -45,7 +45,7 @@ namespace Foam
{
/*---------------------------------------------------------------------------*\
Class powerSeriesReactionRate Declaration
Class powerSeriesReactionRate Declaration
\*---------------------------------------------------------------------------*/
class powerSeriesReactionRate
@ -103,6 +103,9 @@ public:
const scalarField& c
) const;
//- Write to stream
inline void write(Ostream& os) const;
// Ostream Operator

View File

@ -97,6 +97,15 @@ inline Foam::scalar Foam::powerSeriesReactionRate::operator()
}
inline void Foam::powerSeriesReactionRate::write(Ostream& os) const
{
os.writeKeyword("A") << A_ << token::END_STATEMENT << nl;
os.writeKeyword("beta") << beta_ << token::END_STATEMENT << nl;
os.writeKeyword("Ta") << Ta_ << token::END_STATEMENT << nl;
os.writeKeyword("b") << b_ << token::END_STATEMENT << nl;
}
inline Foam::Ostream& Foam::operator<<
(
Ostream& os,

View File

@ -99,6 +99,9 @@ public:
const scalarField& c
) const;
//- Write to stream
inline void write(Ostream& os) const;
// Ostream Operator

View File

@ -85,6 +85,13 @@ inline Foam::scalar Foam::thirdBodyArrheniusReactionRate::operator()
}
inline void Foam::thirdBodyArrheniusReactionRate::write(Ostream& os) const
{
ArrheniusReactionRate::write(os);
thirdBodyEfficiencies_.write(os);
}
inline Foam::Ostream& Foam::operator<<
(
Ostream& os,

View File

@ -93,6 +93,10 @@ public:
//- Calculate and return M, the concentration of the third-bodies
inline scalar M(const scalarList& c) const;
//- Write to stream
inline void write(Ostream& os) const;
// Ostream Operator

View File

@ -161,6 +161,19 @@ inline Foam::scalar Foam::thirdBodyEfficiencies::M(const scalarList& c) const
}
inline void Foam::thirdBodyEfficiencies::write(Ostream& os) const
{
List<Tuple2<word, scalar> > coeffs(species_.size());
forAll(coeffs, i)
{
coeffs[i].first() = species_[i];
coeffs[i].second() = operator[](i);
}
os.writeKeyword("coeffs") << coeffs << token::END_STATEMENT << nl;
}
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
inline Foam::Ostream& Foam::operator<<

View File

@ -59,6 +59,15 @@ Foam::specie::specie(const dictionary& dict)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::specie::write(Ostream& os) const
{
os.writeKeyword("nMoles") << nMoles_ << token::END_STATEMENT << nl;
os.writeKeyword("molWeight") << molWeight_ << token::END_STATEMENT << nl;
}
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
Foam::Ostream& Foam::operator<<(Ostream& os, const specie& st)

View File

@ -115,6 +115,9 @@ public:
// Access
//- Name
inline const word& name() const;
//- Molecular weight [kg/kmol]
inline scalar W() const;
@ -125,6 +128,12 @@ public:
inline scalar R() const;
// I-O
//- Write to Ostream
void write(Ostream& os) const;
// Member operators
inline void operator=(const specie&);

View File

@ -32,7 +32,6 @@ namespace Foam
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// Construct from components
inline specie::specie
(
const word& name,
@ -46,7 +45,6 @@ inline specie::specie
{}
// Construct from components without name
inline specie::specie
(
const scalar nMoles,
@ -60,7 +58,6 @@ inline specie::specie
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct as copy
inline specie::specie(const specie& st)
:
name_(st.name_),
@ -69,7 +66,6 @@ inline specie::specie(const specie& st)
{}
// Construct as named copy
inline specie::specie(const word& name, const specie& st)
:
name_(name),
@ -80,19 +76,24 @@ inline specie::specie(const word& name, const specie& st)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
//- Molecular weight [kg/kmol]
inline const word& specie::name() const
{
return name_;
}
inline scalar specie::W() const
{
return molWeight_;
}
//- No of moles of this species in mixture
inline scalar specie::nMoles() const
{
return nMoles_;
}
//- Gas constant [J/(kg K)]
inline scalar specie::R() const
{
return RR/molWeight_;
@ -103,7 +104,7 @@ inline scalar specie::R() const
inline void specie::operator=(const specie& st)
{
//name_ = st.name_;
//name_ = st.name_;
nMoles_ = st.nMoles_;
molWeight_ = st.molWeight_;
}

View File

@ -48,6 +48,17 @@ Foam::eConstThermo<equationOfState>::eConstThermo(const dictionary& dict)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class equationOfState>
void Foam::eConstThermo<equationOfState>::write(Ostream& os) const
{
equationOfState::write(os);
os.writeKeyword("Cv") << Cv_ << token::END_STATEMENT << nl;
os.writeKeyword("Hf") << Hf_ << token::END_STATEMENT << nl;
}
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
template<class equationOfState>

View File

@ -135,7 +135,7 @@ public:
// Member Functions
// Fundamaental properties
// Fundamental properties
//- Heat capacity at constant pressure [J/(kmol K)]
inline scalar cp(const scalar T) const;
@ -153,6 +153,12 @@ public:
inline scalar s(const scalar T) const;
// I-O
//- Write to Ostream
void write(Ostream& os) const;
// Member operators
inline void operator+=(const eConstThermo&);

View File

@ -48,6 +48,17 @@ Foam::hConstThermo<equationOfState>::hConstThermo(const dictionary& dict)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class equationOfState>
void Foam::hConstThermo<equationOfState>::write(Ostream& os) const
{
equationOfState::write(os);
os.writeKeyword("Cp") << Cp_ << token::END_STATEMENT << nl;
os.writeKeyword("Hf") << Hf_ << token::END_STATEMENT << nl;
}
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
template<class equationOfState>

View File

@ -133,7 +133,7 @@ public:
// Member Functions
// Fundamaental properties
// Fundamental properties
//- Heat capacity at constant pressure [J/(kmol K)]
inline scalar cp(const scalar T) const;
@ -151,6 +151,12 @@ public:
inline scalar s(const scalar T) const;
// I-O
//- Write to Ostream
void write(Ostream& os) const;
// Member operators
inline void operator+=(const hConstThermo&);

View File

@ -84,6 +84,22 @@ Foam::hPolynomialThermo<EquationOfState, PolySize>::hPolynomialThermo
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class EquationOfState, int PolySize>
void Foam::hPolynomialThermo<EquationOfState, PolySize>::write
(
Ostream& os
) const
{
EquationOfState::write(os);
os.writeKeyword("Hf") << Hf_ << token::END_STATEMENT << nl;
os.writeKeyword("Sf") << Sf_ << token::END_STATEMENT << nl;
os.writeKeyword("cpPolynomial") << cpPolynomial_/this->W()
<< token::END_STATEMENT << nl;
}
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
template<class EquationOfState, int PolySize>

View File

@ -150,20 +150,28 @@ public:
// Member Functions
//- Heat capacity at constant pressure [J/(kmol K)]
inline scalar cp(const scalar T) const;
// Fundamental properties
//- Enthalpy [J/kmol]
inline scalar h(const scalar T) const;
//- Heat capacity at constant pressure [J/(kmol K)]
inline scalar cp(const scalar T) const;
//- Sensible enthalpy [J/kmol]
inline scalar hs(const scalar T) const;
//- Enthalpy [J/kmol]
inline scalar h(const scalar T) const;
//- Chemical enthalpy [J/kmol]
inline scalar hc() const;
//- Sensible enthalpy [J/kmol]
inline scalar hs(const scalar T) const;
//- Entropy [J/(kmol K)]
inline scalar s(const scalar T) const;
//- Chemical enthalpy [J/kmol]
inline scalar hc() const;
//- Entropy [J/(kmol K)]
inline scalar s(const scalar T) const;
// I-O
//- Write to Ostream
void write(Ostream& os) const;
// Member operators

View File

@ -95,6 +95,22 @@ Foam::janafThermo<equationOfState>::janafThermo(const dictionary& dict)
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class equationOfState>
void Foam::janafThermo<equationOfState>::write(Ostream& os) const
{
equationOfState::write(os);
os.writeKeyword("Tlow") << Tlow_ << token::END_STATEMENT << endl;
os.writeKeyword("Thigh") << Thigh_ << token::END_STATEMENT << endl;
os.writeKeyword("Tcommon") << Tcommon_ << token::END_STATEMENT << endl;
os.writeKeyword("highCpCoeffs") << highCpCoeffs_ << token::END_STATEMENT
<< endl;
os.writeKeyword("lowCpCoeffs") << lowCpCoeffs_ << token::END_STATEMENT
<< endl;
}
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
template<class equationOfState>

View File

@ -153,20 +153,28 @@ public:
// Member Functions
//- Heat capacity at constant pressure [J/(kmol K)]
inline scalar cp(const scalar T) const;
// Fundamental properties
//- Enthalpy [J/kmol]
inline scalar h(const scalar T) const;
//- Heat capacity at constant pressure [J/(kmol K)]
inline scalar cp(const scalar T) const;
//- Sensible enthalpy [J/kmol]
inline scalar hs(const scalar T) const;
//- Enthalpy [J/kmol]
inline scalar h(const scalar T) const;
//- Chemical enthalpy [J/kmol]
inline scalar hc() const;
//- Sensible enthalpy [J/kmol]
inline scalar hs(const scalar T) const;
//- Entropy [J/(kmol K)]
inline scalar s(const scalar T) const;
//- Chemical enthalpy [J/kmol]
inline scalar hc() const;
//- Entropy [J/(kmol K)]
inline scalar s(const scalar T) const;
// I-O
//- Write to Ostream
void write(Ostream& os) const;
// Member operators

View File

@ -53,6 +53,15 @@ Foam::specieThermo<thermo>::specieThermo(const dictionary& dict)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class thermo>
void Foam::specieThermo<thermo>::write(Ostream& os) const
{
thermo::write(os);
}
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
template<class thermo>

View File

@ -251,6 +251,12 @@ public:
inline scalar TE(const scalar E, const scalar T0) const;
// I-O
//- Write to Ostream
void write(Ostream& os) const;
// Member operators
inline void operator+=(const specieThermo&);

View File

@ -37,8 +37,8 @@ template<class thermo>
constTransport<thermo>::constTransport(Istream& is)
:
thermo(is),
Mu(readScalar(is)),
rPr(1.0/readScalar(is))
Mu_(readScalar(is)),
rPr_(1.0/readScalar(is))
{
is.check("constTransport::constTransport(Istream& is)");
}
@ -48,18 +48,32 @@ template<class thermo>
constTransport<thermo>::constTransport(const dictionary& dict)
:
thermo(dict),
Mu(readScalar(dict.lookup("Mu"))),
rPr(1.0/readScalar(dict.lookup("Pr")))
Mu_(readScalar(dict.lookup("Mu"))),
rPr_(1.0/readScalar(dict.lookup("Pr")))
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class thermo>
void constTransport<thermo>::constTransport::write(Ostream& os) const
{
os << this->name() << endl;
os << token::BEGIN_BLOCK << incrIndent << nl;
thermo::write(os);
os.writeKeyword("Mu") << Mu_ << token::END_STATEMENT << nl;
os.writeKeyword("Pr") << Mu_ << token::END_STATEMENT << nl;
os << decrIndent << token::END_BLOCK << nl;
}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
template<class thermo>
Ostream& operator<<(Ostream& os, const constTransport<thermo>& ct)
{
operator<<(os, static_cast<const thermo&>(ct));
os << tab << ct.Mu << tab << 1.0/ct.rPr;
os << tab << ct.Mu_ << tab << 1.0/ct.rPr_;
os.check("Ostream& operator<<(Ostream& os, const constTransport& ct)");

View File

@ -94,8 +94,11 @@ class constTransport
{
// Private data
//- Constant viscosity and reciprocal Prandtl Number.
scalar Mu, rPr;
//- Constant viscosity [Pa.s]
scalar Mu_;
//- Reciprocal Prandtl Number []
scalar rPr_;
// Private Member Functions
@ -137,6 +140,9 @@ public:
// Species diffusivity
//inline scalar D(const scalar T) const;
//- Write to Ostream
void write(Ostream& os) const;
// Member operators

View File

@ -30,7 +30,6 @@ namespace Foam
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
template<class thermo>
inline constTransport<thermo>::constTransport
(
@ -40,12 +39,11 @@ inline constTransport<thermo>::constTransport
)
:
thermo(t),
Mu(mu),
rPr(1.0/Pr)
Mu_(mu),
rPr_(1.0/Pr)
{}
// Construct as named copy
template<class thermo>
inline constTransport<thermo>::constTransport
(
@ -54,30 +52,27 @@ inline constTransport<thermo>::constTransport
)
:
thermo(name, ct),
Mu(ct.Mu),
rPr(ct.rPr)
Mu_(ct.Mu_),
rPr_(ct.rPr_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// Dynamic viscosity [kg/ms]
template<class thermo>
inline scalar constTransport<thermo>::mu(const scalar) const
{
return Mu;
return Mu_;
}
// Thermal conductivity [W/mK]
template<class thermo>
inline scalar constTransport<thermo>::kappa(const scalar T) const
{
return this->Cp(T)*mu(T)*rPr;
return this->Cp(T)*mu(T)*rPr_;
}
// Thermal diffusivity for enthalpy [kg/ms]
template<class thermo>
inline scalar constTransport<thermo>::alpha(const scalar T) const
{
@ -87,7 +82,7 @@ inline scalar constTransport<thermo>::alpha(const scalar T) const
scalar CpBar =
(deltaT*(this->H(T) - this->H(specie::Tstd)) + Cp_)/(sqr(deltaT) + 1);
return Cp_*mu(T)*rPr/CpBar;
return Cp_*mu(T)*rPr_/CpBar;
}
@ -101,8 +96,8 @@ inline constTransport<thermo>& constTransport<thermo>::operator=
{
thermo::operator=(ct);
Mu = ct.Mu;
rPr = ct.rPr;
Mu_ = ct.Mu_;
rPr_ = ct.rPr_;
return *this;
}
@ -128,8 +123,8 @@ inline constTransport<thermo> operator+
return constTransport<thermo>
(
t,
molr1*ct1.Mu + molr2*ct2.Mu,
molr1*ct1.rPr + molr2*ct2.rPr
molr1*ct1.Mu_ + molr2*ct2.Mu_,
molr1*ct1.rPr_ + molr2*ct2.rPr_
);
}
@ -152,8 +147,8 @@ inline constTransport<thermo> operator-
return constTransport<thermo>
(
t,
molr1*ct1.Mu - molr2*ct2.Mu,
molr1*ct1.rPr - molr2*ct2.rPr
molr1*ct1.Mu_ - molr2*ct2.Mu_,
molr1*ct1.rPr_ - molr2*ct2.rPr_
);
}
@ -168,8 +163,8 @@ inline constTransport<thermo> operator*
return constTransport<thermo>
(
s*static_cast<const thermo&>(ct),
ct.Mu,
ct.rPr
ct.Mu_,
ct.rPr_
);
}

View File

@ -55,6 +55,22 @@ Foam::polynomialTransport<Thermo, PolySize>::polynomialTransport
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Thermo, int PolySize>
void Foam::polynomialTransport<Thermo, PolySize>::write(Ostream& os) const
{
os << this->name() << endl;
os << token::BEGIN_BLOCK << incrIndent << nl;
Thermo::write(os);
os.writeKeyword("muPolynomial") << muPolynomial_/this->W()
<< token::END_STATEMENT << nl;
os.writeKeyword("kappaPolynomial") << kappaPolynomial_/this->W()
<< token::END_STATEMENT << nl;
os << decrIndent << token::END_BLOCK << nl;
}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
template<class Thermo, int PolySize>

View File

@ -154,6 +154,9 @@ public:
// Species diffusivity
//inline scalar D(const scalar T) const;
//- Write to Ostream
void write(Ostream& os) const;
// Member operators

View File

@ -50,6 +50,17 @@ speciesTransport::speciesTransport(const dictionary& dict)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void speciesTransport::write(Ostream& os) const
{
os << this->name() << endl;
os << token::BEGIN_BLOCK << incrIndent << nl;
janafThermo::write(os);
os << decrIndent << token::END_BLOCK << nl;
}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
Ostream& operator<<(Ostream& os, const speciesTransport& sTranport)

View File

@ -87,6 +87,9 @@ public:
// Species diffusivity
//inline scalar D(const scalar T) const;
//- Write to Ostream
void write(Ostream& os) const;
// Ostream Operator

View File

@ -53,6 +53,19 @@ sutherlandTransport<thermo>::sutherlandTransport(const dictionary& dict)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class thermo>
void sutherlandTransport<thermo>::write(Ostream& os) const
{
os << this->name() << endl;
os << token::BEGIN_BLOCK << incrIndent << nl;
thermo::write(os);
os.writeKeyword("As") << As_ << token::END_STATEMENT << nl;
os.writeKeyword("Ts") << As_ << token::END_STATEMENT << nl;
os << decrIndent << token::END_BLOCK << nl;
}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
template<class thermo>

View File

@ -168,6 +168,9 @@ public:
// Species diffusivity
//inline scalar D(const scalar T) const;
//- Write to Ostream
void write(Ostream& os) const;
// Member operators