Compare commits
3 Commits
develop.mo
...
feature-wa
| Author | SHA1 | Date | |
|---|---|---|---|
| f7ee5bcb10 | |||
| f2793f2ac8 | |||
| 013dbb8248 |
@ -855,7 +855,7 @@ bool Foam::UPstream::finishedRequest(const label i)
|
||||
// This allows MPI to progress behind the scenes if it wishes.
|
||||
|
||||
int flag = 0;
|
||||
if (i < 0 || i >= PstreamGlobals::outstandingRequests_.size())
|
||||
if (i >= 0 && i < PstreamGlobals::outstandingRequests_.size())
|
||||
{
|
||||
auto& request = PstreamGlobals::outstandingRequests_[i];
|
||||
|
||||
|
||||
@ -218,9 +218,11 @@ tmp<vectorField> atmBoundaryLayer::U(const vectorField& pCf) const
|
||||
const scalar groundMin = zDir() & ppMin_;
|
||||
|
||||
// (YGCJ:Table 1, RH:Eq. 6, HW:Eq. 5)
|
||||
scalarField zEff(max((zDir() & pCf) - groundMin - d + z0, z0));
|
||||
|
||||
scalarField Un
|
||||
(
|
||||
(Ustar(z0)/kappa_)*log(((zDir() & pCf) - groundMin - d + z0)/z0)
|
||||
(Ustar(z0)/kappa_)*log(zEff/z0)
|
||||
);
|
||||
|
||||
return flowDir()*Un;
|
||||
@ -235,9 +237,9 @@ tmp<scalarField> atmBoundaryLayer::k(const vectorField& pCf) const
|
||||
const scalar groundMin = zDir() & ppMin_;
|
||||
|
||||
// (YGCJ:Eq. 21; RH:Eq. 7, HW:Eq. 6 when C1=0 and C2=1)
|
||||
return
|
||||
sqr(Ustar(z0))/sqrt(Cmu_)
|
||||
*sqrt(C1_*log(((zDir() & pCf) - groundMin - d + z0)/z0) + C2_);
|
||||
scalarField zEff(max((zDir() & pCf) - groundMin - d + z0, z0));
|
||||
|
||||
return sqr(Ustar(z0))/sqrt(Cmu_)*sqrt(C1_*log(zEff/z0) + C2_);
|
||||
}
|
||||
|
||||
|
||||
@ -249,9 +251,9 @@ tmp<scalarField> atmBoundaryLayer::epsilon(const vectorField& pCf) const
|
||||
const scalar groundMin = zDir() & ppMin_;
|
||||
|
||||
// (YGCJ:Eq. 22; RH:Eq. 8, HW:Eq. 7 when C1=0 and C2=1)
|
||||
return
|
||||
pow3(Ustar(z0))/(kappa_*((zDir() & pCf) - groundMin - d + z0))
|
||||
*sqrt(C1_*log(((zDir() & pCf) - groundMin - d + z0)/z0) + C2_);
|
||||
scalarField zEff(max((zDir() & pCf) - groundMin - d + z0, z0));
|
||||
|
||||
return pow3(Ustar(z0))/(kappa_*zEff)*sqrt(C1_*log(zEff/z0) + C2_);
|
||||
}
|
||||
|
||||
|
||||
@ -263,7 +265,9 @@ tmp<scalarField> atmBoundaryLayer::omega(const vectorField& pCf) const
|
||||
const scalar groundMin = zDir() & ppMin_;
|
||||
|
||||
// (YGJ:Eq. 13)
|
||||
return Ustar(z0)/(kappa_*sqrt(Cmu_)*((zDir() & pCf) - groundMin - d + z0));
|
||||
scalarField zEff(max((zDir() & pCf) - groundMin - d + z0, z0));
|
||||
|
||||
return Ustar(z0)/(kappa_*sqrt(Cmu_)*zEff);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -108,6 +108,10 @@ turbulenceFields/turbulenceFields.C
|
||||
yPlus/yPlus.C
|
||||
wallShearStress/wallShearStress.C
|
||||
wallHeatFlux/wallHeatFlux.C
|
||||
wallHeatFlux/wallHeatFluxModels/wallHeatFluxModel/wallHeatFluxModel.C
|
||||
wallHeatFlux/wallHeatFluxModels/wallHeatFluxModel/wallHeatFluxModelNew.C
|
||||
wallHeatFlux/wallHeatFluxModels/wall/wall.C
|
||||
wallHeatFlux/wallHeatFluxModels/gauge/gauge.C
|
||||
|
||||
writeCellCentres/writeCellCentres.C
|
||||
writeCellVolumes/writeCellVolumes.C
|
||||
|
||||
@ -5,8 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2025 OpenCFD Ltd.
|
||||
Copyright (C) 2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -27,14 +26,8 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "wallHeatFlux.H"
|
||||
#include "turbulentFluidThermoModel.H"
|
||||
#include "solidThermo.H"
|
||||
#include "surfaceInterpolate.H"
|
||||
#include "fvcSnGrad.H"
|
||||
#include "wallPolyPatch.H"
|
||||
#include "turbulentFluidThermoModel.H"
|
||||
#include "wallHeatFluxModel.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "multiphaseInterSystem.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
@ -47,54 +40,6 @@ namespace functionObjects
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
|
||||
|
||||
void Foam::functionObjects::wallHeatFlux::writeFileHeader(Ostream& os) const
|
||||
{
|
||||
writeHeader(os, "Wall heat-flux");
|
||||
writeCommented(os, "Time");
|
||||
writeTabbed(os, "patch");
|
||||
writeTabbed(os, "min");
|
||||
writeTabbed(os, "max");
|
||||
writeTabbed(os, "integral");
|
||||
os << endl;
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::wallHeatFlux::calcHeatFlux
|
||||
(
|
||||
const volScalarField& alpha,
|
||||
const volScalarField& he,
|
||||
volScalarField& wallHeatFlux
|
||||
)
|
||||
{
|
||||
volScalarField::Boundary& wallHeatFluxBf = wallHeatFlux.boundaryFieldRef();
|
||||
|
||||
const volScalarField::Boundary& heBf = he.boundaryField();
|
||||
|
||||
const volScalarField::Boundary& alphaBf = alpha.boundaryField();
|
||||
|
||||
for (const label patchi : patchIDs_)
|
||||
{
|
||||
wallHeatFluxBf[patchi] = alphaBf[patchi]*heBf[patchi].snGrad();
|
||||
}
|
||||
|
||||
|
||||
const auto* qrPtr = cfindObject<volScalarField>(qrName_);
|
||||
|
||||
if (qrPtr)
|
||||
{
|
||||
const volScalarField::Boundary& radHeatFluxBf = qrPtr->boundaryField();
|
||||
|
||||
for (const label patchi : patchIDs_)
|
||||
{
|
||||
wallHeatFluxBf[patchi] -= radHeatFluxBf[patchi];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::wallHeatFlux::wallHeatFlux
|
||||
@ -105,32 +50,19 @@ Foam::functionObjects::wallHeatFlux::wallHeatFlux
|
||||
)
|
||||
:
|
||||
fvMeshFunctionObject(name, runTime, dict),
|
||||
writeFile(obr_, name, typeName, dict),
|
||||
qrName_("qr")
|
||||
qModelPtr_
|
||||
(
|
||||
wallHeatFluxModel::New
|
||||
(
|
||||
dict,
|
||||
mesh_,
|
||||
name,
|
||||
scopedName(typeName),
|
||||
*this
|
||||
)
|
||||
)
|
||||
{
|
||||
read(dict);
|
||||
|
||||
writeFileHeader(file());
|
||||
|
||||
volScalarField* wallHeatFluxPtr
|
||||
(
|
||||
new volScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
scopedName(typeName),
|
||||
mesh_.time().timeName(),
|
||||
mesh_.thisDb(),
|
||||
IOobjectOption::NO_READ,
|
||||
IOobjectOption::NO_WRITE,
|
||||
IOobjectOption::REGISTER
|
||||
),
|
||||
mesh_,
|
||||
dimensionedScalar(dimMass/pow3(dimTime), Zero)
|
||||
)
|
||||
);
|
||||
|
||||
regIOobject::store(wallHeatFluxPtr);
|
||||
}
|
||||
|
||||
|
||||
@ -138,178 +70,26 @@ Foam::functionObjects::wallHeatFlux::wallHeatFlux
|
||||
|
||||
bool Foam::functionObjects::wallHeatFlux::read(const dictionary& dict)
|
||||
{
|
||||
const polyBoundaryMesh& pbm = mesh_.boundaryMesh();
|
||||
|
||||
fvMeshFunctionObject::read(dict);
|
||||
writeFile::read(dict);
|
||||
|
||||
dict.readIfPresent("qr", qrName_);
|
||||
|
||||
wordRes patchNames;
|
||||
labelHashSet patchSet;
|
||||
if (dict.readIfPresent("patches", patchNames) && !patchNames.empty())
|
||||
Log << type() << ' ' << name() << " read:" << endl;
|
||||
if (!fvMeshFunctionObject::read(dict) || !qModelPtr_->read(dict))
|
||||
{
|
||||
patchSet = pbm.patchSet(patchNames);
|
||||
return false;
|
||||
}
|
||||
|
||||
labelHashSet allWalls(pbm.findPatchIDs<wallPolyPatch>());
|
||||
|
||||
Info<< type() << ' ' << name() << ':' << nl;
|
||||
|
||||
if (patchSet.empty())
|
||||
{
|
||||
patchIDs_ = allWalls.sortedToc();
|
||||
|
||||
Info<< " processing all (" << patchIDs_.size()
|
||||
<< ") wall patches" << nl << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
allWalls &= patchSet;
|
||||
patchSet -= allWalls;
|
||||
patchIDs_ = allWalls.sortedToc();
|
||||
|
||||
if (!patchSet.empty())
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Requested wall heat-flux on ("
|
||||
<< patchSet.size() << ") non-wall patches:" << nl;
|
||||
|
||||
for (const label patchi : patchSet.sortedToc())
|
||||
{
|
||||
Info<< " " << pbm[patchi].name() << nl;
|
||||
}
|
||||
Info<< nl;
|
||||
}
|
||||
|
||||
Info<< " processing (" << patchIDs_.size()
|
||||
<< ") wall patches:" << nl;
|
||||
|
||||
for (const label patchi : patchIDs_)
|
||||
{
|
||||
Info<< " " << pbm[patchi].name() << nl;
|
||||
}
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::wallHeatFlux::execute()
|
||||
{
|
||||
auto& wallHeatFlux = lookupObjectRef<volScalarField>(scopedName(typeName));
|
||||
|
||||
if
|
||||
(
|
||||
foundObject<compressible::turbulenceModel>
|
||||
(
|
||||
turbulenceModel::propertiesName
|
||||
)
|
||||
)
|
||||
{
|
||||
const compressible::turbulenceModel& turbModel =
|
||||
lookupObject<compressible::turbulenceModel>
|
||||
(
|
||||
turbulenceModel::propertiesName
|
||||
);
|
||||
|
||||
calcHeatFlux
|
||||
(
|
||||
turbModel.alphaEff()(),
|
||||
turbModel.transport().he(),
|
||||
wallHeatFlux
|
||||
);
|
||||
}
|
||||
else if (foundObject<fluidThermo>(fluidThermo::dictName))
|
||||
{
|
||||
const fluidThermo& thermo =
|
||||
lookupObject<fluidThermo>(fluidThermo::dictName);
|
||||
|
||||
calcHeatFlux
|
||||
(
|
||||
thermo.alpha(),
|
||||
thermo.he(),
|
||||
wallHeatFlux
|
||||
);
|
||||
}
|
||||
else if (foundObject<solidThermo>(solidThermo::dictName))
|
||||
{
|
||||
const solidThermo& thermo =
|
||||
lookupObject<solidThermo>(solidThermo::dictName);
|
||||
|
||||
calcHeatFlux(thermo.alpha(), thermo.he(), wallHeatFlux);
|
||||
}
|
||||
else if
|
||||
(
|
||||
foundObject<multiphaseInterSystem>
|
||||
(multiphaseInterSystem::phasePropertiesName)
|
||||
)
|
||||
{
|
||||
const auto& thermo = lookupObject<multiphaseInterSystem>
|
||||
(
|
||||
multiphaseInterSystem::phasePropertiesName
|
||||
);
|
||||
|
||||
calcHeatFlux(thermo.kappaEff()(), thermo.T(), wallHeatFlux);
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unable to find compressible turbulence model in the "
|
||||
<< "database" << exit(FatalError);
|
||||
}
|
||||
|
||||
|
||||
const fvPatchList& patches = mesh_.boundary();
|
||||
|
||||
const surfaceScalarField::Boundary& magSf = mesh_.magSf().boundaryField();
|
||||
|
||||
for (const label patchi : patchIDs_)
|
||||
{
|
||||
const fvPatch& pp = patches[patchi];
|
||||
|
||||
const scalarField& hfp = wallHeatFlux.boundaryField()[patchi];
|
||||
|
||||
const MinMax<scalar> limits = gMinMax(hfp);
|
||||
const scalar integralHfp = gWeightedSum(magSf[patchi], hfp);
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
writeCurrentTime(file());
|
||||
|
||||
file()
|
||||
<< token::TAB << pp.name()
|
||||
<< token::TAB << limits.min()
|
||||
<< token::TAB << limits.max()
|
||||
<< token::TAB << integralHfp
|
||||
<< endl;
|
||||
}
|
||||
|
||||
Log << " min/max/integ(" << pp.name() << ") = "
|
||||
<< limits.min() << ", " << limits.max()
|
||||
<< ", " << integralHfp << endl;
|
||||
|
||||
this->setResult("min(" + pp.name() + ")", limits.min());
|
||||
this->setResult("max(" + pp.name() + ")", limits.max());
|
||||
this->setResult("int(" + pp.name() + ")", integralHfp);
|
||||
}
|
||||
|
||||
return true;
|
||||
Log << type() << ' ' << name() << " execute:" << endl;
|
||||
return qModelPtr_->execute();
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::wallHeatFlux::write()
|
||||
{
|
||||
const auto& wallHeatFlux =
|
||||
lookupObject<volScalarField>(scopedName(typeName));
|
||||
|
||||
Log << type() << ' ' << name() << " write:" << nl
|
||||
<< " writing field " << wallHeatFlux.name() << endl;
|
||||
|
||||
wallHeatFlux.write();
|
||||
|
||||
return true;
|
||||
Log << type() << ' ' << name() << " write:" << endl;
|
||||
return qModelPtr_->write();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -5,8 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -28,31 +27,47 @@ Class
|
||||
Foam::functionObjects::wallHeatFlux
|
||||
|
||||
Group
|
||||
grpForcesFunctionObjects
|
||||
|
||||
Description
|
||||
Computes the wall-heat flux at selected wall patches.
|
||||
|
||||
\table
|
||||
Operand | Type | Location
|
||||
input | - | -
|
||||
output file | dat | postProcessing/<FO>/<time>/field
|
||||
output field | volScalarField (only boundaryField) <!--
|
||||
--> | postProcessing/<FO>/<time>/outField
|
||||
\endtable
|
||||
This function object calculates the wall heat flux based on a custom model
|
||||
defined in the dictionary. The model can be specified to compute the heat
|
||||
flux according to user-defined criteria or equations.
|
||||
|
||||
Usage
|
||||
Minimal example by using \c system/controlDict.functions:
|
||||
\verbatim
|
||||
wallHeatFluxFO
|
||||
wallHeatFlux1
|
||||
{
|
||||
// Mandatory entries
|
||||
type wallHeatFlux;
|
||||
libs (fieldFunctionObjects);
|
||||
|
||||
// Optional entries
|
||||
patches (<patch1> ... <patchN>); // (wall1 "(wall2|wall3)");
|
||||
qr <word>;;
|
||||
model <word>;
|
||||
|
||||
// Conditional entries
|
||||
|
||||
// Option-1: when 'model' is 'wall' - previous 'wallHeatFlux' state
|
||||
|
||||
// Optional entries
|
||||
patches (<patch1> ... <patchN>); // (wall1 "(wall2|wall3)");
|
||||
qr <word>;
|
||||
|
||||
|
||||
// Option-2: when 'model' is 'gauge'
|
||||
// Mandatory entries
|
||||
patch <word>;
|
||||
Tgauge <scalar>;
|
||||
|
||||
// Optional entries
|
||||
absorptivity <scalar>;
|
||||
emissivity <scalar>;
|
||||
T <word>;
|
||||
qin <word>;
|
||||
alphat <word>;
|
||||
convective <bool>;
|
||||
radiative <bool>;
|
||||
writeFields <bool>;
|
||||
|
||||
// Inherited entries
|
||||
...
|
||||
@ -64,31 +79,45 @@ Usage
|
||||
Property | Description | Type | Reqd | Deflt
|
||||
type | Type name: wallHeatFlux | word | yes | -
|
||||
libs | Library name: fieldFunctionObjects | word | yes | -
|
||||
model | Model name | word | no | wall
|
||||
patches | Names of operand patches | wordList | no | all wall patches
|
||||
qr | Name of radiative heat flux field | word | no | qr
|
||||
patch | Name of the patch to probe | word | yes | -
|
||||
Tgauge | Gauge temperature (K) | scalar | yes | -
|
||||
absorptivity | Absorptivity of the gauge | scalar | no | 1
|
||||
emissivity | Emissivity of the gauge | scalar | no | 1
|
||||
T | Name of the temperature field | word | no | T
|
||||
qin | Name of the incident radiative heat flux field | word | no | qin
|
||||
alphat | Name of turbulent thermal diffusivity field | word | no | alphat
|
||||
convective | Write convective heat flux into file | bool | no | true
|
||||
radiative | Write radiative heat flux into file | bool | no | true
|
||||
writeFields | Write the fields 'qConv' and 'qRad' | bool | no | true
|
||||
\endtable
|
||||
|
||||
The inherited entries are elaborated in:
|
||||
- \link functionObject.H \endlink
|
||||
- \link writeFile.H \endlink
|
||||
- \link fvMeshFunctionObject.H \endlink
|
||||
- \link writeFile.H \endlink
|
||||
- \link pointProberBase.H \endlink
|
||||
- \link patchProber.H \endlink
|
||||
|
||||
SourceFiles
|
||||
wallHeatFlux.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef Foam_functionObjects_wallHeatFlux_H
|
||||
#define Foam_functionObjects_wallHeatFlux_H
|
||||
#ifndef functionObjects_wallHeatFlux_H
|
||||
#define functionObjects_wallHeatFlux_H
|
||||
|
||||
#include "fvMeshFunctionObject.H"
|
||||
#include "writeFile.H"
|
||||
#include "volFieldsFwd.H"
|
||||
#include "HashSet.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward Declarations
|
||||
class wallHeatFluxModel;
|
||||
|
||||
namespace functionObjects
|
||||
{
|
||||
|
||||
@ -98,32 +127,12 @@ namespace functionObjects
|
||||
|
||||
class wallHeatFlux
|
||||
:
|
||||
public fvMeshFunctionObject,
|
||||
public writeFile
|
||||
public fvMeshFunctionObject
|
||||
{
|
||||
protected:
|
||||
// Private Data
|
||||
|
||||
// Protected Data
|
||||
|
||||
//- Wall patches to process (optionally filtered by name)
|
||||
labelList patchIDs_;
|
||||
|
||||
//- Name of radiative heat flux name
|
||||
word qrName_;
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- File header information
|
||||
virtual void writeFileHeader(Ostream& os) const;
|
||||
|
||||
//- Calculate the heat-flux
|
||||
void calcHeatFlux
|
||||
(
|
||||
const volScalarField& alpha,
|
||||
const volScalarField& he,
|
||||
volScalarField& wallHeatFlux
|
||||
);
|
||||
//- Heat-flux model
|
||||
autoPtr<wallHeatFluxModel> qModelPtr_;
|
||||
|
||||
|
||||
public:
|
||||
@ -139,15 +148,9 @@ public:
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary&
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
//- No copy construct
|
||||
wallHeatFlux(const wallHeatFlux&) = delete;
|
||||
|
||||
//- No copy assignment
|
||||
void operator=(const wallHeatFlux&) = delete;
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~wallHeatFlux() = default;
|
||||
@ -155,13 +158,13 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Read the function-object dictionary
|
||||
//- Read the settings
|
||||
virtual bool read(const dictionary& dict);
|
||||
|
||||
//- Execute the function-object operations
|
||||
//- Calculate the heat-flux data
|
||||
virtual bool execute();
|
||||
|
||||
//- Write the function-object results
|
||||
//- Write the heat-flux data
|
||||
virtual bool write();
|
||||
};
|
||||
|
||||
|
||||
@ -0,0 +1,548 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
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 "gauge.H"
|
||||
#include "physicoChemicalConstants.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace wallHeatFluxModels
|
||||
{
|
||||
defineTypeNameAndDebug(gauge, 0);
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
wallHeatFluxModel,
|
||||
gauge,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
Foam::scalar Foam::wallHeatFluxModels::gauge::calcRadiantExitance() const
|
||||
{
|
||||
// Radiant exitance (Wikipedia EN): https://w.wiki/CdZz
|
||||
return e_*constant::physicoChemical::sigma.value()*Foam::pow4(Tgauge_);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::labelField>
|
||||
Foam::wallHeatFluxModels::gauge::identifyProbeCells() const
|
||||
{
|
||||
// Fetch the neighbour cells of the operand patch
|
||||
const polyPatch& patch = mesh().boundaryMesh()[patchID_];
|
||||
const labelUList& faceCells = patch.faceCells();
|
||||
const label patchFaceStart = patch.start();
|
||||
|
||||
// Fetch the patch faces that correspond to the specified probes
|
||||
const labelList& probeFaces = patchProber::faces();
|
||||
|
||||
// Initialise the size of the operand cells
|
||||
auto tprobeCells = tmp<labelField>::New(probeFaces.size(), -1);
|
||||
labelField& probeCells = tprobeCells.ref();
|
||||
|
||||
// Store the indices of the cells that contain the probed patch faces
|
||||
forAll(probeFaces, facei)
|
||||
{
|
||||
if (activeFaces_[facei])
|
||||
{
|
||||
const label patchFaceGlobali = probeFaces[facei];
|
||||
const label patchFaceLocali = patchFaceGlobali - patchFaceStart;
|
||||
|
||||
probeCells[facei] = faceCells[patchFaceLocali];
|
||||
}
|
||||
}
|
||||
|
||||
return tprobeCells;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::wallHeatFluxModels::gauge::writeFileHeader(Ostream& os)
|
||||
{
|
||||
writeHeader(os, typeName);
|
||||
os << "# Patch," << mesh().boundaryMesh()[patchID_].name() << nl
|
||||
<< "# Tgauge," << Tgauge_ << nl
|
||||
<< "# Absorptivity," << a_ << nl
|
||||
<< "# Emissivity," << e_ << nl
|
||||
<< "# ProbeID,Original Location,Patch Location" << nl;
|
||||
|
||||
const pointField& oldPoints = patchProber::oldPoints();
|
||||
const pointField& probeLocs = patchProber::probeLocations();
|
||||
|
||||
for (label i = 0; i < szProbes_; ++i)
|
||||
{
|
||||
const vector& oldPoint = oldPoints[i];
|
||||
const vector& probeLoc = probeLocs[i];
|
||||
|
||||
os << '#' << ' ' << i
|
||||
<< ',' << oldPoint.x() << ',' << oldPoint.y() << ',' << oldPoint.z()
|
||||
<< ',' << probeLoc.x() << ',' << probeLoc.y() << ',' << probeLoc.z()
|
||||
<< nl;
|
||||
}
|
||||
|
||||
os << "# Time";
|
||||
for (int i = 0; i < szProbes_; ++i)
|
||||
{
|
||||
os << ',' << i;
|
||||
}
|
||||
|
||||
os << endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::wallHeatFluxModels::gauge::calcConvectiveHeatFlux()
|
||||
{
|
||||
// Fetch the turbulent thermal diffusivity field
|
||||
const auto* alphatPtr = mesh().cfindObject<volScalarField>(alphatName_);
|
||||
|
||||
#ifdef FULLDEBUG
|
||||
if (!alphatPtr)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Turbulent thermal diffusivity field, alphat, is not available."
|
||||
<< nl << "alphat: " << alphatName_
|
||||
<< exit(FatalError);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Compute the term: C_p*(alpha + alpha_t)
|
||||
tmp<volScalarField> tkappaEff = thermo_.kappaEff(*alphatPtr);
|
||||
const volScalarField& kappaEff = tkappaEff.cref();
|
||||
|
||||
// Sample the term above at patch-probe locations
|
||||
tmp<scalarField> tsampledKappaEff = patchProber::sample(kappaEff);
|
||||
const scalarField& sampledKappaEff = tsampledKappaEff.cref();
|
||||
|
||||
|
||||
// Compute the patch-normal gradient of temperature with respect to the
|
||||
// specified gauge temperature
|
||||
tmp<scalarField> tdTdn = calcdTdn();
|
||||
const scalarField& dTdn = tdTdn.cref();
|
||||
|
||||
#ifdef FULLDEBUG
|
||||
if (sampledKappaEff.size() != dTdn.size())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Size mismatch: kappaEff samples (" << sampledKappaEff.size()
|
||||
<< ") vs dTdn (" << dTdn.size() << ")." << nl
|
||||
<< "Probe selection/order must match." << nl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Compute q''_conv = k_eff * dT/dn
|
||||
tmp<scalarField> tq = sampledKappaEff*dTdn;
|
||||
const scalarField& q = tq.cref();
|
||||
|
||||
// Be picky - Ensure storage exists and matches size
|
||||
if (qConvPtr_ && (qConvPtr_->size() == q.size()))
|
||||
{
|
||||
*qConvPtr_ = q;
|
||||
}
|
||||
else
|
||||
{
|
||||
IOobject io
|
||||
(
|
||||
"qConv",
|
||||
mesh().time().timeName(),
|
||||
mesh()
|
||||
);
|
||||
|
||||
qConvPtr_.reset(new scalarIOField(io, q));
|
||||
}
|
||||
|
||||
|
||||
// Note that for inactive faces q=0 since dT/dn=0
|
||||
Pstream::listReduce(*qConvPtr_, sumOp<scalar>());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::scalarField>
|
||||
Foam::wallHeatFluxModels::gauge::calcdTdn() const
|
||||
{
|
||||
// Allocate and initialise the storage for dT/dn
|
||||
auto tdTdn = tmp<scalarField>::New(szProbes_, 0);
|
||||
scalarField& dTdn = tdTdn.ref();
|
||||
|
||||
// Fetch the temperature field
|
||||
const auto* Tptr = mesh().cfindObject<volScalarField>(Tname_);
|
||||
|
||||
#ifdef FULLDEBUG
|
||||
if (!Tptr)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Temperature field, T, is not available."
|
||||
<< nl << "T: " << Tname_
|
||||
<< exit(FatalError);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Fetch the internal fields for temperature and distance-to-patch fields
|
||||
const scalarField& Ti = Tptr->primitiveField();
|
||||
const auto& pdc = mesh().deltaCoeffs().boundaryField()[patchID_];
|
||||
|
||||
|
||||
// Compute dT/dn for active faces and their owner cells
|
||||
forAll(cells_, probei)
|
||||
{
|
||||
if (activeFaces_[probei])
|
||||
{
|
||||
const label cellID = cells_[probei];
|
||||
dTdn[probei] = (Ti[cellID] - Tgauge_)/max(pdc[probei], SMALL);
|
||||
}
|
||||
}
|
||||
|
||||
return tdTdn;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::wallHeatFluxModels::gauge::calcRadiativeHeatFlux()
|
||||
{
|
||||
// Fetch the incident radiative heat-flux field
|
||||
const auto* qinPtr = mesh().getObjectPtr<volScalarField>(qinName_);
|
||||
|
||||
#ifdef FULLDEBUG
|
||||
if (!qinPtr)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Incident radiative heat-flux field, qin, is not available."
|
||||
<< nl << "qin: " << qinName_
|
||||
<< exit(FatalError);
|
||||
}
|
||||
#endif
|
||||
|
||||
const volScalarField& qin = *qinPtr;
|
||||
|
||||
// Sample the incident radiative heat-flux field at patch-probe locations
|
||||
tmp<scalarField> tq = patchProber::sample(qin);
|
||||
const scalarField& q = tq.cref();
|
||||
|
||||
// Compute q''_rad = a * q_in - M_e
|
||||
tmp<scalarField> tqrad = a_*q - Me_;
|
||||
scalarField& qrad = tqrad.ref();
|
||||
|
||||
// Overwrite q''_rad=0 for inactive probed faces
|
||||
forAll(qrad, probei)
|
||||
{
|
||||
if (!activeFaces_[probei])
|
||||
{
|
||||
qrad[probei] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Be picky - Ensure storage exists and matches size
|
||||
if (qRadPtr_ && (qRadPtr_->size() == qrad.size()))
|
||||
{
|
||||
*qRadPtr_ = qrad;
|
||||
}
|
||||
else
|
||||
{
|
||||
IOobject io
|
||||
(
|
||||
"qRad",
|
||||
mesh().time().timeName(),
|
||||
mesh()
|
||||
);
|
||||
|
||||
qRadPtr_.reset(new scalarIOField(io, qrad));
|
||||
}
|
||||
|
||||
// Note that for inactive faces qrad=0
|
||||
Pstream::listReduce(*qRadPtr_, sumOp<scalar>());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::wallHeatFluxModels::gauge::gauge
|
||||
(
|
||||
const dictionary& dict,
|
||||
const fvMesh& mesh,
|
||||
const word& name,
|
||||
const word objName,
|
||||
functionObjects::stateFunctionObject& state
|
||||
)
|
||||
:
|
||||
wallHeatFluxModel(dict, mesh, name, objName, state),
|
||||
patchProber(mesh, dict),
|
||||
thermo_(mesh.lookupObject<fluidThermo>(fluidThermo::dictName))
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::wallHeatFluxModels::gauge::read(const dictionary& dict)
|
||||
{
|
||||
if (!wallHeatFluxModel::read(dict) || !patchProber::read(dict))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Do not proceed if the operand heat-flux field is not registered
|
||||
qinName_ = dict.getOrDefault<word>("qin", "qin");
|
||||
|
||||
const auto* qinPtr = mesh().cfindObject<volScalarField>(qinName_);
|
||||
if (!qinPtr)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Incident radiative heat-flux field, qin, is not available."
|
||||
<< nl << "qin: " << qinName_
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
|
||||
// Fetch the patch-prober data
|
||||
const labelList& patchIDs = patchProber::patchIDs();
|
||||
if (patchIDs.size() == 1)
|
||||
{
|
||||
patchID_ = patchIDs[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalIOErrorInFunction(dict)
|
||||
<< "This function object can operate on only a single patch." << nl
|
||||
<< "The number of input patches: " << patchIDs.size()
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
|
||||
// Fetch the number of probes, and verify the consistent sizing
|
||||
szProbes_ = patchProber::probeLocations().size();
|
||||
|
||||
const labelList& probeFaces = patchProber::faces();
|
||||
|
||||
if (szProbes_ != probeFaces.size())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Size mismatch: szProbes (" << szProbes_
|
||||
<< ") vs probeFaces (" << probeFaces.size() << ")." << nl
|
||||
<< "Number of patch probes and patch faces must match." << nl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
|
||||
// Create and register the output heat-flux fields
|
||||
// Maybe number of probes is changed; thus, no check for the pointer
|
||||
qConvPtr_.reset
|
||||
(
|
||||
new scalarIOField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"qConv",
|
||||
mesh().time().timeName(),
|
||||
mesh()
|
||||
),
|
||||
szProbes_
|
||||
)
|
||||
);
|
||||
|
||||
qRadPtr_.reset
|
||||
(
|
||||
new scalarIOField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"qRad",
|
||||
mesh().time().timeName(),
|
||||
mesh()
|
||||
),
|
||||
szProbes_
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
// Read and store the common properties of the gauges
|
||||
Tgauge_ = dict.getScalar("Tgauge");
|
||||
if (Tgauge_ < 0)
|
||||
{
|
||||
FatalIOErrorInFunction(dict)
|
||||
<< "Gauge temperature cannot be negative." << nl
|
||||
<< "Tgauge: " << Tgauge_
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
a_ = dict.getOrDefault<scalar>("absorptivity", 1);
|
||||
e_ = dict.getOrDefault<scalar>("emissivity", 1);
|
||||
if (a_ < 0 || a_ > 1 || e_ < 0 || e_ > 1)
|
||||
{
|
||||
FatalIOErrorInFunction(dict)
|
||||
<< "The range of absorptivity and emissivity can only be [0,1]."
|
||||
<< "Absorptivity: " << a_ << nl
|
||||
<< "Emissivity: " << e_
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
|
||||
// Read names of various fields; also early check if the fields exist
|
||||
Tname_ = dict.getOrDefault<word>("T", "T");
|
||||
const auto* Tptr = mesh().cfindObject<volScalarField>(Tname_);
|
||||
if (!Tptr)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Temperature field, T, is not available."
|
||||
<< nl << "T: " << Tname_
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
alphatName_ = dict.getOrDefault<word>("alphat", "alphat");
|
||||
const auto* alphatPtr = mesh().cfindObject<volScalarField>(alphatName_);
|
||||
if (!alphatPtr)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Turbulent thermal diffusivity field, alphat, is not available."
|
||||
<< nl << "alphat: " << alphatName_
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
|
||||
// Compute the radiant-exitance term of the radiative heat flux
|
||||
// The term is calculated once per simulation unless Tgauge is changed
|
||||
Me_ = calcRadiantExitance();
|
||||
|
||||
|
||||
// Identify the faces that are actively sampled - assuming no duplication
|
||||
activeFaces_.resize_fill(probeFaces.size(), false);
|
||||
|
||||
forAll(probeFaces, facei)
|
||||
{
|
||||
if (probeFaces[facei] != -1)
|
||||
{
|
||||
activeFaces_[facei] = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Identify the indices of the cells that contain the probed patch faces
|
||||
cells_ = identifyProbeCells();
|
||||
|
||||
|
||||
// Prepare the output files
|
||||
if (writeFile::canResetFile())
|
||||
{
|
||||
writeFile::resetFile(objName());
|
||||
}
|
||||
|
||||
if (writeFile::canWriteHeader())
|
||||
{
|
||||
writeFileHeader(file());
|
||||
writtenHeader_ = true;
|
||||
}
|
||||
|
||||
bool convective = dict.getOrDefault<bool>("convective", false);
|
||||
if (UPstream::master() && convective && !convectiveFilePtr_)
|
||||
{
|
||||
convectiveFilePtr_ = newFileAtStartTime("convective");
|
||||
writeFileHeader(convectiveFilePtr_());
|
||||
}
|
||||
|
||||
bool radiative = dict.getOrDefault<bool>("radiative", false);
|
||||
if (UPstream::master() && radiative && !radiativeFilePtr_)
|
||||
{
|
||||
radiativeFilePtr_ = newFileAtStartTime("radiative");
|
||||
writeFileHeader(radiativeFilePtr_());
|
||||
}
|
||||
|
||||
|
||||
writeFields_ = dict.getOrDefault<bool>("writeFields", false);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::wallHeatFluxModels::gauge::execute()
|
||||
{
|
||||
if (!(calcConvectiveHeatFlux() && calcRadiativeHeatFlux()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::wallHeatFluxModels::gauge::write()
|
||||
{
|
||||
if (UPstream::master())
|
||||
{
|
||||
Ostream& os = file();
|
||||
|
||||
os << mesh().time().timeOutputValue();
|
||||
for (label pi = 0; pi < szProbes_; ++pi)
|
||||
{
|
||||
os << ',' << (*qConvPtr_)[pi] + (*qRadPtr_)[pi];
|
||||
}
|
||||
os << endl;
|
||||
}
|
||||
|
||||
if (UPstream::master() && convectiveFilePtr_)
|
||||
{
|
||||
OFstream& os = convectiveFilePtr_.ref();
|
||||
|
||||
os << mesh().time().timeOutputValue();
|
||||
for (label pi = 0; pi < szProbes_; ++pi)
|
||||
{
|
||||
os << ',' << (*qConvPtr_)[pi];
|
||||
}
|
||||
os << endl;
|
||||
}
|
||||
|
||||
if (UPstream::master() && radiativeFilePtr_)
|
||||
{
|
||||
OFstream& os = radiativeFilePtr_.ref();
|
||||
|
||||
os << mesh().time().timeOutputValue();
|
||||
for (label pi = 0; pi < szProbes_; ++pi)
|
||||
{
|
||||
os << ',' << (*qRadPtr_)[pi];
|
||||
}
|
||||
os << endl;
|
||||
}
|
||||
|
||||
if (writeFields_)
|
||||
{
|
||||
if (qConvPtr_) qConvPtr_->write();
|
||||
if (qRadPtr_) qRadPtr_->write();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,247 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
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::wallHeatFluxModels::gauge
|
||||
|
||||
Description
|
||||
This model computes the wall-heat flux at a selected patch using
|
||||
imaginary heat-flux gauges.
|
||||
|
||||
Heat-flux gauges are measurement tools that are placed on walls. The
|
||||
temperature of the gauges is usually different from that of the surrounding
|
||||
wall - an order of magnitude lower. The model allows the user to
|
||||
specify the gauge temperature and other gauge properties such as
|
||||
absorptivity or emissivity without creating separate patches.
|
||||
The model calculates the net convective and radiative heat fluxes at the
|
||||
gauge locations, combines them, and writes the results to the output files.
|
||||
|
||||
Usage
|
||||
Minimal example by using \c system/controlDict.functions:
|
||||
\verbatim
|
||||
wallHeatFlux1
|
||||
{
|
||||
// Mandatory entries
|
||||
type wallHeatFlux;
|
||||
libs (fieldFunctionObjects);
|
||||
|
||||
model gauge;
|
||||
|
||||
Tgauge <scalar>;
|
||||
patch <word>;
|
||||
|
||||
// Optional entries
|
||||
absorptivity <scalar>;
|
||||
emissivity <scalar>;
|
||||
T <word>;
|
||||
qin <word>;
|
||||
alphat <word>;
|
||||
convective <bool>;
|
||||
radiative <bool>;
|
||||
writeFields <bool>;
|
||||
|
||||
// Inherited entries
|
||||
...
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
where the entries mean:
|
||||
\table
|
||||
Property | Description | Type | Reqd | Deflt
|
||||
type | Type name: wallHeatFlux | word | yes | -
|
||||
libs | Library name: fieldFunctionObjects | word | yes | -
|
||||
model | Model name: gauge | word | no | wall
|
||||
Tgauge | Gauge temperature (K) | scalar | yes | -
|
||||
patch | Name of the patch to probe | word | yes | -
|
||||
absorptivity | Absorptivity of the gauge | scalar | no | 1
|
||||
emissivity | Emissivity of the gauge | scalar | no | 1
|
||||
T | Name of the temperature field | word | no | T
|
||||
qin | Name of the incident radiative heat flux field | word | no | qin
|
||||
alphat | Name of turbulent thermal diffusivity field | word | no | alphat
|
||||
convective | Calculate convective heat flux | bool | no | false
|
||||
radiative | Calculate radiative heat flux | bool | no | false
|
||||
writeFields | Write the fields to file | bool | no | false
|
||||
\endtable
|
||||
|
||||
The inherited entries are elaborated in:
|
||||
- \link fvMeshFunctionObject.H \endlink
|
||||
- \link writeFile.H \endlink
|
||||
- \link pointProberBase.H \endlink
|
||||
- \link patchProber.H \endlink
|
||||
|
||||
SourceFiles
|
||||
gauge.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef wallHeatFluxModels_gauge_H
|
||||
#define wallHeatFluxModels_gauge_H
|
||||
|
||||
#include "wallHeatFluxModel.H"
|
||||
#include "writeFile.H"
|
||||
#include "patchProber.H"
|
||||
#include "wallDist.H"
|
||||
#include "turbulentFluidThermoModel.H"
|
||||
#include "scalarIOField.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace wallHeatFluxModels
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class gauge Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class gauge
|
||||
:
|
||||
public wallHeatFluxModel,
|
||||
public patchProber
|
||||
{
|
||||
// Private Data
|
||||
|
||||
//- Const reference to the thermo database
|
||||
const fluidThermo& thermo_;
|
||||
|
||||
//- Net convective gauge heat flux at patch-probe locations
|
||||
std::unique_ptr<scalarIOField> qConvPtr_;
|
||||
|
||||
//- Net radiative gauge heat flux at patch-probe locations
|
||||
std::unique_ptr<scalarIOField> qRadPtr_;
|
||||
|
||||
//- Flag to output the net convective heat flux data
|
||||
autoPtr<OFstream> convectiveFilePtr_;
|
||||
|
||||
//- Flag to output the net radiative heat flux data
|
||||
autoPtr<OFstream> radiativeFilePtr_;
|
||||
|
||||
//- Indices of the patch cells that will be probed
|
||||
labelField cells_;
|
||||
|
||||
//- Identifier of the faces that are actively sampled
|
||||
boolList activeFaces_;
|
||||
|
||||
//- Name of the incident radiative heat-flux field
|
||||
word qinName_;
|
||||
|
||||
//- Name of the temperature field
|
||||
word Tname_;
|
||||
|
||||
//- Name of the turbulent thermal diffusivity field
|
||||
word alphatName_;
|
||||
|
||||
//- Common and constant temperature of the gauges
|
||||
scalar Tgauge_;
|
||||
|
||||
//- Radiant exitance
|
||||
scalar Me_;
|
||||
|
||||
//- Absorptivity of the gauge surfaces
|
||||
scalar a_;
|
||||
|
||||
//- Emissivity of the gauge surfaces
|
||||
scalar e_;
|
||||
|
||||
//- Index of the operand patch
|
||||
label patchID_;
|
||||
|
||||
//- Number of specified patch probes
|
||||
label szProbes_;
|
||||
|
||||
//- Flag to output the net convective/radiative heat flux fields
|
||||
bool writeFields_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Return the radiant-exitance term of the radiative heat flux
|
||||
scalar calcRadiantExitance() const;
|
||||
|
||||
//- Return the indices of the cells that contain the probed patch faces
|
||||
tmp<labelField> identifyProbeCells() const;
|
||||
|
||||
//- Write the file-header information
|
||||
bool writeFileHeader(Ostream& os);
|
||||
|
||||
//- Calculate the net convective heat flux
|
||||
bool calcConvectiveHeatFlux();
|
||||
|
||||
//- Return the dT/dn term of the convective heat flux
|
||||
tmp<scalarField> calcdTdn() const;
|
||||
|
||||
//- Calculate the net radiative heat flux
|
||||
bool calcRadiativeHeatFlux();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("gauge");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
gauge
|
||||
(
|
||||
const dictionary& dict,
|
||||
const fvMesh& mesh,
|
||||
const word& name,
|
||||
const word objName,
|
||||
functionObjects::stateFunctionObject& state
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~gauge() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Evaluation
|
||||
|
||||
//- Read the settings
|
||||
virtual bool read(const dictionary& dict);
|
||||
|
||||
//- Calculate the heat-flux data
|
||||
virtual bool execute();
|
||||
|
||||
//- Write the heat-flux data
|
||||
virtual bool write();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace wallHeatFluxModels
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,333 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
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 "wall.H"
|
||||
#include "turbulentFluidThermoModel.H"
|
||||
#include "solidThermo.H"
|
||||
#include "surfaceInterpolate.H"
|
||||
#include "fvcSnGrad.H"
|
||||
#include "wallPolyPatch.H"
|
||||
#include "turbulentFluidThermoModel.H"
|
||||
#include "multiphaseInterSystem.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace wallHeatFluxModels
|
||||
{
|
||||
defineTypeNameAndDebug(wall, 0);
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
wallHeatFluxModel,
|
||||
wall,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::wallHeatFluxModels::wall::writeFileHeader(Ostream& os)
|
||||
{
|
||||
writeHeader(os, "Wall heat-flux");
|
||||
writeCommented(os, "Time");
|
||||
writeTabbed(os, "patch");
|
||||
writeTabbed(os, "min");
|
||||
writeTabbed(os, "max");
|
||||
writeTabbed(os, "integral");
|
||||
os << endl;
|
||||
|
||||
writtenHeader_ = true;
|
||||
}
|
||||
|
||||
|
||||
void Foam::wallHeatFluxModels::wall::calcHeatFlux
|
||||
(
|
||||
const volScalarField& alpha,
|
||||
const volScalarField& he,
|
||||
volScalarField& wallHeatFlux
|
||||
)
|
||||
{
|
||||
volScalarField::Boundary& wallHeatFluxBf = wallHeatFlux.boundaryFieldRef();
|
||||
|
||||
const volScalarField::Boundary& heBf = he.boundaryField();
|
||||
|
||||
const volScalarField::Boundary& alphaBf = alpha.boundaryField();
|
||||
|
||||
const labelHashSet& patches = patchSet();
|
||||
for (const label patchi : patches)
|
||||
{
|
||||
wallHeatFluxBf[patchi] = alphaBf[patchi]*heBf[patchi].snGrad();
|
||||
}
|
||||
|
||||
|
||||
const auto* qrPtr = mesh().cfindObject<volScalarField>(qrName());
|
||||
|
||||
if (qrPtr)
|
||||
{
|
||||
const volScalarField::Boundary& radHeatFluxBf = qrPtr->boundaryField();
|
||||
|
||||
for (const label patchi : patches)
|
||||
{
|
||||
wallHeatFluxBf[patchi] -= radHeatFluxBf[patchi];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::wallHeatFluxModels::wall::wall
|
||||
(
|
||||
const dictionary& dict,
|
||||
const fvMesh& mesh,
|
||||
const word& name,
|
||||
const word objName,
|
||||
functionObjects::stateFunctionObject& state
|
||||
)
|
||||
:
|
||||
wallHeatFluxModel(dict, mesh, name, objName, state)
|
||||
{
|
||||
auto* wallHeatFluxPtr
|
||||
(
|
||||
new volScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
objName,
|
||||
mesh.time().timeName(),
|
||||
mesh
|
||||
),
|
||||
mesh,
|
||||
dimensionedScalar(dimMass/pow3(dimTime), Zero)
|
||||
)
|
||||
);
|
||||
|
||||
mesh.objectRegistry::store(wallHeatFluxPtr);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::wallHeatFluxModels::wall::read(const dictionary& dict)
|
||||
{
|
||||
if (!wallHeatFluxModel::read(dict))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
qrName_ = dict.getOrDefault<word>("qr", "qr");
|
||||
|
||||
|
||||
Info<< state().type() << " " << state().name() << ":" << nl;
|
||||
|
||||
patchSet_ = mesh().boundaryMesh().patchSet
|
||||
(
|
||||
dict.getOrDefault<wordRes>("patches", wordRes())
|
||||
);
|
||||
|
||||
const polyBoundaryMesh& pbm = mesh().boundaryMesh();
|
||||
if (patchSet_.empty())
|
||||
{
|
||||
forAll(pbm, patchi)
|
||||
{
|
||||
if (isA<wallPolyPatch>(pbm[patchi]))
|
||||
{
|
||||
patchSet_.insert(patchi);
|
||||
}
|
||||
}
|
||||
|
||||
Info<< " processing all wall patches" << nl << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< " processing wall patches: " << nl;
|
||||
labelHashSet filteredPatchSet;
|
||||
for (const label patchi : patchSet_)
|
||||
{
|
||||
if (isA<wallPolyPatch>(pbm[patchi]))
|
||||
{
|
||||
filteredPatchSet.insert(patchi);
|
||||
Info<< " " << pbm[patchi].name() << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Requested wall heat-flux on non-wall boundary "
|
||||
<< "type patch: " << pbm[patchi].name() << endl;
|
||||
}
|
||||
}
|
||||
|
||||
Info<< endl;
|
||||
|
||||
patchSet_ = filteredPatchSet;
|
||||
}
|
||||
|
||||
|
||||
if (writeFile::canResetFile())
|
||||
{
|
||||
writeFile::resetFile(objName());
|
||||
}
|
||||
|
||||
if (writeFile::canWriteHeader())
|
||||
{
|
||||
writeFileHeader(file());
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::wallHeatFluxModels::wall::execute()
|
||||
{
|
||||
auto& wallHeatFlux = mesh().lookupObjectRef<volScalarField>(objName());
|
||||
|
||||
if
|
||||
(
|
||||
mesh().foundObject<compressible::turbulenceModel>
|
||||
(
|
||||
turbulenceModel::propertiesName
|
||||
)
|
||||
)
|
||||
{
|
||||
const compressible::turbulenceModel& turbModel =
|
||||
mesh().lookupObject<compressible::turbulenceModel>
|
||||
(
|
||||
turbulenceModel::propertiesName
|
||||
);
|
||||
|
||||
calcHeatFlux
|
||||
(
|
||||
turbModel.alphaEff()(),
|
||||
turbModel.transport().he(),
|
||||
wallHeatFlux
|
||||
);
|
||||
}
|
||||
else if (mesh().foundObject<fluidThermo>(fluidThermo::dictName))
|
||||
{
|
||||
const fluidThermo& thermo =
|
||||
mesh().lookupObject<fluidThermo>(fluidThermo::dictName);
|
||||
|
||||
calcHeatFlux
|
||||
(
|
||||
thermo.alpha(),
|
||||
thermo.he(),
|
||||
wallHeatFlux
|
||||
);
|
||||
}
|
||||
else if (mesh().foundObject<solidThermo>(solidThermo::dictName))
|
||||
{
|
||||
const solidThermo& thermo =
|
||||
mesh().lookupObject<solidThermo>(solidThermo::dictName);
|
||||
|
||||
calcHeatFlux(thermo.alpha(), thermo.he(), wallHeatFlux);
|
||||
}
|
||||
else if
|
||||
(
|
||||
mesh().foundObject<multiphaseInterSystem>
|
||||
(multiphaseInterSystem::phasePropertiesName)
|
||||
)
|
||||
{
|
||||
const auto& thermo = mesh().lookupObject<multiphaseInterSystem>
|
||||
(
|
||||
multiphaseInterSystem::phasePropertiesName
|
||||
);
|
||||
|
||||
calcHeatFlux(thermo.kappaEff()(), thermo.T(), wallHeatFlux);
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unable to find compressible turbulence model in the "
|
||||
<< "database" << exit(FatalError);
|
||||
}
|
||||
|
||||
const fvPatchList& patches = mesh().boundary();
|
||||
|
||||
const surfaceScalarField::Boundary& magSf = mesh().magSf().boundaryField();
|
||||
|
||||
const labelHashSet& patchset = patchSet();
|
||||
for (const label patchi : patchset)
|
||||
{
|
||||
const fvPatch& pp = patches[patchi];
|
||||
|
||||
const scalarField& hfp = wallHeatFlux.boundaryField()[patchi];
|
||||
|
||||
const scalar minHfp = gMin(hfp);
|
||||
const scalar maxHfp = gMax(hfp);
|
||||
const scalar integralHfp = gSum(magSf[patchi]*hfp);
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
writeCurrentTime(file());
|
||||
|
||||
file()
|
||||
<< token::TAB << pp.name()
|
||||
<< token::TAB << minHfp
|
||||
<< token::TAB << maxHfp
|
||||
<< token::TAB << integralHfp
|
||||
<< endl;
|
||||
}
|
||||
|
||||
if (state().log)
|
||||
{
|
||||
Info<< " min/max/integ(" << pp.name() << ") = "
|
||||
<< minHfp << ", " << maxHfp << ", " << integralHfp << endl;
|
||||
}
|
||||
|
||||
state().setResult("min(" + pp.name() + ")", minHfp);
|
||||
state().setResult("max(" + pp.name() + ")", maxHfp);
|
||||
state().setResult("int(" + pp.name() + ")", integralHfp);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::wallHeatFluxModels::wall::write()
|
||||
{
|
||||
const auto& wallHeatFlux =
|
||||
mesh().lookupObject<volScalarField>(objName());
|
||||
|
||||
if (state().log)
|
||||
{
|
||||
Info<< " writing field " << wallHeatFlux.name() << endl;
|
||||
}
|
||||
|
||||
wallHeatFlux.write();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,176 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
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::wallHeatFluxModels::wall
|
||||
|
||||
Description
|
||||
This model computes the wall-heat flux at selected wall patches.
|
||||
|
||||
Usage
|
||||
Minimal example by using \c system/controlDict.functions:
|
||||
\verbatim
|
||||
wallHeatFlux1
|
||||
{
|
||||
// Mandatory entries
|
||||
type wallHeatFlux;
|
||||
libs (fieldFunctionObjects);
|
||||
|
||||
model wall;
|
||||
|
||||
// Optional entries
|
||||
patches (<patch1> ... <patchN>); // (wall1 "(wall2|wall3)");
|
||||
qr <word>;
|
||||
|
||||
// Inherited entries
|
||||
...
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
where the entries mean:
|
||||
\table
|
||||
Property | Description | Type | Reqd | Deflt
|
||||
type | Type name: wallHeatFlux | word | yes | -
|
||||
libs | Library name: fieldFunctionObjects | word | yes | -
|
||||
patches | Names of operand patches | wordList | no | all wall patches
|
||||
qr | Name of radiative heat flux field | word | no | qr
|
||||
\endtable
|
||||
|
||||
The inherited entries are elaborated in:
|
||||
- \link fvMeshFunctionObject.H \endlink
|
||||
- \link writeFile.H \endlink
|
||||
|
||||
Note
|
||||
- The model \c wall corresponds to \c wallHeatFlux in OpenFOAM v2506 and
|
||||
earlier versions.
|
||||
|
||||
SourceFiles
|
||||
wall.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef wallHeatFluxModels_wall_H
|
||||
#define wallHeatFluxModels_wall_H
|
||||
|
||||
#include "wallHeatFluxModel.H"
|
||||
#include "writeFile.H"
|
||||
#include "volFieldsFwd.H"
|
||||
#include "HashSet.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace wallHeatFluxModels
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class wall Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class wall
|
||||
:
|
||||
public wallHeatFluxModel
|
||||
{
|
||||
// Private Data
|
||||
|
||||
//- Name of the radiative heat-flux field
|
||||
word qrName_;
|
||||
|
||||
//- List of names of wall patches to process
|
||||
labelHashSet patchSet_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Write file-header information
|
||||
void writeFileHeader(Ostream& os);
|
||||
|
||||
//- Calculate the wall heat-flux
|
||||
void calcHeatFlux
|
||||
(
|
||||
const volScalarField& alpha,
|
||||
const volScalarField& he,
|
||||
volScalarField& wallHeatFlux
|
||||
);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("wall");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
wall
|
||||
(
|
||||
const dictionary& dict,
|
||||
const fvMesh& mesh,
|
||||
const word& name,
|
||||
const word objName,
|
||||
functionObjects::stateFunctionObject& state
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~wall() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
//- Return const reference to name of radiative heat-flux field
|
||||
const word& qrName() const noexcept { return qrName_; }
|
||||
|
||||
//- Return const reference to patches to process
|
||||
const labelHashSet& patchSet() const noexcept { return patchSet_; }
|
||||
|
||||
|
||||
// Evaluation
|
||||
|
||||
//- Read the settings
|
||||
virtual bool read(const dictionary& dict);
|
||||
|
||||
//- Calculate the heat-flux data
|
||||
virtual bool execute();
|
||||
|
||||
//- Write the heat-flux data
|
||||
virtual bool write();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace wallHeatFluxModels
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,73 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
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 "wallHeatFluxModel.H"
|
||||
#include "fvMesh.H"
|
||||
#include "wallPolyPatch.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(wallHeatFluxModel, 0);
|
||||
defineRunTimeSelectionTable(wallHeatFluxModel, dictionary);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::wallHeatFluxModel::wallHeatFluxModel
|
||||
(
|
||||
const dictionary& dict,
|
||||
const fvMesh& mesh,
|
||||
const word& name,
|
||||
const word objName,
|
||||
functionObjects::stateFunctionObject& state
|
||||
)
|
||||
:
|
||||
functionObjects::writeFile(mesh, name, objName, dict),
|
||||
mesh_(mesh),
|
||||
state_(state),
|
||||
objName_(objName)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::wallHeatFluxModel::read(const dictionary& dict)
|
||||
{
|
||||
if (!writeFile::read(dict))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,181 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
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/>.
|
||||
|
||||
Namespace
|
||||
Foam::wallHeatFluxModels
|
||||
|
||||
Description
|
||||
A namespace for various heat-flux model implementations.
|
||||
|
||||
Class
|
||||
Foam::wallHeatFluxModel
|
||||
|
||||
Description
|
||||
A base class for heat-flux models.
|
||||
|
||||
SourceFiles
|
||||
wallHeatFluxModel.C
|
||||
wallHeatFluxModelNew.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef Foam_wallHeatFluxModel_H
|
||||
#define Foam_wallHeatFluxModel_H
|
||||
|
||||
#include "writeFile.H"
|
||||
#include "volFieldsFwd.H"
|
||||
#include "HashSet.H"
|
||||
#include "stateFunctionObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward Declarations
|
||||
class fvMesh;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class wallHeatFluxModel Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class wallHeatFluxModel
|
||||
:
|
||||
public functionObjects::writeFile
|
||||
{
|
||||
// Private Data
|
||||
|
||||
//- Const reference to the mesh
|
||||
const fvMesh& mesh_;
|
||||
|
||||
//- Reference to the state function object
|
||||
functionObjects::stateFunctionObject& state_;
|
||||
|
||||
//- Name of the function object
|
||||
const word objName_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("wallHeatFluxModel");
|
||||
|
||||
|
||||
// Declare runtime constructor selection table
|
||||
|
||||
declareRunTimeSelectionTable
|
||||
(
|
||||
autoPtr,
|
||||
wallHeatFluxModel,
|
||||
dictionary,
|
||||
(
|
||||
const dictionary& dict,
|
||||
const fvMesh& mesh,
|
||||
const word& name,
|
||||
const word objName,
|
||||
functionObjects::stateFunctionObject& state
|
||||
),
|
||||
(dict, mesh, name, objName, state)
|
||||
);
|
||||
|
||||
|
||||
// Selectors
|
||||
|
||||
//- Return a reference to the selected heat-flux model
|
||||
static autoPtr<wallHeatFluxModel> New
|
||||
(
|
||||
const dictionary& dict,
|
||||
const fvMesh& mesh,
|
||||
const word& name,
|
||||
const word objName,
|
||||
functionObjects::stateFunctionObject& state
|
||||
);
|
||||
|
||||
|
||||
// Generated Methods
|
||||
|
||||
//- No copy construct
|
||||
wallHeatFluxModel(const wallHeatFluxModel&) = delete;
|
||||
|
||||
//- No copy assignment
|
||||
void operator=(const wallHeatFluxModel&) = delete;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
wallHeatFluxModel
|
||||
(
|
||||
const dictionary& dict,
|
||||
const fvMesh& mesh,
|
||||
const word& name,
|
||||
const word objName,
|
||||
functionObjects::stateFunctionObject& state
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~wallHeatFluxModel() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
//- Return const reference to the mesh
|
||||
const fvMesh& mesh() const noexcept { return mesh_; }
|
||||
|
||||
//- Return const reference to the state function object
|
||||
functionObjects::stateFunctionObject& state() const noexcept
|
||||
{
|
||||
return state_;
|
||||
}
|
||||
|
||||
//- Return const reference to the function-object name
|
||||
const word& objName() const noexcept { return objName_; }
|
||||
|
||||
|
||||
// Evaluation
|
||||
|
||||
//- Read the settings
|
||||
virtual bool read(const dictionary& dict) = 0;
|
||||
|
||||
//- Calculate the heat-flux data
|
||||
virtual bool execute() = 0;
|
||||
|
||||
//- Write the heat-flux data
|
||||
virtual bool write() = 0;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,67 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
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 "wallHeatFluxModel.H"
|
||||
#include "fvMesh.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::autoPtr<Foam::wallHeatFluxModel> Foam::wallHeatFluxModel::New
|
||||
(
|
||||
const dictionary& dict,
|
||||
const fvMesh& mesh,
|
||||
const word& name,
|
||||
const word objName,
|
||||
functionObjects::stateFunctionObject& state
|
||||
)
|
||||
{
|
||||
const word modelType(dict.getOrDefault<word>("model", "wall"));
|
||||
|
||||
Info<< "Selecting heat-flux model: " << modelType << endl;
|
||||
|
||||
auto* ctorPtr = dictionaryConstructorTable(modelType);
|
||||
|
||||
if (!ctorPtr)
|
||||
{
|
||||
FatalIOErrorInLookup
|
||||
(
|
||||
dict,
|
||||
"wallHeatFluxModel",
|
||||
modelType,
|
||||
*dictionaryConstructorTablePtr_
|
||||
) << exit(FatalIOError);
|
||||
}
|
||||
|
||||
return autoPtr<wallHeatFluxModel>
|
||||
(
|
||||
ctorPtr(dict, mesh, name, objName, state)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user