ParticleI.H
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 "polyMesh.H"
00028
00029
00030
00031 template<class ParticleType>
00032 inline Foam::scalar Foam::Particle<ParticleType>::lambda
00033 (
00034 const vector& from,
00035 const vector& to,
00036 const label facei,
00037 const scalar stepFraction
00038 ) const
00039 {
00040 const polyMesh& mesh = cloud_.polyMesh_;
00041 bool movingMesh = mesh.moving();
00042
00043 if (movingMesh)
00044 {
00045 vector Sf = mesh.faceAreas()[facei];
00046 Sf /= mag(Sf);
00047 vector Cf = mesh.faceCentres()[facei];
00048
00049
00050 if (!cloud_.internalFace(facei))
00051 {
00052 const vector& C = mesh.cellCentres()[celli_];
00053 scalar CCf = mag((C - Cf) & Sf);
00054
00055
00056 if
00057 (
00058 CCf
00059 > static_cast<const ParticleType&>(*this).wallImpactDistance(Sf)
00060 )
00061 {
00062 Cf -= static_cast<const ParticleType&>(*this)
00063 .wallImpactDistance(Sf)*Sf;
00064 }
00065 }
00066
00067
00068
00069
00070 const vectorField& oldPoints = mesh.oldPoints();
00071
00072 vector Cf00 = mesh.faces()[facei].centre(oldPoints);
00073 vector Cf0 = Cf00 + stepFraction*(Cf - Cf00);
00074
00075 vector Sf00 = mesh.faces()[facei].normal(oldPoints);
00076
00077
00078 if (mag(Sf00) > SMALL)
00079 {
00080 Sf00 /= mag(Sf00);
00081 }
00082 else
00083 {
00084 Sf00 = Sf;
00085 }
00086
00087 scalar magSfDiff = mag(Sf - Sf00);
00088
00089
00090 if (magSfDiff > SMALL)
00091 {
00092 vector Sf0 = Sf00 + stepFraction*(Sf - Sf00);
00093
00094
00095 vector omega = Sf0 ^ Sf;
00096 scalar magOmega = mag(omega);
00097 omega /= magOmega + SMALL;
00098 vector n0 = omega ^ Sf0;
00099 scalar lam = ((Cf - Cf0) & Sf)/(n0 & Sf);
00100 vector r0 = Cf0 + lam*n0;
00101
00102
00103
00104
00105
00106
00107 vector alpha = from - r0;
00108 vector beta = to - from;
00109 scalar a = beta & (Sf - Sf0);
00110 scalar b = (alpha & (Sf - Sf0)) + (beta & Sf0);
00111 scalar c = alpha & Sf0;
00112
00113 if (mag(a) > SMALL)
00114 {
00115
00116 scalar ap = b/a;
00117 scalar bp = c/a;
00118 scalar cp = ap*ap - 4.0*bp;
00119
00120 if (cp < 0.0)
00121 {
00122
00123 return GREAT;
00124 }
00125 else
00126 {
00127 scalar l1 = -0.5*(ap - ::sqrt(cp));
00128 scalar l2 = -0.5*(ap + ::sqrt(cp));
00129
00130
00131
00132 if (mag(l1) < mag(l2))
00133 {
00134 return l1;
00135 }
00136 else
00137 {
00138 return l2;
00139 }
00140 }
00141 }
00142 else
00143 {
00144
00145 return (-c/b);
00146 }
00147 }
00148 else
00149 {
00150 vector alpha = from - Cf0;
00151 vector beta = to - from - (Cf - Cf0);
00152 scalar lambdaNominator = alpha & Sf;
00153 scalar lambdaDenominator = beta & Sf;
00154
00155
00156 if (mag(lambdaDenominator) < SMALL)
00157 {
00158 if (lambdaDenominator < 0.0)
00159 {
00160 lambdaDenominator = -SMALL;
00161 }
00162 else
00163 {
00164 lambdaDenominator = SMALL;
00165 }
00166 }
00167
00168 return (-lambdaNominator/lambdaDenominator);
00169 }
00170 }
00171 else
00172 {
00173
00174 return lambda(from, to, facei);
00175 }
00176 }
00177
00178
00179 template<class ParticleType>
00180 inline Foam::scalar Foam::Particle<ParticleType>::lambda
00181 (
00182 const vector& from,
00183 const vector& to,
00184 const label facei
00185 ) const
00186 {
00187 const polyMesh& mesh = cloud_.polyMesh_;
00188
00189 vector Sf = mesh.faceAreas()[facei];
00190 Sf /= mag(Sf);
00191 vector Cf = mesh.faceCentres()[facei];
00192
00193
00194 if (!cloud_.internalFace(facei))
00195 {
00196 const vector& C = mesh.cellCentres()[celli_];
00197 scalar CCf = mag((C - Cf) & Sf);
00198
00199
00200 if
00201 (
00202 CCf
00203 > static_cast<const ParticleType&>(*this).wallImpactDistance(Sf)
00204 )
00205 {
00206 Cf -= static_cast<const ParticleType&>(*this)
00207 .wallImpactDistance(Sf)*Sf;
00208 }
00209 }
00210
00211 scalar lambdaNominator = (Cf - from) & Sf;
00212 scalar lambdaDenominator = (to - from) & Sf;
00213
00214
00215 if (mag(lambdaDenominator) < SMALL)
00216 {
00217 if (lambdaDenominator < 0.0)
00218 {
00219 lambdaDenominator = -SMALL;
00220 }
00221 else
00222 {
00223 lambdaDenominator = SMALL;
00224 }
00225 }
00226
00227 return lambdaNominator/lambdaDenominator;
00228 }
00229
00230
00231 template<class ParticleType>
00232 inline bool Foam::Particle<ParticleType>::inCell() const
00233 {
00234 DynamicList<label>& faces = cloud_.labels_;
00235 findFaces(position_, faces);
00236
00237 return (!faces.size());
00238 }
00239
00240
00241 template<class ParticleType>
00242 inline bool Foam::Particle<ParticleType>::inCell
00243 (
00244 const vector& position,
00245 const label celli,
00246 const scalar stepFraction
00247 ) const
00248 {
00249 DynamicList<label>& faces = cloud_.labels_;
00250 findFaces(position, celli, stepFraction, faces);
00251
00252 return (!faces.size());
00253 }
00254
00255
00256
00257
00258 template<class ParticleType>
00259 inline Foam::Particle<ParticleType>::trackData::trackData
00260 (
00261 Cloud<ParticleType>& cloud
00262 )
00263 :
00264 cloud_(cloud)
00265 {}
00266
00267
00268 template<class ParticleType>
00269 inline Foam::Cloud<ParticleType>&
00270 Foam::Particle<ParticleType>::trackData::cloud()
00271 {
00272 return cloud_;
00273 }
00274
00275
00276
00277
00278 template<class ParticleType>
00279 inline const Foam::Cloud<ParticleType>&
00280 Foam::Particle<ParticleType>::cloud() const
00281 {
00282 return cloud_;
00283 }
00284
00285
00286 template<class ParticleType>
00287 inline const Foam::vector& Foam::Particle<ParticleType>::position() const
00288 {
00289 return position_;
00290 }
00291
00292
00293 template<class ParticleType>
00294 inline Foam::vector& Foam::Particle<ParticleType>::position()
00295 {
00296 return position_;
00297 }
00298
00299
00300 template<class ParticleType>
00301 inline Foam::label Foam::Particle<ParticleType>::cell() const
00302 {
00303 return celli_;
00304 }
00305
00306
00307 template<class ParticleType>
00308 inline Foam::label& Foam::Particle<ParticleType>::cell()
00309 {
00310 return celli_;
00311 }
00312
00313
00314 template<class ParticleType>
00315 inline Foam::label Foam::Particle<ParticleType>::face() const
00316 {
00317 return facei_;
00318 }
00319
00320
00321 template<class ParticleType>
00322 inline bool Foam::Particle<ParticleType>::onBoundary() const
00323 {
00324 return facei_ != -1 && facei_ >= cloud_.pMesh().nInternalFaces();
00325 }
00326
00327
00328 template<class ParticleType>
00329 inline Foam::scalar& Foam::Particle<ParticleType>::stepFraction()
00330 {
00331 return stepFraction_;
00332 }
00333
00334
00335 template<class ParticleType>
00336 inline Foam::scalar Foam::Particle<ParticleType>::stepFraction() const
00337 {
00338 return stepFraction_;
00339 }
00340
00341
00342 template<class ParticleType>
00343 inline Foam::label Foam::Particle<ParticleType>::origProc() const
00344 {
00345 return origProc_;
00346 }
00347
00348
00349 template<class ParticleType>
00350 inline Foam::label Foam::Particle<ParticleType>::origId() const
00351 {
00352 return origId_;
00353 }
00354
00355
00356 template<class ParticleType>
00357 inline bool Foam::Particle<ParticleType>::softImpact() const
00358 {
00359 return false;
00360 }
00361
00362
00363 template<class ParticleType>
00364 inline Foam::scalar Foam::Particle<ParticleType>::currentTime() const
00365 {
00366 return
00367 cloud_.pMesh().time().value()
00368 + stepFraction_*cloud_.pMesh().time().deltaT().value();
00369 }
00370
00371
00372 template<class ParticleType>
00373 inline Foam::label Foam::Particle<ParticleType>::patch(const label facei) const
00374 {
00375 return cloud_.facePatch(facei);
00376 }
00377
00378
00379 template<class ParticleType>
00380 inline Foam::label Foam::Particle<ParticleType>::patchFace
00381 (
00382 const label patchi,
00383 const label facei
00384 ) const
00385 {
00386 return cloud_.patchFace(patchi, facei);
00387 }
00388
00389
00390 template<class ParticleType>
00391 inline Foam::scalar
00392 Foam::Particle<ParticleType>::wallImpactDistance(const vector&) const
00393 {
00394 return 0.0;
00395 }
00396
00397
00398 template<class ParticleType>
00399 inline Foam::label Foam::Particle<ParticleType>::faceInterpolation() const
00400 {
00401 return facei_;
00402 }
00403
00404
00405
Copyright © 2000-2009 OpenCFD Ltd