totalEnthalpy.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2020-2022 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "totalEnthalpy.H"
27 #include "fluidThermo.H"
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 namespace functionObjects
35 {
38 }
39 }
40 
41 
42 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
43 
45 (
46  const word& name,
47  const Time& runTime,
48  const dictionary& dict
49 )
50 :
51  fvMeshFunctionObject(name, runTime, dict),
52  writeLocalObjects(obr_),
53  phaseName_(word::null)
54 {
55  read(dict);
56  resetLocalObjectName(IOobject::groupName("Ha", phaseName_));
57 }
58 
59 
60 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
61 
63 {}
64 
65 
66 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
67 
69 (
70  const dictionary& dict
71 )
72 {
75 
76  phaseName_ = dict.lookupOrDefault<word>("phase", word::null);
77 
78  return true;
79 }
80 
81 
83 {
84  const word fieldName(IOobject::groupName("Ha", phaseName_));
85 
86  const word thermoName
87  (
88  IOobject::groupName(physicalProperties::typeName, phaseName_)
89  );
90 
91  if (mesh_.foundObject<fluidThermo>(thermoName))
92  {
93  const fluidThermo& thermo = mesh_.lookupObject<fluidThermo>(thermoName);
94  const volVectorField& U = mesh_.lookupObject<volVectorField>
95  (
96  IOobject::groupName("U", phaseName_)
97  );
98 
99  return store(fieldName, thermo.ha() + 0.5*magSqr(U));
100  }
101  else
102  {
104  << "Unable to find fluidThermo " << thermoName
105  << " in the database"
106  << exit(FatalError);
107 
108  return false;
109  }
110 }
111 
112 
114 {
115  return writeLocalObjects::write();
116 }
117 
118 
119 // ************************************************************************* //
Macros for easy insertion into run-time selection tables.
Generic GeometricField class.
static word groupName(Name name, const word &group)
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:76
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
Base-class for fluid thermodynamic properties.
Definition: fluidThermo.H:57
Abstract base-class for Time/database functionObjects.
Specialisation of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
Calculates the magnitude of the sqr of a field.
Definition: magSqr.H:59
virtual bool read(const dictionary &)
Read optional controls.
Calculates and writes the total enthalpy (ha + K) as the volScalarField Ha.
Definition: totalEnthalpy.H:59
totalEnthalpy(const word &name, const Time &runTime, const dictionary &)
Construct from Time and dictionary.
Definition: totalEnthalpy.C:45
virtual ~totalEnthalpy()
Destructor.
Definition: totalEnthalpy.C:62
virtual bool execute()
Calculate the totalEnthalpy field.
Definition: totalEnthalpy.C:82
virtual bool write()
Do nothing.
virtual bool read(const dictionary &)
Read the data.
Definition: totalEnthalpy.C:69
FunctionObject base class for managing a list of objects on behalf of the inheriting function object,...
void resetLocalObjectName(const word &name)
Reset the list of local object names from a single word.
virtual bool read(const dictionary &)
Read the list of objects to be written.
virtual bool write()
Write function.
A class for handling words, derived from string.
Definition: word.H:62
static const word null
An empty word.
Definition: word.H:77
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
U
Definition: pEqn.H:72
defineTypeNameAndDebug(adjustTimeStepToCombustion, 0)
addToRunTimeSelectionTable(functionObject, adjustTimeStepToCombustion, dictionary)
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
word name(const bool)
Return a word representation of a bool.
Definition: boolIO.C:39
error FatalError
dictionary dict
fluidMulticomponentThermo & thermo
Definition: createFields.H:31