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 "ThermoLookupTableInjection.H"
28 #include "scalarIOList.H"
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 template<class CloudType>
33 Foam::label Foam::ThermoLookupTableInjection<CloudType>::INPUT_FILE_COLS = 11;
35 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
37 template<class CloudType>
38 Foam::label Foam::ThermoLookupTableInjection<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::ThermoLookupTableInjection<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::ThermoLookupTableInjection<CloudType>::ThermoLookupTableInjection
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"))
100 scalarListIOList injectorData
105 owner.db().time().constant(),
112 x_.setSize(injectorData.size());
113 U_.setSize(injectorData.size());
114 d_.setSize(injectorData.size());
115 rho_.setSize(injectorData.size());
116 mDot_.setSize(injectorData.size());
117 T_.setSize(injectorData.size());
118 cp_.setSize(injectorData.size());
121 forAll(injectorData, injectorI)
123 if (injectorData[injectorI].size() != INPUT_FILE_COLS)
127 "ThermoLookupTableInjection"
132 ) << "Incorrect number of entries in injector specification "
133 << "- found " << injectorData[injectorI].size()
134 << ", expected " << INPUT_FILE_COLS << ":" << nl
135 << " x0 x1 x2 u0 u1 u2 d rho mDot T cp"
136 << nl << exit(FatalError);
138 x_[injectorI].component(0) = injectorData[injectorI][0];
139 x_[injectorI].component(1) = injectorData[injectorI][1];
140 x_[injectorI].component(2) = injectorData[injectorI][2];
141 U_[injectorI].component(0) = injectorData[injectorI][3];
142 U_[injectorI].component(1) = injectorData[injectorI][4];
143 U_[injectorI].component(2) = injectorData[injectorI][5];
144 d_[injectorI] = injectorData[injectorI][6];
145 rho_[injectorI] = injectorData[injectorI][7];
146 mDot_[injectorI] = injectorData[injectorI][8];
147 T_[injectorI] = injectorData[injectorI][9];
148 cp_[injectorI] = injectorData[injectorI][10];
151 // Set/cache the injector cells
152 injectorCells_.setSize(injectorData.size());
153 forAll(x_, injectorI)
155 this->findCellAtPosition(injectorCells_[injectorI], x_[injectorI]);
158 // Determine volume of particles to inject
159 this->volumeTotal_ = 0.0;
160 forAll(mDot_, injectorI)
162 this->volumeTotal_ += mDot_[injectorI]/rho_[injectorI];
164 this->volumeTotal_ *= duration_;
168 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
170 template<class CloudType>
171 Foam::ThermoLookupTableInjection<CloudType>::~ThermoLookupTableInjection()
175 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
177 template<class CloudType>
178 bool Foam::ThermoLookupTableInjection<CloudType>::active() const
184 template<class CloudType>
185 Foam::scalar Foam::ThermoLookupTableInjection<CloudType>::timeEnd() const
187 return this->SOI_ + duration_;
191 template<class CloudType>
192 void Foam::ThermoLookupTableInjection<CloudType>::setPositionAndCell
195 const label nParcels,
201 label injectorI = parcelI*injectorCells_.size()/nParcels;
203 position = x_[injectorI];
204 cellOwner = injectorCells_[injectorI];
208 template<class CloudType>
209 void Foam::ThermoLookupTableInjection<CloudType>::setProperties
212 const label nParcels,
214 typename CloudType::parcelType* pPtr
217 label injectorI = parcelI*injectorCells_.size()/nParcels;
219 // set particle velocity
220 parcel.U() = U_[injectorI];
222 // set particle diameter
223 parcel.d() = d_[injectorI];
225 // set particle density
226 parcel.rho() = rho_[injectorI];
228 // set particle temperature
229 parcel.T() = T_[injectorI];
231 // set particle specific heat capacity
232 parcel.cp() = cp_[injectorI];
236 template<class CloudType>
237 bool Foam::ThermoLookupTableInjection<CloudType>::fullyDescribed() const
243 template<class CloudType>
244 bool Foam::ThermoLookupTableInjection<CloudType>::validInjection(const label)
250 // ************************************************************************* //