Commit 4726029e authored by Henry's avatar Henry
Browse files

limitTemperature: Set the field name to that of the energy field from which...

limitTemperature: Set the field name to that of the energy field from which the temperature is obtained
Removes the need for the 'alwaysApply' hack.
parent 39466811
......@@ -44,6 +44,7 @@ namespace fv
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fv::limitTemperature::limitTemperature
......@@ -58,66 +59,62 @@ Foam::fv::limitTemperature::limitTemperature
Tmin_(readScalar(coeffs_.lookup("Tmin"))),
Tmax_(readScalar(coeffs_.lookup("Tmax")))
{
fieldNames_.setSize(1, "energy");
applied_.setSize(1, false);
}
// Set the field name to that of the energy field from which the temperature
// is obtained
const basicThermo& thermo =
mesh_.lookupObject<basicThermo>("thermophysicalProperties");
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
fieldNames_.setSize(1, thermo.he().name());
bool Foam::fv::limitTemperature::alwaysApply() const
{
return true;
applied_.setSize(1, false);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::fv::limitTemperature::correct(volScalarField& he)
{
const basicThermo& thermo =
mesh_.lookupObject<basicThermo>("thermophysicalProperties");
if (he.name() == thermo.he().name())
{
scalarField Tmin(cells_.size(), Tmin_);
scalarField Tmax(cells_.size(), Tmax_);
scalarField Tmin(cells_.size(), Tmin_);
scalarField Tmax(cells_.size(), Tmax_);
scalarField heMin(thermo.he(thermo.p(), Tmin, cells_));
scalarField heMax(thermo.he(thermo.p(), Tmax, cells_));
scalarField heMin(thermo.he(thermo.p(), Tmin, cells_));
scalarField heMax(thermo.he(thermo.p(), Tmax, cells_));
scalarField& hec = he.internalField();
scalarField& hec = he.internalField();
forAll(cells_, i)
{
label cellI = cells_[i];
hec[cellI]= max(min(hec[cellI], heMax[i]), heMin[i]);
}
forAll(cells_, i)
{
label cellI = cells_[i];
hec[cellI]= max(min(hec[cellI], heMax[i]), heMin[i]);
}
// handle boundaries in the case of 'all'
if (selectionMode_ == smAll)
// handle boundaries in the case of 'all'
if (selectionMode_ == smAll)
{
volScalarField::GeometricBoundaryField& bf = he.boundaryField();
forAll(bf, patchi)
{
volScalarField::GeometricBoundaryField& bf = he.boundaryField();
fvPatchScalarField& hep = bf[patchi];
forAll(bf, patchI)
if (!hep.fixesValue())
{
fvPatchScalarField& hep = bf[patchI];
if (hep.fixesValue())
{
// not over-riding fixed conditions
continue;
}
const scalarField& pp = thermo.p().boundaryField()[patchI];
const scalarField& pp = thermo.p().boundaryField()[patchi];
scalarField Tminp(pp.size(), Tmin_);
scalarField Tmaxp(pp.size(), Tmax_);
scalarField heMinp(thermo.he(pp, Tminp, patchI));
scalarField heMaxp(thermo.he(pp, Tmaxp, patchI));
scalarField heMinp(thermo.he(pp, Tminp, patchi));
scalarField heMaxp(thermo.he(pp, Tmaxp, patchi));
forAll(hep, faceI)
forAll(hep, facei)
{
hep[faceI] =
max(min(hep[faceI], heMaxp[faceI]), heMinp[faceI]);
hep[facei] =
max(min(hep[facei], heMaxp[facei]), heMinp[facei]);
}
}
}
......
......@@ -109,9 +109,6 @@ public:
// Member Functions
virtual bool alwaysApply() const;
// Evaluate
//- Correct the energy field
......
Supports Markdown
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