BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / src / lagrangian / intermediate / submodels / Kinematic / InjectionModel / KinematicLookupTableInjection / KinematicLookupTableInjection.C
blobab10a98a0958d0846a96883d2ba280df67bdf5bd
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 "KinematicLookupTableInjection.H"
27 #include "scalarIOList.H"
29 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
31 template<class CloudType>
32 Foam::KinematicLookupTableInjection<CloudType>::KinematicLookupTableInjection
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::KinematicLookupTableInjection<CloudType>::KinematicLookupTableInjection
89     const KinematicLookupTableInjection<CloudType>& im
92     InjectionModel<CloudType>(im),
93     inputFileName_(im.inputFileName_),
94     duration_(im.duration_),
95     parcelsPerSecond_(im.parcelsPerSecond_),
96     injectors_(im.injectors_),
97     injectorCells_(im.injectorCells_),
98     injectorTetFaces_(im.injectorTetFaces_),
99     injectorTetPts_(im.injectorTetPts_)
103 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
105 template<class CloudType>
106 Foam::KinematicLookupTableInjection<CloudType>::~KinematicLookupTableInjection()
110 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
112 template<class CloudType>
113 Foam::scalar Foam::KinematicLookupTableInjection<CloudType>::timeEnd() const
115     return this->SOI_ + duration_;
119 template<class CloudType>
120 Foam::label Foam::KinematicLookupTableInjection<CloudType>::parcelsToInject
122     const scalar time0,
123     const scalar time1
126     if ((time0 >= 0.0) && (time0 < duration_))
127     {
128         return floor(injectorCells_.size()*(time1 - time0)*parcelsPerSecond_);
129     }
130     else
131     {
132         return 0;
133     }
137 template<class CloudType>
138 Foam::scalar Foam::KinematicLookupTableInjection<CloudType>::volumeToInject
140     const scalar time0,
141     const scalar time1
144     scalar volume = 0.0;
145     if ((time0 >= 0.0) && (time0 < duration_))
146     {
147         forAll(injectors_, i)
148         {
149             volume += injectors_[i].mDot()/injectors_[i].rho()*(time1 - time0);
150         }
151     }
153     return volume;
157 template<class CloudType>
158 void Foam::KinematicLookupTableInjection<CloudType>::setPositionAndCell
160     const label parcelI,
161     const label nParcels,
162     const scalar time,
163     vector& position,
164     label& cellOwner,
165     label& tetFaceI,
166     label& tetPtI
169     label injectorI = parcelI*injectorCells_.size()/nParcels;
171     position = injectors_[injectorI].x();
172     cellOwner = injectorCells_[injectorI];
173     tetFaceI = injectorTetFaces_[injectorI];
174     tetPtI = injectorTetPts_[injectorI];
178 template<class CloudType>
179 void Foam::KinematicLookupTableInjection<CloudType>::setProperties
181     const label parcelI,
182     const label nParcels,
183     const scalar,
184     typename CloudType::parcelType& parcel
187     label injectorI = parcelI*injectorCells_.size()/nParcels;
189     // set particle velocity
190     parcel.U() = injectors_[injectorI].U();
192     // set particle diameter
193     parcel.d() = injectors_[injectorI].d();
195     // set particle density
196     parcel.rho() = injectors_[injectorI].rho();
200 template<class CloudType>
201 bool Foam::KinematicLookupTableInjection<CloudType>::fullyDescribed() const
203     return true;
207 template<class CloudType>
208 bool Foam::KinematicLookupTableInjection<CloudType>::validInjection
210     const label
213     return true;
217 // ************************************************************************* //