functionObjects::totalEnthalpy: New functionObject to calculate, cache and write the total enthalpy
The total enthalpy is calculated as
Ha = ha + K
where
ha is absolute enthalpy
K is the kinetic energy: 1/2*magSqr(U)
The total enthalpy or a particular phase can be calculated by specifying the
optional "phase" name, e.g.
#includeFunc totalEnthalpy(phase = liquid)
This commit is contained in:
19
etc/caseDicts/postProcessing/fields/totalEnthalpy
Normal file
19
etc/caseDicts/postProcessing/fields/totalEnthalpy
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
/*--------------------------------*- C++ -*----------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration | Website: https://openfoam.org
|
||||||
|
\\ / A nd | Version: dev
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Description
|
||||||
|
Calculates and writes the total enthalpy (ha + K) as the volScalarField Ha
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
type totalEnthalpy;
|
||||||
|
libs ("libfieldFunctionObjects.so");
|
||||||
|
|
||||||
|
executeControl writeTime;
|
||||||
|
writeControl writeTime;
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -48,6 +48,7 @@ blendingFactor/blendingFactor.C
|
|||||||
pressure/pressure.C
|
pressure/pressure.C
|
||||||
MachNo/MachNo.C
|
MachNo/MachNo.C
|
||||||
shearStress/shearStress.C
|
shearStress/shearStress.C
|
||||||
|
totalEnthalpy/totalEnthalpy.C
|
||||||
|
|
||||||
turbulenceFields/turbulenceFields.C
|
turbulenceFields/turbulenceFields.C
|
||||||
yPlus/yPlus.C
|
yPlus/yPlus.C
|
||||||
|
|||||||
119
src/functionObjects/field/totalEnthalpy/totalEnthalpy.C
Normal file
119
src/functionObjects/field/totalEnthalpy/totalEnthalpy.C
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration | Website: https://openfoam.org
|
||||||
|
\\ / A nd | Copyright (C) 2020 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 "totalEnthalpy.H"
|
||||||
|
#include "fluidThermo.H"
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
namespace functionObjects
|
||||||
|
{
|
||||||
|
defineTypeNameAndDebug(totalEnthalpy, 0);
|
||||||
|
addToRunTimeSelectionTable(functionObject, totalEnthalpy, dictionary);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::functionObjects::totalEnthalpy::totalEnthalpy
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
const Time& runTime,
|
||||||
|
const dictionary& dict
|
||||||
|
)
|
||||||
|
:
|
||||||
|
fvMeshFunctionObject(name, runTime, dict),
|
||||||
|
writeLocalObjects(obr_, false),
|
||||||
|
phaseName_(word::null)
|
||||||
|
{
|
||||||
|
read(dict);
|
||||||
|
resetLocalObjectName(IOobject::groupName("Ha", phaseName_));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::functionObjects::totalEnthalpy::~totalEnthalpy()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
bool Foam::functionObjects::totalEnthalpy::read
|
||||||
|
(
|
||||||
|
const dictionary& dict
|
||||||
|
)
|
||||||
|
{
|
||||||
|
fvMeshFunctionObject::read(dict);
|
||||||
|
writeLocalObjects::read(dict);
|
||||||
|
|
||||||
|
phaseName_ = dict.lookupOrDefault<word>("phase", word::null);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::functionObjects::totalEnthalpy::execute()
|
||||||
|
{
|
||||||
|
const word fieldName(IOobject::groupName("Ha", phaseName_));
|
||||||
|
|
||||||
|
const word thermoName
|
||||||
|
(
|
||||||
|
IOobject::groupName(fluidThermo::dictName, phaseName_)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (mesh_.foundObject<fluidThermo>(thermoName))
|
||||||
|
{
|
||||||
|
const fluidThermo& thermo = mesh_.lookupObject<fluidThermo>(thermoName);
|
||||||
|
const volVectorField& U = mesh_.lookupObject<volVectorField>
|
||||||
|
(
|
||||||
|
IOobject::groupName("U", phaseName_)
|
||||||
|
);
|
||||||
|
|
||||||
|
return store(fieldName, thermo.ha() + 0.5*magSqr(U));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "Unable to find fluidThermo " << thermoName
|
||||||
|
<< " in the database"
|
||||||
|
<< exit(FatalError);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::functionObjects::totalEnthalpy::write()
|
||||||
|
{
|
||||||
|
return writeLocalObjects::write();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
111
src/functionObjects/field/totalEnthalpy/totalEnthalpy.H
Normal file
111
src/functionObjects/field/totalEnthalpy/totalEnthalpy.H
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration | Website: https://openfoam.org
|
||||||
|
\\ / A nd | Copyright (C) 2020 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::totalEnthalpy
|
||||||
|
|
||||||
|
Description
|
||||||
|
Calculates and writes the total enthalpy (ha + K) as the volScalarField
|
||||||
|
'Ha'.
|
||||||
|
|
||||||
|
See also
|
||||||
|
Foam::functionObjects::fvMeshFunctionObject
|
||||||
|
Foam::functionObjects::writeLocalObjects
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
totalEnthalpy.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef functionObjects_totalEnthalpy_H
|
||||||
|
#define functionObjects_totalEnthalpy_H
|
||||||
|
|
||||||
|
#include "fieldExpression.H"
|
||||||
|
#include "writeLocalObjects.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
namespace functionObjects
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class totalEnthalpy Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class totalEnthalpy
|
||||||
|
:
|
||||||
|
public fvMeshFunctionObject,
|
||||||
|
public writeLocalObjects
|
||||||
|
{
|
||||||
|
// Private Data
|
||||||
|
|
||||||
|
//- The name of the phase
|
||||||
|
word phaseName_;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("totalEnthalpy");
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from Time and dictionary
|
||||||
|
totalEnthalpy
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
const Time& runTime,
|
||||||
|
const dictionary&
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~totalEnthalpy();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
//- Read the data
|
||||||
|
virtual bool read(const dictionary&);
|
||||||
|
|
||||||
|
//- Calculate the totalEnthalpy field
|
||||||
|
virtual bool execute();
|
||||||
|
|
||||||
|
//- Do nothing
|
||||||
|
virtual bool write();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace functionObjects
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
Reference in New Issue
Block a user