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-2020 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 :
39  InjectionModel<CloudType>(dict, owner, modelName, typeName),
40  inputFileName_(this->coeffDict().lookup("inputFile")),
41  duration_(this->coeffDict().template lookup<scalar>("duration")),
42  parcelsPerSecond_
43  (
44  this->coeffDict().template lookup<scalar>("parcelsPerSecond")
45  ),
46  randomise_(readBool(this->coeffDict().lookup("randomise"))),
47  injectors_
48  (
49  IOobject
50  (
51  inputFileName_,
52  owner.db().time().constant(),
53  owner.db(),
54  IOobject::MUST_READ,
55  IOobject::NO_WRITE
56  )
57  ),
58  injectorCells_(0),
59  injectorTetFaces_(0),
60  injectorTetPts_(0)
61 {
62  duration_ = owner.db().time().userTimeToTime(duration_);
63 
64  // Set/cache the injector cells
65  injectorCells_.setSize(injectors_.size());
66  injectorTetFaces_.setSize(injectors_.size());
67  injectorTetPts_.setSize(injectors_.size());
68 
69  updateMesh();
70 
71  // Determine volume of particles to inject
72  this->volumeTotal_ = 0.0;
73  forAll(injectors_, i)
74  {
75  this->volumeTotal_ += injectors_[i].mDot()/injectors_[i].rho();
76  }
77  this->volumeTotal_ *= duration_;
78 }
79 
80 
81 template<class CloudType>
84 (
86 )
87 :
89  inputFileName_(im.inputFileName_),
90  duration_(im.duration_),
91  parcelsPerSecond_(im.parcelsPerSecond_),
92  randomise_(im.randomise_),
93  injectors_(im.injectors_),
94  injectorCells_(im.injectorCells_),
95  injectorTetFaces_(im.injectorTetFaces_),
96  injectorTetPts_(im.injectorTetPts_)
97 {}
98 
99 
100 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
101 
102 template<class CloudType>
105 {}
106 
107 
108 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
109 
110 template<class CloudType>
112 {
113  // Set/cache the injector cells
114  forAll(injectors_, i)
115  {
116  this->findCellAtPosition
117  (
118  injectorCells_[i],
119  injectorTetFaces_[i],
120  injectorTetPts_[i],
121  injectors_[i].x()
122  );
123  }
124 }
125 
126 
127 template<class CloudType>
128 Foam::scalar
130 {
131  return this->SOI_ + duration_;
132 }
133 
134 
135 template<class CloudType>
138 (
139  const scalar time0,
140  const scalar time1
141 )
142 {
143  if ((time0 >= 0.0) && (time0 < duration_))
144  {
145  return floor(injectorCells_.size()*(time1 - time0)*parcelsPerSecond_);
146  }
147  else
148  {
149  return 0;
150  }
151 }
152 
153 
154 template<class CloudType>
155 Foam::scalar
157 (
158  const scalar time0,
159  const scalar time1
160 )
161 {
162  scalar volume = 0.0;
163  if ((time0 >= 0.0) && (time0 < duration_))
164  {
165  forAll(injectors_, i)
166  {
167  volume += injectors_[i].mDot()/injectors_[i].rho()*(time1 - time0);
168  }
169  }
170 
171  return volume;
172 }
173 
174 
175 template<class CloudType>
177 (
178  const label parcelI,
179  const label nParcels,
180  const scalar time,
181  vector& position,
182  label& cellOwner,
183  label& tetFacei,
184  label& tetPti
185 )
186 {
187  label injectorI = 0;
188  if (randomise_)
189  {
190  Random& rnd = this->owner().rndGen();
191  injectorI = rnd.sampleAB<label>(0, injectorCells_.size());
192  }
193  else
194  {
195  injectorI = parcelI*injectorCells_.size()/nParcels;
196  }
197 
198  position = injectors_[injectorI].x();
199  cellOwner = injectorCells_[injectorI];
200  tetFacei = injectorTetFaces_[injectorI];
201  tetPti = injectorTetPts_[injectorI];
202 }
203 
204 
205 template<class CloudType>
207 (
208  const label parcelI,
209  const label nParcels,
210  const scalar,
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 template<class CloudType>
255 (
256  const label
257 )
258 {
259  return true;
260 }
261 
262 
263 // ************************************************************************* //
scalar timeEnd() const
Return the end-of-injection time.
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
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
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
Templated injection model class.
Type sampleAB(const Type &a, const Type &b)
Advance the state and return a sample of a given type from a.
Definition: RandomI.H:98
virtual void setProperties(const label parcelI, const label nParcels, const scalar time, typename CloudType::parcelType &parcel)
Set the parcel properties.
bool readBool(Istream &)
Definition: boolIO.C:60
virtual void setPositionAndCell(const label parcelI, const label nParcels, const scalar time, vector &position, label &cellOwner, label &tetFacei, label &tetPti)
Set the injection position and owner cell, tetFace and tetPt.
stressControl lookup("compactNormalStress") >> compactNormalStress
A class for handling words, derived from string.
Definition: word.H:59
virtual label parcelsToInject(const scalar time0, const scalar time1)
Number of parcels to introduce relative to SOI.
virtual bool validInjection(const label parcelI)
Return flag to identify whether or not injection of parcelI is.
ReactingMultiphaseLookupTableInjection(const dictionary &dict, CloudType &owner, const word &modelName)
Construct from dictionary.
const Cmpt & x() const
Definition: VectorI.H:75
Random number generator.
Definition: Random.H:57
ParcelType parcelType
Type of parcel the cloud was instantiated for.
Definition: DSMCCloud.H:221
Particle injection sources read from look-up table. Each row corresponds to an injection site...
virtual void updateMesh()
Set injector locations when mesh is updated.
virtual bool fullyDescribed() const
Flag to identify whether model fully describes the parcel.
virtual scalar volumeToInject(const scalar time0, const scalar time1)
Volume of parcels to introduce relative to SOI.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:92
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:75