multiphaseExternalTemperatureFvPatchScalarField: New multiphase version of externalTemperatureFvPatchScalarField

for the multiphaseEuler solver module, replacing the more specific
uniformFixedMultiphaseHeatFluxFvPatchScalarField as it provide equivalent
functionality if the heat-flux q is specified.

multiphaseExternalTemperatureFvPatchScalarField is derived from the refactored
and generalised externalTemperatureFvPatchScalarField, overriding the
getKappa member function to provide the multiphase equivalents of kappa and
other heat transfer properties.  All controls for
multiphaseExternalTemperatureFvPatchScalarField are the same as for
externalTemperatureFvPatchScalarField:

Class
    Foam::externalTemperatureFvPatchScalarField

Description
    This boundary condition applies a heat flux condition to temperature
    on an external wall. Heat flux can be specified in the following ways:

      - Fixed power: requires \c Q
      - Fixed heat flux: requires \c q
      - Fixed heat transfer coefficient: requires \c h and \c Ta

    where:
    \vartable
        Q  | Power Function1 of time [W]
        q  | Heat flux Function1 of time [W/m^2]
        h  | Heat transfer coefficient Function1 of time [W/m^2/K]
        Ta | Ambient temperature Function1 of time [K]
    \endvartable

    Only one of \c Q or \c q may be specified, if \c h and \c Ta are also
    specified the corresponding heat-flux is added.

    If the heat transfer coefficient \c h is specified an optional thin thermal
    layer resistances can also be specified through thicknessLayers and
    kappaLayers entries.

    The patch thermal conductivity \c kappa is obtained from the region
    thermophysicalTransportModel so that this boundary condition can be applied
    directly to either fluid or solid regions.

Usage
    \table
    Property     | Description                 | Required | Default value
    Q            | Power [W]                   | no       |
    q            | Heat flux [W/m^2]           | no       |
    h            | Heat transfer coefficient [W/m^2/K] | no |
    Ta           | Ambient temperature [K]     | if h is given  |
    thicknessLayers | Layer thicknesses [m]    | no |
    kappaLayers  | Layer thermal conductivities [W/m/K] | no |
    relaxation   | Relaxation for the wall temperature | no | 1
    emissivity   | Surface emissivity for radiative flux to ambient | no | 0
    qr           | Name of the radiative field | no | none
    qrRelaxation | Relaxation factor for radiative field | no | 1
    \endtable

    Example of the boundary condition specification:
    \verbatim
    <patchName>
    {
        type            externalTemperature;

        Ta              constant 300.0;
        h               uniform 10.0;
        thicknessLayers (0.1 0.2 0.3 0.4);
        kappaLayers     (1 2 3 4);

        value           $internalField;
    }
    \endverbatim

See also
    Foam::mixedFvPatchScalarField
    Foam::Function1
This commit is contained in:
Henry Weller
2023-07-15 21:50:14 +01:00
parent 75106dcb62
commit 6fce005097
13 changed files with 349 additions and 396 deletions

View File

@ -31,7 +31,7 @@ wallBoilingSubModels/departureFrequencyModels/KocamustafaogullariIshiiDepartureF
derivedFvPatchFields/alphatPhaseChangeWallFunctionBase/alphatPhaseChangeWallFunctionBase.C
derivedFvPatchFields/alphatWallBoilingWallFunction/alphatWallBoilingWallFunctionFvPatchScalarField.C
derivedFvPatchFields/uniformFixedMultiphaseHeatFlux/uniformFixedMultiphaseHeatFluxFvPatchScalarField.C
derivedFvPatchFields/coupledMultiphaseTemperature/coupledMultiphaseTemperatureFvPatchScalarField.C
derivedFvPatchFields/multiphaseExternalTemperature/multiphaseExternalTemperatureFvPatchScalarField.C
LIB = $(FOAM_LIBBIN)/libmultiphaseThermophysicalTransportModels

View File

@ -0,0 +1,144 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "multiphaseExternalTemperatureFvPatchScalarField.H"
#include "phaseSystem.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
void Foam::multiphaseExternalTemperatureFvPatchScalarField::getKappa
(
scalarField& kappa,
scalarField& sumKappaTByDelta,
scalarField& sumKappaByDelta,
scalarField& Tref,
scalarField& Tw,
scalarField& sumq,
scalarField& qByKappa
) const
{
// Lookup the fluid model
const phaseSystem& fluid =
db().lookupObject<phaseSystem>(phaseSystem::propertiesName);
const phaseModel& thisPhase = fluid.phases()[internalField().group()];
scalarField sumKappa(size(), scalar(0));
scalarField sumKappaT(size(), scalar(0));
scalarField sumKappaTw(size(), scalar(0));
const label patchi = patch().index();
forAll(fluid.phases(), phasei)
{
const phaseModel& phase = fluid.phases()[phasei];
if (&phase != &thisPhase)
{
const scalarField& alpha = phase.boundaryField()[patchi];
const scalarField kappaEff(phase.kappaEff(patchi));
const scalarField alphaKappaEff(alpha*kappaEff);
const fvPatchScalarField& T =
phase.thermo().T().boundaryField()[patchi];
sumKappa += alphaKappaEff;
sumKappaT += alphaKappaEff*T.patchInternalField();
sumKappaTw += alphaKappaEff*T;
}
}
const scalarField& alpha = thisPhase.boundaryField()[patchi];
const scalarField kappaEff(thisPhase.kappaEff(patchi));
const scalarField alphaKappaEff(alpha*kappaEff);
kappa = alphaKappaEff;
qByKappa = sumq/(max(alpha, rootSmall)*kappaEff);
// sumq -= alpha*sumq;
const scalarField& T = *this;
Tw = (sumKappaTw + alphaKappaEff*T)/(sumKappa + alphaKappaEff);
Tref =
(sumKappaT + rootSmall*kappaEff*patchInternalField())
/(sumKappa + rootSmall*kappaEff);
sumKappaByDelta = sumKappa*patch().deltaCoeffs();
sumKappaTByDelta = sumKappaT*patch().deltaCoeffs();
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::multiphaseExternalTemperatureFvPatchScalarField::
multiphaseExternalTemperatureFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const dictionary& dict
)
:
externalTemperatureFvPatchScalarField(p, iF, dict)
{}
Foam::multiphaseExternalTemperatureFvPatchScalarField::
multiphaseExternalTemperatureFvPatchScalarField
(
const multiphaseExternalTemperatureFvPatchScalarField& psf,
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
externalTemperatureFvPatchScalarField(psf, p, iF, mapper)
{}
Foam::multiphaseExternalTemperatureFvPatchScalarField::
multiphaseExternalTemperatureFvPatchScalarField
(
const multiphaseExternalTemperatureFvPatchScalarField& psf,
const DimensionedField<scalar, volMesh>& iF
)
:
externalTemperatureFvPatchScalarField(psf, iF)
{}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
makePatchTypeField
(
fvPatchScalarField,
multiphaseExternalTemperatureFvPatchScalarField
);
}
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2015-2023 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -22,44 +22,26 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::uniformFixedMultiphaseHeatFluxFvPatchScalarField
Foam::multiphaseExternalTemperatureFvPatchScalarField
Description
Uniform fixed heat flux boundary condition for Eulerian multi-phase cases.
Constructs a mixed constraint which portions the heat flux between the
phases in such a way as to keep the boundary temperature uniform across all
phases. The heat flux can be specified as a time-varying function, and an
under-relaxation factor can be supplied if this is necessary to maintain
stability.
Mixed boundary condition for the phase temperature of a phase in an
Euler-Euler multiphase simulation, to be used for heat-transfer with another
region in a CHT case. Optional thin wall material layer resistances can be
specified through thicknessLayers and kappaLayers entries.
Usage
\table
Property | Description | Required | Default value
q | Heat flux [w/m^2] | yes |
relax | Relaxation factor | no | 1
\endtable
Example of the boundary condition specification:
\verbatim
<patchName>
{
type uniformFixedMultiphaseHeatFlux;
q 1000;
relax 0.3;
value $internalField;
}
\endverbatim
See also
Foam::externalTemperatureFvPatchScalarField
SourceFiles
uniformFixedMultiphaseHeatFluxFvPatchScalarField.C
multiphaseExternalTemperatureFvPatchScalarField.C
\*---------------------------------------------------------------------------*/
#ifndef uniformFixedMultiphaseHeatFluxFvPatchScalarField_H
#define uniformFixedMultiphaseHeatFluxFvPatchScalarField_H
#ifndef multiphaseExternalTemperatureFvPatchScalarField_H
#define multiphaseExternalTemperatureFvPatchScalarField_H
#include "mixedFvPatchFields.H"
#include "Function1.H"
#include "externalTemperatureFvPatchScalarField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -67,32 +49,42 @@ namespace Foam
{
/*---------------------------------------------------------------------------*\
Class uniformFixedMultiphaseHeatFluxFvPatchScalarField Declaration
Class multiphaseExternalTemperatureFvPatchScalarField Declaration
\*---------------------------------------------------------------------------*/
class uniformFixedMultiphaseHeatFluxFvPatchScalarField
class multiphaseExternalTemperatureFvPatchScalarField
:
public mixedFvPatchScalarField
public externalTemperatureFvPatchScalarField
{
// Private Data
//- Heat flux [W/m^2]
autoPtr<Function1<scalar>> q_;
protected:
//- Relaxation factor
scalar relax_;
//- Get the patch kappa, sum kappa*Tc/delta, kappa/delta and
// reference temperature for all phases except the phase being solved
// and also the current phase-average wall T and phase heat-flux
// obtained by partitioning the sum heat-flux provided
virtual void getKappa
(
scalarField& kappa,
scalarField& sumKappaTByDelta,
scalarField& sumKappaByDelta,
scalarField& Tref,
scalarField& Tw,
scalarField& sumq,
scalarField& qByKappa
) const;
public:
//- Runtime type information
TypeName("uniformFixedMultiphaseHeatFlux");
TypeName("multiphaseExternalTemperature");
// Constructors
//- Construct from patch, internal field and dictionary
uniformFixedMultiphaseHeatFluxFvPatchScalarField
multiphaseExternalTemperatureFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
@ -100,26 +92,26 @@ public:
);
//- Construct by mapping given
// uniformFixedMultiphaseHeatFluxFvPatchScalarField
// multiphaseExternalTemperatureFvPatchScalarField
// onto a new patch
uniformFixedMultiphaseHeatFluxFvPatchScalarField
multiphaseExternalTemperatureFvPatchScalarField
(
const uniformFixedMultiphaseHeatFluxFvPatchScalarField&,
const multiphaseExternalTemperatureFvPatchScalarField&,
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const fvPatchFieldMapper&
);
//- Disallow copy without setting internal field reference
uniformFixedMultiphaseHeatFluxFvPatchScalarField
multiphaseExternalTemperatureFvPatchScalarField
(
const uniformFixedMultiphaseHeatFluxFvPatchScalarField&
const multiphaseExternalTemperatureFvPatchScalarField&
) = delete;
//- Copy constructor setting internal field reference
uniformFixedMultiphaseHeatFluxFvPatchScalarField
multiphaseExternalTemperatureFvPatchScalarField
(
const uniformFixedMultiphaseHeatFluxFvPatchScalarField&,
const multiphaseExternalTemperatureFvPatchScalarField&,
const DimensionedField<scalar, volMesh>&
);
@ -131,32 +123,9 @@ public:
{
return tmp<fvPatchScalarField>
(
new uniformFixedMultiphaseHeatFluxFvPatchScalarField(*this, iF)
new multiphaseExternalTemperatureFvPatchScalarField(*this, iF)
);
}
// Member Functions
// Access
//- Allow manipulation of the boundary values
virtual bool fixesValue() const
{
return false;
}
// Evaluation functions
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();
// I-O
//- Write
virtual void write(Ostream&) const;
};

View File

@ -1,185 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2015-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "uniformFixedMultiphaseHeatFluxFvPatchScalarField.H"
#include "fvPatchFieldMapper.H"
#include "phaseSystem.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::uniformFixedMultiphaseHeatFluxFvPatchScalarField::
uniformFixedMultiphaseHeatFluxFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const dictionary& dict
)
:
mixedFvPatchScalarField(p, iF, dict, false),
q_(Function1<scalar>::New("q", dict)),
relax_(dict.lookupOrDefault<scalar>("relax", 1))
{
fvPatchScalarField::operator=(scalarField("value", dict, p.size()));
valueFraction() = 1;
refValue() = patchInternalField();
refGrad() = Zero;
}
Foam::uniformFixedMultiphaseHeatFluxFvPatchScalarField::
uniformFixedMultiphaseHeatFluxFvPatchScalarField
(
const uniformFixedMultiphaseHeatFluxFvPatchScalarField& psf,
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
mixedFvPatchScalarField(psf, p, iF, mapper),
q_(psf.q_, false),
relax_(psf.relax_)
{}
Foam::uniformFixedMultiphaseHeatFluxFvPatchScalarField::
uniformFixedMultiphaseHeatFluxFvPatchScalarField
(
const uniformFixedMultiphaseHeatFluxFvPatchScalarField& psf,
const DimensionedField<scalar, volMesh>& iF
)
:
mixedFvPatchScalarField(psf, iF),
q_(psf.q_, false),
relax_(psf.relax_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::uniformFixedMultiphaseHeatFluxFvPatchScalarField::updateCoeffs()
{
if (updated())
{
return;
}
const label patchi = patch().index();
const scalar q = q_->value(db().time().userTimeValue());
const phaseSystem& fluid =
db().lookupObject<phaseSystem>(phaseSystem::propertiesName);
const phaseModel& thisPhase = fluid.phases()[internalField().group()];
// Sums of alpha*kappaEff
scalarField sumNotThisAlphaKappaEff(patch().size(), 0);
scalarField sumNotThisAlphaKappaEffT(patch().size(), 0);
scalarField sumNotThisAlphaKappaEffTw(patch().size(), 0);
// Contributions from phases other than this one
forAll(fluid.phases(), phasei)
{
const phaseModel& phase = fluid.phases()[phasei];
if (&phase != &thisPhase)
{
const scalarField& alpha = phase.boundaryField()[patchi];
const scalarField kappaEff(phase.kappaEff(patchi));
const scalarField alphaKappaEff(alpha*kappaEff);
const fvPatchScalarField& T =
phase.thermo().T().boundaryField()[patchi];
sumNotThisAlphaKappaEff += alphaKappaEff;
sumNotThisAlphaKappaEffT += alphaKappaEff*T.patchInternalField();
sumNotThisAlphaKappaEffTw += alphaKappaEff*T;
}
}
// Contribution from this phase, and stabilisation
const scalarField& alpha = thisPhase.boundaryField()[patchi];
const scalarField kappaEff(thisPhase.kappaEff(patchi));
const scalarField alphaKappaEff(alpha*kappaEff);
const fvPatchScalarField& T = *this;
// Calculate the phase average wall temperature
const scalarField Tw =
(sumNotThisAlphaKappaEffTw + alphaKappaEff*T)
/(sumNotThisAlphaKappaEff + alphaKappaEff);
valueFraction() =
sumNotThisAlphaKappaEff/(sumNotThisAlphaKappaEff + alphaKappaEff);
// Stabilisation for refValue
sumNotThisAlphaKappaEff = max(sumNotThisAlphaKappaEff, rootSmall*kappaEff);
sumNotThisAlphaKappaEffT =
max
(
sumNotThisAlphaKappaEffT,
rootSmall*kappaEff*T.patchInternalField()
);
refValue() = sumNotThisAlphaKappaEffT/sumNotThisAlphaKappaEff;
refGrad() = q/(max(alpha, rootSmall)*kappaEff);
// Modify mixed parameters for under-relaxation
if (relax_ != 1)
{
const scalarField f(valueFraction());
valueFraction() = 1 - relax_*(1 - f);
refValue() = (f*relax_*refValue() + (1 - relax_)*Tw)/valueFraction();
//refGrad() = refGrad(); // No change
}
mixedFvPatchScalarField::updateCoeffs();
}
void Foam::uniformFixedMultiphaseHeatFluxFvPatchScalarField::write
(
Ostream& os
) const
{
mixedFvPatchScalarField::write(os);
writeEntry(os, q_());
writeEntry(os, "relax", relax_);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
makePatchTypeField
(
fvPatchScalarField,
uniformFixedMultiphaseHeatFluxFvPatchScalarField
);
}
// ************************************************************************* //

View File

@ -31,6 +31,38 @@ License
using Foam::constant::physicoChemical::sigma;
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
void Foam::externalTemperatureFvPatchScalarField::getKappa
(
scalarField& kappa,
scalarField& sumKappaTByDelta,
scalarField& sumKappaByDelta,
scalarField& Tref,
scalarField& Tw,
scalarField& sumq,
scalarField& qByKappa
) const
{
const thermophysicalTransportModel& ttm =
patch().boundaryMesh().mesh()
.lookupType<thermophysicalTransportModel>();
kappa = ttm.kappaEff(patch().index());
tmp<scalarField> qCorr(ttm.qCorr(patch().index()));
if (qCorr.valid())
{
sumq += qCorr;
}
qByKappa = sumq/kappa;
Tw = *this;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::externalTemperatureFvPatchScalarField::
@ -43,11 +75,21 @@ externalTemperatureFvPatchScalarField
:
mixedFvPatchScalarField(p, iF, dict, false),
haveQ_(dict.found("Q")),
Q_(haveQ_ ? dict.lookup<scalar>("Q") : NaN),
Q_
(
haveQ_
? Function1<scalar>::New("Q", dict)
: autoPtr<Function1<scalar>>()
),
haveq_(dict.found("q")),
q_(haveq_ ? scalarField("q", dict, p.size()) : scalarField()),
q_
(
haveq_
? Function1<scalar>::New("q", dict)
: autoPtr<Function1<scalar>>()
),
haveh_(dict.found("h")),
h_(haveh_ ? scalarField("h", dict, p.size()) : scalarField()),
h_(haveh_ ? Function1<scalar>::New("h", dict).ptr() : nullptr),
Ta_(haveh_ ? Function1<scalar>::New("Ta", dict).ptr() : nullptr),
emissivity_(dict.lookupOrDefault<scalar>("emissivity", 0)),
thicknessLayers_
@ -58,9 +100,9 @@ externalTemperatureFvPatchScalarField
(
dict.lookupOrDefault<scalarList>("kappaLayers", scalarList())
),
relaxation_(dict.lookupOrDefault<scalar>("relaxation", 1)),
relax_(dict.lookupOrDefault<scalar>("relaxation", 1)),
qrName_(dict.lookupOrDefault<word>("qr", word::null)),
qrRelaxation_(dict.lookupOrDefault<scalar>("qrRelaxation", 1)),
qrRelax_(dict.lookupOrDefault<scalar>("qrRelaxation", 1)),
qrPrevious_
(
qrName_ != word::null
@ -116,18 +158,18 @@ externalTemperatureFvPatchScalarField
:
mixedFvPatchScalarField(ptf, p, iF, mapper),
haveQ_(ptf.haveQ_),
Q_(ptf.Q_),
Q_(ptf.Q_, false),
haveq_(ptf.haveq_),
q_(haveq_ ? mapper(ptf.q_)() : scalarField()),
q_(ptf.q_, false),
haveh_(ptf.haveh_),
h_(haveh_ ? mapper(ptf.h_)() : scalarField()),
h_(ptf.h_, false),
Ta_(ptf.Ta_, false),
emissivity_(ptf.emissivity_),
thicknessLayers_(ptf.thicknessLayers_),
kappaLayers_(ptf.kappaLayers_),
relaxation_(ptf.relaxation_),
relax_(ptf.relax_),
qrName_(ptf.qrName_),
qrRelaxation_(ptf.qrRelaxation_),
qrRelax_(ptf.qrRelax_),
qrPrevious_
(
qrName_ != word::null
@ -146,18 +188,18 @@ externalTemperatureFvPatchScalarField
:
mixedFvPatchScalarField(tppsf, iF),
haveQ_(tppsf.haveQ_),
Q_(tppsf.Q_),
Q_(tppsf.Q_, false),
haveq_(tppsf.haveq_),
q_(tppsf.q_),
q_(tppsf.q_, false),
haveh_(tppsf.haveh_),
h_(tppsf.h_),
h_(tppsf.h_, false),
Ta_(tppsf.Ta_, false),
emissivity_(tppsf.emissivity_),
thicknessLayers_(tppsf.thicknessLayers_),
kappaLayers_(tppsf.kappaLayers_),
relaxation_(tppsf.relaxation_),
relax_(tppsf.relax_),
qrName_(tppsf.qrName_),
qrRelaxation_(tppsf.qrRelaxation_),
qrRelax_(tppsf.qrRelax_),
qrPrevious_(tppsf.qrPrevious_)
{}
@ -175,16 +217,6 @@ void Foam::externalTemperatureFvPatchScalarField::map
const externalTemperatureFvPatchScalarField& tiptf =
refCast<const externalTemperatureFvPatchScalarField>(ptf);
if (haveq_)
{
mapper(q_, tiptf.q_);
}
if (haveh_)
{
mapper(h_, tiptf.h_);
}
if (qrName_ != word::null)
{
mapper(qrPrevious_, tiptf.qrPrevious_);
@ -202,16 +234,6 @@ void Foam::externalTemperatureFvPatchScalarField::reset
const externalTemperatureFvPatchScalarField& tiptf =
refCast<const externalTemperatureFvPatchScalarField>(ptf);
if (haveq_)
{
q_.reset(tiptf.q_);
}
if (haveh_)
{
h_.reset(tiptf.h_);
}
if (qrName_ != word::null)
{
qrPrevious_.reset(tiptf.qrPrevious_);
@ -226,54 +248,47 @@ void Foam::externalTemperatureFvPatchScalarField::updateCoeffs()
return;
}
const scalarField& Tp(*this);
// Store current valueFraction and refValue for relaxation
const scalarField valueFraction0(valueFraction());
const scalarField refValue0(refValue());
// Get the radiative heat flux and relax
scalarField qr(Tp.size(), 0);
scalarField qr(size(), 0);
if (qrName_ != word::null)
{
qr =
qrRelaxation_
qrRelax_
*patch().lookupPatchField<volScalarField, scalar>(qrName_)
+ (1 - qrRelaxation_)*qrPrevious_;
+ (1 - qrRelax_)*qrPrevious_;
qrPrevious_ = qr;
}
// Compute the total non-convective heat flux
scalarField qTot(qr);
scalarField sumq(qr);
if (haveQ_)
{
qTot += Q_/gSum(patch().magSf());
sumq += Q_->value(db().time().userTimeValue())/gSum(patch().magSf());
}
if (haveq_)
{
qTot += q_;
sumq += q_->value(db().time().userTimeValue());
}
const thermophysicalTransportModel& ttm =
patch().boundaryMesh().mesh()
.lookupType<thermophysicalTransportModel>();
scalarField kappa(size(), 0);
scalarField sumKappaTByDelta(size(), 0);
scalarField sumKappaByDelta(size(), 0);
scalarField Tref(*this);
scalarField Tw(*this);
scalarField qByKappa(size(), 0);
getKappa
(
kappa,
sumKappaTByDelta,
sumKappaByDelta,
Tref,
Tw,
sumq,
qByKappa
);
const scalarField kappa(ttm.kappaEff(patch().index()));
tmp<scalarField> qCorr(ttm.qCorr(patch().index()));
if (qCorr.valid())
{
qTot += qCorr;
}
// Evaluate
if (!haveh_)
{
refGrad() = qTot/kappa;
refValue() = Tp;
valueFraction() = 0;
}
else
// Add optional external convective heat transfer contribution
if (haveh_)
{
scalar totalSolidRes = 0;
if (thicknessLayers_.size())
@ -288,6 +303,7 @@ void Foam::externalTemperatureFvPatchScalarField::updateCoeffs()
}
}
const scalar h = h_->value(this->db().time().userTimeValue());
const scalar Ta = Ta_->value(this->db().time().userTimeValue());
const scalarField hp
@ -298,44 +314,38 @@ void Foam::externalTemperatureFvPatchScalarField::updateCoeffs()
/(
(emissivity_ > 0)
? (
h_
h
+ emissivity_*sigma.value()
*((pow3(Ta) + pow3(Tp)) + Ta*Tp*(Ta + Tp))
*((pow3(Ta) + pow3(Tw)) + Ta*Tw*(Ta + Tw))
)()
: h_
: scalarField(size(), h)
) + totalSolidRes
)
);
const scalarField hpTa(hp*Ta);
sumKappaByDelta += hp;
sumKappaTByDelta += hp*Ta;
const scalarField kappaDeltaCoeffs
(
kappa*patch().deltaCoeffs()
);
refGrad() = 0;
forAll(Tp, i)
{
if (qTot[i] < 0)
{
const scalar hpmqTot = hp[i] - qTot[i]/Tp[i];
refValue()[i] = hpTa[i]/hpmqTot;
valueFraction()[i] = hpmqTot/(hpmqTot + kappaDeltaCoeffs[i]);
}
else
{
refValue()[i] = (hpTa[i] + qTot[i])/hp[i];
valueFraction()[i] = hp[i]/(hp[i] + kappaDeltaCoeffs[i]);
}
}
refValue() = sumKappaTByDelta/sumKappaByDelta;
}
else
{
refValue() = Tref;
}
// Relax
valueFraction() =
relaxation_*valueFraction() + (1 - relaxation_)*valueFraction0;
refValue() =
relaxation_*refValue() + (1 - relaxation_)*refValue0;
sumKappaByDelta/(kappa*patch().deltaCoeffs() + sumKappaByDelta);
refGrad() = qByKappa;
// Modify mixed parameters for under-relaxation
if (relax_ != 1)
{
const scalarField f(valueFraction());
valueFraction() = 1 - relax_*(1 - f);
refValue() = (f*relax_*refValue() + (1 - relax_)*Tw)/valueFraction();
// refGrad() = No change
}
mixedFvPatchScalarField::updateCoeffs();
@ -365,17 +375,17 @@ void Foam::externalTemperatureFvPatchScalarField::write
if (haveQ_)
{
writeEntry(os, "Q", Q_);
writeEntry(os, Q_());
}
if (haveq_)
{
writeEntry(os, "q", q_);
writeEntry(os, q_());
}
if (haveh_)
{
writeEntry(os, "h", h_);
writeEntry(os, h_());
writeEntry(os, Ta_());
writeEntryIfDifferent(os, "emissivity", scalar(0), emissivity_);
writeEntryIfDifferent
@ -394,12 +404,12 @@ void Foam::externalTemperatureFvPatchScalarField::write
);
}
writeEntryIfDifferent(os, "relaxation", scalar(1), relaxation_);
writeEntryIfDifferent(os, "relaxation", scalar(1), relax_);
if (qrName_ != word::null)
{
writeEntry(os, "qr", qrName_);
writeEntry(os, "qrRelaxation", qrRelaxation_);
writeEntry(os, "qrRelaxation", qrRelax_);
writeEntry(os, "qrPrevious", qrPrevious_);
}

View File

@ -28,37 +28,35 @@ Description
This boundary condition applies a heat flux condition to temperature
on an external wall. Heat flux can be specified in the following ways:
- fixed power: supply Q
- fixed heat flux: supply q
- fixed heat transfer coefficient: supply h and Ta
- Fixed power: requires \c Q
- Fixed heat flux: requires \c q
- Fixed heat transfer coefficient: requires \c h and \c Ta
where:
\vartable
Q | Power [W]
q | Heat flux [W/m^2]
h | Heat transfer coefficient [W/m^2/K]
Ta | Ambient temperature [K]
Q | Power Function1 of time [W]
q | Heat flux Function1 of time [W/m^2]
h | Heat transfer coefficient Function1 of time [W/m^2/K]
Ta | Ambient temperature Function1 of time [K]
\endvartable
If more than one parameter is given then the heat fluxes are summed.
Only one of \c Q or \c q may be specified, if \c h and \c Ta are also
specified the corresponding heat-flux is added.
If a heat transfer coefficient is given optional thin thermal layer
resistances can be specified through thicknessLayers and kappaLayers
entries.
If the heat transfer coefficient \c h is specified an optional thin thermal
layer resistances can also be specified through thicknessLayers and
kappaLayers entries.
The patch thermal conductivity \c kappa is obtained from the region
thermophysicalTransportModel so that this boundary condition can be applied
directly to either fluid or solid regions.
The ambient temperature Ta is specified as a Foam::Function1 of time but
uniform is space.
Usage
\table
Property | Description | Required | Default value
Q | Power [W] | no | 0
q | Heat flux [W/m^2] | no | 0
h | Heat transfer coefficient [W/m^2/K] | no | 0
Q | Power [W] | no |
q | Heat flux [W/m^2] | no |
h | Heat transfer coefficient [W/m^2/K] | no |
Ta | Ambient temperature [K] | if h is given |
thicknessLayers | Layer thicknesses [m] | no |
kappaLayers | Layer thermal conductivities [W/m/K] | no |
@ -84,8 +82,8 @@ Usage
\endverbatim
See also
Foam::patchKappa
Foam::mixedFvPatchScalarField
Foam::Function1
SourceFiles
externalTemperatureFvPatchScalarField.C
@ -119,7 +117,7 @@ class externalTemperatureFvPatchScalarField
bool haveQ_;
//- Heat power [W]
scalar Q_;
autoPtr<Function1<scalar>> Q_;
// Heat flux
@ -128,7 +126,7 @@ class externalTemperatureFvPatchScalarField
bool haveq_;
//- Heat flux [W/m^2]
scalarField q_;
autoPtr<Function1<scalar>> q_;
// Heat transfer coefficient
@ -137,7 +135,7 @@ class externalTemperatureFvPatchScalarField
bool haveh_;
//- Heat transfer coefficient [W/m^2K]
scalarField h_;
autoPtr<Function1<scalar>> h_;
//- Ambient temperature [K]
autoPtr<Function1<scalar>> Ta_;
@ -152,8 +150,8 @@ class externalTemperatureFvPatchScalarField
scalarList kappaLayers_;
//- Relaxation for the wall temperature (thermal inertia)
scalar relaxation_;
//- Relaxation factor for the wall temperature (thermal inertia)
scalar relax_;
// Radiation
@ -161,13 +159,30 @@ class externalTemperatureFvPatchScalarField
//- Name of the radiative heat flux
const word qrName_;
//- Relaxation for qr
scalar qrRelaxation_;
//- Relaxation factor for qr
scalar qrRelax_;
//- Cache qr for relaxation
scalarField qrPrevious_;
protected:
//- Get the patch kappa, kappa*Tc/delta, kappa/delta,
// reference T, current wall T and also the
// heat-flux/delta obtained from the sum heat-flux provided
virtual void getKappa
(
scalarField& kappa,
scalarField& sumKappaTByDelta,
scalarField& sumKappaByDelta,
scalarField& Tref,
scalarField& Tw,
scalarField& sumq,
scalarField& qByKappa
) const;
public:
//- Runtime type information

View File

@ -34,8 +34,8 @@ boundaryField
}
wall
{
type uniformFixedMultiphaseHeatFlux;
q
type multiphaseExternalTemperature;
q0
{
type scale;
value 73890;
@ -46,7 +46,7 @@ boundaryField
duration 0.01;
}
}
relax 0.3;
relaxation 0.3;
value $internalField;
}
front

View File

@ -34,7 +34,7 @@ boundaryField
}
wall
{
type uniformFixedMultiphaseHeatFlux;
type multiphaseExternalTemperature;
q
{
type scale;
@ -46,7 +46,7 @@ boundaryField
duration 0.01;
}
}
relax 0.3;
relaxation 0.3;
value $internalField;
}
front

View File

@ -34,7 +34,7 @@ boundaryField
}
wall
{
type uniformFixedMultiphaseHeatFlux;
type multiphaseExternalTemperature;
q
{
type scale;
@ -46,7 +46,7 @@ boundaryField
duration 0.01;
}
}
relax 0.3;
relaxation 0.3;
value $internalField;
}
front

View File

@ -34,7 +34,7 @@ boundaryField
}
wall
{
type uniformFixedMultiphaseHeatFlux;
type multiphaseExternalTemperature;
q
{
type scale;
@ -46,7 +46,7 @@ boundaryField
duration 0.01;
}
}
relax 0.3;
relaxation 0.3;
value $internalField;
}
front

View File

@ -34,7 +34,7 @@ boundaryField
}
wall
{
type uniformFixedMultiphaseHeatFlux;
type multiphaseExternalTemperature;
q
{
type scale;
@ -46,7 +46,7 @@ boundaryField
duration 0.01;
}
}
relax 0.3;
relaxation 0.3;
value $internalField;
}
front

View File

@ -34,7 +34,7 @@ boundaryField
}
wall
{
type uniformFixedMultiphaseHeatFlux;
type multiphaseExternalTemperature;
q
{
type scale;
@ -46,7 +46,7 @@ boundaryField
duration 0.01;
}
}
relax 0.3;
relaxation 0.3;
value $internalField;
}
front

View File

@ -34,7 +34,7 @@ boundaryField
}
wall
{
type uniformFixedMultiphaseHeatFlux;
type multiphaseExternalTemperature;
q
{
type scale;
@ -46,7 +46,7 @@ boundaryField
duration 0.01;
}
}
relax 0.3;
relaxation 0.3;
value $internalField;
}
front