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