BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / src / lagrangian / intermediate / submodels / Reacting / InjectionModel / ReactingLookupTableInjection / ReactingLookupTableInjection.C
blobdd3d80ca0b3e8d1c87e230018e996f23070d55a0
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
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
13     the Free Software Foundation, either version 3 of the License, or
14     (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "ReactingLookupTableInjection.H"
28 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
30 template<class CloudType>
31 Foam::ReactingLookupTableInjection<CloudType>::ReactingLookupTableInjection
33     const dictionary& dict,
34     CloudType& owner
37     InjectionModel<CloudType>(dict, owner, typeName),
38     inputFileName_(this->coeffDict().lookup("inputFile")),
39     duration_(readScalar(this->coeffDict().lookup("duration"))),
40     parcelsPerSecond_
41     (
42         readScalar(this->coeffDict().lookup("parcelsPerSecond"))
43     ),
44     injectors_
45     (
46         IOobject
47         (
48             inputFileName_,
49             owner.db().time().constant(),
50             owner.db(),
51             IOobject::MUST_READ,
52             IOobject::NO_WRITE
53         )
54     ),
55     injectorCells_(0),
56     injectorTetFaces_(0),
57     injectorTetPts_(0)
59     // Set/cache the injector cells
60     injectorCells_.setSize(injectors_.size());
61     injectorTetFaces_.setSize(injectors_.size());
62     injectorTetPts_.setSize(injectors_.size());
64     forAll(injectors_, i)
65     {
66         this->findCellAtPosition
67         (
68             injectorCells_[i],
69             injectorTetFaces_[i],
70             injectorTetPts_[i],
71             injectors_[i].x()
72         );
73     }
75     // Determine volume of particles to inject
76     this->volumeTotal_ = 0.0;
77     forAll(injectors_, i)
78     {
79         this->volumeTotal_ += injectors_[i].mDot()/injectors_[i].rho();
80     }
81     this->volumeTotal_ *= duration_;
85 template<class CloudType>
86 Foam::ReactingLookupTableInjection<CloudType>::ReactingLookupTableInjection
88     const ReactingLookupTableInjection<CloudType>& im
91     InjectionModel<CloudType>(im),
92     inputFileName_(im.inputFileName_),
93     duration_(im.duration_),
94     parcelsPerSecond_(im.parcelsPerSecond_),
95     injectors_(im.injectors_),
96     injectorCells_(im.injectorCells_),
97     injectorTetFaces_(im.injectorTetFaces_),
98     injectorTetPts_(im.injectorTetPts_)
102 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
104 template<class CloudType>
105 Foam::ReactingLookupTableInjection<CloudType>::~ReactingLookupTableInjection()
109 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
111 template<class CloudType>
112 Foam::scalar Foam::ReactingLookupTableInjection<CloudType>::timeEnd() const
114     return this->SOI_ + duration_;
118 template<class CloudType>
119 Foam::label Foam::ReactingLookupTableInjection<CloudType>::parcelsToInject
121     const scalar time0,
122     const scalar time1
125     if ((time0 >= 0.0) && (time0 < duration_))
126     {
127         return floor(injectorCells_.size()*(time1 - time0)*parcelsPerSecond_);
128     }
129     else
130     {
131         return 0;
132     }
136 template<class CloudType>
137 Foam::scalar Foam::ReactingLookupTableInjection<CloudType>::volumeToInject
139     const scalar time0,
140     const scalar time1
143     scalar volume = 0.0;
144     if ((time0 >= 0.0) && (time0 < duration_))
145     {
146         forAll(injectors_, i)
147         {
148             volume += injectors_[i].mDot()/injectors_[i].rho()*(time1 - time0);
149         }
150     }
152     return volume;
156 template<class CloudType>
157 void Foam::ReactingLookupTableInjection<CloudType>::setPositionAndCell
159     const label parcelI,
160     const label nParcels,
161     const scalar time,
162     vector& position,
163     label& cellOwner,
164     label& tetFaceI,
165     label& tetPtI
168     label injectorI = parcelI*injectorCells_.size()/nParcels;
170     position = injectors_[injectorI].x();
171     cellOwner = injectorCells_[injectorI];
172     tetFaceI = injectorTetFaces_[injectorI];
173     tetPtI = injectorTetPts_[injectorI];
177 template<class CloudType>
178 void Foam::ReactingLookupTableInjection<CloudType>::setProperties
180     const label parcelI,
181     const label nParcels,
182     const scalar,
183     typename CloudType::parcelType& parcel
186     label injectorI = parcelI*injectorCells_.size()/nParcels;
188     // set particle velocity
189     parcel.U() = injectors_[injectorI].U();
191     // set particle diameter
192     parcel.d() = injectors_[injectorI].d();
194     // set particle density
195     parcel.rho() = injectors_[injectorI].rho();
197     // set particle temperature
198     parcel.T() = injectors_[injectorI].T();
200     // set particle specific heat capacity
201     parcel.Cp() = injectors_[injectorI].Cp();
203     // set particle component mass fractions
204     parcel.Y() = injectors_[injectorI].Y();
208 template<class CloudType>
209 bool Foam::ReactingLookupTableInjection<CloudType>::fullyDescribed() const
211     return true;
215 template<class CloudType>
216 bool Foam::ReactingLookupTableInjection<CloudType>::validInjection(const label)
218     return true;
222 // ************************************************************************* //