1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2008-2009 OpenCFD Ltd.
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"
30 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
32 template<class CloudType>
33 Foam::label Foam::FieldActivatedInjection<CloudType>::parcelsToInject
39 if (sum(nParcelsInjected_) < nParcelsPerInjector_*positions_.size())
41 return positions_.size();
50 template<class CloudType>
51 Foam::scalar Foam::FieldActivatedInjection<CloudType>::volumeToInject
57 if (sum(nParcelsInjected_) < nParcelsPerInjector_*positions_.size())
59 return this->volumeTotal_/nParcelsPerInjector_;
68 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
70 template<class CloudType>
71 Foam::FieldActivatedInjection<CloudType>::FieldActivatedInjection
73 const dictionary& dict,
77 InjectionModel<CloudType>(dict, owner, typeName),
78 factor_(readScalar(this->coeffDict().lookup("factor"))),
81 owner.db().objectRegistry::lookupObject<volScalarField>
83 this->coeffDict().lookup("referenceField")
88 owner.db().objectRegistry::lookupObject<volScalarField>
90 this->coeffDict().lookup("thresholdField")
93 positionsFile_(this->coeffDict().lookup("positionsFile")),
99 owner.db().time().constant(),
105 injectorCells_(positions_.size()),
108 readLabel(this->coeffDict().lookup("parcelsPerInjector"))
110 nParcelsInjected_(positions_.size(), 0),
111 U0_(this->coeffDict().lookup("U0")),
112 diameters_(positions_.size()),
117 this->coeffDict().subDict("parcelPDF"),
122 // Construct parcel diameters - one per injector cell
123 forAll(diameters_, i)
125 diameters_[i] = parcelPDF_->sample();
128 // Determine total volume of particles to inject
131 *sum(pow3(diameters_))
132 *mathematicalConstant::pi/6.0;
134 // Set/cache the injector cells
135 forAll(positions_, i)
137 this->findCellAtPosition
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
162 template<class CloudType>
163 Foam::scalar Foam::FieldActivatedInjection<CloudType>::timeEnd() const
169 template<class CloudType>
170 void Foam::FieldActivatedInjection<CloudType>::setPositionAndCell
179 position = positions_[parcelI];
180 cellOwner = injectorCells_[parcelI];
184 template<class CloudType>
185 void Foam::FieldActivatedInjection<CloudType>::setProperties
190 typename CloudType::parcelType& parcel
193 // set particle velocity
196 // set particle diameter
197 parcel.d() = diameters_[parcelI];
201 template<class CloudType>
202 bool Foam::FieldActivatedInjection<CloudType>::fullyDescribed() const
208 template<class CloudType>
209 bool Foam::FieldActivatedInjection<CloudType>::validInjection
214 const label cellI = injectorCells_[parcelI];
218 nParcelsInjected_[parcelI] < nParcelsPerInjector_
219 && factor_*referenceField_[cellI] > thresholdField_[cellI]
222 nParcelsInjected_[parcelI]++;
230 // ************************************************************************* //