GaussianbXiIgnition.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 "GaussianbXiIgnition.H"
27 #include "mathematicalConstants.H"
29 
30 // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34  namespace fv
35  {
37 
39  (
40  fvModel,
43  );
44  }
45 }
46 
48 
49 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
50 
51 void Foam::fv::GaussianbXiIgnition::calcVk()
52 {
53  const labelList& cells = zone_.zone();
54  const scalarField& V(mesh().V());
55  const vectorField& C(mesh().C());
56 
57  const scalar diameter = diameter_.value();
58  const vector& position = position_.value();
59 
60  Vk_.setSize(cells.size());
61 
62  forAll(cells, i)
63  {
64  const label celli = cells[i];
65  Vk_[i] = V[celli]*exp(-magSqr(C[celli] - position)/sqr(diameter));
66  }
67 
68  const scalar sumVk = gSum(Vk_);
69  const scalar Vg =
70  kernelShape_->Dcorr().value()
71  *pow(sqrt(pi)*diameter, mesh().nGeometricD());
72 
73  forAll(Vk_, i)
74  {
75  Vk_[i] *= Vg/sumVk;
76  }
77 }
78 
79 
80 void Foam::fv::GaussianbXiIgnition::readCoeffs(const dictionary& dict)
81 {
82  position_.read(dict);
83  diameter_.read(dict);
84 
85  rate_.reset
86  (
88  (
89  "rate",
90  mesh().time().userUnits(),
91  dimRate,
92  dict
93  ).ptr()
94  );
95 
96  calcVk();
97 }
98 
99 
100 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
101 
103 (
104  const word& name,
105  const word& modelType,
106  const fvMesh& mesh,
107  const dictionary& dict
108 )
109 :
110  bXiTimedIgnition(name, modelType, mesh, dict),
111  zone_(mesh, coeffs(dict)),
112  kernelShape_(kernelShape::New(mesh, coeffs(dict))),
113  position_("position", dimLength, Zero),
114  diameter_("diameter", dimLength, 0)
115 {
116  readCoeffs(coeffs(dict));
117 }
118 
119 
120 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
121 
123 (
124  const volScalarField& rho,
125  const volScalarField& b,
126  fvMatrix<scalar>& eqn
127 ) const
128 {
129  if (!igniting()) return;
130 
131  if (debug)
132  {
133  Info<< type() << ": applying source to " << eqn.psi().name() << endl;
134  }
135 
136  scalarField& Sp = eqn.diag();
137  const labelList& cells = zone_.zone();
138  const scalar rate = rate_->value(ignRelTime(mesh().time().value()));
139 
140  forAll(cells, i)
141  {
142  const label celli = cells[i];
143  Sp[celli] -= Vk_[i]*rho[celli]*rate;
144  }
145 }
146 
147 
149 (
150  const polyTopoChangeMap& map
151 )
152 {
153  zone_.topoChange(map);
154  calcVk();
155 }
156 
157 
159 {
160  zone_.mapMesh(map);
161  calcVk();
162 }
163 
164 
166 (
167  const polyDistributionMap& map
168 )
169 {
170  zone_.distribute(map);
171  calcVk();
172 }
173 
174 
176 {
177  zone_.movePoints();
178  calcVk();
179  return true;
180 }
181 
182 
184 {
185  if (bXiIgnition::read(dict))
186  {
187  zone_.read(coeffs(dict));
188  readCoeffs(coeffs(dict));
189  return true;
190  }
191  else
192  {
193  return false;
194  }
195 
196  return false;
197 }
198 
199 
200 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:449
Macros for easy insertion into run-time selection tables.
static autoPtr< Function1< scalar > > New(const word &name, const Function1s::unitSets &units, const dictionary &dict)
Select from dictionary.
Definition: Function1New.C:32
Generic GeometricField class.
void setSize(const label)
Reset size of List.
Definition: List.C:281
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
const Type & value() const
Return const reference to value.
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
Finite volume model abstract base class.
Definition: fvModel.H:60
static const dictionary & coeffs(const word &modelType, const dictionary &)
Return the coefficients sub-dictionary for a given model type.
Definition: fvModelI.H:31
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
Gaussian profile time dependent rate ignition model for the Weller b-Xi combustion model.
virtual bool movePoints()
Update for mesh motion.
scalarList Vk_
Kernel volume correction factor.
fvCellZone zone_
The ignition cellZone.
virtual void topoChange(const polyTopoChangeMap &)
Update topology using the given map.
virtual void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
virtual bool read(const dictionary &dict)
Read source dictionary.
autoPtr< kernelShape > kernelShape_
GaussianbXiIgnition(const word &name, const word &modelType, const fvMesh &mesh, const dictionary &dict)
Construct from explicit source name and mesh.
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.
Abstract base-class for timed ignition models for the Weller b-Xi combustion models.
const cellZone & zone() const
Return const access to the cell set.
Base class for ignition kernel flame wrinkling Xi correction.
Definition: kernelShape.H:60
scalarField & diag()
Definition: lduMatrix.C:186
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.
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
const dimensionSet rate
addToRunTimeSelectionTable(fvConstraint, bound, dictionary)
defineTypeNameAndDebug(bound, 0)
tmp< VolField< Type > > Sp(const volScalarField &sp, const VolField< Type > &vf)
Definition: fvcSup.C:67
static const coefficient C("C", dimTemperature, 234.5)
point position(const polyMesh &mesh, const barycentric &coordinates, const label celli, const label facei, const label faceTrii, const scalar stepFraction)
Return the position given the coordinates and tet topology.
Definition: trackingI.H:224
Namespace for OpenFOAM.
static const zero Zero
Definition: zero.H:97
dimensionedScalar exp(const dimensionedScalar &ds)
List< label > labelList
A List of labels.
Definition: labelList.H:56
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
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:288
const dimensionSet & dimLength
Definition: dimensions.C:141
messageStream Info
Type gSum(const UList< Type > &f, const label comm)
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
tmp< DimensionedField< typename outerProduct< Type, Type >::type, GeoMesh, Field >> sqr(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:49
Field< vector > vectorField
Specialisation of Field<T> for vector.
const dimensionSet & dimRate
Definition: dimensions.C:152
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
tmp< DimensionedField< typename powProduct< Type, r >::type, GeoMesh, Field > > pow(const DimensionedField< Type, GeoMesh, PrimitiveField > &df, typename powProduct< Type, r >::type)
void sqrt(LagrangianPatchField< scalar > &f, const LagrangianPatchField< scalar > &f1)
tmp< DimensionedField< scalar, GeoMesh, Field > > magSqr(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
tmp< DimensionedField< TypeR, GeoMesh, Field > > New(const tmp< DimensionedField< TypeR, GeoMesh, Field >> &tdf1, const word &name, const dimensionSet &dimensions)
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