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