bXiKernelCorr.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) 2025-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 "bXiKernelCorr.H"
27 #include "bXiIgnition.H"
29 
30 // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34  namespace fv
35  {
37 
39  (
40  fvModel,
43  );
44  }
45 }
46 
47 
48 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
49 
50 void Foam::fv::bXiKernelCorr::readCoeffs(const dictionary& dict)
51 {
52  duration_.read(dict, mesh().time().userUnits());
54 }
55 
56 
57 template<class Type>
58 inline auto Foam::fv::bXiKernelCorr::bFunc(const Type& b, const Type& R) const
59 {
60  // Analytical solution of b-Xi model with linear Xi and heat release
61  return (R - (R - 1)*b)*(1 - b);
62 
63  // Fit to Gaussian kernel position distribution
64  // return pow(max(1 - b, 0.0), 0.8)/pow(max(b, bMin_.value()), 0.2);
65 }
66 
67 
68 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
69 
71 (
72  const word& name,
73  const word& modelType,
74  const fvMesh& mesh,
75  const dictionary& dict
76 )
77 :
78  fvModel(name, modelType, mesh, dict),
79  zone_(mesh, coeffs(dict)),
80  kernelShape_(kernelShape::New(mesh, coeffs(dict))),
81  ignition_
82  (
83  refCast<const fv::bXiIgnition>
84  (
85  fvModels::New(mesh)[coeffs(dict).lookup<word>("ignition")]
86  )
87  ),
88  duration_("duration", mesh.time().userUnits(), coeffs(dict)),
89  bMin_
90  (
91  "bMin",
92  dimless,
93  coeffs(dict),
94  mesh.lookupObject<solvers::XiFluid>(solver::typeName).bMin()/2
95  )
96 {}
97 
98 
99 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
100 
102 {
103  return ignition_.addSupFields();
104 }
105 
106 
108 (
109  const volScalarField& rho,
110  const volScalarField& b,
111  fvMatrix<scalar>& eqn
112 ) const
113 {
114  if (!ignition_.igniting(duration_)) return;
115 
116  const labelList& cells = zone_.zone();
117 
118  const scalarField bc(b, cells);
119  const scalar bMin = returnReduce(min(bc), minOp<scalar>());
120 
121  // Check if min(b) is < 1, i.e. ignition has occurred
122  // and min(b) > small, i.e. burnout has not occurred requiring correction
123  if (bMin < 1 - bMin_.value() && bMin > bMin_.value())
124  {
125  if (debug)
126  {
127  Info<< type()
128  << ": applying source to " << eqn.psi().name() << endl;
129  }
130 
132  (
134  );
135 
137  (
139  );
140 
141  const volScalarField& mgb = mesh().lookupObject<volScalarField>("mgb");
142  const volScalarField& Sl = mesh().lookupObject<volScalarField>("Su");
143  const volScalarField& Xi = mesh().lookupObject<volScalarField>("Xi");
144 
145  const scalarField& V = mesh().V();
146 
147  const scalarField Vc(V, cells);
148  const scalarField Rc(scalarField(rhou, cells)/scalarField(rhob, cells));
149 
150  // Calculate volume of kernel
151  const dimensionedScalar Vk("Vk", dimVolume, gSum((1 - bc)*Vc));
152 
153  // Calculate kernel area from its volume
154  const scalar Ak(kernelShape_->Ak(Vk).value());
155 
156  // Calculate volume integral of kernel distribution function
157  const scalar Vkd = gSum(bFunc(bc, Rc)*bc*Vc);
158 
159  scalarField& Sp = eqn.diag();
160 
161  forAll(cells, i)
162  {
163  const label celli = cells[i];
164  const scalar b = bc[i];
165 
166  // Add kernel propagation correction source
167  Sp[celli] -=
168  Vc[i]*rhou[celli]*Sl[celli]*Xi[celli]
169  *max(Ak*bFunc(b, Rc[i])/Vkd - mgb[celli]/max(b, bMin), 0);
170  }
171  }
172 }
173 
174 
176 (
177  const polyTopoChangeMap& map
178 )
179 {
180  zone_.topoChange(map);
181 }
182 
183 
185 {
186  zone_.mapMesh(map);
187 }
188 
189 
191 (
192  const polyDistributionMap& map
193 )
194 {
195  zone_.distribute(map);
196 }
197 
198 
200 {
201  zone_.movePoints();
202  return true;
203 }
204 
205 
207 {
208  if (fvModel::read(dict))
209  {
210  zone_.read(coeffs(dict));
211  readCoeffs(coeffs(dict));
212  return true;
213  }
214  else
215  {
216  return false;
217  }
218 
219  return false;
220 }
221 
222 
223 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:449
Macros for easy insertion into run-time selection tables.
Generic GeometricField class.
static word groupName(Name name, const word &group)
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
void read(const dictionary &, const unitSet &defaultUnits=NullObjectRef< unitSet >())
Update the value of dimensioned<Type>
bool readIfPresent(const dictionary &, const unitSet &defaultUnits=NullObjectRef< unitSet >())
Update the value of dimensioned<Type> if found in the dictionary.
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvMatrix.H:118
VolField< Type > & psi()
Definition: fvMatrix.H:289
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:98
const DimensionedField< scalar, fvMesh > & V() const
Return cell volumes.
Finite volume model abstract base class.
Definition: fvModel.H:60
virtual bool read(const dictionary &dict)
Read source dictionary.
Definition: fvModel.C:196
const fvMesh & mesh() const
Return const access to the mesh database.
Definition: fvModelI.H:69
Finite volume models.
Definition: fvModels.H:69
Abstract base-class for ignition models for the Weller b-Xi combustion models.
Definition: bXiIgnition.H:55
Early kernel propagation rate correction based on specified shape.
virtual bool movePoints()
Update for mesh motion.
virtual wordList addSupFields() const
Return the list of fields for which the option adds source term.
bXiKernelCorr(const word &name, const word &modelType, const fvMesh &mesh, const dictionary &dict)
Construct from explicit source name and mesh.
Definition: bXiKernelCorr.C:71
dimensionedScalar duration_
Maximum correction duration.
virtual void topoChange(const polyTopoChangeMap &)
Update topology using the given map.
dimensionedScalar bMin_
Minimum b below which the Xi correction is not applied.
virtual void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
virtual bool read(const dictionary &dict)
Read source dictionary.
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
virtual void addSup(const volScalarField &rho, const volScalarField &b, fvMatrix< scalar > &eqn) const
Add ignition contribution to b equation.
Base class for ignition kernel flame wrinkling Xi correction.
Definition: kernelShape.H:60
scalarField & diag()
Definition: lduMatrix.C:186
const Type & lookupObject(const word &name) const
Lookup and return the object of the given Type and name.
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
Class containing mesh-to-mesh mapping information.
Definition: polyMeshMap.H:51
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Abstract base class for run-time selectable region solvers.
Definition: solver.H:56
Template function which returns the un-mangled name of a given type. Useful for types which do not ha...
static const word burntPhaseName
Definition: ubRhoThermo.H:79
static const word unburntPhaseName
Definition: ubRhoThermo.H:78
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)
const cellShapeList & cells
volScalarField & b
Definition: createFields.H:27
rho
Definition: pEqn.H:1
const dimensionSet time
addToRunTimeSelectionTable(fvConstraint, bound, dictionary)
defineTypeNameAndDebug(bound, 0)
tmp< VolField< Type > > Sp(const volScalarField &sp, const VolField< Type > &vf)
Definition: fvcSup.C:67
const unitSet & lookup(const word &unitName)
Lookup and return the named unit from the table.
Definition: units.C:346
Namespace for OpenFOAM.
const dimensionSet & dimless
Definition: dimensions.C:138
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
To & refCast(From &r)
Reference type cast template function.
Definition: typeInfo.H:141
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:288
messageStream Info
const dimensionSet & dimVolume
Definition: dimensions.C:150
Type gSum(const UList< Type > &f, const label comm)
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
dimensioned< Type > min(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
static scalar R(const scalar a, const scalar x)
Definition: invIncGamma.C:102
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
tmp< DimensionedField< TypeR, GeoMesh, Field > > New(const tmp< DimensionedField< TypeR, GeoMesh, Field >> &tdf1, const word &name, const dimensionSet &dimensions)
dimensioned< Type > max(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488
labelList fv(nPoints)
dictionary dict