mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
fixedTemperatureConstraint,effectivenessHeatExchangerSource: Set the field name to that of the energy
field from which the temperature is obtained Removes the need for the 'alwaysApply' hack.
This commit is contained in:
@ -94,19 +94,20 @@ Foam::fv::fixedTemperatureConstraint::fixedTemperatureConstraint
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fieldNames_.setSize(1, "energy");
|
// Set the field name to that of the energy field from which the temperature
|
||||||
|
// is obtained
|
||||||
|
|
||||||
|
const basicThermo& thermo =
|
||||||
|
mesh_.lookupObject<basicThermo>("thermophysicalProperties");
|
||||||
|
|
||||||
|
fieldNames_.setSize(1, thermo.he().name());
|
||||||
|
|
||||||
applied_.setSize(1, false);
|
applied_.setSize(1, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
bool Foam::fv::fixedTemperatureConstraint::alwaysApply() const
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Foam::fv::fixedTemperatureConstraint::constrain
|
void Foam::fv::fixedTemperatureConstraint::constrain
|
||||||
(
|
(
|
||||||
fvMatrix<scalar>& eqn,
|
fvMatrix<scalar>& eqn,
|
||||||
@ -116,34 +117,30 @@ void Foam::fv::fixedTemperatureConstraint::constrain
|
|||||||
const basicThermo& thermo =
|
const basicThermo& thermo =
|
||||||
mesh_.lookupObject<basicThermo>("thermophysicalProperties");
|
mesh_.lookupObject<basicThermo>("thermophysicalProperties");
|
||||||
|
|
||||||
if (eqn.psi().name() == thermo.he().name())
|
switch (mode_)
|
||||||
{
|
{
|
||||||
switch (mode_)
|
case tmUniform:
|
||||||
{
|
{
|
||||||
case tmUniform:
|
const scalar t = mesh_.time().value();
|
||||||
{
|
scalarField Tuni(cells_.size(), Tuniform_->value(t));
|
||||||
const scalar t = mesh_.time().value();
|
eqn.setValues(cells_, thermo.he(thermo.p(), Tuni, cells_));
|
||||||
scalarField Tuni(cells_.size(), Tuniform_->value(t));
|
|
||||||
eqn.setValues(cells_, thermo.he(thermo.p(), Tuni, cells_));
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case tmLookup:
|
|
||||||
{
|
|
||||||
const volScalarField& T =
|
|
||||||
mesh().lookupObject<volScalarField>(TName_);
|
|
||||||
|
|
||||||
scalarField Tlkp(T, cells_);
|
|
||||||
eqn.setValues(cells_, thermo.he(thermo.p(), Tlkp, cells_));
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
// error handling done by NamedEnum
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
case tmLookup:
|
||||||
|
{
|
||||||
|
const volScalarField& T =
|
||||||
|
mesh().lookupObject<volScalarField>(TName_);
|
||||||
|
|
||||||
|
scalarField Tlkp(T, cells_);
|
||||||
|
eqn.setValues(cells_, thermo.he(thermo.p(), Tlkp, cells_));
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
// error handling done by NamedEnum
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -136,13 +136,8 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
virtual bool alwaysApply() const;
|
//- Constrain energy equation to fix the temperature
|
||||||
|
virtual void constrain(fvMatrix<scalar>& eqn, const label fieldI);
|
||||||
|
|
||||||
// Set values directly
|
|
||||||
|
|
||||||
//- Scalar
|
|
||||||
virtual void constrain(fvMatrix<scalar>& eqn, const label fieldI);
|
|
||||||
|
|
||||||
|
|
||||||
// IO
|
// IO
|
||||||
|
|||||||
@ -166,7 +166,6 @@ Foam::fv::effectivenessHeatExchangerSource::effectivenessHeatExchangerSource
|
|||||||
faceSign_(),
|
faceSign_(),
|
||||||
faceZoneArea_(0)
|
faceZoneArea_(0)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (zoneID_ < 0)
|
if (zoneID_ < 0)
|
||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
@ -185,7 +184,14 @@ Foam::fv::effectivenessHeatExchangerSource::effectivenessHeatExchangerSource
|
|||||||
<< nl << exit(FatalError);
|
<< nl << exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
fieldNames_.setSize(1, "energy");
|
// Set the field name to that of the energy field from which the temperature
|
||||||
|
// is obtained
|
||||||
|
|
||||||
|
const basicThermo& thermo =
|
||||||
|
mesh_.lookupObject<basicThermo>("thermophysicalProperties");
|
||||||
|
|
||||||
|
fieldNames_.setSize(1, thermo.he().name());
|
||||||
|
|
||||||
applied_.setSize(1, false);
|
applied_.setSize(1, false);
|
||||||
|
|
||||||
eTable_.reset(new interpolation2DTable<scalar>(coeffs_));
|
eTable_.reset(new interpolation2DTable<scalar>(coeffs_));
|
||||||
@ -196,12 +202,6 @@ Foam::fv::effectivenessHeatExchangerSource::effectivenessHeatExchangerSource
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
bool Foam::fv::effectivenessHeatExchangerSource::alwaysApply() const
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Foam::fv::effectivenessHeatExchangerSource::addSup
|
void Foam::fv::effectivenessHeatExchangerSource::addSup
|
||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
@ -212,11 +212,6 @@ void Foam::fv::effectivenessHeatExchangerSource::addSup
|
|||||||
const basicThermo& thermo =
|
const basicThermo& thermo =
|
||||||
mesh_.lookupObject<basicThermo>("thermophysicalProperties");
|
mesh_.lookupObject<basicThermo>("thermophysicalProperties");
|
||||||
|
|
||||||
if (eqn.psi().name() != thermo.he().name())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const surfaceScalarField Cpf(fvc::interpolate(thermo.Cp()));
|
const surfaceScalarField Cpf(fvc::interpolate(thermo.Cp()));
|
||||||
|
|
||||||
const surfaceScalarField& phi =
|
const surfaceScalarField& phi =
|
||||||
|
|||||||
@ -245,10 +245,7 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
virtual bool alwaysApply() const;
|
// Explicit and implicit source
|
||||||
|
|
||||||
|
|
||||||
// Add explicit and implicit contributions
|
|
||||||
|
|
||||||
//- Scalar
|
//- Scalar
|
||||||
virtual void addSup
|
virtual void addSup
|
||||||
@ -265,7 +262,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Add explicit and implicit contributions to compressible equation
|
// Explicit and implicit source for compressible equation
|
||||||
|
|
||||||
//- Scalar
|
//- Scalar
|
||||||
virtual void addSup
|
virtual void addSup
|
||||||
|
|||||||
@ -55,13 +55,13 @@ void Foam::fv::solidificationMeltingSource::apply
|
|||||||
if (eqn.psi().dimensions() == dimTemperature)
|
if (eqn.psi().dimensions() == dimTemperature)
|
||||||
{
|
{
|
||||||
// isothermal phase change - only include time derivative
|
// isothermal phase change - only include time derivative
|
||||||
// eqn -= L/Cp*(fvc::ddt(rho, alpha1_) + fvc::div(phi, alpha1_));
|
// eqn -= L/Cp*(fvc::ddt(rho, alpha1_) + fvc::div(phi, alpha1_));
|
||||||
eqn -= L/Cp*(fvc::ddt(rho, alpha1_));
|
eqn -= L/Cp*(fvc::ddt(rho, alpha1_));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// isothermal phase change - only include time derivative
|
// isothermal phase change - only include time derivative
|
||||||
// eqn -= L*(fvc::ddt(rho, alpha1_) + fvc::div(phi, alpha1_));
|
// eqn -= L*(fvc::ddt(rho, alpha1_) + fvc::div(phi, alpha1_));
|
||||||
eqn -= L*(fvc::ddt(rho, alpha1_));
|
eqn -= L*(fvc::ddt(rho, alpha1_));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user