fixed writing out entries in advective bc
[OpenFOAM-1.6-ext.git] / src / lagrangian / intermediate / submodels / Kinematic / InjectionModel / FieldActivatedInjection / FieldActivatedInjection.C
blob9bc4b29b3877e489362c51ed0d36a7f4c0319153
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright held by original author
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"
29 #include "mathematicalConstants.H"
31 // * * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * * //
33 template<class CloudType>
34 Foam::label Foam::FieldActivatedInjection<CloudType>::parcelsToInject
36     const scalar time0,
37     const scalar time1
38 ) const
40     if (sum(nParcelsInjected_) < nParcelsPerInjector_*positions_.size())
41     {
42         return positions_.size();
43     }
44     else
45     {
46         return 0;
47     }
51 template<class CloudType>
52 Foam::scalar Foam::FieldActivatedInjection<CloudType>::volumeToInject
54     const scalar time0,
55     const scalar time1
56 ) const
58     if (sum(nParcelsInjected_) < nParcelsPerInjector_*positions_.size())
59     {
60         return this->volumeTotal_/nParcelsPerInjector_;
61     }
62     else
63     {
64         return 0;
65     }
69 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
71 template<class CloudType>
72 Foam::FieldActivatedInjection<CloudType>::FieldActivatedInjection
74     const dictionary& dict,
75     CloudType& owner
78     InjectionModel<CloudType>(dict, owner, typeName),
79     factor_(readScalar(this->coeffDict().lookup("factor"))),
80     referenceField_
81     (
82         owner.db().objectRegistry::lookupObject<volScalarField>
83         (
84             this->coeffDict().lookup("referenceField")
85         )
86     ),
87     thresholdField_
88     (
89         owner.db().objectRegistry::lookupObject<volScalarField>
90         (
91             this->coeffDict().lookup("thresholdField")
92         )
93     ),
94     positionsFile_(this->coeffDict().lookup("positionsFile")),
95     positions_
96     (
97         IOobject
98         (
99             positionsFile_,
100             owner.db().time().constant(),
101             owner.mesh(),
102             IOobject::MUST_READ,
103             IOobject::NO_WRITE
104         )
105     ),
106     injectorCells_(positions_.size()),
107     nParcelsPerInjector_
108     (
109         readLabel(this->coeffDict().lookup("parcelsPerInjector"))
110     ),
111     nParcelsInjected_(positions_.size(), 0),
112     U0_(this->coeffDict().lookup("U0")),
113     diameters_(positions_.size()),
114     parcelPDF_
115     (
116         pdf::New
117         (
118             this->coeffDict().subDict("parcelPDF"),
119             owner.rndGen()
120         )
121     )
123     // Construct parcel diameters - one per injector cell
124     forAll(diameters_, i)
125     {
126         diameters_[i] = parcelPDF_->sample();
127     }
129     // Determine total volume of particles to inject
130     this->volumeTotal_ =
131         nParcelsPerInjector_*sum(pow3(diameters_))*mathematicalConstant::pi/6.0;
133     // Set/cache the injector cells
134     forAll(positions_, i)
135     {
136         this->findCellAtPosition
137         (
138             injectorCells_[i],
139             positions_[i]
140         );
141     }
145 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
147 template<class CloudType>
148 Foam::FieldActivatedInjection<CloudType>::~FieldActivatedInjection()
152 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
154 template<class CloudType>
155 bool Foam::FieldActivatedInjection<CloudType>::active() const
157     return true;
161 template<class CloudType>
162 Foam::scalar Foam::FieldActivatedInjection<CloudType>::timeEnd() const
164     return GREAT;
168 template<class CloudType>
169 void Foam::FieldActivatedInjection<CloudType>::setPositionAndCell
171     const label parcelI,
172     const label,
173     const scalar,
174     vector& position,
175     label& cellOwner
178     position = positions_[parcelI];
179     cellOwner = injectorCells_[parcelI];
183 template<class CloudType>
184 void Foam::FieldActivatedInjection<CloudType>::setProperties
186     const label parcelI,
187     const label,
188     const scalar,
189     typename CloudType::parcelType& parcel
192     // set particle velocity
193     parcel.U() = U0_;
195     // set particle diameter
196     parcel.d() = diameters_[parcelI];
200 template<class CloudType>
201 bool Foam::FieldActivatedInjection<CloudType>::fullyDescribed() const
203     return false;
207 template<class CloudType>
208 bool Foam::FieldActivatedInjection<CloudType>::validInjection
210     const label parcelI
213     const label cellI = injectorCells_[parcelI];
215     if
216     (
217         nParcelsInjected_[parcelI] < nParcelsPerInjector_
218      && factor_*referenceField_[cellI] > thresholdField_[cellI]
219     )
220     {
221         nParcelsInjected_[parcelI]++;
222         return true;
223     }
225     return false;
229 // ************************************************************************* //