Commit 85360967 authored by andy's avatar andy
Browse files

ENH: Updated thermo dictionary i/o

parent 64f230ae
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2008-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -47,7 +47,13 @@ template<int PolySize>
icoPolynomial<PolySize>::icoPolynomial(const dictionary& dict)
:
specie(dict),
rhoCoeffs_(dict.lookup("rhoCoeffs<" + Foam::name(PolySize) + '>'))
rhoCoeffs_
(
dict.subDict("equationOfState").lookup
(
"rhoCoeffs<" + Foam::name(PolySize) + '>'
)
)
{
rhoCoeffs_ *= this->W();
}
......@@ -59,8 +65,15 @@ template<int PolySize>
void icoPolynomial<PolySize>::write(Ostream& os) const
{
specie::write(os);
os.writeKeyword(word("rhoCoeffs<" + Foam::name(PolySize) + '>'))
<< rhoCoeffs_/this->W() << token::END_STATEMENT << nl;
dictionary dict("equationOfState");
dict.add
(
word("rhoCoeffs<" + Foam::name(PolySize) + '>'),
rhoCoeffs_/this->W()
);
os << dict;
}
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -40,10 +40,23 @@ Foam::incompressible::incompressible(Istream& is)
Foam::incompressible::incompressible(const dictionary& dict)
:
specie(dict),
rho_(readScalar(dict.lookup("rho")))
rho_(readScalar(dict.subDict("equationOfState").lookup("rho")))
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::incompressible::write(Ostream& os) const
{
specie::write(os);
dictionary dict("equationOfState");
dict.add("rho", rho_);
os << dict;
}
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
Foam::Ostream& Foam::operator<<(Ostream& os, const incompressible& ico)
......@@ -51,7 +64,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const incompressible& ico)
os << static_cast<const specie&>(ico)
<< token::SPACE << ico.rho_;
os.check("Ostream& operator<<(Ostream& os, const incompressible& st)");
os.check("Ostream& operator<<(Ostream& os, const incompressible& ico)");
return os;
}
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -83,14 +83,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
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -54,8 +54,8 @@ Foam::specie::specie(Istream& is)
Foam::specie::specie(const dictionary& dict)
:
name_(dict.dictName()),
nMoles_(readScalar(dict.lookup("nMoles"))),
molWeight_(readScalar(dict.lookup("molWeight")))
nMoles_(readScalar(dict.subDict("specie").lookup("nMoles"))),
molWeight_(readScalar(dict.subDict("specie").lookup("molWeight")))
{}
......@@ -63,8 +63,10 @@ Foam::specie::specie(const dictionary& dict)
void Foam::specie::write(Ostream& os) const
{
os.writeKeyword("nMoles") << nMoles_ << token::END_STATEMENT << nl;
os.writeKeyword("molWeight") << molWeight_ << token::END_STATEMENT << nl;
dictionary dict("specie");
dict.add("nMoles", nMoles_);
dict.add("molWeight", molWeight_);
os << dict;
}
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -43,8 +43,8 @@ template<class EquationOfState>
Foam::eConstThermo<EquationOfState>::eConstThermo(const dictionary& dict)
:
EquationOfState(dict),
Cv_(readScalar(dict.lookup("Cv"))),
Hf_(readScalar(dict.lookup("Hf")))
Cv_(readScalar(dict.subDict("thermodynamics").lookup("Cv"))),
Hf_(readScalar(dict.subDict("thermodynamics").lookup("Hf")))
{}
......@@ -54,8 +54,11 @@ 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;
dictionary dict("thermodynamics");
dict.add("Cv", Cv_);
dict.add("Hf", Hf_);
os << dict;
}
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -43,8 +43,8 @@ template<class equationOfState>
Foam::hConstThermo<equationOfState>::hConstThermo(const dictionary& dict)
:
equationOfState(dict),
Cp_(readScalar(dict.lookup("Cp"))),
Hf_(readScalar(dict.lookup("Hf")))
Cp_(readScalar(dict.subDict("thermodynamics").lookup("Cp"))),
Hf_(readScalar(dict.subDict("thermodynamics").lookup("Hf")))
{}
......@@ -54,8 +54,11 @@ 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;
dictionary dict("thermodynamics");
dict.add("Cp", Cp_);
dict.add("Hf", Hf_);
os << dict;
}
......
......@@ -63,9 +63,15 @@ Foam::hPolynomialThermo<EquationOfState, PolySize>::hPolynomialThermo
)
:
EquationOfState(dict),
Hf_(readScalar(dict.lookup("Hf"))),
Sf_(readScalar(dict.lookup("Sf"))),
CpCoeffs_(dict.lookup("CpCoeffs<" + Foam::name(PolySize) + '>')),
Hf_(readScalar(dict.subDict("thermodynamics").lookup("Hf"))),
Sf_(readScalar(dict.subDict("thermodynamics").lookup("Sf"))),
CpCoeffs_
(
dict.subDict("thermodynamics").lookup
(
"CpCoeffs<" + Foam::name(PolySize) + '>'
)
),
hCoeffs_(),
sCoeffs_()
{
......@@ -93,10 +99,16 @@ void Foam::hPolynomialThermo<EquationOfState, PolySize>::write
) const
{
EquationOfState::write(os);
os.writeKeyword("Hf") << Hf_/this->W() << token::END_STATEMENT << nl;
os.writeKeyword("Sf") << Sf_/this->W() << token::END_STATEMENT << nl;
os.writeKeyword(word("CpCoeffs<" + Foam::name(PolySize) + '>'))
<< CpCoeffs_/this->W() << token::END_STATEMENT << nl;
dictionary dict("thermodynamics");
dict.add("Hf", Hf_);
dict.add("Sf", Sf_);
dict.add
(
word("CpCoeffs<" + Foam::name(PolySize) + '>'),
CpCoeffs_/this->W()
);
os << dict;
}
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -85,11 +85,11 @@ template<class EquationOfState>
Foam::janafThermo<EquationOfState>::janafThermo(const dictionary& dict)
:
EquationOfState(dict),
Tlow_(readScalar(dict.lookup("Tlow"))),
Thigh_(readScalar(dict.lookup("Thigh"))),
Tcommon_(readScalar(dict.lookup("Tcommon"))),
highCpCoeffs_(dict.lookup("highCpCoeffs")),
lowCpCoeffs_(dict.lookup("lowCpCoeffs"))
Tlow_(readScalar(dict.subDict("thermodynamics").lookup("Tlow"))),
Thigh_(readScalar(dict.subDict("thermodynamics").lookup("Thigh"))),
Tcommon_(readScalar(dict.subDict("thermodynamics").lookup("Tcommon"))),
highCpCoeffs_(dict.subDict("thermodynamics").lookup("highCpCoeffs")),
lowCpCoeffs_(dict.subDict("thermodynamics").lookup("lowCpCoeffs"))
{
checkInputData();
}
......@@ -101,13 +101,14 @@ 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;
dictionary dict("thermodynamics");
dict.add("Tlow", Tlow_);
dict.add("Thigh", Thigh_);
dict.add("Tcommon", Tcommon_);
dict.add("highCpCoeffs", highCpCoeffs_);
dict.add("lowCpCoeffs", lowCpCoeffs_);
os << dict;
}
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -43,8 +43,8 @@ template<class Thermo>
Foam::constTransport<Thermo>::constTransport(const dictionary& dict)
:
Thermo(dict),
mu_(readScalar(dict.lookup("mu"))),
rPr_(1.0/readScalar(dict.lookup("Pr")))
mu_(readScalar(dict.subDict("transport").lookup("mu"))),
rPr_(1.0/readScalar(dict.subDict("transport").lookup("Pr")))
{}
......@@ -55,9 +55,14 @@ void Foam::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") << 1.0/rPr_ << token::END_STATEMENT << nl;
dictionary dict("transport");
dict.add("mu", mu_);
dict.add("Pr", 1.0/rPr_);
os << dict;
os << decrIndent << token::END_BLOCK << nl;
}
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2008-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -47,8 +47,20 @@ Foam::polynomialTransport<Thermo, PolySize>::polynomialTransport
)
:
Thermo(dict),
muCoeffs_(dict.lookup("muCoeffs<" + Foam::name(PolySize) + '>')),
kappaCoeffs_(dict.lookup("kappaCoeffs<" + Foam::name(PolySize) + '>'))
muCoeffs_
(
dict.subDict("transport").lookup
(
"muCoeffs<" + Foam::name(PolySize) + '>'
)
),
kappaCoeffs_
(
dict.subDict("transport").lookup
(
"kappaCoeffs<" + Foam::name(PolySize) + '>'
)
)
{
muCoeffs_ *= this->W();
kappaCoeffs_ *= this->W();
......@@ -62,11 +74,22 @@ void Foam::polynomialTransport<Thermo, PolySize>::write(Ostream& os) const
{
os << this->name() << endl;
os << token::BEGIN_BLOCK << incrIndent << nl;
Thermo::write(os);
os.writeKeyword(word("muCoeffs<" + Foam::name(PolySize) + '>'))
<< muCoeffs_/this->W() << token::END_STATEMENT << nl;
os.writeKeyword(word("kappaCoeffs<" + Foam::name(PolySize) + '>'))
<< kappaCoeffs_/this->W() << token::END_STATEMENT << nl;
dictionary dict("transport");
dict.add
(
word("muCoeffs<" + Foam::name(PolySize) + '>'),
muCoeffs_/this->W()
);
dict.add
(
word("kappaCoeffs<" + Foam::name(PolySize) + '>'),
kappaCoeffs_/this->W()
);
os << dict;
os << decrIndent << token::END_BLOCK << nl;
}
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -43,8 +43,8 @@ template<class Thermo>
Foam::sutherlandTransport<Thermo>::sutherlandTransport(const dictionary& dict)
:
Thermo(dict),
As_(readScalar(dict.lookup("As"))),
Ts_(readScalar(dict.lookup("Ts")))
As_(readScalar(dict.subDict("transport").lookup("As"))),
Ts_(readScalar(dict.subDict("transport").lookup("Ts")))
{}
......@@ -55,9 +55,14 @@ void Foam::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") << Ts_ << token::END_STATEMENT << nl;
dictionary dict("transport");
dict.add("As", As_);
dict.add("Ts", Ts_);
os << dict;
os << decrIndent << token::END_BLOCK << nl;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment