mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Enabled setting fixed temperature constaint to a field
This commit is contained in:
@ -41,8 +41,18 @@ namespace Foam
|
||||
fixedTemperatureSource,
|
||||
dictionary
|
||||
);
|
||||
|
||||
template<>
|
||||
const char* NamedEnum<fixedTemperatureSource::temperatureMode, 2>::names[] =
|
||||
{
|
||||
"constantTemperature",
|
||||
"lookup"
|
||||
};
|
||||
}
|
||||
|
||||
const Foam::NamedEnum<Foam::fixedTemperatureSource::temperatureMode, 2>
|
||||
Foam::fixedTemperatureSource::temperatureModeNames_;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
@ -55,8 +65,29 @@ Foam::fixedTemperatureSource::fixedTemperatureSource
|
||||
)
|
||||
:
|
||||
basicSource(name, modelType, dict, mesh),
|
||||
T_(readScalar(coeffs_.lookup("temperature")))
|
||||
mode_(temperatureModeNames_.read(coeffs_.lookup("mode"))),
|
||||
Tconstant_(0.0),
|
||||
TName_("T")
|
||||
{
|
||||
switch (mode_)
|
||||
{
|
||||
case tmConstant:
|
||||
{
|
||||
coeffs_.lookup("temperature") >> Tconstant_;
|
||||
break;
|
||||
}
|
||||
case tmLookup:
|
||||
{
|
||||
TName_ = coeffs_.lookupOrDefault<word>("TName", "T");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
// error handling done by NamedEnum
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fieldNames_.setSize(1, "energy");
|
||||
applied_.setSize(1, false);
|
||||
}
|
||||
@ -81,8 +112,31 @@ void Foam::fixedTemperatureSource::setValue
|
||||
|
||||
if (eqn.psi().name() == thermo.he().name())
|
||||
{
|
||||
const scalarField Tfield(cells_.size(), T_);
|
||||
eqn.setValues(cells_, thermo.he(thermo.p(), Tfield, cells_));
|
||||
switch (mode_)
|
||||
{
|
||||
case tmConstant:
|
||||
{
|
||||
scalarField Tconst(cells_.size(), Tconstant_);
|
||||
eqn.setValues(cells_, thermo.he(thermo.p(), Tconst, cells_));
|
||||
|
||||
break;
|
||||
}
|
||||
case tmLookup:
|
||||
{
|
||||
const volScalarField& T =
|
||||
mesh().lookupObject<volScalarField>(TName_);
|
||||
|
||||
scalarField Tlookup(T, cells_);
|
||||
eqn.setValues(cells_, thermo.he(thermo.p(), Tlookup, cells_));
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
// error handling done by NamedEnum
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -98,7 +152,8 @@ bool Foam::fixedTemperatureSource::read(const dictionary& dict)
|
||||
{
|
||||
if (basicSource::read(dict))
|
||||
{
|
||||
coeffs_.readIfPresent("T", T_);
|
||||
coeffs_.readIfPresent("temperature", Tconstant_);
|
||||
coeffs_.readIfPresent("TName", TName_);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -33,7 +33,13 @@ Description
|
||||
fixedTemperatureSourceCoeffs
|
||||
{
|
||||
fieldNames (h e hs); // names of fields to apply source
|
||||
mode constant; // constant or lookup
|
||||
|
||||
// constant option
|
||||
temperature 500; // fixed temperature [K]
|
||||
|
||||
// loolup option
|
||||
// TName T; // optional temperature field name
|
||||
}
|
||||
|
||||
|
||||
@ -46,6 +52,7 @@ SourceFiles
|
||||
#define fixedTemperatureSource_H
|
||||
|
||||
#include "basicSource.H"
|
||||
#include "NamedEnum.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -61,12 +68,32 @@ class fixedTemperatureSource
|
||||
public basicSource
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//- Temperature mode
|
||||
enum temperatureMode
|
||||
{
|
||||
tmConstant,
|
||||
tmLookup
|
||||
};
|
||||
|
||||
|
||||
//- String representation of temperatureMode enums
|
||||
static const NamedEnum<temperatureMode, 2> temperatureModeNames_;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Fixed temperature [K]
|
||||
scalar T_;
|
||||
//- Operation mode
|
||||
temperatureMode mode_;
|
||||
|
||||
//- Constant temperature [K]
|
||||
scalar Tconstant_;
|
||||
|
||||
//- Temperature field name
|
||||
word TName_;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user