externalWallHeatFluxTemperature: Changed Ta entry to Function1 to support time variation

Temporal variation of Ta is generally more useful than spatial variation but
a run-time switch between the two modes of operation could be implemented in
needed.
This commit is contained in:
Henry Weller
2017-06-13 09:00:48 +01:00
parent af66eb78a6
commit 50cb9ea495
5 changed files with 161 additions and 13 deletions

View File

@ -0,0 +1,41 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 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 "Uniform.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
Foam::Function1Types::Uniform<Type>::Uniform
(
const word& entryName,
const dictionary& dict
)
:
Constant<Type>(entryName, dict)
{}
// ************************************************************************* //

View File

@ -0,0 +1,104 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 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/>.
Class
Foam::Function1Types::Uniform
Description
Templated function that returns a constant value.
Provides backward-compatibility for cases where a field is spatially
"uniform" and may be treated as a constant value.
Usage - for entry \<entryName\> returning the value <value>:
\verbatim
<entryName> uniform <value>
\endverbatim
SourceFiles
Uniform.C
\*---------------------------------------------------------------------------*/
#ifndef Uniform_H
#define Uniform_H
#include "Function1.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace Function1Types
{
/*---------------------------------------------------------------------------*\
Class Uniform Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class Uniform
:
public Constant<Type>
{
// Private Member Functions
//- Disallow default bitwise assignment
void operator=(const Uniform<Type>&);
public:
// Runtime type information
TypeName("uniform");
// Constructors
//- Construct from entry name and dictionary
Uniform(const word& entryName, const dictionary& dict);
//- Construct and return a clone
virtual tmp<Function1<Type>> clone() const
{
return tmp<Function1<Type>>(new Uniform<Type>(*this));
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Function1Types
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "Uniform.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -24,6 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "Constant.H"
#include "Uniform.H"
#include "ZeroConstant.H"
#include "OneConstant.H"
#include "PolynomialEntry.H"
@ -41,6 +42,7 @@ License
#define makeFunction1s(Type) \
makeFunction1(Type); \
makeFunction1Type(Constant, Type); \
makeFunction1Type(Uniform, Type); \
makeFunction1Type(ZeroConstant, Type); \
makeFunction1Type(OneConstant, Type); \
makeFunction1Type(Polynomial, Type); \

View File

@ -69,6 +69,7 @@ externalWallHeatFluxTemperatureFvPatchScalarField
temperatureCoupledBase(patch(), "undefined", "undefined", "undefined-K"),
mode_(fixedHeatFlux),
Q_(0),
Ta_(),
relaxation_(1),
emissivity_(0),
qrRelaxation_(1),
@ -94,6 +95,7 @@ externalWallHeatFluxTemperatureFvPatchScalarField
temperatureCoupledBase(patch(), dict),
mode_(operationModeNames.read(dict.lookup("mode"))),
Q_(0),
Ta_(Function1<scalar>::New("Ta", dict)),
relaxation_(dict.lookupOrDefault<scalar>("relaxation", 1)),
emissivity_(dict.lookupOrDefault<scalar>("emissivity", 0)),
qrRelaxation_(dict.lookupOrDefault<scalar>("qrRelaxation", 1)),
@ -118,7 +120,6 @@ externalWallHeatFluxTemperatureFvPatchScalarField
case fixedHeatTransferCoeff:
{
h_ = scalarField("h", dict, p.size());
Ta_ = scalarField("Ta", dict, p.size());
if (dict.found("thicknessLayers"))
{
@ -174,6 +175,7 @@ externalWallHeatFluxTemperatureFvPatchScalarField
temperatureCoupledBase(patch(), ptf),
mode_(ptf.mode_),
Q_(ptf.Q_),
Ta_(ptf.Ta_, false),
relaxation_(ptf.relaxation_),
emissivity_(ptf.emissivity_),
qrRelaxation_(ptf.qrRelaxation_),
@ -196,7 +198,6 @@ externalWallHeatFluxTemperatureFvPatchScalarField
case fixedHeatTransferCoeff:
{
h_.map(ptf.h_, mapper);
Ta_.map(ptf.Ta_, mapper);
break;
}
@ -221,7 +222,7 @@ externalWallHeatFluxTemperatureFvPatchScalarField
Q_(tppsf.Q_),
q_(tppsf.q_),
h_(tppsf.h_),
Ta_(tppsf.Ta_),
Ta_(tppsf.Ta_, false),
relaxation_(tppsf.relaxation_),
emissivity_(tppsf.emissivity_),
qrPrevious_(tppsf.qrPrevious_),
@ -245,7 +246,7 @@ externalWallHeatFluxTemperatureFvPatchScalarField
Q_(tppsf.Q_),
q_(tppsf.q_),
h_(tppsf.h_),
Ta_(tppsf.Ta_),
Ta_(tppsf.Ta_, false),
relaxation_(tppsf.relaxation_),
emissivity_(tppsf.emissivity_),
qrPrevious_(tppsf.qrPrevious_),
@ -280,7 +281,6 @@ void Foam::externalWallHeatFluxTemperatureFvPatchScalarField::autoMap
case fixedHeatTransferCoeff:
{
h_.autoMap(m);
Ta_.autoMap(m);
break;
}
@ -319,7 +319,6 @@ void Foam::externalWallHeatFluxTemperatureFvPatchScalarField::rmap
case fixedHeatTransferCoeff:
{
h_.rmap(tiptf.h_, addr);
Ta_.rmap(tiptf.Ta_, addr);
break;
}
@ -386,7 +385,8 @@ void Foam::externalWallHeatFluxTemperatureFvPatchScalarField::updateCoeffs()
}
scalarField hp(1/(1/h_ + totalSolidRes));
scalarField hpTa(hp*Ta_);
const scalar Ta = Ta_->value(this->db().time().timeOutputValue());
scalarField hpTa(hp*Ta);
if (emissivity_ > 0)
{
@ -397,18 +397,18 @@ void Foam::externalWallHeatFluxTemperatureFvPatchScalarField::updateCoeffs()
// ... including the effect of the solid wall thermal
// resistance
scalarField TpLambda(h_/(h_ + 1/totalSolidRes));
scalarField Ts(TpLambda*Tp + (1 - TpLambda)*Ta_);
scalarField lambdaTa4(pow4((1 - TpLambda)*Ta_));
scalarField Ts(TpLambda*Tp + (1 - TpLambda)*Ta);
scalarField lambdaTa4(pow4((1 - TpLambda)*Ta));
hp += emissivity_*sigma.value()*(pow4(Ts) - lambdaTa4)/Tp;
hpTa += sigma.value()*(emissivity_*lambdaTa4 + pow4(Ta_));
hpTa += sigma.value()*(emissivity_*lambdaTa4 + pow4(Ta));
}
else
{
// ... if there is no solid wall thermal resistance use
// the current wall temperature
hp += emissivity_*sigma.value()*pow3(Tp);
hpTa += sigma.value()*pow4(Ta_);
hpTa += sigma.value()*pow4(Ta);
}
}
@ -490,7 +490,7 @@ void Foam::externalWallHeatFluxTemperatureFvPatchScalarField::write
case fixedHeatTransferCoeff:
{
h_.writeEntry("h", os);
Ta_.writeEntry("Ta", os);
Ta_->writeData(os);
if (relaxation_ < 1)
{

View File

@ -100,6 +100,7 @@ SourceFiles
#include "mixedFvPatchFields.H"
#include "temperatureCoupledBase.H"
#include "Function1.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -147,7 +148,7 @@ private:
scalarField h_;
//- Ambient temperature [K]
scalarField Ta_;
autoPtr<Function1<scalar>> Ta_;
//- Relaxation for the wall temperature (thermal inertia)
scalar relaxation_;