ExactParticle.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 "ExactParticle.H"
00028
00029
00030
00031 template<class ParticleType>
00032 template<class TrackingData>
00033 Foam::label Foam::ExactParticle<ParticleType>::track
00034 (
00035 const vector& endPosition,
00036 TrackingData& td
00037 )
00038 {
00039 this->facei_ = -1;
00040
00041
00042 while(!this->onBoundary() && this->stepFraction_ < 1.0 - SMALL)
00043 {
00044 this->stepFraction_ +=
00045 trackToFace(endPosition, td)
00046 *(1.0 - this->stepFraction_);
00047 }
00048
00049 return this->facei_;
00050 }
00051
00052
00053 template<class ParticleType>
00054 Foam::label Foam::ExactParticle<ParticleType>::track
00055 (
00056 const vector& endPosition
00057 )
00058 {
00059 int dummyTd;
00060 return track(endPosition, dummyTd);
00061 }
00062
00063
00064 template<class ParticleType>
00065 template<class TrackingData>
00066 Foam::scalar Foam::ExactParticle<ParticleType>::trackToFace
00067 (
00068 const vector& endPosition,
00069 TrackingData& td
00070 )
00071 {
00072 const polyMesh& mesh = this->cloud().pMesh();
00073 const labelList& cFaces = mesh.cells()[this->celli_];
00074
00075 point intersection(vector::zero);
00076 scalar trackFraction = VGREAT;
00077 label hitFacei = -1;
00078
00079 const vector vec = endPosition-this->position_;
00080
00081 forAll(cFaces, i)
00082 {
00083 label facei = cFaces[i];
00084
00085 if (facei != this->face())
00086 {
00087 pointHit inter = mesh.faces()[facei].intersection
00088 (
00089 this->position_,
00090 vec,
00091 mesh.faceCentres()[facei],
00092 mesh.points(),
00093 intersection::HALF_RAY
00094 );
00095
00096 if (inter.hit() && inter.distance() < trackFraction)
00097 {
00098 trackFraction = inter.distance();
00099 hitFacei = facei;
00100 intersection = inter.hitPoint();
00101 }
00102 }
00103 }
00104
00105 if (hitFacei == -1)
00106 {
00107
00108
00109 return Particle<ParticleType>::trackToFace
00110 (
00111 endPosition,
00112 td
00113 );
00114 }
00115
00116 if (trackFraction >= (1.0-SMALL))
00117 {
00118
00119 trackFraction = 1.0;
00120 this->position_ = endPosition;
00121 this->facei_ = -1;
00122 return 1.0;
00123 }
00124 else
00125 {
00126 this->position_ = intersection;
00127 this->facei_ = hitFacei;
00128 }
00129
00130
00131
00132
00133
00134 bool internalFace = this->cloud().internalFace(this->facei_);
00135
00136
00137 if (internalFace)
00138 {
00139 if (this->celli_ == mesh.faceOwner()[this->facei_])
00140 {
00141 this->celli_ = mesh.faceNeighbour()[this->facei_];
00142 }
00143 else if (this->celli_ == mesh.faceNeighbour()[this->facei_])
00144 {
00145 this->celli_ = mesh.faceOwner()[this->facei_];
00146 }
00147 else
00148 {
00149 FatalErrorIn
00150 (
00151 "ExactParticle::trackToFace"
00152 "(const vector&, TrackingData&)"
00153 )<< "addressing failure" << nl
00154 << abort(FatalError);
00155 }
00156 }
00157 else
00158 {
00159 ParticleType& p = static_cast<ParticleType&>(*this);
00160
00161
00162 if (p.softImpact())
00163 {
00164 trackFraction = 1.0;
00165 this->position_ = endPosition;
00166 }
00167
00168 label patchi = patch(this->facei_);
00169 const polyPatch& patch = mesh.boundaryMesh()[patchi];
00170
00171 if (isA<wedgePolyPatch>(patch))
00172 {
00173 p.hitWedgePatch
00174 (
00175 static_cast<const wedgePolyPatch&>(patch), td
00176 );
00177 }
00178 else if (isA<symmetryPolyPatch>(patch))
00179 {
00180 p.hitSymmetryPatch
00181 (
00182 static_cast<const symmetryPolyPatch&>(patch), td
00183 );
00184 }
00185 else if (isA<cyclicPolyPatch>(patch))
00186 {
00187 p.hitCyclicPatch
00188 (
00189 static_cast<const cyclicPolyPatch&>(patch), td
00190 );
00191 }
00192 else if (isA<processorPolyPatch>(patch))
00193 {
00194 p.hitProcessorPatch
00195 (
00196 static_cast<const processorPolyPatch&>(patch), td
00197 );
00198 }
00199 else if (isA<wallPolyPatch>(patch))
00200 {
00201 p.hitWallPatch
00202 (
00203 static_cast<const wallPolyPatch&>(patch), td
00204 );
00205 }
00206 else if (isA<polyPatch>(patch))
00207 {
00208 p.hitPatch
00209 (
00210 static_cast<const polyPatch&>(patch), td
00211 );
00212 }
00213 else
00214 {
00215 FatalErrorIn
00216 (
00217 "ExactParticle::trackToFace"
00218 "(const vector& endPosition, scalar& trackFraction)"
00219 )<< "patch type " << patch.type() << " not suported" << nl
00220 << abort(FatalError);
00221 }
00222 }
00223
00224
00225
00226
00227
00228
00229
00230 if (trackFraction < SMALL)
00231 {
00232 this->position_ +=
00233 1.0e-6*(mesh.cellCentres()[this->celli_] - this->position_);
00234 }
00235
00236 return trackFraction;
00237 }
00238
00239
00240 template<class ParticleType>
00241 Foam::scalar Foam::ExactParticle<ParticleType>::trackToFace
00242 (
00243 const vector& endPosition
00244 )
00245 {
00246 int dummyTd;
00247 return trackToFace(endPosition, dummyTd);
00248 }
00249
00250
00251 template<class ParticleType>
00252 Foam::Ostream& Foam::operator<<
00253 (
00254 Ostream& os,
00255 const ExactParticle<ParticleType>& p
00256 )
00257 {
00258 return operator<<(os, static_cast<const Particle<ParticleType>&>(p));
00259 }
00260
00261
00262
Copyright © 2000-2009 OpenCFD Ltd