ReactingLookupTableInjection.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>
32 (
33  const dictionary& dict,
34  CloudType& owner,
35  const word& modelName
36 )
37 :
39  inputFileName_(this->typeDict().lookup("inputFile")),
40  duration_(this->readDuration(dict, owner)),
41  parcelsPerSecond_(this->readParcelsPerSecond(dict, owner)),
42  randomise_(readBool(this->typeDict().lookup("randomise"))),
43  injectors_
44  (
45  IOobject
46  (
47  inputFileName_,
48  owner.time().constant(),
49  owner.parent(),
50  IOobject::MUST_READ,
51  IOobject::NO_WRITE
52  )
53  ),
54  injectorCoordinates_(0),
55  injectorCells_(0),
56  injectorTetFaces_(0),
57  injectorTetPts_(0)
58 {
59  // Set/cache the injector cells
60  injectorCoordinates_.setSize(injectors_.size());
61  injectorCells_.setSize(injectors_.size());
62  injectorTetFaces_.setSize(injectors_.size());
63  injectorTetPts_.setSize(injectors_.size());
64 
65  topoChange();
66 }
67 
68 
69 template<class CloudType>
71 (
73 )
74 :
76  inputFileName_(im.inputFileName_),
77  duration_(im.duration_),
78  parcelsPerSecond_(im.parcelsPerSecond_, false),
79  randomise_(im.randomise_),
80  injectors_(im.injectors_),
81  injectorCoordinates_(im.injectorCoordinates_),
82  injectorCells_(im.injectorCells_),
83  injectorTetFaces_(im.injectorTetFaces_),
84  injectorTetPts_(im.injectorTetPts_)
85 {}
86 
87 
88 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
89 
90 template<class CloudType>
92 {}
93 
94 
95 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
96 
97 template<class CloudType>
99 {
100  const meshSearch& searchEngine = meshSearch::New(this->owner().mesh());
101 
102  // Set/cache the injector cells
103  forAll(injectors_, i)
104  {
105  this->findCellAtPosition
106  (
107  searchEngine,
108  injectors_[i].x(),
109  injectorCoordinates_[i],
110  injectorCells_[i],
111  injectorTetFaces_[i],
112  injectorTetPts_[i]
113  );
114  }
115 }
116 
117 
118 template<class CloudType>
120 {
121  return this->SOI_ + duration_;
122 }
123 
124 
125 template<class CloudType>
127 (
128  const scalar t0,
129  const scalar t1
130 )
131 {
132  if (t1 >= 0 && t0 < duration_)
133  {
134  return
135  injectorCells_.size()
136  *parcelsPerSecond_->integral(max(t0, 0), min(t1, duration_));
137  }
138  else
139  {
140  return 0;
141  }
142 }
143 
144 
145 template<class CloudType>
147 (
148  const scalar t0,
149  const scalar t1
150 )
151 {
152  scalar mass = 0;
153 
154  if (t1 >= 0 && t0 < duration_)
155  {
156  forAll(injectors_, i)
157  {
158  mass += injectors_[i].mDot()*(min(t1, duration_) - max(t0, 0));
159  }
160  }
161 
162  return mass;
163 }
164 
165 
166 template<class CloudType>
168 (
169  const meshSearch& searchEngine,
170  const label parcelI,
171  const label nParcels,
172  const scalar time,
174  label& celli,
175  label& tetFacei,
176  label& tetPti,
177  label& facei
178 )
179 {
180  label injectorI = 0;
181  if (randomise_)
182  {
183  randomGenerator& rndGen = this->owner().rndGen();
184  injectorI = rndGen.sampleAB<label>(0, injectorCells_.size());
185  }
186  else
187  {
188  injectorI = parcelI*injectorCells_.size()/nParcels;
189  }
190 
191  coordinates = injectorCoordinates_[injectorI];
192  celli = injectorCells_[injectorI];
193  tetFacei = injectorTetFaces_[injectorI];
194  tetPti = injectorTetPts_[injectorI];
195 }
196 
197 
198 template<class CloudType>
200 (
201  const label parcelI,
202  const label nParcels,
203  const scalar,
204  typename CloudType::parcelType::trackingData& td,
205  typename CloudType::parcelType& parcel
206 )
207 {
208  label injectorI = parcelI*injectorCells_.size()/nParcels;
209 
210  // set particle velocity
211  parcel.U() = injectors_[injectorI].U();
212 
213  // set particle diameter
214  parcel.d() = injectors_[injectorI].d();
215 
216  // set particle density
217  parcel.rho() = injectors_[injectorI].rho();
218 
219  // set particle temperature
220  parcel.T() = injectors_[injectorI].T();
221 
222  // set particle specific heat capacity
223  parcel.Cp() = injectors_[injectorI].Cp();
224 
225  // set particle component mass fractions
226  parcel.Y() = injectors_[injectorI].Y();
227 }
228 
229 
230 template<class CloudType>
232 {
233  return true;
234 }
235 
236 
237 // ************************************************************************* //
#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.
ReactingLookupTableInjection(const dictionary &dict, CloudType &owner, const word &modelName)
Construct from dictionary.
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.
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)