specieFlux.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) 2024-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 "specieFlux.H"
28 #include "fvcFlux.H"
29 #include "multicomponentThermo.H"
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 namespace functionObjects
37 {
40 
43 
46 }
47 }
48 
49 
50 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
51 
52 bool Foam::functionObjects::specieFluxBase::calc()
53 {
54  const word thermoName =
56  (
59  );
60 
61  const word ttmName =
63  (
66  );
67 
68  if
69  (
70  !foundObject<multicomponentThermo>(thermoName)
71  || !foundObject<fluidThermophysicalTransportModel>(ttmName)
72  )
73  {
74  return false;
75  }
76 
77  const multicomponentThermo& thermo =
78  lookupObject<multicomponentThermo>(thermoName);
79 
80  const fluidThermophysicalTransportModel& ttm =
81  lookupObject<fluidThermophysicalTransportModel>(ttmName);
82 
84 
85  store(resultName_, calc(ttm, Yi));
86 
87  return true;
88 }
89 
90 
92 Foam::functionObjects::specieFlux::calc
93 (
94  const fluidThermophysicalTransportModel& ttm,
95  const volScalarField& Yi
96 )
97 {
98  return calcPhiYif(ttm, Yi) + calcJ(ttm, Yi);
99 }
100 
101 
103 Foam::functionObjects::specieAdvectiveFlux::calc
104 (
105  const fluidThermophysicalTransportModel& ttm,
106  const volScalarField& Yi
107 )
108 {
109  return calcPhiYif(ttm, Yi);
110 }
111 
112 
114 Foam::functionObjects::specieDiffusiveFlux::calc
115 (
116  const fluidThermophysicalTransportModel& ttm,
117  const volScalarField& Yi
118 )
119 {
120  return calcJ(ttm, Yi);
121 }
122 
123 
124 // * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
125 
128 (
130  const volScalarField& Yi
131 ) const
132 {
133  const surfaceScalarField& phi = ttm.momentumTransport().alphaRhoPhi();
134 
135  return
136  fvc::flux
137  (
138  phi,
139  Yi,
140  "div(" + phi.name() + "," + schemesField_ + ")"
141  );
142 }
143 
144 
147 (
149  const volScalarField& Yi
150 ) const
151 {
152  return mesh().magSf()*ttm.j(Yi);
153 }
154 
155 
156 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
157 
159 (
160  const word& name,
161  const Time& runTime,
162  const dictionary& dict,
163  const word& typeName
164 )
165 :
166  fieldExpression(name, runTime, dict, typeName),
167  schemesField_(dict.lookupOrDefault<word>("schemesField", "Yi"))
168 {}
169 
170 
172 (
173  const word& name,
174  const Time& runTime,
175  const dictionary& dict
176 )
177 :
178  specieFluxBase(name, runTime, dict, typeName)
179 {}
180 
181 
183 (
184  const word& name,
185  const Time& runTime,
186  const dictionary& dict
187 )
188 :
189  specieFluxBase(name, runTime, dict, typeName)
190 {}
191 
192 
194 (
195  const word& name,
196  const Time& runTime,
197  const dictionary& dict
198 )
199 :
200  specieFluxBase(name, runTime, dict, typeName)
201 {}
202 
203 
204 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
205 
207 {}
208 
209 
210 // ************************************************************************* //
Macros for easy insertion into run-time selection tables.
Generic GeometricField class.
word group() const
Return group (extension part of name)
Definition: IOobject.C:321
word member() const
Return member (name without the extension)
Definition: IOobject.C:327
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
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 tmp< surfaceScalarField > j(const volScalarField &Yi) const =0
Return the specie flux for the given specie mass-fraction [kg/m^2/s].
Abstract base-class for Time/database functionObjects.
word resultName_
Name of result field.
const word fieldName_
Name of field to process.
ObjectType & store(const tmp< ObjectType > &tfield)
Store the given field in the objectRegistry.
specieAdvectiveFlux(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: specieFlux.C:183
specieDiffusiveFlux(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: specieFlux.C:194
tmp< surfaceScalarField > calcPhiYif(const fluidThermophysicalTransportModel &ttm, const volScalarField &Yi) const
Return the advective flux.
Definition: specieFlux.C:128
tmp< surfaceScalarField > calcJ(const fluidThermophysicalTransportModel &ttm, const volScalarField &Yi) const
Return the diffusive flux.
Definition: specieFlux.C:147
specieFluxBase(const word &name, const Time &runTime, const dictionary &dict, const word &typeName)
Construct from Time and dictionary.
Definition: specieFlux.C:159
virtual ~specieFluxBase()
Destructor.
Definition: specieFlux.C:206
These functions calculate the specie-flux and write it as a surfaceScalarField called 'specie<Type>Fl...
Definition: specieFlux.H:182
specieFlux(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: specieFlux.C:172
const surfaceScalarField & magSf() const
Return cell face area magnitudes.
const surfaceScalarField & alphaRhoPhi() const
Access function to phase flux field.
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
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.
VolField< scalar > volScalarField
Definition: volFieldsFwd.H:62
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
dictionary dict
fluidMulticomponentThermo & thermo
Definition: createFields.H:15