initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / lagrangian / intermediate / submodels / Kinematic / InjectionModel / FieldActivatedInjection / FieldActivatedInjection.C
blob8429ca7ca6543c88b80066ec1bfde05d61063e82
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 "FieldActivatedInjection.H"
28 #include "volFields.H"
30 // * * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * * //
32 template<class CloudType>
33 Foam::label Foam::FieldActivatedInjection<CloudType>::parcelsToInject
35     const scalar time0,
36     const scalar time1
37 ) const
39     if (sum(nParcelsInjected_) < nParcelsPerInjector_*positions_.size())
40     {
41         return positions_.size();
42     }
43     else
44     {
45         return 0;
46     }
50 template<class CloudType>
51 Foam::scalar Foam::FieldActivatedInjection<CloudType>::volumeToInject
53     const scalar time0,
54     const scalar time1
55 ) const
57     if (sum(nParcelsInjected_) < nParcelsPerInjector_*positions_.size())
58     {
59         return this->volumeTotal_/nParcelsPerInjector_;
60     }
61     else
62     {
63         return 0;
64     }
68 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
70 template<class CloudType>
71 Foam::FieldActivatedInjection<CloudType>::FieldActivatedInjection
73     const dictionary& dict,
74     CloudType& owner
77     InjectionModel<CloudType>(dict, owner, typeName),
78     factor_(readScalar(this->coeffDict().lookup("factor"))),
79     referenceField_
80     (
81         owner.db().objectRegistry::lookupObject<volScalarField>
82         (
83             this->coeffDict().lookup("referenceField")
84         )
85     ),
86     thresholdField_
87     (
88         owner.db().objectRegistry::lookupObject<volScalarField>
89         (
90             this->coeffDict().lookup("thresholdField")
91         )
92     ),
93     positionsFile_(this->coeffDict().lookup("positionsFile")),
94     positions_
95     (
96         IOobject
97         (
98             positionsFile_,
99             owner.db().time().constant(),
100             owner.mesh(),
101             IOobject::MUST_READ,
102             IOobject::NO_WRITE
103         )
104     ),
105     injectorCells_(positions_.size()),
106     nParcelsPerInjector_
107     (
108         readLabel(this->coeffDict().lookup("parcelsPerInjector"))
109     ),
110     nParcelsInjected_(positions_.size(), 0),
111     U0_(this->coeffDict().lookup("U0")),
112     diameters_(positions_.size()),
113     parcelPDF_
114     (
115         pdf::New
116         (
117             this->coeffDict().subDict("parcelPDF"),
118             owner.rndGen()
119         )
120     )
122     // Construct parcel diameters - one per injector cell
123     forAll(diameters_, i)
124     {
125         diameters_[i] = parcelPDF_->sample();
126     }
128     // Determine total volume of particles to inject
129     this->volumeTotal_ =
130          nParcelsPerInjector_
131         *sum(pow3(diameters_))
132         *mathematicalConstant::pi/6.0;
134     // Set/cache the injector cells
135     forAll(positions_, i)
136     {
137         this->findCellAtPosition
138         (
139             injectorCells_[i],
140             positions_[i]
141         );
142     }
146 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
148 template<class CloudType>
149 Foam::FieldActivatedInjection<CloudType>::~FieldActivatedInjection()
153 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
155 template<class CloudType>
156 bool Foam::FieldActivatedInjection<CloudType>::active() const
158     return true;
162 template<class CloudType>
163 Foam::scalar Foam::FieldActivatedInjection<CloudType>::timeEnd() const
165     return GREAT;
169 template<class CloudType>
170 void Foam::FieldActivatedInjection<CloudType>::setPositionAndCell
172     const label parcelI,
173     const label,
174     const scalar,
175     vector& position,
176     label& cellOwner
179     position = positions_[parcelI];
180     cellOwner = injectorCells_[parcelI];
184 template<class CloudType>
185 void Foam::FieldActivatedInjection<CloudType>::setProperties
187     const label parcelI,
188     const label,
189     const scalar,
190     typename CloudType::parcelType& parcel
193     // set particle velocity
194     parcel.U() = U0_;
196     // set particle diameter
197     parcel.d() = diameters_[parcelI];
201 template<class CloudType>
202 bool Foam::FieldActivatedInjection<CloudType>::fullyDescribed() const
204     return false;
208 template<class CloudType>
209 bool Foam::FieldActivatedInjection<CloudType>::validInjection
211     const label parcelI
214     const label cellI = injectorCells_[parcelI];
216     if
217     (
218         nParcelsInjected_[parcelI] < nParcelsPerInjector_
219      && factor_*referenceField_[cellI] > thresholdField_[cellI]
220     )
221     {
222         nParcelsInjected_[parcelI]++;
223         return true;
224     }
226     return false;
230 // ************************************************************************* //