initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / lagrangian / intermediate / submodels / Kinematic / InjectionModel / KinematicLookupTableInjection / KinematicLookupTableInjection.C
blob5fd976e0160d5ba25a548b86730e38b007085d3b
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 "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
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::KinematicLookupTableInjection<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::KinematicLookupTableInjection<CloudType>::KinematicLookupTableInjection
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     injectorCells_(0)
98     scalarListIOList injectorData
99     (
100         IOobject
101         (
102             inputFileName_,
103             owner.db().time().constant(),
104             owner.db(),
105             IOobject::MUST_READ,
106             IOobject::NO_WRITE
107         )
108     );
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());
116     // Populate lists
117     forAll(injectorData, injectorI)
118     {
119         if (injectorData[injectorI].size() != INPUT_FILE_COLS)
120         {
121             FatalErrorIn
122             (
123                 "KinematicLookupTableInjection"
124                 "("
125                     "const dictionary&,"
126                     "CloudType& owner"
127                 ")"
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
132                 << exit(FatalError);
133         }
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];
143     }
145     // Set/cache the injector cells
146     injectorCells_.setSize(injectorData.size());
147     forAll(x_, injectorI)
148     {
149         this->findCellAtPosition(injectorCells_[injectorI], x_[injectorI]);
150     }
152     // Determine volume of particles to inject
153     this->volumeTotal_ = 0.0;
154     forAll(mDot_, injectorI)
155     {
156         this->volumeTotal_ += mDot_[injectorI]/rho_[injectorI];
157     }
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
174     return true;
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
188     const label parcelI,
189     const label nParcels,
190     const scalar time,
191     vector& position,
192     label& cellOwner
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
205     const label parcelI,
206     const label nParcels,
207     const scalar,
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
227     return true;
231 template<class CloudType>
232 bool Foam::KinematicLookupTableInjection<CloudType>::validInjection
234     const label
237     return true;
241 // ************************************************************************* //