fvOptions::function2HeatTransfer: Generalised replacement for tabulatedHeatTransfer using Function2

This commit is contained in:
Henry Weller
2020-11-13 16:37:43 +00:00
parent 2c6e4320af
commit b2bf6f3733
3 changed files with 37 additions and 49 deletions

View File

@ -49,7 +49,7 @@ interRegion = sources/interRegion
$(interRegion)/interRegionHeatTransfer/interRegionHeatTransferModel/interRegionHeatTransferModel.C
$(interRegion)/interRegionHeatTransfer/interRegionHeatTransferModel/interRegionHeatTransferModelIO.C
$(interRegion)/interRegionHeatTransfer/constantHeatTransfer/constantHeatTransfer.C
$(interRegion)/interRegionHeatTransfer/tabulatedHeatTransfer/tabulatedHeatTransfer.C
$(interRegion)/interRegionHeatTransfer/function2HeatTransfer/function2HeatTransfer.C
$(interRegion)/interRegionHeatTransfer/variableHeatTransfer/variableHeatTransfer.C
$(interRegion)/interRegionExplicitPorositySource/interRegionExplicitPorositySource.C

View File

@ -23,7 +23,7 @@ License
\*---------------------------------------------------------------------------*/
#include "tabulatedHeatTransfer.H"
#include "function2HeatTransfer.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -32,11 +32,11 @@ namespace Foam
{
namespace fv
{
defineTypeNameAndDebug(tabulatedHeatTransfer, 0);
defineTypeNameAndDebug(function2HeatTransfer, 0);
addToRunTimeSelectionTable
(
option,
tabulatedHeatTransfer,
function2HeatTransfer,
dictionary
);
}
@ -45,19 +45,19 @@ namespace fv
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
const Foam::interpolation2DTable<Foam::scalar>&
Foam::fv::tabulatedHeatTransfer::hTable() const
const Foam::Function2<Foam::scalar>&
Foam::fv::function2HeatTransfer::htcFunc() const
{
if (!hTable_.valid())
if (!htcFunc_.valid())
{
hTable_.reset(new interpolation2DTable<scalar>(coeffs_));
htcFunc_ = Function2<scalar>::New("htcFunc", coeffs_);
}
return hTable_();
return htcFunc_();
}
const Foam::volScalarField& Foam::fv::tabulatedHeatTransfer::AoV() const
const Foam::volScalarField& Foam::fv::function2HeatTransfer::AoV() const
{
if (!AoV_.valid())
{
@ -84,7 +84,7 @@ const Foam::volScalarField& Foam::fv::tabulatedHeatTransfer::AoV() const
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fv::tabulatedHeatTransfer::tabulatedHeatTransfer
Foam::fv::function2HeatTransfer::function2HeatTransfer
(
const word& name,
const word& modelType,
@ -95,7 +95,7 @@ Foam::fv::tabulatedHeatTransfer::tabulatedHeatTransfer
interRegionHeatTransferModel(name, modelType, dict, mesh),
UName_(coeffs_.lookupOrDefault<word>("U", "U")),
UNbrName_(coeffs_.lookupOrDefault<word>("UNbr", "U")),
hTable_(),
htcFunc_(),
AoV_(),
startTimeName_(mesh.time().timeName())
{}
@ -103,13 +103,13 @@ Foam::fv::tabulatedHeatTransfer::tabulatedHeatTransfer
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::fv::tabulatedHeatTransfer::~tabulatedHeatTransfer()
Foam::fv::function2HeatTransfer::~function2HeatTransfer()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::fv::tabulatedHeatTransfer::calculateHtc() const
void Foam::fv::function2HeatTransfer::calculateHtc() const
{
const fvMesh& nbrMesh = mesh_.time().lookupObject<fvMesh>(nbrRegionName());
@ -117,23 +117,14 @@ void Foam::fv::tabulatedHeatTransfer::calculateHtc() const
nbrMesh.lookupObject<volVectorField>(UNbrName_);
const scalarField UMagNbr(mag(UNbr));
const scalarField UMagNbrMapped(interpolate(UMagNbr));
const volVectorField& U = mesh_.lookupObject<volVectorField>(UName_);
scalarField& htcc = htc_.primitiveFieldRef();
forAll(htcc, i)
{
htcc[i] = hTable()(mag(U[i]), UMagNbrMapped[i]);
}
htcc = htcc*AoV();
htc_.primitiveFieldRef() = htcFunc().value(mag(U()), UMagNbrMapped)*AoV();
}
bool Foam::fv::tabulatedHeatTransfer::read(const dictionary& dict)
bool Foam::fv::function2HeatTransfer::read(const dictionary& dict)
{
if (interRegionHeatTransferModel::read(dict))
{

View File

@ -22,21 +22,22 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::fv::tabulatedHeatTransfer
Foam::fv::function2HeatTransfer
Description
Tabulated heat transfer model. The heat exchange area per unit volume
must be provided. The 2D table returns the heat transfer coefficient
by querying the local and neighbour region velocities
Function2 heat transfer model.
The heat exchange area per unit volume must be provided. The 2D function
returns the heat transfer coefficient by querying the local and neighbour
region velocities.
\*---------------------------------------------------------------------------*/
#ifndef tabulatedHeatTransfer_H
#define tabulatedHeatTransfer_H
#ifndef function2HeatTransfer_H
#define function2HeatTransfer_H
#include "interRegionHeatTransferModel.H"
#include "autoPtr.H"
#include "interpolation2DTable.H"
#include "Function2.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -46,10 +47,10 @@ namespace fv
{
/*---------------------------------------------------------------------------*\
Class tabulatedHeatTransfer Declaration
Class function2HeatTransfer Declaration
\*---------------------------------------------------------------------------*/
class tabulatedHeatTransfer
class function2HeatTransfer
:
public interRegionHeatTransferModel
{
@ -61,14 +62,14 @@ class tabulatedHeatTransfer
//- Name of neighbour velocity field; default = U
word UNbrName_;
//- 2D look up table
mutable autoPtr<interpolation2DTable<scalar>> hTable_;
//- Heat transfer coefficient function ptr
mutable autoPtr<Function2<scalar>> htcFunc_;
//- Area per unit volume of heat exchanger
mutable autoPtr<volScalarField> AoV_;
//- Heat transfer coefficient table
const interpolation2DTable<scalar>& hTable() const;
//- Heat transfer coefficient function
const Function2<scalar>& htcFunc() const;
//- Field of area divided by volume
const volScalarField& AoV() const;
@ -80,13 +81,13 @@ class tabulatedHeatTransfer
public:
//- Runtime type information
TypeName("tabulatedHeatTransfer");
TypeName("function2HeatTransfer");
// Constructors
//- Construct from dictionary
tabulatedHeatTransfer
function2HeatTransfer
(
const word& name,
const word& modelType,
@ -96,19 +97,16 @@ public:
//- Destructor
virtual ~tabulatedHeatTransfer();
virtual ~function2HeatTransfer();
// Public Functions
// Member Functions
//- Calculate the heat transfer coefficient
virtual void calculateHtc() const;
// IO
//- Read dictionary
virtual bool read(const dictionary& dict);
//- Read dictionary
virtual bool read(const dictionary& dict);
};
@ -119,7 +117,6 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //