ReactingLookupTableInjection.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011-2013 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 :
38  InjectionModel<CloudType>(dict, owner, modelName, typeName),
39  inputFileName_(this->coeffDict().lookup("inputFile")),
40  duration_(readScalar(this->coeffDict().lookup("duration"))),
41  parcelsPerSecond_
42  (
43  readScalar(this->coeffDict().lookup("parcelsPerSecond"))
44  ),
45  randomise_(readBool(this->coeffDict().lookup("randomise"))),
46  injectors_
47  (
48  IOobject
49  (
50  inputFileName_,
51  owner.db().time().constant(),
52  owner.db(),
53  IOobject::MUST_READ,
54  IOobject::NO_WRITE
55  )
56  ),
57  injectorCells_(0),
58  injectorTetFaces_(0),
59  injectorTetPts_(0)
60 {
61  duration_ = owner.db().time().userTimeToTime(duration_);
62 
63  // Set/cache the injector cells
64  injectorCells_.setSize(injectors_.size());
65  injectorTetFaces_.setSize(injectors_.size());
66  injectorTetPts_.setSize(injectors_.size());
67 
68  updateMesh();
69 
70  // Determine volume of particles to inject
71  this->volumeTotal_ = 0.0;
72  forAll(injectors_, i)
73  {
74  this->volumeTotal_ += injectors_[i].mDot()/injectors_[i].rho();
75  }
76  this->volumeTotal_ *= duration_;
77 }
78 
79 
80 template<class CloudType>
82 (
84 )
85 :
87  inputFileName_(im.inputFileName_),
88  duration_(im.duration_),
89  parcelsPerSecond_(im.parcelsPerSecond_),
90  randomise_(im.randomise_),
91  injectors_(im.injectors_),
92  injectorCells_(im.injectorCells_),
93  injectorTetFaces_(im.injectorTetFaces_),
94  injectorTetPts_(im.injectorTetPts_)
95 {}
96 
97 
98 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
99 
100 template<class CloudType>
102 {}
103 
104 
105 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
106 
107 template<class CloudType>
109 {
110  // Set/cache the injector cells
111  forAll(injectors_, i)
112  {
113  this->findCellAtPosition
114  (
115  injectorCells_[i],
116  injectorTetFaces_[i],
117  injectorTetPts_[i],
118  injectors_[i].x()
119  );
120  }
121 }
122 
123 
124 template<class CloudType>
126 {
127  return this->SOI_ + duration_;
128 }
129 
130 
131 template<class CloudType>
133 (
134  const scalar time0,
135  const scalar time1
136 )
137 {
138  if ((time0 >= 0.0) && (time0 < duration_))
139  {
140  return floor(injectorCells_.size()*(time1 - time0)*parcelsPerSecond_);
141  }
142  else
143  {
144  return 0;
145  }
146 }
147 
148 
149 template<class CloudType>
151 (
152  const scalar time0,
153  const scalar time1
154 )
155 {
156  scalar volume = 0.0;
157  if ((time0 >= 0.0) && (time0 < duration_))
158  {
159  forAll(injectors_, i)
160  {
161  volume += injectors_[i].mDot()/injectors_[i].rho()*(time1 - time0);
162  }
163  }
164 
165  return volume;
166 }
167 
168 
169 template<class CloudType>
171 (
172  const label parcelI,
173  const label nParcels,
174  const scalar time,
175  vector& position,
176  label& cellOwner,
177  label& tetFaceI,
178  label& tetPtI
179 )
180 {
181  label injectorI = 0;
182  if (randomise_)
183  {
184  cachedRandom& rnd = this->owner().rndGen();
185  injectorI = rnd.position<label>(0, injectorCells_.size() - 1);
186  }
187  else
188  {
189  injectorI = parcelI*injectorCells_.size()/nParcels;
190  }
191 
192  position = injectors_[injectorI].x();
193  cellOwner = injectorCells_[injectorI];
194  tetFaceI = injectorTetFaces_[injectorI];
195  tetPtI = injectorTetPts_[injectorI];
196 }
197 
198 
199 template<class CloudType>
201 (
202  const label parcelI,
203  const label nParcels,
204  const scalar,
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 template<class CloudType>
239 {
240  return true;
241 }
242 
243 
244 // ************************************************************************* //
Foam::IOobject
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::ReactingLookupTableInjection::volumeToInject
virtual scalar volumeToInject(const scalar time0, const scalar time1)
Volume of parcels to introduce relative to SOI.
Definition: ReactingLookupTableInjection.C:151
Foam::ReactingLookupTableInjection::updateMesh
virtual void updateMesh()
Set injector locations when mesh is updated.
Definition: ReactingLookupTableInjection.C:108
Foam::ReactingLookupTableInjection::injectorTetFaces_
labelList injectorTetFaces_
List of tetFace labels corresoponding to injector positions.
Definition: ReactingLookupTableInjection.H:93
Foam::ReactingLookupTableInjection::setProperties
virtual void setProperties(const label parcelI, const label nParcels, const scalar time, typename CloudType::parcelType &parcel)
Set the parcel properties.
Definition: ReactingLookupTableInjection.C:201
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::InjectionModel
Templated injection model class.
Definition: InjectionModel.H:67
Foam::ReactingLookupTableInjection::~ReactingLookupTableInjection
virtual ~ReactingLookupTableInjection()
Destructor.
Definition: ReactingLookupTableInjection.C:101
Foam::ReactingLookupTableInjection::injectorCells_
labelList injectorCells_
List of cell labels corresoponding to injector positions.
Definition: ReactingLookupTableInjection.H:90
Foam::ReactingLookupTableInjection::ReactingLookupTableInjection
ReactingLookupTableInjection(const dictionary &dict, CloudType &owner, const word &modelName)
Construct from dictionary.
Definition: ReactingLookupTableInjection.C:32
Foam::DSMCCloud::rndGen
Random & rndGen()
Return refernce to the random object.
Definition: DSMCCloudI.H:121
Foam::ReactingLookupTableInjection::duration_
scalar duration_
Injection duration - common to all injection sources.
Definition: ReactingLookupTableInjection.H:78
Foam::ReactingLookupTableInjection::injectors_
reactingParcelInjectionDataIOList injectors_
List of injectors.
Definition: ReactingLookupTableInjection.H:87
Foam::label
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
Foam::cachedRandom
Random number generator.
Definition: cachedRandom.H:63
Foam::ReactingLookupTableInjection::inputFileName_
const word inputFileName_
Name of file containing injector/parcel data.
Definition: ReactingLookupTableInjection.H:75
Foam::cachedRandom::position
Type position(const Type &start, const Type &end)
Return a sample between start and end.
Definition: cachedRandomTemplates.C:58
Foam::ReactingLookupTableInjection::parcelsPerSecond_
const scalar parcelsPerSecond_
Number of parcels per injector - common to all injection sources.
Definition: ReactingLookupTableInjection.H:81
Foam::DSMCCloud
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:68
Foam::ReactingLookupTableInjection::setPositionAndCell
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.
Definition: ReactingLookupTableInjection.C:171
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::Vector::x
const Cmpt & x() const
Definition: VectorI.H:65
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::ReactingLookupTableInjection::validInjection
virtual bool validInjection(const label parcelI)
Return flag to identify whether or not injection of parcelI is.
Definition: ReactingLookupTableInjection.C:238
readScalar
#define readScalar
Definition: doubleScalar.C:38
Foam::ReactingLookupTableInjection::randomise_
bool randomise_
Flag to indicate to randomise injection positions.
Definition: ReactingLookupTableInjection.H:84
Foam::Vector< scalar >
x
x
Definition: LISASMDCalcMethod2.H:52
Foam::ReactingLookupTableInjection::timeEnd
scalar timeEnd() const
Return the end-of-injection time.
Definition: ReactingLookupTableInjection.C:125
Foam::DSMCCloud::parcelType
ParcelType parcelType
Type of parcel the cloud was instantiated for.
Definition: DSMCCloud.H:217
Foam::ReactingLookupTableInjection::parcelsToInject
virtual label parcelsToInject(const scalar time0, const scalar time1)
Number of parcels to introduce relative to SOI.
Definition: ReactingLookupTableInjection.C:133
Foam::readBool
bool readBool(Istream &)
Definition: boolIO.C:60
Foam::ReactingLookupTableInjection::fullyDescribed
virtual bool fullyDescribed() const
Flag to identify whether model fully describes the parcel.
Definition: ReactingLookupTableInjection.C:231
Foam::ReactingLookupTableInjection::injectorTetPts_
labelList injectorTetPts_
List of tetPt labels corresoponding to injector positions.
Definition: ReactingLookupTableInjection.H:96
ReactingLookupTableInjection.H
Foam::ReactingLookupTableInjection
Particle injection sources read from look-up table. Each row corresponds to an injection site.
Definition: ReactingLookupTableInjection.H:68
lookup
stressControl lookup("compactNormalStress") >> compactNormalStress