fvConstraints::limitTemperature: Added options energy/temperature field name
The energy field limited to limit the temperature is obtained automatically from
the thermo package for the phase except for compressibleInterFoam which uniquely
solves for mixture temperature directly rather than energy. To limit this
temperature rather than the energy the optional 'field' entry should be set to
'T', e.g.:
limitT
{
type limitTemperature;
selectionMode all;
field T;
min 310;
max 500;
}
This commit is contained in:
@ -50,6 +50,7 @@ void Foam::fv::limitTemperature::readCoeffs()
|
||||
{
|
||||
Tmin_ = coeffs().lookup<scalar>("min");
|
||||
Tmax_ = coeffs().lookup<scalar>("max");
|
||||
fieldName_ = coeffs().lookupOrDefault<word>("field", word::null);
|
||||
phaseName_ = coeffs().lookupOrDefault<word>("phase", word::null);
|
||||
}
|
||||
|
||||
@ -68,6 +69,7 @@ Foam::fv::limitTemperature::limitTemperature
|
||||
set_(coeffs(), mesh),
|
||||
Tmin_(-vGreat),
|
||||
Tmax_(vGreat),
|
||||
fieldName_(word::null),
|
||||
phaseName_(word::null)
|
||||
{
|
||||
readCoeffs();
|
||||
@ -78,6 +80,12 @@ Foam::fv::limitTemperature::limitTemperature
|
||||
|
||||
Foam::wordList Foam::fv::limitTemperature::constrainedFields() const
|
||||
{
|
||||
if (fieldName_ != word::null)
|
||||
{
|
||||
return wordList(1, IOobject::groupName(fieldName_, phaseName_));
|
||||
}
|
||||
else
|
||||
{
|
||||
const basicThermo& thermo =
|
||||
mesh().lookupObject<basicThermo>
|
||||
(
|
||||
@ -85,31 +93,63 @@ Foam::wordList Foam::fv::limitTemperature::constrainedFields() const
|
||||
);
|
||||
|
||||
return wordList(1, thermo.he().name());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Foam::fv::limitTemperature::constrain(volScalarField& he) const
|
||||
{
|
||||
const labelList& cells = set_.cells();
|
||||
|
||||
if (he.dimensions() == dimTemperature)
|
||||
{
|
||||
scalarField& Tc = he.primitiveFieldRef();
|
||||
|
||||
forAll(cells, i)
|
||||
{
|
||||
const label celli = cells[i];
|
||||
Tc[celli] = max(min(Tc[celli], Tmax_), Tmin_);
|
||||
}
|
||||
|
||||
// Handle boundaries in the case of 'all'
|
||||
if (set_.selectionMode() == fvCellSet::selectionModeType::all)
|
||||
{
|
||||
volScalarField::Boundary& Tbf = he.boundaryFieldRef();
|
||||
|
||||
forAll(Tbf, patchi)
|
||||
{
|
||||
fvPatchScalarField& Tp = Tbf[patchi];
|
||||
|
||||
if (!Tp.fixesValue())
|
||||
{
|
||||
forAll(Tp, facei)
|
||||
{
|
||||
Tp[facei] = max(min(Tp[facei], Tmax_), Tmin_);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const basicThermo& thermo =
|
||||
mesh().lookupObject<basicThermo>
|
||||
(
|
||||
IOobject::groupName(physicalProperties::typeName, phaseName_)
|
||||
);
|
||||
|
||||
const labelList& cells = set_.cells();
|
||||
const scalarField Tmin(cells.size(), Tmin_);
|
||||
const scalarField Tmax(cells.size(), Tmax_);
|
||||
|
||||
scalarField Tmin(cells.size(), Tmin_);
|
||||
scalarField Tmax(cells.size(), Tmax_);
|
||||
|
||||
scalarField heMin(thermo.he(Tmin, cells));
|
||||
scalarField heMax(thermo.he(Tmax, cells));
|
||||
const scalarField heMin(thermo.he(Tmin, cells));
|
||||
const scalarField heMax(thermo.he(Tmax, cells));
|
||||
|
||||
scalarField& hec = he.primitiveFieldRef();
|
||||
|
||||
forAll(cells, i)
|
||||
{
|
||||
const label celli = cells[i];
|
||||
hec[celli]= max(min(hec[celli], heMax[i]), heMin[i]);
|
||||
hec[celli] = max(min(hec[celli], heMax[i]), heMin[i]);
|
||||
}
|
||||
|
||||
// Handle boundaries in the case of 'all'
|
||||
@ -123,11 +163,11 @@ bool Foam::fv::limitTemperature::constrain(volScalarField& he) const
|
||||
|
||||
if (!hep.fixesValue())
|
||||
{
|
||||
scalarField Tminp(hep.size(), Tmin_);
|
||||
scalarField Tmaxp(hep.size(), Tmax_);
|
||||
const scalarField Tminp(hep.size(), Tmin_);
|
||||
const scalarField Tmaxp(hep.size(), Tmax_);
|
||||
|
||||
scalarField heMinp(thermo.he(Tminp, patchi));
|
||||
scalarField heMaxp(thermo.he(Tmaxp, patchi));
|
||||
const scalarField heMinp(thermo.he(Tminp, patchi));
|
||||
const scalarField heMaxp(thermo.he(Tmaxp, patchi));
|
||||
|
||||
forAll(hep, facei)
|
||||
{
|
||||
@ -137,6 +177,7 @@ bool Foam::fv::limitTemperature::constrain(volScalarField& he) const
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return cells.size();
|
||||
}
|
||||
|
||||
@ -36,6 +36,9 @@ Usage
|
||||
|
||||
selectionMode all;
|
||||
|
||||
// field T; // Optional energy/temperature field name
|
||||
// Set to T for compressibleInterFoam
|
||||
|
||||
phase gas; // Optional phase name
|
||||
|
||||
min 200;
|
||||
@ -80,6 +83,9 @@ class limitTemperature
|
||||
//- Maximum temperature limit [K]
|
||||
scalar Tmax_;
|
||||
|
||||
//- Optional energy/temperature field name
|
||||
word fieldName_;
|
||||
|
||||
//- Optional phase name
|
||||
word phaseName_;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user