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 
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  )/Yi.mesh().magSf();
142 }
143 
144 
147 (
149 
150  const volScalarField& Yi
151 ) const
152 {
153  return ttm.j(Yi);
154 }
155 
156 
157 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
158 
160 (
161  const word& name,
162  const Time& runTime,
163  const dictionary& dict,
164  const word& typeName
165 )
166 :
167  fieldExpression(name, runTime, dict, typeName),
168  schemesField_(dict.lookupOrDefault<word>("schemesField", "Yi"))
169 {}
170 
171 
173 (
174  const word& name,
175  const Time& runTime,
176  const dictionary& dict
177 )
178 :
179  specieFluxBase(name, runTime, dict, typeName)
180 {}
181 
182 
184 (
185  const word& name,
186  const Time& runTime,
187  const dictionary& dict
188 )
189 :
190  specieFluxBase(name, runTime, dict, typeName)
191 {}
192 
193 
195 (
196  const word& name,
197  const Time& runTime,
198  const dictionary& dict
199 )
200 :
201  specieFluxBase(name, runTime, dict, typeName)
202 {}
203 
204 
205 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
206 
208 {}
209 
210 
211 // ************************************************************************* //
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: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:184
specieDiffusiveFlux(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: specieFlux.C:195
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:160
virtual ~specieFluxBase()
Destructor.
Definition: specieFlux.C:207
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:173
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.
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:31