initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / lagrangian / intermediate / submodels / Thermodynamic / InjectionModel / ThermoLookupTableInjection / ThermoLookupTableInjection.C
blobad7e13b6d20417d9364345d3da04628588241777
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2008-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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
40     const scalar time0,
41     const scalar time1
42 ) const
44     if ((time0 >= 0.0) && (time0 < duration_))
45     {
46         return round(injectorCells_.size()*(time1 - time0)*nParcelsPerSecond_);
47     }
48     else
49     {
50         return 0;
51     }
55 template<class CloudType>
56 Foam::scalar Foam::ThermoLookupTableInjection<CloudType>::volumeToInject
58     const scalar time0,
59     const scalar time1
60 ) const
62     scalar volume = 0.0;
63     if ((time0 >= 0.0) && (time0 < duration_))
64     {
65         forAll(mDot_, injectorI)
66         {
67             volume += mDot_[injectorI]/rho_[injectorI]*(time1 - time0);
68         }
69     }
71     return volume;
75 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
77 template<class CloudType>
78 Foam::ThermoLookupTableInjection<CloudType>::ThermoLookupTableInjection
80     const dictionary& dict,
81     CloudType& owner
84     InjectionModel<CloudType>(dict, owner, typeName),
85     inputFileName_(this->coeffDict().lookup("inputFile")),
86     duration_(readScalar(this->coeffDict().lookup("duration"))),
87     nParcelsPerSecond_
88     (
89         readScalar(this->coeffDict().lookup("parcelsPerSecond"))
90     ),
91     x_(0),
92     U_(0),
93     d_(0),
94     rho_(0),
95     mDot_(0),
96     T_(0),
97     cp_(0),
98     injectorCells_(0)
100     scalarListIOList injectorData
101     (
102         IOobject
103         (
104             inputFileName_,
105             owner.db().time().constant(),
106             owner.db(),
107             IOobject::MUST_READ,
108             IOobject::NO_WRITE
109         )
110     );
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());
120     // Populate lists
121     forAll(injectorData, injectorI)
122     {
123         if (injectorData[injectorI].size() != INPUT_FILE_COLS)
124         {
125             FatalErrorIn
126             (
127                 "ThermoLookupTableInjection"
128                 "("
129                     "const dictionary&,"
130                     "CloudType& owner"
131                 ")"
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);
137         }
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];
149    }
151     // Set/cache the injector cells
152     injectorCells_.setSize(injectorData.size());
153     forAll(x_, injectorI)
154     {
155         this->findCellAtPosition(injectorCells_[injectorI], x_[injectorI]);
156     }
158     // Determine volume of particles to inject
159     this->volumeTotal_ = 0.0;
160     forAll(mDot_, injectorI)
161     {
162         this->volumeTotal_ += mDot_[injectorI]/rho_[injectorI];
163     }
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
180     return true;
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
194     const label parcelI,
195     const label nParcels,
196     const scalar time,
197     vector& position,
198     label& cellOwner
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
211     const label parcelI,
212     const label nParcels,
213     const scalar,
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
239     return true;
243 template<class CloudType>
244 bool Foam::ThermoLookupTableInjection<CloudType>::validInjection(const label)
246     return true;
250 // ************************************************************************* //