1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2008-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "KinematicLookupTableInjection.H"
28 #include "scalarIOList.H"
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 template<class CloudType>
33 Foam::label Foam::KinematicLookupTableInjection<CloudType>::INPUT_FILE_COLS = 9;
35 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
37 template<class CloudType>
38 Foam::label Foam::KinematicLookupTableInjection<CloudType>::parcelsToInject
44 if ((time0 >= 0.0) && (time0 < duration_))
46 return round(injectorCells_.size()*(time1 - time0)*nParcelsPerSecond_);
55 template<class CloudType>
56 Foam::scalar Foam::KinematicLookupTableInjection<CloudType>::volumeToInject
63 if ((time0 >= 0.0) && (time0 < duration_))
65 forAll(mDot_, injectorI)
67 volume += mDot_[injectorI]/rho_[injectorI]*(time1 - time0);
75 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
77 template<class CloudType>
78 Foam::KinematicLookupTableInjection<CloudType>::KinematicLookupTableInjection
80 const dictionary& dict,
84 InjectionModel<CloudType>(dict, owner, typeName),
85 inputFileName_(this->coeffDict().lookup("inputFile")),
86 duration_(readScalar(this->coeffDict().lookup("duration"))),
89 readScalar(this->coeffDict().lookup("parcelsPerSecond"))
98 scalarListIOList injectorData
103 owner.db().time().constant(),
110 x_.setSize(injectorData.size());
111 U_.setSize(injectorData.size());
112 d_.setSize(injectorData.size());
113 rho_.setSize(injectorData.size());
114 mDot_.setSize(injectorData.size());
117 forAll(injectorData, injectorI)
119 if (injectorData[injectorI].size() != INPUT_FILE_COLS)
123 "KinematicLookupTableInjection"
128 ) << "Incorrect number of entries in injector specification "
129 << "- found " << injectorData[injectorI].size()
130 << ", expected " << INPUT_FILE_COLS << ":" << nl
131 << " x0 x1 x2 u0 u1 u2 d rho mDot " << nl
134 x_[injectorI].component(0) = injectorData[injectorI][0];
135 x_[injectorI].component(1) = injectorData[injectorI][1];
136 x_[injectorI].component(2) = injectorData[injectorI][2];
137 U_[injectorI].component(0) = injectorData[injectorI][3];
138 U_[injectorI].component(1) = injectorData[injectorI][4];
139 U_[injectorI].component(2) = injectorData[injectorI][5];
140 d_[injectorI] = injectorData[injectorI][6];
141 rho_[injectorI] = injectorData[injectorI][7];
142 mDot_[injectorI] = injectorData[injectorI][8];
145 // Set/cache the injector cells
146 injectorCells_.setSize(injectorData.size());
147 forAll(x_, injectorI)
149 this->findCellAtPosition(injectorCells_[injectorI], x_[injectorI]);
152 // Determine volume of particles to inject
153 this->volumeTotal_ = 0.0;
154 forAll(mDot_, injectorI)
156 this->volumeTotal_ += mDot_[injectorI]/rho_[injectorI];
158 this->volumeTotal_ *= duration_;
162 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
164 template<class CloudType>
165 Foam::KinematicLookupTableInjection<CloudType>::~KinematicLookupTableInjection()
169 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
171 template<class CloudType>
172 bool Foam::KinematicLookupTableInjection<CloudType>::active() const
178 template<class CloudType>
179 Foam::scalar Foam::KinematicLookupTableInjection<CloudType>::timeEnd() const
181 return this->SOI_ + duration_;
185 template<class CloudType>
186 void Foam::KinematicLookupTableInjection<CloudType>::setPositionAndCell
189 const label nParcels,
195 label injectorI = parcelI*injectorCells_.size()/nParcels;
197 position = x_[injectorI];
198 cellOwner = injectorCells_[injectorI];
202 template<class CloudType>
203 void Foam::KinematicLookupTableInjection<CloudType>::setProperties
206 const label nParcels,
208 typename CloudType::parcelType& parcel
211 label injectorI = parcelI*injectorCells_.size()/nParcels;
213 // set particle velocity
214 parcel.U() = U_[injectorI];
216 // set particle diameter
217 parcel.d() = d_[injectorI];
219 // set particle density
220 parcel.rho() = rho_[injectorI];
224 template<class CloudType>
225 bool Foam::KinematicLookupTableInjection<CloudType>::fullyDescribed() const
231 template<class CloudType>
232 bool Foam::KinematicLookupTableInjection<CloudType>::validInjection
241 // ************************************************************************* //