FIX: Remove undistributable CHEMKIN files
[freefoam.git] / src / lagrangian / intermediate / submodels / ReactingMultiphase / InjectionModel / ReactingMultiphaseLookupTableInjection / ReactingMultiphaseLookupTableInjection.C
blob222234ff1c88deef2db2b1054829146e91a43c96
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2008-2010 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
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 // * * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * * //
30 template<class CloudType>
31 Foam::label
32 Foam::ReactingMultiphaseLookupTableInjection<CloudType>::parcelsToInject
34     const scalar time0,
35     const scalar time1
36 ) const
38     if ((time0 >= 0.0) && (time0 < duration_))
39     {
40         return round(injectorCells_.size()*(time1 - time0)*nParcelsPerSecond_);
41     }
42     else
43     {
44         return 0;
45     }
49 template<class CloudType>
50 Foam::scalar
51 Foam::ReactingMultiphaseLookupTableInjection<CloudType>::volumeToInject
53     const scalar time0,
54     const scalar time1
55 ) const
57     scalar volume = 0.0;
58     if ((time0 >= 0.0) && (time0 < duration_))
59     {
60         forAll(injectors_, i)
61         {
62             volume += injectors_[i].mDot()/injectors_[i].rho()*(time1 - time0);
63         }
64     }
66     return volume;
70 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
72 template<class CloudType>
73 Foam::ReactingMultiphaseLookupTableInjection<CloudType>::
74 ReactingMultiphaseLookupTableInjection
76     const dictionary& dict,
77     CloudType& owner
80     InjectionModel<CloudType>(dict, owner, typeName),
81     inputFileName_(this->coeffDict().lookup("inputFile")),
82     duration_(readScalar(this->coeffDict().lookup("duration"))),
83     nParcelsPerSecond_
84     (
85         readScalar(this->coeffDict().lookup("parcelsPerSecond"))
86     ),
87     injectors_
88     (
89         IOobject
90         (
91             inputFileName_,
92             owner.db().time().constant(),
93             owner.db(),
94             IOobject::MUST_READ,
95             IOobject::NO_WRITE
96         )
97     ),
98     injectorCells_(0)
100     // Set/cache the injector cells
101     injectorCells_.setSize(injectors_.size());
102     forAll(injectors_, i)
103     {
104         this->findCellAtPosition(injectorCells_[i], injectors_[i].x());
105     }
107     // Determine volume of particles to inject
108     this->volumeTotal_ = 0.0;
109     forAll(injectors_, i)
110     {
111         this->volumeTotal_ += injectors_[i].mDot()/injectors_[i].rho();
112     }
113     this->volumeTotal_ *= duration_;
117 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
119 template<class CloudType>
120 Foam::ReactingMultiphaseLookupTableInjection<CloudType>::
121 ~ReactingMultiphaseLookupTableInjection()
125 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
127 template<class CloudType>
128 bool Foam::ReactingMultiphaseLookupTableInjection<CloudType>::active() const
130     return true;
134 template<class CloudType>
135 Foam::scalar
136 Foam::ReactingMultiphaseLookupTableInjection<CloudType>::timeEnd() const
138     return this->SOI_ + duration_;
142 template<class CloudType>
143 void Foam::ReactingMultiphaseLookupTableInjection<CloudType>::setPositionAndCell
145     const label parcelI,
146     const label nParcels,
147     const scalar time,
148     vector& position,
149     label& cellOwner
152     label injectorI = parcelI*injectorCells_.size()/nParcels;
154     position = injectors_[injectorI].x();
155     cellOwner = injectorCells_[injectorI];
159 template<class CloudType>
160 void Foam::ReactingMultiphaseLookupTableInjection<CloudType>::setProperties
162     const label parcelI,
163     const label nParcels,
164     const scalar,
165     typename CloudType::parcelType& parcel
168     label injectorI = parcelI*injectorCells_.size()/nParcels;
170     // set particle velocity
171     parcel.U() = injectors_[injectorI].U();
173     // set particle diameter
174     parcel.d() = injectors_[injectorI].d();
176     // set particle density
177     parcel.rho() = injectors_[injectorI].rho();
179     // set particle temperature
180     parcel.T() = injectors_[injectorI].T();
182     // set particle specific heat capacity
183     parcel.cp() = injectors_[injectorI].cp();
185     // set particle component mass fractions
186     parcel.Y() = injectors_[injectorI].Y();
188     // set particle gaseous component mass fractions
189     parcel.YGas() = injectors_[injectorI].YGas();
191     // set particle liquid component mass fractions
192     parcel.YLiquid() = injectors_[injectorI].YLiquid();
194     // set particle solid component mass fractions
195     parcel.YSolid() = injectors_[injectorI].YSolid();
199 template<class CloudType>
200 bool
201 Foam::ReactingMultiphaseLookupTableInjection<CloudType>::fullyDescribed() const
203     return true;
207 template<class CloudType>
208 bool Foam::ReactingMultiphaseLookupTableInjection<CloudType>::validInjection
210     const label
213     return true;
217 // ************************ vim: set sw=4 sts=4 et: ************************ //