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-2021 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 {
36  defineTypeNameAndDebug(totalEnthalpy, 0);
37  addToRunTimeSelectionTable(functionObject, totalEnthalpy, dictionary);
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_, false),
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 // ************************************************************************* //
virtual bool write()
Write function.
fluidReactionThermo & thermo
Definition: createFields.H:28
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
U
Definition: pEqn.H:72
error FatalError
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
addToRunTimeSelectionTable(functionObject, Qdot, dictionary)
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:69
Macros for easy insertion into run-time selection tables.
virtual bool execute()
Calculate the totalEnthalpy field.
Definition: totalEnthalpy.C:82
virtual bool read(const dictionary &)
Read optional controls.
virtual bool read(const dictionary &)
Read the data.
Definition: totalEnthalpy.C:69
bool read(const char *, int32_t &)
Definition: int32IO.C:85
totalEnthalpy(const word &name, const Time &runTime, const dictionary &)
Construct from Time and dictionary.
Definition: totalEnthalpy.C:45
A class for handling words, derived from string.
Definition: word.H:59
static word groupName(Name name, const word &group)
Base-class for fluid thermodynamic properties.
Definition: fluidThermo.H:53
static const word null
An empty word.
Definition: word.H:77
dimensioned< scalar > magSqr(const dimensioned< Type > &)
virtual ~totalEnthalpy()
Destructor.
Definition: totalEnthalpy.C:62
defineTypeNameAndDebug(Qdot, 0)
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
FunctionObject base class for managing a list of objects on behalf of the inheriting function object...
virtual bool read(const dictionary &)
Read the list of objects to be written.
virtual bool write()
Do nothing.
Specialisation of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
virtual tmp< volScalarField > ha() const =0
Absolute enthalpy [J/kg].
Namespace for OpenFOAM.