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 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  (
57  physicalProperties::typeName,
59  );
60 
61  const word ttmName =
63  (
64  fluidThermophysicalTransportModel::typeName,
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 
83  const volScalarField& Yi = thermo.Y(fieldName_);
84 
85  return store(resultName_, calc(ttm, Yi));
86 }
87 
88 
90 Foam::functionObjects::specieFlux::calc
91 (
92  const fluidThermophysicalTransportModel& ttm,
93  const volScalarField& Yi
94 )
95 {
96  return calcPhiYif(ttm, Yi) + calcJ(ttm, Yi);
97 }
98 
99 
101 Foam::functionObjects::specieAdvectiveFlux::calc
102 (
103  const fluidThermophysicalTransportModel& ttm,
104  const volScalarField& Yi
105 )
106 {
107  return calcPhiYif(ttm, Yi);
108 }
109 
110 
112 Foam::functionObjects::specieDiffusiveFlux::calc
113 (
114  const fluidThermophysicalTransportModel& ttm,
115  const volScalarField& Yi
116 )
117 {
118  return calcJ(ttm, Yi);
119 }
120 
121 
122 // * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
123 
126 (
128  const volScalarField& Yi
129 ) const
130 {
131  const surfaceScalarField& phi = ttm.momentumTransport().alphaRhoPhi();
132 
133  return
134  fvc::flux
135  (
136  phi,
137  Yi,
138  "div(" + phi.name() + "," + schemesField_ + ")"
139  )/Yi.mesh().magSf();
140 }
141 
142 
145 (
147 
148  const volScalarField& Yi
149 ) const
150 {
151  return ttm.j(Yi);
152 }
153 
154 
155 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
156 
158 (
159  const word& name,
160  const Time& runTime,
161  const dictionary& dict,
162  const word& typeName
163 )
164 :
165  fieldExpression(name, runTime, dict, typeName),
166  schemesField_(dict.lookupOrDefault<word>("schemesField", "Yi"))
167 {}
168 
169 
171 (
172  const word& name,
173  const Time& runTime,
174  const dictionary& dict
175 )
176 :
177  specieFluxBase(name, runTime, dict, typeName)
178 {}
179 
180 
182 (
183  const word& name,
184  const Time& runTime,
185  const dictionary& dict
186 )
187 :
188  specieFluxBase(name, runTime, dict, typeName)
189 {}
190 
191 
193 (
194  const word& name,
195  const Time& runTime,
196  const dictionary& dict
197 )
198 :
199  specieFluxBase(name, runTime, dict, typeName)
200 {}
201 
202 
203 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
204 
206 {}
207 
208 
209 // ************************************************************************* //
Macros for easy insertion into run-time selection tables.
const Mesh & mesh() const
Return mesh.
Generic GeometricField class.
word group() const
Return group (extension part of name)
Definition: IOobject.C:324
const word & name() const
Return name.
Definition: IOobject.H:310
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
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.
bool 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:182
specieDiffusiveFlux(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: specieFlux.C:193
tmp< surfaceScalarField > calcPhiYif(const fluidThermophysicalTransportModel &ttm, const volScalarField &Yi) const
Return the advective flux.
Definition: specieFlux.C:126
tmp< surfaceScalarField > calcJ(const fluidThermophysicalTransportModel &ttm, const volScalarField &Yi) const
Return the diffusive flux.
Definition: specieFlux.C:145
specieFluxBase(const word &name, const Time &runTime, const dictionary &dict, const word &typeName)
Construct from Time and dictionary.
Definition: specieFlux.C:158
virtual ~specieFluxBase()
Destructor.
Definition: specieFlux.C:205
These functions calculate the specie-flux and write it as a surfaceScalarField called 'specie<Type>Fl...
Definition: specieFlux.H:176
specieFlux(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: specieFlux.C:171
const surfaceScalarField & alphaRhoPhi() const
Access function to phase flux field.
A class for managing temporary objects.
Definition: tmp.H:55
A class for handling words, derived from string.
Definition: word.H:62
Calculate the face-flux of the given field.
defineTypeNameAndDebug(adjustTimeStepToCombustion, 0)
addToRunTimeSelectionTable(functionObject, adjustTimeStepToCombustion, 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.
word name(const bool)
Return a word representation of a bool.
Definition: boolIO.C:39
VolField< scalar > volScalarField
Definition: volFieldsFwd.H:64
dictionary dict
fluidMulticomponentThermo & thermo
Definition: createFields.H:31