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:
parent
9b4f327e2b
commit
de44d09ad9
@ -46,6 +46,8 @@ Foam::liquidMixtureProperties::liquidMixtureProperties
|
||||
properties_.setSize(components_.size());
|
||||
|
||||
forAll(components_, i)
|
||||
{
|
||||
if (dict.isDict(components_[i]))
|
||||
{
|
||||
properties_.set
|
||||
(
|
||||
@ -53,6 +55,15 @@ Foam::liquidMixtureProperties::liquidMixtureProperties
|
||||
liquidProperties::New(dict.subDict(components_[i]))
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
properties_.set
|
||||
(
|
||||
i,
|
||||
liquidProperties::New(components_[i])
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -85,6 +85,32 @@ Foam::liquidProperties::liquidProperties(const dictionary& dict)
|
||||
|
||||
// * * * * * * * * * * * * * * * * * 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
|
||||
(
|
||||
const dictionary& dict
|
||||
@ -101,24 +127,9 @@ Foam::autoPtr<Foam::liquidProperties> Foam::liquidProperties::New
|
||||
{
|
||||
// Backward-compatibility
|
||||
|
||||
const Switch defaultCoeffs(dict.lookup("defaultCoeffs"));
|
||||
|
||||
if (defaultCoeffs)
|
||||
if (Switch(dict.lookup("defaultCoeffs")))
|
||||
{
|
||||
ConstructorTable::iterator cstrIter =
|
||||
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()());
|
||||
return New(liquidPropertiesTypeName);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -132,7 +143,7 @@ Foam::autoPtr<Foam::liquidProperties> Foam::liquidProperties::New
|
||||
<< liquidPropertiesTypeName << nl << nl
|
||||
<< "Valid liquidProperties types are:" << nl
|
||||
<< dictionaryConstructorTablePtr_->sortedToc()
|
||||
<< abort(FatalError);
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
return autoPtr<liquidProperties>
|
||||
@ -153,7 +164,7 @@ Foam::autoPtr<Foam::liquidProperties> Foam::liquidProperties::New
|
||||
<< liquidPropertiesTypeName << nl << nl
|
||||
<< "Valid liquidProperties types are:" << nl
|
||||
<< dictionaryConstructorTablePtr_->sortedToc()
|
||||
<< abort(FatalError);
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
return autoPtr<liquidProperties>(cstrIter()(dict));
|
||||
|
@ -145,6 +145,9 @@ public:
|
||||
|
||||
// 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
|
||||
static autoPtr<liquidProperties> New(const dictionary& dict);
|
||||
|
||||
@ -300,22 +303,14 @@ public:
|
||||
//- Read and set the function coefficients
|
||||
// if present it the given dictionary
|
||||
template<class Liquid>
|
||||
inline void readIfPresent
|
||||
(
|
||||
Liquid& l,
|
||||
const dictionary& dict
|
||||
);
|
||||
inline void readIfPresent(Liquid& l, const dictionary& dict);
|
||||
|
||||
//- Write the function coefficients
|
||||
virtual void writeData(Ostream& os) const;
|
||||
|
||||
//- Write the data for each of the property functions
|
||||
template<class Liquid>
|
||||
inline void writeData
|
||||
(
|
||||
const Liquid& l,
|
||||
Ostream& os
|
||||
) const;
|
||||
inline void writeData(const Liquid& l, Ostream& os) const;
|
||||
|
||||
//- Ostream Operator
|
||||
friend Ostream& operator<<(Ostream& os, const liquidProperties& l);
|
||||
|
@ -50,16 +50,12 @@ Foam::C::C()
|
||||
}
|
||||
|
||||
|
||||
Foam::C::C(const solidProperties& s)
|
||||
:
|
||||
solidProperties(s)
|
||||
{}
|
||||
|
||||
|
||||
Foam::C::C(const dictionary& dict)
|
||||
:
|
||||
solidProperties(dict)
|
||||
{}
|
||||
C()
|
||||
{
|
||||
readIfPresent(dict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
@ -42,15 +42,6 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class C;
|
||||
|
||||
Ostream& operator<<
|
||||
(
|
||||
Ostream&,
|
||||
const C&
|
||||
);
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class C Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
@ -59,6 +50,7 @@ class C
|
||||
:
|
||||
public solidProperties
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
@ -70,9 +62,6 @@ public:
|
||||
//- Construct null
|
||||
C();
|
||||
|
||||
//- Construct from solidProperties
|
||||
C(const solidProperties& s);
|
||||
|
||||
//- Construct from dictionary
|
||||
C(const dictionary& dict);
|
||||
|
||||
@ -88,12 +77,14 @@ public:
|
||||
//- Write the function coefficients
|
||||
void writeData(Ostream& os) const;
|
||||
|
||||
|
||||
//- Ostream Operator
|
||||
friend Ostream& operator<<(Ostream& os, const C& s);
|
||||
};
|
||||
|
||||
|
||||
Ostream& operator<<(Ostream& os, const C& s);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
@ -50,16 +50,12 @@ Foam::CaCO3::CaCO3()
|
||||
}
|
||||
|
||||
|
||||
Foam::CaCO3::CaCO3(const solidProperties& s)
|
||||
:
|
||||
solidProperties(s)
|
||||
{}
|
||||
|
||||
|
||||
Foam::CaCO3::CaCO3(const dictionary& dict)
|
||||
:
|
||||
solidProperties(dict)
|
||||
{}
|
||||
CaCO3()
|
||||
{
|
||||
readIfPresent(dict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
@ -42,15 +42,6 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class CaCO3;
|
||||
|
||||
Ostream& operator<<
|
||||
(
|
||||
Ostream&,
|
||||
const CaCO3&
|
||||
);
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class CaCO3 Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
@ -71,9 +62,6 @@ public:
|
||||
//- Construct null
|
||||
CaCO3();
|
||||
|
||||
//- Construct from solidProperties
|
||||
CaCO3(const solidProperties& s);
|
||||
|
||||
//- Construct from dictionary
|
||||
CaCO3(const dictionary& dict);
|
||||
|
||||
@ -89,13 +77,14 @@ public:
|
||||
//- Write the function coefficients
|
||||
void writeData(Ostream& os) const;
|
||||
|
||||
|
||||
// Ostream Operator
|
||||
|
||||
//- Ostream Operator
|
||||
friend Ostream& operator<<(Ostream& os, const CaCO3& s);
|
||||
};
|
||||
|
||||
|
||||
Ostream& operator<<(Ostream& os, const CaCO3& s);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
@ -50,16 +50,12 @@ Foam::ash::ash()
|
||||
}
|
||||
|
||||
|
||||
Foam::ash::ash(const solidProperties& s)
|
||||
:
|
||||
solidProperties(s)
|
||||
{}
|
||||
|
||||
|
||||
Foam::ash::ash(const dictionary& dict)
|
||||
:
|
||||
solidProperties(dict)
|
||||
{}
|
||||
ash()
|
||||
{
|
||||
readIfPresent(dict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
@ -42,15 +42,6 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class ash;
|
||||
|
||||
Ostream& operator<<
|
||||
(
|
||||
Ostream&,
|
||||
const ash&
|
||||
);
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class ash Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
@ -71,9 +62,6 @@ public:
|
||||
//- Construct null
|
||||
ash();
|
||||
|
||||
//- Construct from solidProperties
|
||||
ash(const solidProperties& s);
|
||||
|
||||
//- Construct from dictionary
|
||||
ash(const dictionary& dict);
|
||||
|
||||
@ -89,13 +77,14 @@ public:
|
||||
//- Write the function coefficients
|
||||
void writeData(Ostream& os) const;
|
||||
|
||||
|
||||
// Ostream Operator
|
||||
|
||||
//- Ostream Operator
|
||||
friend Ostream& operator<<(Ostream& os, const ash& s);
|
||||
};
|
||||
|
||||
|
||||
Ostream& operator<<(Ostream& os, const ash& s);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
@ -34,9 +34,25 @@ Foam::solidMixtureProperties::solidMixtureProperties(const dictionary& dict)
|
||||
{
|
||||
components_ = dict.toc();
|
||||
properties_.setSize(components_.size());
|
||||
|
||||
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])
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,14 +40,14 @@ Foam::solidProperties::solidProperties
|
||||
(
|
||||
scalar rho,
|
||||
scalar Cp,
|
||||
scalar K,
|
||||
scalar kappa,
|
||||
scalar Hf,
|
||||
scalar emissivity
|
||||
)
|
||||
:
|
||||
rho_(rho),
|
||||
Cp_(Cp),
|
||||
kappa_(K),
|
||||
kappa_(kappa),
|
||||
Hf_(Hf),
|
||||
emissivity_(emissivity)
|
||||
{}
|
||||
@ -57,7 +57,12 @@ Foam::solidProperties::solidProperties(const dictionary& dict)
|
||||
:
|
||||
rho_(readScalar(dict.lookup("rho"))),
|
||||
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"))),
|
||||
emissivity_(readScalar(dict.lookup("emissivity")))
|
||||
{}
|
||||
@ -65,6 +70,17 @@ Foam::solidProperties::solidProperties(const dictionary& dict)
|
||||
|
||||
// * * * * * * * * * * * * * * * 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
|
||||
{
|
||||
os << rho_ << token::SPACE
|
||||
|
@ -45,22 +45,12 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class solidProperties;
|
||||
|
||||
Ostream& operator<<
|
||||
(
|
||||
Ostream&,
|
||||
const solidProperties&
|
||||
);
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class solidProperties Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class solidProperties
|
||||
{
|
||||
|
||||
// Private data
|
||||
|
||||
//- Density [kg/m3]
|
||||
@ -113,7 +103,7 @@ public:
|
||||
(
|
||||
scalar rho,
|
||||
scalar Cp,
|
||||
scalar K,
|
||||
scalar kappa,
|
||||
scalar Hf,
|
||||
scalar emissivity
|
||||
);
|
||||
@ -130,6 +120,9 @@ public:
|
||||
|
||||
// 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
|
||||
static autoPtr<solidProperties> New(const dictionary& dict);
|
||||
|
||||
@ -164,16 +157,20 @@ public:
|
||||
|
||||
// I-O
|
||||
|
||||
//- Read and set the properties present it the given dictionary
|
||||
void readIfPresent(const dictionary& dict);
|
||||
|
||||
//- Write the solidProperties properties
|
||||
virtual void writeData(Ostream& os) const;
|
||||
|
||||
|
||||
// Ostream Operator
|
||||
|
||||
//- Ostream Operator
|
||||
friend Ostream& operator<<(Ostream& os, const solidProperties& s);
|
||||
};
|
||||
|
||||
|
||||
Ostream& operator<<(Ostream&, const solidProperties&);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
@ -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
|
||||
(
|
||||
const dictionary& dict
|
||||
@ -40,33 +66,40 @@ Foam::autoPtr<Foam::solidProperties> Foam::solidProperties::New
|
||||
|
||||
const word solidType(dict.dictName());
|
||||
|
||||
if (!dict.found("defaultCoeffs") || Switch(dict.lookup("defaultCoeffs")))
|
||||
if (dict.found("defaultCoeffs"))
|
||||
{
|
||||
ConstructorTable::iterator cstrIter =
|
||||
ConstructorTablePtr_->find(solidType);
|
||||
// Backward-compatibility
|
||||
|
||||
if (cstrIter == ConstructorTablePtr_->end())
|
||||
if (Switch(dict.lookup("defaultCoeffs")))
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown solidProperties type " << solidType << nl << nl
|
||||
<< "Valid solidProperties types are :" << endl
|
||||
<< ConstructorTablePtr_->sortedToc()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
return autoPtr<solidProperties>(cstrIter()());
|
||||
return New(solidType);
|
||||
}
|
||||
else
|
||||
{
|
||||
return autoPtr<solidProperties>
|
||||
(
|
||||
new solidProperties
|
||||
(
|
||||
dict.subDict(solidType + "Coeffs")
|
||||
)
|
||||
new solidProperties(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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
@ -36,26 +36,21 @@ inertSpecie N2;
|
||||
|
||||
liquids
|
||||
{
|
||||
H2O {}
|
||||
H2O;
|
||||
}
|
||||
|
||||
solids
|
||||
{
|
||||
C
|
||||
{
|
||||
defaultCoeffs no;
|
||||
|
||||
CCoeffs
|
||||
{
|
||||
rho 2010;
|
||||
Cp 710;
|
||||
K 0.04;
|
||||
kappa 0.04;
|
||||
Hf 0;
|
||||
emissivity 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
ash {}
|
||||
ash;
|
||||
}
|
||||
|
||||
|
||||
|
@ -36,7 +36,7 @@ inertSpecie N2;
|
||||
|
||||
liquids
|
||||
{
|
||||
H2O {}
|
||||
H2O;
|
||||
}
|
||||
|
||||
solids
|
||||
|
@ -36,7 +36,7 @@ inertSpecie N2;
|
||||
|
||||
liquids
|
||||
{
|
||||
H2O {}
|
||||
H2O;
|
||||
}
|
||||
|
||||
solids
|
||||
|
@ -36,7 +36,7 @@ inertSpecie N2;
|
||||
|
||||
liquids
|
||||
{
|
||||
H2O {}
|
||||
H2O;
|
||||
}
|
||||
|
||||
solids
|
||||
|
@ -36,7 +36,7 @@ inertSpecie N2;
|
||||
|
||||
liquids
|
||||
{
|
||||
H2O {}
|
||||
H2O;
|
||||
}
|
||||
|
||||
solids
|
||||
|
@ -36,7 +36,7 @@ foamChemistryThermoFile "$FOAM_CASE/constant/thermo.incompressiblePoly";
|
||||
|
||||
liquids
|
||||
{
|
||||
H2O {}
|
||||
H2O;
|
||||
}
|
||||
|
||||
solids
|
||||
|
@ -38,7 +38,7 @@ inertSpecie air;
|
||||
|
||||
liquids
|
||||
{
|
||||
H2O {}
|
||||
H2O;
|
||||
}
|
||||
|
||||
solids
|
||||
|
@ -38,7 +38,7 @@ inertSpecie air;
|
||||
|
||||
liquids
|
||||
{
|
||||
H2O {}
|
||||
H2O;
|
||||
}
|
||||
|
||||
solids
|
||||
|
@ -36,7 +36,7 @@ inertSpecie air;
|
||||
|
||||
liquids
|
||||
{
|
||||
H2O {}
|
||||
H2O;
|
||||
}
|
||||
|
||||
solids
|
||||
|
@ -36,7 +36,7 @@ inertSpecie air;
|
||||
|
||||
liquids
|
||||
{
|
||||
H2O {}
|
||||
H2O;
|
||||
}
|
||||
|
||||
solids
|
||||
|
@ -36,7 +36,7 @@ inertSpecie N2;
|
||||
|
||||
liquids
|
||||
{
|
||||
C7H16 {}
|
||||
C7H16;
|
||||
}
|
||||
|
||||
solids
|
||||
|
Loading…
Reference in New Issue
Block a user