energyFlux.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) 2026 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 "energyFlux.H"
28 #include "fvcFlux.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35 namespace functionObjects
36 {
39 
42 
45 }
46 }
47 
48 
49 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
50 
51 bool Foam::functionObjects::energyFluxBase::calc()
52 {
53  const word ttmName =
55  (
57  phaseName_
58  );
59 
60  if (!foundObject<thermophysicalTransportModel>(ttmName))
61  {
62  return false;
63  }
64 
65  const thermophysicalTransportModel& ttm =
66  lookupObject<thermophysicalTransportModel>(ttmName);
67 
68  store(resultName_, calc(ttm));
69 
70  return true;
71 }
72 
73 
75 Foam::functionObjects::energyFlux::calc
76 (
77  const thermophysicalTransportModel& ttm
78 ) const
79 {
80  return calcPhihs(ttm) + calcQ(ttm);
81 }
82 
83 
85 Foam::functionObjects::energyAdvectiveFlux::calc
86 (
87  const thermophysicalTransportModel& ttm
88 ) const
89 {
90  return calcPhihs(ttm);
91 }
92 
93 
95 Foam::functionObjects::heatFlux::calc
96 (
97  const thermophysicalTransportModel& ttm
98 ) const
99 {
100  return calcQ(ttm);
101 }
102 
103 
104 // * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
105 
108 (
110 ) const
111 {
112  if (isA<fluidThermophysicalTransportModel>(ttm))
113  {
115  refCast<const fluidThermophysicalTransportModel>(ttm);
116 
117  const surfaceScalarField& phi = fttm.momentumTransport().alphaRhoPhi();
118 
119  const word& schemesField =
120  schemesField_ != word::null
121  ? schemesField_
122  : fttm.thermo().he().name();
123 
124  return
125  fvc::flux
126  (
127  phi,
128  fttm.thermo().hs(),
129  "div(" + phi.name() + "," + schemesField + ")"
130  );
131  }
132 
133  return surfaceScalarField::New("0", mesh(), dimPower);
134 }
135 
136 
139 (
141 ) const
142 {
143  return mesh().magSf()*ttm.q();
144 }
145 
146 
147 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
148 
150 (
151  const word& name,
152  const Time& runTime,
153  const dictionary& dict,
154  const word& typeName
155 )
156 :
157  fieldExpression(name, runTime, dict, typeName, noFieldName_),
158  schemesField_(dict.lookupOrDefault<word>("schemesField", word::null)),
159  phaseName_(word::null)
160 {
161  read(dict);
162 }
163 
164 
166 (
167  const word& name,
168  const Time& runTime,
169  const dictionary& dict
170 )
171 :
172  energyFluxBase(name, runTime, dict, typeName)
173 {}
174 
175 
177 (
178  const word& name,
179  const Time& runTime,
180  const dictionary& dict
181 )
182 :
183  energyFluxBase(name, runTime, dict, typeName)
184 {}
185 
186 
188 (
189  const word& name,
190  const Time& runTime,
191  const dictionary& dict
192 )
193 :
194  energyFluxBase(name, runTime, dict, typeName)
195 {}
196 
197 
198 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
199 
201 {}
202 
203 
204 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
205 
207 (
208  const dictionary& dict
209 )
210 {
212 
213  phaseName_ = dict.lookupOrDefault<word>("phase", word::null);
214 
215  return true;
216 }
217 
218 
219 // ************************************************************************* //
Macros for easy insertion into run-time selection tables.
Generic GeometricField class.
static tmp< GeometricField< Type, GeoMesh, PrimitiveField > > New(const word &name, const Internal &, const PtrList< Patch > &, const HashPtrTable< Source > &=HashPtrTable< Source >())
Return a temporary field constructed from name,.
const word & name() const
Return name.
Definition: IOobject.H:307
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
virtual tmp< volScalarField > hs() const =0
Sensible enthalpy [J/kg].
virtual const volScalarField & he() const =0
Enthalpy/Internal energy [J/kg].
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Abstract base class for fluid thermophysical transport models RAS, LES and laminar.
const compressibleMomentumTransportModel & momentumTransport() const
Access function to momentum transport model.
virtual const fluidThermo & thermo() const =0
Access function to fluid thermophysical properties.
Abstract base-class for Time/database functionObjects.
energyAdvectiveFlux(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: energyFlux.C:177
virtual ~energyFluxBase()
Destructor.
Definition: energyFlux.C:200
tmp< surfaceScalarField > calcPhihs(const thermophysicalTransportModel &ttm) const
Return the advective energy flux.
Definition: energyFlux.C:108
tmp< surfaceScalarField > calcQ(const thermophysicalTransportModel &ttm) const
Return the heat flux.
Definition: energyFlux.C:139
energyFluxBase(const word &name, const Time &runTime, const dictionary &, const word &typeName)
Construct from Time and dictionary.
Definition: energyFlux.C:150
virtual bool read(const dictionary &)
Read the data.
Definition: energyFlux.C:207
These functions calculate the energy-flux and write it as a surfaceScalarField. There are three such ...
Definition: energyFlux.H:173
energyFlux(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: energyFlux.C:166
word resultName_
Name of result field.
heatFlux(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: energyFlux.C:188
ObjectType & store(const tmp< ObjectType > &tfield)
Store the given field in the objectRegistry.
virtual bool read(const dictionary &)
Read optional controls.
const surfaceScalarField & magSf() const
Return cell face area magnitudes.
const surfaceScalarField & alphaRhoPhi() const
Access function to phase flux field.
Abstract base class for all fluid and solid thermophysical transport models.
virtual tmp< surfaceScalarField > q() const =0
Return the heat flux [W/m^2].
A class for managing temporary objects.
Definition: tmp.H:55
Template function which returns the un-mangled name of a given type. Useful for types which do not ha...
A class for handling words, derived from string.
Definition: word.H:63
static const word null
An empty word.
Definition: word.H:78
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
Calculate the face-flux of the given field.
defineTypeNameAndDebug(fvMeshFunctionObject, 0)
addToRunTimeSelectionTable(functionObject, fvModel, dictionary)
tmp< SurfaceField< typename innerProduct< vector, Type >::type > > flux(const VolField< Type > &vf)
Return the face-flux field obtained from the given volVectorField.
Namespace for OpenFOAM.
String typeName(const std::type_info &info)
Return the un-mangled name given the standard type info.
const dimensionSet & dimPower
Definition: dimensions.C:161
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
dictionary dict