ConeInjection.C
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "ConeInjection.H"
00028 #include "DataEntry.H"
00029
00030
00031
00032 template<class CloudType>
00033 Foam::label Foam::ConeInjection<CloudType>::parcelsToInject
00034 (
00035 const scalar time0,
00036 const scalar time1
00037 ) const
00038 {
00039 if ((time0 >= 0.0) && (time0 < duration_))
00040 {
00041 return round((time1 - time0)*parcelsPerSecond_);
00042 }
00043 else
00044 {
00045 return 0;
00046 }
00047 }
00048
00049
00050 template<class CloudType>
00051 Foam::scalar Foam::ConeInjection<CloudType>::volumeToInject
00052 (
00053 const scalar time0,
00054 const scalar time1
00055 ) const
00056 {
00057 if ((time0 >= 0.0) && (time0 < duration_))
00058 {
00059 return volumeFlowRate_().integrate(time0, time1);
00060 }
00061 else
00062 {
00063 return 0.0;
00064 }
00065 }
00066
00067
00068
00069
00070 template<class CloudType>
00071 Foam::ConeInjection<CloudType>::ConeInjection
00072 (
00073 const dictionary& dict,
00074 CloudType& owner
00075 )
00076 :
00077 InjectionModel<CloudType>(dict, owner, typeName),
00078 duration_(readScalar(this->coeffDict().lookup("duration"))),
00079 position_(this->coeffDict().lookup("position")),
00080 injectorCell_(-1),
00081 direction_(this->coeffDict().lookup("direction")),
00082 parcelsPerSecond_
00083 (
00084 readScalar(this->coeffDict().lookup("parcelsPerSecond"))
00085 ),
00086 volumeFlowRate_
00087 (
00088 DataEntry<scalar>::New
00089 (
00090 "volumeFlowRate",
00091 this->coeffDict()
00092 )
00093 ),
00094 Umag_
00095 (
00096 DataEntry<scalar>::New
00097 (
00098 "Umag",
00099 this->coeffDict()
00100 )
00101 ),
00102 thetaInner_
00103 (
00104 DataEntry<scalar>::New
00105 (
00106 "thetaInner",
00107 this->coeffDict()
00108 )
00109 ),
00110 thetaOuter_
00111 (
00112 DataEntry<scalar>::New
00113 (
00114 "thetaOuter",
00115 this->coeffDict()
00116 )
00117 ),
00118 parcelPDF_
00119 (
00120 pdf::New
00121 (
00122 this->coeffDict().subDict("parcelPDF"),
00123 owner.rndGen()
00124 )
00125 ),
00126 tanVec1_(vector::zero),
00127 tanVec2_(vector::zero)
00128 {
00129
00130 direction_ /= mag(direction_);
00131
00132
00133 vector tangent = vector::zero;
00134 scalar magTangent = 0.0;
00135
00136 while (magTangent < SMALL)
00137 {
00138 vector v = this->owner().rndGen().vector01();
00139
00140 tangent = v - (v & direction_)*direction_;
00141 magTangent = mag(tangent);
00142 }
00143
00144 tanVec1_ = tangent/magTangent;
00145 tanVec2_ = direction_^tanVec1_;
00146
00147
00148 this->volumeTotal_ = volumeFlowRate_().integrate(0.0, duration_);
00149
00150
00151 this->findCellAtPosition(injectorCell_, position_);
00152 }
00153
00154
00155
00156
00157 template<class CloudType>
00158 Foam::ConeInjection<CloudType>::~ConeInjection()
00159 {}
00160
00161
00162
00163
00164 template<class CloudType>
00165 bool Foam::ConeInjection<CloudType>::active() const
00166 {
00167 return true;
00168 }
00169
00170
00171 template<class CloudType>
00172 Foam::scalar Foam::ConeInjection<CloudType>::timeEnd() const
00173 {
00174 return this->SOI_ + duration_;
00175 }
00176
00177
00178 template<class CloudType>
00179 void Foam::ConeInjection<CloudType>::setPositionAndCell
00180 (
00181 const label,
00182 const label,
00183 const scalar,
00184 vector& position,
00185 label& cellOwner
00186 )
00187 {
00188 position = position_;
00189 cellOwner = injectorCell_;
00190 }
00191
00192
00193 template<class CloudType>
00194 void Foam::ConeInjection<CloudType>::setProperties
00195 (
00196 const label parcelI,
00197 const label,
00198 const scalar time,
00199 typename CloudType::parcelType& parcel
00200 )
00201 {
00202
00203 const scalar deg2Rad = mathematicalConstant::pi/180.0;
00204
00205 scalar t = time - this->SOI_;
00206 scalar ti = thetaInner_().value(t);
00207 scalar to = thetaOuter_().value(t);
00208 scalar coneAngle = this->owner().rndGen().scalar01()*(to - ti) + ti;
00209
00210 coneAngle *= deg2Rad;
00211 scalar alpha = sin(coneAngle);
00212 scalar dcorr = cos(coneAngle);
00213 scalar beta =
00214 2.0*mathematicalConstant::pi*this->owner().rndGen().scalar01();
00215
00216 vector normal = alpha*(tanVec1_*cos(beta) + tanVec2_*sin(beta));
00217 vector dirVec = dcorr*direction_;
00218 dirVec += normal;
00219 dirVec /= mag(dirVec);
00220
00221 parcel.U() = Umag_().value(t)*dirVec;
00222
00223
00224 parcel.d() = parcelPDF_().sample();
00225 }
00226
00227
00228 template<class CloudType>
00229 bool Foam::ConeInjection<CloudType>::fullyDescribed() const
00230 {
00231 return false;
00232 }
00233
00234
00235 template<class CloudType>
00236 bool Foam::ConeInjection<CloudType>::validInjection(const label)
00237 {
00238 return true;
00239 }
00240
00241
00242
Copyright © 2000-2009 OpenCFD Ltd