BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / src / lagrangian / intermediate / submodels / ReactingMultiphase / InjectionModel / ReactingMultiphaseLookupTableInjection / ReactingMultiphaseLookupTableInjection.C
blob274c8cc7187c3bd649f3301a77bd33d7dfd1b090
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 "ReactingMultiphaseLookupTableInjection.H"
28 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
30 template<class CloudType>
31 Foam::ReactingMultiphaseLookupTableInjection<CloudType>::
32 ReactingMultiphaseLookupTableInjection
34     const dictionary& dict,
35     CloudType& owner
38     InjectionModel<CloudType>(dict, owner, typeName),
39     inputFileName_(this->coeffDict().lookup("inputFile")),
40     duration_(readScalar(this->coeffDict().lookup("duration"))),
41     parcelsPerSecond_
42     (
43         readScalar(this->coeffDict().lookup("parcelsPerSecond"))
44     ),
45     injectors_
46     (
47         IOobject
48         (
49             inputFileName_,
50             owner.db().time().constant(),
51             owner.db(),
52             IOobject::MUST_READ,
53             IOobject::NO_WRITE
54         )
55     ),
56     injectorCells_(0),
57     injectorTetFaces_(0),
58     injectorTetPts_(0)
60     // Set/cache the injector cells
61     injectorCells_.setSize(injectors_.size());
62     injectorTetFaces_.setSize(injectors_.size());
63     injectorTetPts_.setSize(injectors_.size());
65     forAll(injectors_, i)
66     {
67         this->findCellAtPosition
68         (
69             injectorCells_[i],
70             injectorTetFaces_[i],
71             injectorTetPts_[i],
72             injectors_[i].x()
73         );
74     }
76     // Determine volume of particles to inject
77     this->volumeTotal_ = 0.0;
78     forAll(injectors_, i)
79     {
80         this->volumeTotal_ += injectors_[i].mDot()/injectors_[i].rho();
81     }
82     this->volumeTotal_ *= duration_;
86 template<class CloudType>
87 Foam::ReactingMultiphaseLookupTableInjection<CloudType>::
88 ReactingMultiphaseLookupTableInjection
90     const ReactingMultiphaseLookupTableInjection<CloudType>& im
93     InjectionModel<CloudType>(im),
94     inputFileName_(im.inputFileName_),
95     duration_(im.duration_),
96     parcelsPerSecond_(im.parcelsPerSecond_),
97     injectors_(im.injectors_),
98     injectorCells_(im.injectorCells_),
99     injectorTetFaces_(im.injectorTetFaces_),
100     injectorTetPts_(im.injectorTetPts_)
104 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
106 template<class CloudType>
107 Foam::ReactingMultiphaseLookupTableInjection<CloudType>::
108 ~ReactingMultiphaseLookupTableInjection()
112 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
114 template<class CloudType>
115 Foam::scalar
116 Foam::ReactingMultiphaseLookupTableInjection<CloudType>::timeEnd() const
118     return this->SOI_ + duration_;
122 template<class CloudType>
123 Foam::label
124 Foam::ReactingMultiphaseLookupTableInjection<CloudType>::parcelsToInject
126     const scalar time0,
127     const scalar time1
130     if ((time0 >= 0.0) && (time0 < duration_))
131     {
132         return floor(injectorCells_.size()*(time1 - time0)*parcelsPerSecond_);
133     }
134     else
135     {
136         return 0;
137     }
141 template<class CloudType>
142 Foam::scalar
143 Foam::ReactingMultiphaseLookupTableInjection<CloudType>::volumeToInject
145     const scalar time0,
146     const scalar time1
149     scalar volume = 0.0;
150     if ((time0 >= 0.0) && (time0 < duration_))
151     {
152         forAll(injectors_, i)
153         {
154             volume += injectors_[i].mDot()/injectors_[i].rho()*(time1 - time0);
155         }
156     }
158     return volume;
162 template<class CloudType>
163 void Foam::ReactingMultiphaseLookupTableInjection<CloudType>::setPositionAndCell
165     const label parcelI,
166     const label nParcels,
167     const scalar time,
168     vector& position,
169     label& cellOwner,
170     label& tetFaceI,
171     label& tetPtI
174     label injectorI = parcelI*injectorCells_.size()/nParcels;
176     position = injectors_[injectorI].x();
177     cellOwner = injectorCells_[injectorI];
178     tetFaceI = injectorTetFaces_[injectorI];
179     tetPtI = injectorTetPts_[injectorI];
183 template<class CloudType>
184 void Foam::ReactingMultiphaseLookupTableInjection<CloudType>::setProperties
186     const label parcelI,
187     const label nParcels,
188     const scalar,
189     typename CloudType::parcelType& parcel
192     label injectorI = parcelI*injectorCells_.size()/nParcels;
194     // set particle velocity
195     parcel.U() = injectors_[injectorI].U();
197     // set particle diameter
198     parcel.d() = injectors_[injectorI].d();
200     // set particle density
201     parcel.rho() = injectors_[injectorI].rho();
203     // set particle temperature
204     parcel.T() = injectors_[injectorI].T();
206     // set particle specific heat capacity
207     parcel.Cp() = injectors_[injectorI].Cp();
209     // set particle component mass fractions
210     parcel.Y() = injectors_[injectorI].Y();
212     // set particle gaseous component mass fractions
213     parcel.YGas() = injectors_[injectorI].YGas();
215     // set particle liquid component mass fractions
216     parcel.YLiquid() = injectors_[injectorI].YLiquid();
218     // set particle solid component mass fractions
219     parcel.YSolid() = injectors_[injectorI].YSolid();
223 template<class CloudType>
224 bool
225 Foam::ReactingMultiphaseLookupTableInjection<CloudType>::fullyDescribed() const
227     return true;
231 template<class CloudType>
232 bool Foam::ReactingMultiphaseLookupTableInjection<CloudType>::validInjection
234     const label
237     return true;
241 // ************************************************************************* //