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 "ConeInjection.H"
28 #include "DataEntry.H"
29 #include "mathematicalConstants.H"
31 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
33 template<class CloudType>
34 Foam::label Foam::ConeInjection<CloudType>::parcelsToInject
40 if ((time0 >= 0.0) && (time0 < duration_))
42 return round((time1 - time0)*parcelsPerSecond_);
51 template<class CloudType>
52 Foam::scalar Foam::ConeInjection<CloudType>::volumeToInject
58 if ((time0 >= 0.0) && (time0 < duration_))
60 return volumeFlowRate_().integrate(time0, time1);
69 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
71 template<class CloudType>
72 Foam::ConeInjection<CloudType>::ConeInjection
74 const dictionary& dict,
78 InjectionModel<CloudType>(dict, owner, typeName),
79 duration_(readScalar(this->coeffDict().lookup("duration"))),
80 position_(this->coeffDict().lookup("position")),
82 direction_(this->coeffDict().lookup("direction")),
85 readScalar(this->coeffDict().lookup("parcelsPerSecond"))
89 DataEntry<scalar>::New
97 DataEntry<scalar>::New
105 DataEntry<scalar>::New
113 DataEntry<scalar>::New
123 this->coeffDict().subDict("parcelPDF"),
127 tanVec1_(vector::zero),
128 tanVec2_(vector::zero)
130 // Normalise direction vector
131 direction_ /= mag(direction_);
133 // Determine direction vectors tangential to direction
134 vector tangent = vector::zero;
135 scalar magTangent = 0.0;
137 while (magTangent < SMALL)
139 vector v = this->owner().rndGen().vector01();
141 tangent = v - (v & direction_)*direction_;
142 magTangent = mag(tangent);
145 tanVec1_ = tangent/magTangent;
146 tanVec2_ = direction_^tanVec1_;
148 // Set total volume to inject
149 this->volumeTotal_ = volumeFlowRate_().integrate(0.0, duration_);
151 // Set/cache the injector cell
152 this->findCellAtPosition(injectorCell_, position_);
156 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
158 template<class CloudType>
159 Foam::ConeInjection<CloudType>::~ConeInjection()
163 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
165 template<class CloudType>
166 bool Foam::ConeInjection<CloudType>::active() const
172 template<class CloudType>
173 Foam::scalar Foam::ConeInjection<CloudType>::timeEnd() const
175 return this->SOI_ + duration_;
179 template<class CloudType>
180 void Foam::ConeInjection<CloudType>::setPositionAndCell
189 position = position_;
190 cellOwner = injectorCell_;
194 template<class CloudType>
195 void Foam::ConeInjection<CloudType>::setProperties
200 typename CloudType::parcelType& parcel
203 // set particle velocity
204 const scalar deg2Rad = mathematicalConstant::pi/180.0;
206 scalar t = time - this->SOI_;
207 scalar ti = thetaInner_().value(t);
208 scalar to = thetaOuter_().value(t);
209 scalar coneAngle = this->owner().rndGen().scalar01()*(to - ti) + ti;
211 coneAngle *= deg2Rad;
212 scalar alpha = sin(coneAngle);
213 scalar dcorr = cos(coneAngle);
214 scalar beta = mathematicalConstant::twoPi*this->owner().rndGen().scalar01();
216 vector normal = alpha*(tanVec1_*cos(beta) + tanVec2_*sin(beta));
217 vector dirVec = dcorr*direction_;
219 dirVec /= mag(dirVec);
221 parcel.U() = Umag_().value(t)*dirVec;
223 // set particle diameter
224 parcel.d() = parcelPDF_().sample();
228 template<class CloudType>
229 bool Foam::ConeInjection<CloudType>::fullyDescribed() const
235 template<class CloudType>
236 bool Foam::ConeInjection<CloudType>::validInjection(const label)
242 // ************************************************************************* //