From 9902cf49330c222846915776f0feee21ba9bd8fb Mon Sep 17 00:00:00 2001 From: andy Date: Mon, 19 Nov 2012 10:12:44 +0000 Subject: [PATCH] ENH: Updated fixedTemperature to use DataEntry functionality --- .../fixedTemperatureSource.C | 31 +++++++++++++------ .../fixedTemperatureSource.H | 16 ++++++---- 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/src/fieldSources/derived/fixedTemperatureSource/fixedTemperatureSource.C b/src/fieldSources/derived/fixedTemperatureSource/fixedTemperatureSource.C index 34db0a7e3e..26dff507d3 100644 --- a/src/fieldSources/derived/fixedTemperatureSource/fixedTemperatureSource.C +++ b/src/fieldSources/derived/fixedTemperatureSource/fixedTemperatureSource.C @@ -45,7 +45,7 @@ namespace Foam template<> const char* NamedEnum::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::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(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::New(Tuniform_->name(), dict).ptr() + ); + } + coeffs_.readIfPresent("TName", TName_); return true; diff --git a/src/fieldSources/derived/fixedTemperatureSource/fixedTemperatureSource.H b/src/fieldSources/derived/fixedTemperatureSource/fixedTemperatureSource.H index 3aefdb5645..7552934038 100644 --- a/src/fieldSources/derived/fixedTemperatureSource/fixedTemperatureSource.H +++ b/src/fieldSources/derived/fixedTemperatureSource/fixedTemperatureSource.H @@ -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 > Tuniform_; //- Temperature field name word TName_;