1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
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
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
40 if (sum(nParcelsInjected_) < nParcelsPerInjector_*positions_.size())
42 return positions_.size();
51 template<class CloudType>
52 Foam::scalar Foam::FieldActivatedInjection<CloudType>::volumeToInject
58 if (sum(nParcelsInjected_) < nParcelsPerInjector_*positions_.size())
60 return this->volumeTotal_/nParcelsPerInjector_;
69 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
71 template<class CloudType>
72 Foam::FieldActivatedInjection<CloudType>::FieldActivatedInjection
74 const dictionary& dict,
78 InjectionModel<CloudType>(dict, owner, typeName),
79 factor_(readScalar(this->coeffDict().lookup("factor"))),
82 owner.db().objectRegistry::lookupObject<volScalarField>
84 this->coeffDict().lookup("referenceField")
89 owner.db().objectRegistry::lookupObject<volScalarField>
91 this->coeffDict().lookup("thresholdField")
94 positionsFile_(this->coeffDict().lookup("positionsFile")),
100 owner.db().time().constant(),
106 injectorCells_(positions_.size()),
109 readLabel(this->coeffDict().lookup("parcelsPerInjector"))
111 nParcelsInjected_(positions_.size(), 0),
112 U0_(this->coeffDict().lookup("U0")),
113 diameters_(positions_.size()),
118 this->coeffDict().subDict("parcelPDF"),
123 // Construct parcel diameters - one per injector cell
124 forAll(diameters_, i)
126 diameters_[i] = parcelPDF_->sample();
129 // Determine total volume of particles to inject
131 nParcelsPerInjector_*sum(pow3(diameters_))*mathematicalConstant::pi/6.0;
133 // Set/cache the injector cells
134 forAll(positions_, i)
136 this->findCellAtPosition
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
161 template<class CloudType>
162 Foam::scalar Foam::FieldActivatedInjection<CloudType>::timeEnd() const
168 template<class CloudType>
169 void Foam::FieldActivatedInjection<CloudType>::setPositionAndCell
178 position = positions_[parcelI];
179 cellOwner = injectorCells_[parcelI];
183 template<class CloudType>
184 void Foam::FieldActivatedInjection<CloudType>::setProperties
189 typename CloudType::parcelType& parcel
192 // set particle velocity
195 // set particle diameter
196 parcel.d() = diameters_[parcelI];
200 template<class CloudType>
201 bool Foam::FieldActivatedInjection<CloudType>::fullyDescribed() const
207 template<class CloudType>
208 bool Foam::FieldActivatedInjection<CloudType>::validInjection
213 const label cellI = injectorCells_[parcelI];
217 nParcelsInjected_[parcelI] < nParcelsPerInjector_
218 && factor_*referenceField_[cellI] > thresholdField_[cellI]
221 nParcelsInjected_[parcelI]++;
229 // ************************************************************************* //