wallHeatTransferCoeff: New functionObject to calculate the wall heat transfer coefficient

for incompressible flow simulated using simpleFoam, pimpleFoam or pisoFoam.

Description
    Calculates and write the estimated incompressible flow heat transfer
    coefficient at wall patches as the volScalarField field
    'wallHeatTransferCoeff'.

    All wall patches are included by default; to restrict the calculation to
    certain patches, use the optional 'patches' entry.

    Example of function object specification:
    wallHeatTransferCoeff1
    {
        type        wallHeatTransferCoeff;
        libs        ("libfieldFunctionObjects.so");
        ...
        region      fluid;
        patches     (".*Wall");
        rho         1.225;
        Cp          1005;
        Prl         0.707;
        Prt         0.9;
    }

Usage
    Property | Description                   | Required | Default value
    type     | Type name: wallHeatTransferCoeff | yes   |
    patches  | List of patches to process    | no       | all wall patches
    region   | Region to be evaluated        | no       | default region
    rho      | Fluid density                 | yes      |
    Cp       | Fluid heat capacity           | yes      |
    Prl      | Fluid laminar Prandtl number  | yes      |
    Prt      | Fluid turbulent Prandtl number| yes      |

Note
    Writing field 'wallHeatTransferCoeff' is done by default, but it can be
    overridden by defining an empty \c objects list. For details see
    writeLocalObjects.
This commit is contained in:
Henry Weller
2017-12-06 16:10:34 +00:00
parent cc4d4433b8
commit 99841e29b7
4 changed files with 484 additions and 3 deletions

View File

@ -50,6 +50,7 @@ turbulenceFields/turbulenceFields.C
yPlus/yPlus.C
wallShearStress/wallShearStress.C
wallHeatFlux/wallHeatFlux.C
wallHeatTransferCoeff/wallHeatTransferCoeff.C
writeCellCentres/writeCellCentres.C
writeCellVolumes/writeCellVolumes.C

View File

@ -25,7 +25,7 @@ Class
Foam::functionObjects::wallHeatFlux
Group
grpForcesFunctionObjects
grpFieldFunctionObjects
Description
Calculates and write the heat-flux at wall patches as the
@ -63,7 +63,6 @@ See also
Foam::functionObjects::fvMeshFunctionObject
Foam::functionObjects::logFiles
Foam::functionObjects::writeLocalObjects
Foam::functionObjects::pressureTools
Foam::functionObjects::timeControl
SourceFiles
@ -77,8 +76,8 @@ SourceFiles
#include "fvMeshFunctionObject.H"
#include "logFiles.H"
#include "writeLocalObjects.H"
#include "volFieldsFwd.H"
#include "HashSet.H"
#include "volFieldsFwd.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -0,0 +1,283 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "wallHeatTransferCoeff.H"
#include "turbulentTransportModel.H"
#include "wallPolyPatch.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace functionObjects
{
defineTypeNameAndDebug(wallHeatTransferCoeff, 0);
addToRunTimeSelectionTable
(
functionObject,
wallHeatTransferCoeff,
dictionary
);
}
}
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
void Foam::functionObjects::wallHeatTransferCoeff::writeFileHeader
(
const label i
)
{
// Add headers to output data
writeHeader(file(), "Wall heat transfer coefficient");
writeCommented(file(), "Time");
writeTabbed(file(), "patch");
writeTabbed(file(), "min");
writeTabbed(file(), "max");
writeTabbed(file(), "integral");
file() << endl;
}
void Foam::functionObjects::wallHeatTransferCoeff::calcHeatTransferCoeff
(
const volScalarField& nu,
const volScalarField& nut,
volScalarField& wallHeatTransferCoeff
)
{
volScalarField::Boundary& wallHeatTransferCoeffBf =
wallHeatTransferCoeff.boundaryFieldRef();
const volScalarField::Boundary& nuBf = nu.boundaryField();
const volScalarField::Boundary& nutBf = nut.boundaryField();
forAll(wallHeatTransferCoeffBf, patchi)
{
if (!wallHeatTransferCoeffBf[patchi].coupled())
{
wallHeatTransferCoeffBf[patchi] =
rho_*Cp_*(nuBf[patchi]/Prl_ + nutBf[patchi]/Prt_);
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::functionObjects::wallHeatTransferCoeff::wallHeatTransferCoeff
(
const word& name,
const Time& runTime,
const dictionary& dict
)
:
fvMeshFunctionObject(name, runTime, dict),
logFiles(obr_, name),
writeLocalObjects(obr_, log),
patchSet_()
{
volScalarField* wallHeatTransferCoeffPtr
(
new volScalarField
(
IOobject
(
type(),
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
dimensionedScalar("0", dimMass/pow3(dimTime)/dimTemperature, 0)
)
);
mesh_.objectRegistry::store(wallHeatTransferCoeffPtr);
read(dict);
resetName(typeName);
resetLocalObjectName(typeName);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::functionObjects::wallHeatTransferCoeff::~wallHeatTransferCoeff()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::functionObjects::wallHeatTransferCoeff::read(const dictionary& dict)
{
fvMeshFunctionObject::read(dict);
writeLocalObjects::read(dict);
const polyBoundaryMesh& pbm = mesh_.boundaryMesh();
patchSet_ =
mesh_.boundaryMesh().patchSet
(
wordReList(dict.lookupOrDefault("patches", wordReList()))
);
Info<< type() << " " << name() << ":" << nl;
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;
forAllConstIter(labelHashSet, patchSet_, iter)
{
label patchi = iter.key();
if (isA<wallPolyPatch>(pbm[patchi]))
{
filteredPatchSet.insert(patchi);
Info<< " " << pbm[patchi].name() << endl;
}
else
{
WarningInFunction
<< "Requested wall heat-transferCoeff on non-wall boundary "
<< "type patch: " << pbm[patchi].name() << endl;
}
}
Info<< endl;
patchSet_ = filteredPatchSet;
}
dict.lookup("rho") >> rho_;
dict.lookup("Cp") >> Cp_;
dict.lookup("Prl") >> Prl_;
dict.lookup("Prt") >> Prt_;
return true;
}
bool Foam::functionObjects::wallHeatTransferCoeff::execute()
{
volScalarField& wallHeatTransferCoeff =
lookupObjectRef<volScalarField>(type());
if
(
foundObject<incompressible::turbulenceModel>
(
turbulenceModel::propertiesName
)
)
{
const incompressible::turbulenceModel& turbModel =
lookupObject<incompressible::turbulenceModel>
(
turbulenceModel::propertiesName
);
calcHeatTransferCoeff
(
turbModel.nu(),
turbModel.nut(),
wallHeatTransferCoeff
);
}
else
{
FatalErrorInFunction
<< "Unable to find incompressible turbulence model in the "
<< "database" << exit(FatalError);
}
return true;
}
bool Foam::functionObjects::wallHeatTransferCoeff::write()
{
Log << type() << " " << name() << " write:" << nl;
writeLocalObjects::write();
logFiles::write();
const volScalarField& wallHeatTransferCoeff =
obr_.lookupObject<volScalarField>(type());
const fvPatchList& patches = mesh_.boundary();
const surfaceScalarField::Boundary& magSf =
mesh_.magSf().boundaryField();
forAllConstIter(labelHashSet, patchSet_, iter)
{
label patchi = iter.key();
const fvPatch& pp = patches[patchi];
const scalarField& hfp = wallHeatTransferCoeff.boundaryField()[patchi];
const scalar minHtcp = gMin(hfp);
const scalar maxHtcp = gMax(hfp);
const scalar integralHtcp = gSum(magSf[patchi]*hfp);
if (Pstream::master())
{
file()
<< mesh_.time().value()
<< tab << pp.name()
<< tab << minHtcp
<< tab << maxHtcp
<< tab << integralHtcp
<< endl;
}
Log << " min/max/integ(" << pp.name() << ") = "
<< minHtcp << ", " << maxHtcp << ", " << integralHtcp << endl;
}
Log << endl;
return true;
}
// ************************************************************************* //

View File

@ -0,0 +1,198 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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::functionObjects::wallHeatTransferCoeff
Group
grpFieldFunctionObjects
Description
Calculates and write the estimated incompressible flow heat transfer
coefficient at wall patches as the volScalarField field
'wallHeatTransferCoeff'.
All wall patches are included by default; to restrict the calculation to
certain patches, use the optional 'patches' entry.
Example of function object specification:
\verbatim
wallHeatTransferCoeff1
{
type wallHeatTransferCoeff;
libs ("libfieldFunctionObjects.so");
...
region fluid;
patches (".*Wall");
rho 1.225;
Cp 1005;
Prl 0.707;
Prt 0.9;
}
\endverbatim
Usage
\table
Property | Description | Required | Default value
type | Type name: wallHeatTransferCoeff | yes |
patches | List of patches to process | no | all wall patches
region | Region to be evaluated | no | default region
rho | Fluid density | yes |
Cp | Fluid heat capacity | yes |
Prl | Fluid laminar Prandtl number | yes |
Prt | Fluid turbulent Prandtl number| yes |
\endtable
Note
Writing field 'wallHeatTransferCoeff' is done by default, but it can be
overridden by defining an empty \c objects list. For details see
writeLocalObjects.
See also
Foam::functionObject
Foam::functionObjects::fvMeshFunctionObject
Foam::functionObjects::logFiles
Foam::functionObjects::writeLocalObjects
Foam::functionObjects::timeControl
SourceFiles
wallHeatTransferCoeff.C
\*---------------------------------------------------------------------------*/
#ifndef functionObjects_wallHeatTransferCoeff_H
#define functionObjects_wallHeatTransferCoeff_H
#include "fvMeshFunctionObject.H"
#include "logFiles.H"
#include "writeLocalObjects.H"
#include "HashSet.H"
#include "volFieldsFwd.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace functionObjects
{
/*---------------------------------------------------------------------------*\
Class wallHeatTransferCoeff Declaration
\*---------------------------------------------------------------------------*/
class wallHeatTransferCoeff
:
public fvMeshFunctionObject,
public logFiles,
public writeLocalObjects
{
protected:
// Protected data
//- Optional list of patches to process
labelHashSet patchSet_;
//- Fluid density
scalar rho_;
//- Fluid heat capacity
scalar Cp_;
//- Fluid laminar Prandtl number
scalar Prl_;
//- Fluid turbulent Prandtl number
scalar Prt_;
// Protected Member Functions
//- File header information
virtual void writeFileHeader(const label i);
//- Calculate the heat transfer coefficient
void calcHeatTransferCoeff
(
const volScalarField& nu,
const volScalarField& nut,
volScalarField& wallHeatTransferCoeff
);
private:
// Private member functions
//- Disallow default bitwise copy construct
wallHeatTransferCoeff(const wallHeatTransferCoeff&);
//- Disallow default bitwise assignment
void operator=(const wallHeatTransferCoeff&);
public:
//- Runtime type information
TypeName("wallHeatTransferCoeff");
// Constructors
//- Construct from Time and dictionary
wallHeatTransferCoeff
(
const word& name,
const Time& runTime,
const dictionary&
);
//- Destructor
virtual ~wallHeatTransferCoeff();
// Member Functions
//- Read the wallHeatTransferCoeff data
virtual bool read(const dictionary&);
//- Calculate the wall heat transfer coefficient
virtual bool execute();
//- Write the wall heat transfer coefficient
virtual bool write();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace functionObjects
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //