liquidProperties, solidProperties: Simplified input

The entries for liquid and solid species can now be simply be the name unless
property coefficients are overridden in which are specified in a dictionary as
before e.g. in the tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek case
the water is simply specified

liquids
{
    H2O;
}

and solid ash uses standard coefficients but the coefficients for carbon are
overridden thus

solids
{
    C
    {
        rho             2010;
        Cp              710;
        kappa           0.04;
        Hf              0;
        emissivity      1.0;
    }

    ash;
}
This commit is contained in:
Henry Weller
2017-02-18 12:43:10 +00:00
parent 081f1784f9
commit 95574a6c6b
24 changed files with 194 additions and 163 deletions

View File

@ -46,6 +46,8 @@ Foam::liquidMixtureProperties::liquidMixtureProperties
properties_.setSize(components_.size()); properties_.setSize(components_.size());
forAll(components_, i) forAll(components_, i)
{
if (dict.isDict(components_[i]))
{ {
properties_.set properties_.set
( (
@ -53,6 +55,15 @@ Foam::liquidMixtureProperties::liquidMixtureProperties
liquidProperties::New(dict.subDict(components_[i])) liquidProperties::New(dict.subDict(components_[i]))
); );
} }
else
{
properties_.set
(
i,
liquidProperties::New(components_[i])
);
}
}
} }

View File

@ -85,6 +85,32 @@ Foam::liquidProperties::liquidProperties(const dictionary& dict)
// * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
Foam::autoPtr<Foam::liquidProperties> Foam::liquidProperties::New
(
const word& name
)
{
if (debug)
{
InfoInFunction << "Constructing liquidProperties" << endl;
}
ConstructorTable::iterator cstrIter = ConstructorTablePtr_->find(name);
if (cstrIter == ConstructorTablePtr_->end())
{
FatalErrorInFunction
<< "Unknown liquidProperties type "
<< name << nl << nl
<< "Valid liquidProperties types are:" << nl
<< ConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
return autoPtr<liquidProperties>(cstrIter()());
}
Foam::autoPtr<Foam::liquidProperties> Foam::liquidProperties::New Foam::autoPtr<Foam::liquidProperties> Foam::liquidProperties::New
( (
const dictionary& dict const dictionary& dict
@ -101,24 +127,9 @@ Foam::autoPtr<Foam::liquidProperties> Foam::liquidProperties::New
{ {
// Backward-compatibility // Backward-compatibility
const Switch defaultCoeffs(dict.lookup("defaultCoeffs")); if (Switch(dict.lookup("defaultCoeffs")))
if (defaultCoeffs)
{ {
ConstructorTable::iterator cstrIter = return New(liquidPropertiesTypeName);
ConstructorTablePtr_->find(liquidPropertiesTypeName);
if (cstrIter == ConstructorTablePtr_->end())
{
FatalErrorInFunction
<< "Unknown liquidProperties type "
<< liquidPropertiesTypeName << nl << nl
<< "Valid liquidProperties types are:" << nl
<< ConstructorTablePtr_->sortedToc()
<< abort(FatalError);
}
return autoPtr<liquidProperties>(cstrIter()());
} }
else else
{ {
@ -132,7 +143,7 @@ Foam::autoPtr<Foam::liquidProperties> Foam::liquidProperties::New
<< liquidPropertiesTypeName << nl << nl << liquidPropertiesTypeName << nl << nl
<< "Valid liquidProperties types are:" << nl << "Valid liquidProperties types are:" << nl
<< dictionaryConstructorTablePtr_->sortedToc() << dictionaryConstructorTablePtr_->sortedToc()
<< abort(FatalError); << exit(FatalError);
} }
return autoPtr<liquidProperties> return autoPtr<liquidProperties>
@ -153,7 +164,7 @@ Foam::autoPtr<Foam::liquidProperties> Foam::liquidProperties::New
<< liquidPropertiesTypeName << nl << nl << liquidPropertiesTypeName << nl << nl
<< "Valid liquidProperties types are:" << nl << "Valid liquidProperties types are:" << nl
<< dictionaryConstructorTablePtr_->sortedToc() << dictionaryConstructorTablePtr_->sortedToc()
<< abort(FatalError); << exit(FatalError);
} }
return autoPtr<liquidProperties>(cstrIter()(dict)); return autoPtr<liquidProperties>(cstrIter()(dict));

View File

@ -145,6 +145,9 @@ public:
// Selectors // Selectors
//- Return a pointer to a new liquidProperties created from name
static autoPtr<liquidProperties> New(const word& name);
//- Return a pointer to a new liquidProperties created from dictionary //- Return a pointer to a new liquidProperties created from dictionary
static autoPtr<liquidProperties> New(const dictionary& dict); static autoPtr<liquidProperties> New(const dictionary& dict);
@ -300,22 +303,14 @@ public:
//- Read and set the function coefficients //- Read and set the function coefficients
// if present it the given dictionary // if present it the given dictionary
template<class Liquid> template<class Liquid>
inline void readIfPresent inline void readIfPresent(Liquid& l, const dictionary& dict);
(
Liquid& l,
const dictionary& dict
);
//- Write the function coefficients //- Write the function coefficients
virtual void writeData(Ostream& os) const; virtual void writeData(Ostream& os) const;
//- Write the data for each of the property functions //- Write the data for each of the property functions
template<class Liquid> template<class Liquid>
inline void writeData inline void writeData(const Liquid& l, Ostream& os) const;
(
const Liquid& l,
Ostream& os
) const;
//- Ostream Operator //- Ostream Operator
friend Ostream& operator<<(Ostream& os, const liquidProperties& l); friend Ostream& operator<<(Ostream& os, const liquidProperties& l);

View File

@ -50,16 +50,12 @@ Foam::C::C()
} }
Foam::C::C(const solidProperties& s)
:
solidProperties(s)
{}
Foam::C::C(const dictionary& dict) Foam::C::C(const dictionary& dict)
: :
solidProperties(dict) C()
{} {
readIfPresent(dict);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //

View File

@ -42,15 +42,6 @@ SourceFiles
namespace Foam namespace Foam
{ {
class C;
Ostream& operator<<
(
Ostream&,
const C&
);
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class C Declaration Class C Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -59,6 +50,7 @@ class C
: :
public solidProperties public solidProperties
{ {
public: public:
//- Runtime type information //- Runtime type information
@ -70,9 +62,6 @@ public:
//- Construct null //- Construct null
C(); C();
//- Construct from solidProperties
C(const solidProperties& s);
//- Construct from dictionary //- Construct from dictionary
C(const dictionary& dict); C(const dictionary& dict);
@ -88,12 +77,14 @@ public:
//- Write the function coefficients //- Write the function coefficients
void writeData(Ostream& os) const; void writeData(Ostream& os) const;
//- Ostream Operator //- Ostream Operator
friend Ostream& operator<<(Ostream& os, const C& s); friend Ostream& operator<<(Ostream& os, const C& s);
}; };
Ostream& operator<<(Ostream& os, const C& s);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam } // End namespace Foam

View File

@ -50,16 +50,12 @@ Foam::CaCO3::CaCO3()
} }
Foam::CaCO3::CaCO3(const solidProperties& s)
:
solidProperties(s)
{}
Foam::CaCO3::CaCO3(const dictionary& dict) Foam::CaCO3::CaCO3(const dictionary& dict)
: :
solidProperties(dict) CaCO3()
{} {
readIfPresent(dict);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //

View File

@ -42,15 +42,6 @@ SourceFiles
namespace Foam namespace Foam
{ {
class CaCO3;
Ostream& operator<<
(
Ostream&,
const CaCO3&
);
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class CaCO3 Declaration Class CaCO3 Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -71,9 +62,6 @@ public:
//- Construct null //- Construct null
CaCO3(); CaCO3();
//- Construct from solidProperties
CaCO3(const solidProperties& s);
//- Construct from dictionary //- Construct from dictionary
CaCO3(const dictionary& dict); CaCO3(const dictionary& dict);
@ -89,13 +77,14 @@ public:
//- Write the function coefficients //- Write the function coefficients
void writeData(Ostream& os) const; void writeData(Ostream& os) const;
//- Ostream Operator
// Ostream Operator
friend Ostream& operator<<(Ostream& os, const CaCO3& s); friend Ostream& operator<<(Ostream& os, const CaCO3& s);
}; };
Ostream& operator<<(Ostream& os, const CaCO3& s);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam } // End namespace Foam

View File

@ -50,16 +50,12 @@ Foam::ash::ash()
} }
Foam::ash::ash(const solidProperties& s)
:
solidProperties(s)
{}
Foam::ash::ash(const dictionary& dict) Foam::ash::ash(const dictionary& dict)
: :
solidProperties(dict) ash()
{} {
readIfPresent(dict);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //

View File

@ -42,15 +42,6 @@ SourceFiles
namespace Foam namespace Foam
{ {
class ash;
Ostream& operator<<
(
Ostream&,
const ash&
);
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class ash Declaration Class ash Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -71,9 +62,6 @@ public:
//- Construct null //- Construct null
ash(); ash();
//- Construct from solidProperties
ash(const solidProperties& s);
//- Construct from dictionary //- Construct from dictionary
ash(const dictionary& dict); ash(const dictionary& dict);
@ -89,13 +77,14 @@ public:
//- Write the function coefficients //- Write the function coefficients
void writeData(Ostream& os) const; void writeData(Ostream& os) const;
//- Ostream Operator
// Ostream Operator
friend Ostream& operator<<(Ostream& os, const ash& s); friend Ostream& operator<<(Ostream& os, const ash& s);
}; };
Ostream& operator<<(Ostream& os, const ash& s);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam } // End namespace Foam

View File

@ -34,9 +34,25 @@ Foam::solidMixtureProperties::solidMixtureProperties(const dictionary& dict)
{ {
components_ = dict.toc(); components_ = dict.toc();
properties_.setSize(components_.size()); properties_.setSize(components_.size());
forAll(components_, i) forAll(components_, i)
{ {
properties_.set(i, solidProperties::New(dict.subDict(components_[i]))); if (dict.isDict(components_[i]))
{
properties_.set
(
i,
solidProperties::New(dict.subDict(components_[i]))
);
}
else
{
properties_.set
(
i,
solidProperties::New(components_[i])
);
}
} }
} }

View File

@ -40,14 +40,14 @@ Foam::solidProperties::solidProperties
( (
scalar rho, scalar rho,
scalar Cp, scalar Cp,
scalar K, scalar kappa,
scalar Hf, scalar Hf,
scalar emissivity scalar emissivity
) )
: :
rho_(rho), rho_(rho),
Cp_(Cp), Cp_(Cp),
kappa_(K), kappa_(kappa),
Hf_(Hf), Hf_(Hf),
emissivity_(emissivity) emissivity_(emissivity)
{} {}
@ -57,7 +57,12 @@ Foam::solidProperties::solidProperties(const dictionary& dict)
: :
rho_(readScalar(dict.lookup("rho"))), rho_(readScalar(dict.lookup("rho"))),
Cp_(readScalar(dict.lookup("Cp"))), Cp_(readScalar(dict.lookup("Cp"))),
kappa_(readScalar(dict.lookup("K"))), kappa_
(
dict.found("K")
? readScalar(dict.lookup("K"))
: readScalar(dict.lookup("kappa"))
),
Hf_(readScalar(dict.lookup("Hf"))), Hf_(readScalar(dict.lookup("Hf"))),
emissivity_(readScalar(dict.lookup("emissivity"))) emissivity_(readScalar(dict.lookup("emissivity")))
{} {}
@ -65,6 +70,17 @@ Foam::solidProperties::solidProperties(const dictionary& dict)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::solidProperties::readIfPresent(const dictionary& dict)
{
dict.readIfPresent("rho", rho_);
dict.readIfPresent("Cp", Cp_);
dict.readIfPresent("K", kappa_);
dict.readIfPresent("kappa", kappa_);
dict.readIfPresent("Hf_", Hf_);
dict.readIfPresent("emissivity", emissivity_);
}
void Foam::solidProperties::writeData(Ostream& os) const void Foam::solidProperties::writeData(Ostream& os) const
{ {
os << rho_ << token::SPACE os << rho_ << token::SPACE

View File

@ -45,22 +45,12 @@ SourceFiles
namespace Foam namespace Foam
{ {
class solidProperties;
Ostream& operator<<
(
Ostream&,
const solidProperties&
);
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class solidProperties Declaration Class solidProperties Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class solidProperties class solidProperties
{ {
// Private data // Private data
//- Density [kg/m3] //- Density [kg/m3]
@ -113,7 +103,7 @@ public:
( (
scalar rho, scalar rho,
scalar Cp, scalar Cp,
scalar K, scalar kappa,
scalar Hf, scalar Hf,
scalar emissivity scalar emissivity
); );
@ -130,6 +120,9 @@ public:
// Selectors // Selectors
//- Return a pointer to a new solidProperties created from name
static autoPtr<solidProperties> New(const word& name);
//- Return a pointer to a new solidProperties created from dictionary //- Return a pointer to a new solidProperties created from dictionary
static autoPtr<solidProperties> New(const dictionary& dict); static autoPtr<solidProperties> New(const dictionary& dict);
@ -164,16 +157,20 @@ public:
// I-O // I-O
//- Read and set the properties present it the given dictionary
void readIfPresent(const dictionary& dict);
//- Write the solidProperties properties //- Write the solidProperties properties
virtual void writeData(Ostream& os) const; virtual void writeData(Ostream& os) const;
//- Ostream Operator
// Ostream Operator
friend Ostream& operator<<(Ostream& os, const solidProperties& s); friend Ostream& operator<<(Ostream& os, const solidProperties& s);
}; };
Ostream& operator<<(Ostream&, const solidProperties&);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam } // End namespace Foam

View File

@ -28,6 +28,32 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Foam::autoPtr<Foam::solidProperties> Foam::solidProperties::New
(
const word& name
)
{
if (debug)
{
InfoInFunction << "Constructing solidProperties" << endl;
}
ConstructorTable::iterator cstrIter = ConstructorTablePtr_->find(name);
if (cstrIter == ConstructorTablePtr_->end())
{
FatalErrorInFunction
<< "Unknown solidProperties type "
<< name << nl << nl
<< "Valid solidProperties types are:" << nl
<< ConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
return autoPtr<solidProperties>(cstrIter()());
}
Foam::autoPtr<Foam::solidProperties> Foam::solidProperties::New Foam::autoPtr<Foam::solidProperties> Foam::solidProperties::New
( (
const dictionary& dict const dictionary& dict
@ -40,32 +66,39 @@ Foam::autoPtr<Foam::solidProperties> Foam::solidProperties::New
const word solidType(dict.dictName()); const word solidType(dict.dictName());
if (!dict.found("defaultCoeffs") || Switch(dict.lookup("defaultCoeffs"))) if (dict.found("defaultCoeffs"))
{ {
ConstructorTable::iterator cstrIter = // Backward-compatibility
ConstructorTablePtr_->find(solidType);
if (cstrIter == ConstructorTablePtr_->end()) if (Switch(dict.lookup("defaultCoeffs")))
{ {
FatalErrorInFunction return New(solidType);
<< "Unknown solidProperties type " << solidType << nl << nl
<< "Valid solidProperties types are :" << endl
<< ConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
return autoPtr<solidProperties>(cstrIter()());
} }
else else
{ {
return autoPtr<solidProperties> return autoPtr<solidProperties>
( (
new solidProperties new solidProperties(dict.subDict(solidType + "Coeffs"))
(
dict.subDict(solidType + "Coeffs")
)
); );
} }
}
else
{
dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(solidType);
if (cstrIter == dictionaryConstructorTablePtr_->end())
{
FatalErrorInFunction
<< "Unknown solidProperties type "
<< solidType << nl << nl
<< "Valid solidProperties types are:" << nl
<< dictionaryConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
return autoPtr<solidProperties>(cstrIter()(dict));
}
} }

View File

@ -36,26 +36,21 @@ inertSpecie N2;
liquids liquids
{ {
H2O {} H2O;
} }
solids solids
{ {
C C
{
defaultCoeffs no;
CCoeffs
{ {
rho 2010; rho 2010;
Cp 710; Cp 710;
K 0.04; kappa 0.04;
Hf 0; Hf 0;
emissivity 1.0; emissivity 1.0;
} }
}
ash {} ash;
} }

View File

@ -36,7 +36,7 @@ inertSpecie N2;
liquids liquids
{ {
H2O {} H2O;
} }
solids solids

View File

@ -36,7 +36,7 @@ inertSpecie N2;
liquids liquids
{ {
H2O {} H2O;
} }
solids solids

View File

@ -36,7 +36,7 @@ inertSpecie N2;
liquids liquids
{ {
H2O {} H2O;
} }
solids solids

View File

@ -36,7 +36,7 @@ inertSpecie N2;
liquids liquids
{ {
H2O {} H2O;
} }
solids solids

View File

@ -36,7 +36,7 @@ foamChemistryThermoFile "$FOAM_CASE/constant/thermo.incompressiblePoly";
liquids liquids
{ {
H2O {} H2O;
} }
solids solids

View File

@ -38,7 +38,7 @@ inertSpecie air;
liquids liquids
{ {
H2O {} H2O;
} }
solids solids

View File

@ -38,7 +38,7 @@ inertSpecie air;
liquids liquids
{ {
H2O {} H2O;
} }
solids solids

View File

@ -36,7 +36,7 @@ inertSpecie air;
liquids liquids
{ {
H2O {} H2O;
} }
solids solids

View File

@ -36,7 +36,7 @@ inertSpecie air;
liquids liquids
{ {
H2O {} H2O;
} }
solids solids

View File

@ -36,7 +36,7 @@ inertSpecie N2;
liquids liquids
{ {
C7H16 {} C7H16;
} }
solids solids