FreeFOAM The Cross-Platform CFD Toolkit
ReactingMultiphaseLookupTableInjection.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) 2008-2010 OpenCFD Ltd.
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 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
29 
30 template<class CloudType>
31 Foam::label
33 (
34  const scalar time0,
35  const scalar time1
36 ) const
37 {
38  if ((time0 >= 0.0) && (time0 < duration_))
39  {
40  return round(injectorCells_.size()*(time1 - time0)*nParcelsPerSecond_);
41  }
42  else
43  {
44  return 0;
45  }
46 }
47 
48 
49 template<class CloudType>
50 Foam::scalar
52 (
53  const scalar time0,
54  const scalar time1
55 ) const
56 {
57  scalar volume = 0.0;
58  if ((time0 >= 0.0) && (time0 < duration_))
59  {
60  forAll(injectors_, i)
61  {
62  volume += injectors_[i].mDot()/injectors_[i].rho()*(time1 - time0);
63  }
64  }
65 
66  return volume;
67 }
68 
69 
70 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
71 
72 template<class CloudType>
75 (
76  const dictionary& dict,
77  CloudType& owner
78 )
79 :
80  InjectionModel<CloudType>(dict, owner, typeName),
81  inputFileName_(this->coeffDict().lookup("inputFile")),
82  duration_(readScalar(this->coeffDict().lookup("duration"))),
83  nParcelsPerSecond_
84  (
85  readScalar(this->coeffDict().lookup("parcelsPerSecond"))
86  ),
87  injectors_
88  (
89  IOobject
90  (
91  inputFileName_,
92  owner.db().time().constant(),
93  owner.db(),
94  IOobject::MUST_READ,
95  IOobject::NO_WRITE
96  )
97  ),
98  injectorCells_(0)
99 {
100  // Set/cache the injector cells
101  injectorCells_.setSize(injectors_.size());
102  forAll(injectors_, i)
103  {
104  this->findCellAtPosition(injectorCells_[i], injectors_[i].x());
105  }
106 
107  // Determine volume of particles to inject
108  this->volumeTotal_ = 0.0;
109  forAll(injectors_, i)
110  {
111  this->volumeTotal_ += injectors_[i].mDot()/injectors_[i].rho();
112  }
113  this->volumeTotal_ *= duration_;
114 }
115 
116 
117 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
118 
119 template<class CloudType>
122 {}
123 
124 
125 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
126 
127 template<class CloudType>
129 {
130  return true;
131 }
132 
133 
134 template<class CloudType>
135 Foam::scalar
137 {
138  return this->SOI_ + duration_;
139 }
140 
141 
142 template<class CloudType>
144 (
145  const label parcelI,
146  const label nParcels,
147  const scalar time,
148  vector& position,
149  label& cellOwner
150 )
151 {
152  label injectorI = parcelI*injectorCells_.size()/nParcels;
153 
154  position = injectors_[injectorI].x();
155  cellOwner = injectorCells_[injectorI];
156 }
157 
158 
159 template<class CloudType>
161 (
162  const label parcelI,
163  const label nParcels,
164  const scalar,
165  typename CloudType::parcelType& parcel
166 )
167 {
168  label injectorI = parcelI*injectorCells_.size()/nParcels;
169 
170  // set particle velocity
171  parcel.U() = injectors_[injectorI].U();
172 
173  // set particle diameter
174  parcel.d() = injectors_[injectorI].d();
175 
176  // set particle density
177  parcel.rho() = injectors_[injectorI].rho();
178 
179  // set particle temperature
180  parcel.T() = injectors_[injectorI].T();
181 
182  // set particle specific heat capacity
183  parcel.cp() = injectors_[injectorI].cp();
184 
185  // set particle component mass fractions
186  parcel.Y() = injectors_[injectorI].Y();
187 
188  // set particle gaseous component mass fractions
189  parcel.YGas() = injectors_[injectorI].YGas();
190 
191  // set particle liquid component mass fractions
192  parcel.YLiquid() = injectors_[injectorI].YLiquid();
193 
194  // set particle solid component mass fractions
195  parcel.YSolid() = injectors_[injectorI].YSolid();
196 }
197 
198 
199 template<class CloudType>
200 bool
202 {
203  return true;
204 }
205 
206 
207 template<class CloudType>
209 (
210  const label
211 )
212 {
213  return true;
214 }
215 
216 
217 // ************************ vim: set sw=4 sts=4 et: ************************ //