Skip to content
Snippets Groups Projects
Commit 9902cf49 authored by andy's avatar andy
Browse files

ENH: Updated fixedTemperature to use DataEntry functionality

parent 640d8157
Branches
Tags
No related merge requests found
......@@ -45,7 +45,7 @@ namespace Foam
template<>
const char* NamedEnum<fixedTemperatureSource::temperatureMode, 2>::names[] =
{
"constant",
"uniform",
"lookup"
};
}
......@@ -66,14 +66,17 @@ Foam::fixedTemperatureSource::fixedTemperatureSource
:
basicSource(name, modelType, dict, mesh),
mode_(temperatureModeNames_.read(coeffs_.lookup("mode"))),
Tconstant_(0.0),
Tuniform_(NULL),
TName_("T")
{
switch (mode_)
{
case tmConstant:
case tmUniform:
{
coeffs_.lookup("temperature") >> Tconstant_;
Tuniform_.reset
(
DataEntry<scalar>::New("temperature", coeffs_).ptr()
);
break;
}
case tmLookup:
......@@ -114,10 +117,11 @@ void Foam::fixedTemperatureSource::setValue
{
switch (mode_)
{
case tmConstant:
case tmUniform:
{
scalarField Tconst(cells_.size(), Tconstant_);
eqn.setValues(cells_, thermo.he(thermo.p(), Tconst, cells_));
const scalar t = mesh_.time().value();
scalarField Tuni(cells_.size(), Tuniform_->value(t));
eqn.setValues(cells_, thermo.he(thermo.p(), Tuni, cells_));
break;
}
......@@ -126,8 +130,8 @@ void Foam::fixedTemperatureSource::setValue
const volScalarField& T =
mesh().lookupObject<volScalarField>(TName_);
scalarField Tlookup(T, cells_);
eqn.setValues(cells_, thermo.he(thermo.p(), Tlookup, cells_));
scalarField Tlkp(T, cells_);
eqn.setValues(cells_, thermo.he(thermo.p(), Tlkp, cells_));
break;
}
......@@ -152,7 +156,14 @@ bool Foam::fixedTemperatureSource::read(const dictionary& dict)
{
if (basicSource::read(dict))
{
coeffs_.readIfPresent("temperature", Tconstant_);
if (coeffs_.found(Tuniform_->name()))
{
Tuniform_.reset
(
DataEntry<scalar>::New(Tuniform_->name(), dict).ptr()
);
}
coeffs_.readIfPresent("TName", TName_);
return true;
......
......@@ -33,15 +33,18 @@ Description
fixedTemperatureSourceCoeffs
{
fieldNames (h e hs); // names of fields to apply source
mode constant; // constant or lookup
mode uniform; // constant or lookup
// constant option
temperature 500; // fixed temperature [K]
// uniform option
temperature constant 500; // fixed temperature [K]
// loolup option
// TName T; // optional temperature field name
}
Note:
The 'uniform' option allows the use of a time-varying uniform temperature
by means of the DataEntry type.
SourceFiles
basicSource.C
......@@ -53,6 +56,7 @@ SourceFiles
#include "basicSource.H"
#include "NamedEnum.H"
#include "DataEntry.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -73,7 +77,7 @@ public:
//- Temperature mode
enum temperatureMode
{
tmConstant,
tmUniform,
tmLookup
};
......@@ -89,8 +93,8 @@ protected:
//- Operation mode
temperatureMode mode_;
//- Constant temperature [K]
scalar Tconstant_;
//- Uniform temperature [K]
autoPtr<DataEntry<scalar> > Tuniform_;
//- Temperature field name
word TName_;
......
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