1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "ConeInjection.H"
27 #include "DataEntry.H"
28 #include "mathematicalConstants.H"
30 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
32 template<class CloudType>
33 Foam::label Foam::ConeInjection<CloudType>::parcelsToInject
39 if ((time0 >= 0.0) && (time0 < duration_))
41 return round((time1 - time0)*parcelsPerSecond_);
50 template<class CloudType>
51 Foam::scalar Foam::ConeInjection<CloudType>::volumeToInject
57 if ((time0 >= 0.0) && (time0 < duration_))
59 return volumeFlowRate_().integrate(time0, time1);
68 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
70 template<class CloudType>
71 Foam::ConeInjection<CloudType>::ConeInjection
73 const dictionary& dict,
77 InjectionModel<CloudType>(dict, owner, typeName),
78 duration_(readScalar(this->coeffDict().lookup("duration"))),
79 position_(this->coeffDict().lookup("position")),
81 direction_(this->coeffDict().lookup("direction")),
84 readScalar(this->coeffDict().lookup("parcelsPerSecond"))
88 DataEntry<scalar>::New
96 DataEntry<scalar>::New
104 DataEntry<scalar>::New
112 DataEntry<scalar>::New
122 this->coeffDict().subDict("parcelPDF"),
126 tanVec1_(vector::zero),
127 tanVec2_(vector::zero)
129 // Normalise direction vector
130 direction_ /= mag(direction_);
132 // Determine direction vectors tangential to direction
133 vector tangent = vector::zero;
134 scalar magTangent = 0.0;
136 while (magTangent < SMALL)
138 vector v = this->owner().rndGen().vector01();
140 tangent = v - (v & direction_)*direction_;
141 magTangent = mag(tangent);
144 tanVec1_ = tangent/magTangent;
145 tanVec2_ = direction_^tanVec1_;
147 // Set total volume to inject
148 this->volumeTotal_ = volumeFlowRate_().integrate(0.0, duration_);
150 // Set/cache the injector cell
151 this->findCellAtPosition(injectorCell_, position_);
155 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
157 template<class CloudType>
158 Foam::ConeInjection<CloudType>::~ConeInjection()
162 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
164 template<class CloudType>
165 bool Foam::ConeInjection<CloudType>::active() const
171 template<class CloudType>
172 Foam::scalar Foam::ConeInjection<CloudType>::timeEnd() const
174 return this->SOI_ + duration_;
178 template<class CloudType>
179 void Foam::ConeInjection<CloudType>::setPositionAndCell
188 position = position_;
189 cellOwner = injectorCell_;
193 template<class CloudType>
194 void Foam::ConeInjection<CloudType>::setProperties
199 typename CloudType::parcelType& parcel
202 // set particle velocity
203 const scalar deg2Rad = mathematicalConstant::pi/180.0;
205 scalar t = time - this->SOI_;
206 scalar ti = thetaInner_().value(t);
207 scalar to = thetaOuter_().value(t);
208 scalar coneAngle = this->owner().rndGen().scalar01()*(to - ti) + ti;
210 coneAngle *= deg2Rad;
211 scalar alpha = sin(coneAngle);
212 scalar dcorr = cos(coneAngle);
213 scalar beta = mathematicalConstant::twoPi*this->owner().rndGen().scalar01();
215 vector normal = alpha*(tanVec1_*cos(beta) + tanVec2_*sin(beta));
216 vector dirVec = dcorr*direction_;
218 dirVec /= mag(dirVec);
220 parcel.U() = Umag_().value(t)*dirVec;
222 // set particle diameter
223 parcel.d() = parcelPDF_().sample();
227 template<class CloudType>
228 bool Foam::ConeInjection<CloudType>::fullyDescribed() const
234 template<class CloudType>
235 bool Foam::ConeInjection<CloudType>::validInjection(const label)
241 // ************************************************************************* //