diff --git a/etc/caseDicts/postProcessing/fields/totalEnthalpy b/etc/caseDicts/postProcessing/fields/totalEnthalpy new file mode 100644 index 0000000000..330d6d1315 --- /dev/null +++ b/etc/caseDicts/postProcessing/fields/totalEnthalpy @@ -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; + +// ************************************************************************* // diff --git a/src/functionObjects/field/Make/files b/src/functionObjects/field/Make/files index e9aa3d4b7c..e24d4569f5 100644 --- a/src/functionObjects/field/Make/files +++ b/src/functionObjects/field/Make/files @@ -48,6 +48,7 @@ blendingFactor/blendingFactor.C pressure/pressure.C MachNo/MachNo.C shearStress/shearStress.C +totalEnthalpy/totalEnthalpy.C turbulenceFields/turbulenceFields.C yPlus/yPlus.C diff --git a/src/functionObjects/field/totalEnthalpy/totalEnthalpy.C b/src/functionObjects/field/totalEnthalpy/totalEnthalpy.C new file mode 100644 index 0000000000..33de3c9ad0 --- /dev/null +++ b/src/functionObjects/field/totalEnthalpy/totalEnthalpy.C @@ -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 . + +\*---------------------------------------------------------------------------*/ + +#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("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(thermoName)) + { + const fluidThermo& thermo = mesh_.lookupObject(thermoName); + const volVectorField& U = mesh_.lookupObject + ( + 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(); +} + + +// ************************************************************************* // diff --git a/src/functionObjects/field/totalEnthalpy/totalEnthalpy.H b/src/functionObjects/field/totalEnthalpy/totalEnthalpy.H new file mode 100644 index 0000000000..c5e2d1c634 --- /dev/null +++ b/src/functionObjects/field/totalEnthalpy/totalEnthalpy.H @@ -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 . + +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 + +// ************************************************************************* //