ReactingMultiphaseLookupTableInjection.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) 2011-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 
27 
28 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
29 
30 template<class CloudType>
33 (
34  const dictionary& dict,
35  CloudType& owner,
36  const word& modelName
37 )
38 :
40  inputFileName_(this->typeDict().lookup("inputFile")),
41  duration_(this->readDuration(dict, owner)),
42  parcelsPerSecond_(this->readParcelsPerSecond(dict, owner)),
43  randomise_(readBool(this->typeDict().lookup("randomise"))),
44  injectors_
45  (
46  IOobject
47  (
48  inputFileName_,
49  owner.time().constant(),
50  owner.parent(),
51  IOobject::MUST_READ,
52  IOobject::NO_WRITE
53  )
54  ),
55  injectorCoordinates_(0),
56  injectorCells_(0),
57  injectorTetFaces_(0),
58  injectorTetPts_(0)
59 {
60  // Set/cache the injector cells
61  injectorCoordinates_.setSize(injectors_.size());
62  injectorCells_.setSize(injectors_.size());
63  injectorTetFaces_.setSize(injectors_.size());
64  injectorTetPts_.setSize(injectors_.size());
65 
66  topoChange();
67 }
68 
69 
70 template<class CloudType>
73 (
75 )
76 :
78  inputFileName_(im.inputFileName_),
79  duration_(im.duration_),
80  parcelsPerSecond_(im.parcelsPerSecond_, false),
81  randomise_(im.randomise_),
82  injectors_(im.injectors_),
83  injectorCoordinates_(im.injectorCoordinates_),
84  injectorCells_(im.injectorCells_),
85  injectorTetFaces_(im.injectorTetFaces_),
86  injectorTetPts_(im.injectorTetPts_)
87 {}
88 
89 
90 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
91 
92 template<class CloudType>
95 {}
96 
97 
98 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
99 
100 template<class CloudType>
102 {
103  const meshSearch& searchEngine = meshSearch::New(this->owner().mesh());
104 
105  // Set/cache the injector cells
106  forAll(injectors_, i)
107  {
108  this->findCellAtPosition
109  (
110  searchEngine,
111  injectors_[i].x(),
112  injectorCoordinates_[i],
113  injectorCells_[i],
114  injectorTetFaces_[i],
115  injectorTetPts_[i]
116  );
117  }
118 }
119 
120 
121 template<class CloudType>
122 Foam::scalar
124 {
125  return this->SOI_ + duration_;
126 }
127 
128 
129 template<class CloudType>
130 Foam::scalar
132 (
133  const scalar t0,
134  const scalar t1
135 )
136 {
137  if (t1 >= 0 && t0 < duration_)
138  {
139  return
140  injectorCells_.size()
141  *parcelsPerSecond_->integral(max(t0, 0), min(t1, duration_));
142  }
143  else
144  {
145  return 0;
146  }
147 }
148 
149 
150 template<class CloudType>
151 Foam::scalar
153 (
154  const scalar t0,
155  const scalar t1
156 )
157 {
158  scalar mass = 0;
159 
160  if (t1 >= 0 && t0 < duration_)
161  {
162  forAll(injectors_, i)
163  {
164  mass += injectors_[i].mDot()*(min(t1, duration_) - max(t0, 0));
165  }
166  }
167 
168  return mass;
169 }
170 
171 
172 template<class CloudType>
174 (
175  const meshSearch& searchEngine,
176  const label parcelI,
177  const label nParcels,
178  const scalar time,
180  label& celli,
181  label& tetFacei,
182  label& tetPti,
183  label& facei
184 )
185 {
186  label injectorI = 0;
187  if (randomise_)
188  {
189  randomGenerator& rndGen = this->owner().rndGen();
190  injectorI = rndGen.sampleAB<label>(0, injectorCells_.size());
191  }
192  else
193  {
194  injectorI = parcelI*injectorCells_.size()/nParcels;
195  }
196 
197  coordinates = injectorCoordinates_[injectorI];
198  celli = injectorCells_[injectorI];
199  tetFacei = injectorTetFaces_[injectorI];
200  tetPti = injectorTetPts_[injectorI];
201 }
202 
203 
204 template<class CloudType>
206 (
207  const label parcelI,
208  const label nParcels,
209  const scalar,
210  typename CloudType::parcelType::trackingData& td,
211  typename CloudType::parcelType& parcel
212 )
213 {
214  label injectorI = parcelI*injectorCells_.size()/nParcels;
215 
216  // set particle velocity
217  parcel.U() = injectors_[injectorI].U();
218 
219  // set particle diameter
220  parcel.d() = injectors_[injectorI].d();
221 
222  // set particle density
223  parcel.rho() = injectors_[injectorI].rho();
224 
225  // set particle temperature
226  parcel.T() = injectors_[injectorI].T();
227 
228  // set particle specific heat capacity
229  parcel.Cp() = injectors_[injectorI].Cp();
230 
231  // set particle component mass fractions
232  parcel.Y() = injectors_[injectorI].Y();
233 
234  // set particle gaseous component mass fractions
235  parcel.YGas() = injectors_[injectorI].YGas();
236 
237  // set particle liquid component mass fractions
238  parcel.YLiquid() = injectors_[injectorI].YLiquid();
239 
240  // set particle solid component mass fractions
241  parcel.YSolid() = injectors_[injectorI].YSolid();
242 }
243 
244 
245 template<class CloudType>
246 bool
248 {
249  return true;
250 }
251 
252 
253 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:449
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:80
ParcelType parcelType
Type of parcel the cloud was instantiated for.
Definition: DSMCCloud.H:225
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
Templated injection model class.
void setSize(const label)
Reset size of List.
Definition: List.C:281
Particle injection sources read from look-up table. Each row corresponds to an injection site.
virtual scalar nParcelsToInject(const scalar time0, const scalar time1)
Number of parcels to introduce relative to SOI.
virtual void topoChange()
Set injector locations when mesh is updated.
virtual void setProperties(const label parcelI, const label nParcels, const scalar time, typename CloudType::parcelType::trackingData &td, typename CloudType::parcelType &parcel)
Set the parcel properties.
ReactingMultiphaseLookupTableInjection(const dictionary &dict, CloudType &owner, const word &modelName)
Construct from dictionary.
virtual void setPositionAndCell(const meshSearch &searchEngine, const label parcelI, const label nParcels, const scalar time, barycentric &coordinates, label &celli, label &tetFacei, label &tetPti, label &facei)
Set the injection position and owner cell, tetFace and tetPt.
virtual bool fullyDescribed() const
Flag to identify whether model fully describes the parcel.
scalar timeEnd() const
Return the end-of-injection time.
virtual scalar massToInject(const scalar time0, const scalar time1)
Parcel mass to introduce relative to SOI.
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Mesh object that implements searches within the local cells and faces.
Definition: meshSearch.H:59
static const meshSearch & New(const polyMesh &mesh, const pointInCellShapes=pointInCellShapes::tets)
Lookup or construct from mesh and cell decomposition option.
Definition: meshSearch.C:61
Random number generator.
Type sampleAB(const Type &a, const Type &b)
Return a type with components uniformly distributed between two.
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)
const dimensionSet time
const dimensionSet mass
barycentric coordinates(const polyMesh &mesh, const point &position, const label celli, const label facei, const label faceTrii, const scalar stepFraction)
Return the coordinates given the position and tet topology.
Definition: tracking.C:1258
const unitSet & lookup(const word &unitName)
Lookup and return the named unit from the table.
Definition: units.C:346
bool readBool(Istream &)
Definition: boolIO.C:63
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
dimensioned< Type > min(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
dimensioned< Type > max(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
dictionary dict
randomGenerator rndGen(653213)