48 bool Foam::uniformSet::nextSample
50 const point& currentPt,
52 const scalar smallDist,
57 bool pointFound =
false;
59 const vector normOffset = offset/
mag(offset);
64 for (; sampleI < nPoints_; ++sampleI)
66 scalar
s = (samplePt - currentPt) & normOffset;
82 bool Foam::uniformSet::trackToBoundary
84 passiveParticleCloud& particleCloud,
85 passiveParticle& singleParticle,
88 DynamicList<point>& samplingPts,
89 DynamicList<label>& samplingCells,
90 DynamicList<label>& samplingFaces,
91 DynamicList<scalar>& samplingCurveDist
95 const vector offset = (end_ - start_)/(nPoints_ - 1);
96 const vector smallVec = tol*offset;
97 const scalar smallDist =
mag(smallVec);
99 point trackPt = singleParticle.position();
104 if (!nextSample(trackPt, offset, smallDist, samplePt, sampleI))
109 Pout<<
"trackToBoundary : Reached end : samplePt now:"
110 << samplePt <<
" sampleI now:" << sampleI <<
endl;
115 if (
mag(samplePt - trackPt) < smallDist)
120 Pout<<
"trackToBoundary : samplePt corresponds to trackPt : "
121 <<
" trackPt:" << trackPt <<
" samplePt:" << samplePt
125 samplingPts.append(trackPt);
126 samplingCells.append(singleParticle.cell());
127 samplingFaces.append(-1);
128 samplingCurveDist.append(
mag(trackPt - start_));
131 if (!nextSample(trackPt, offset, smallDist, samplePt, sampleI))
136 Pout<<
"trackToBoundary : Reached end : "
137 <<
" samplePt now:" << samplePt
138 <<
" sampleI now:" << sampleI
149 Pout<<
"Searching along trajectory from "
150 <<
" trackPt:" << trackPt
151 <<
" trackCelli:" << singleParticle.cell()
152 <<
" to:" << samplePt <<
endl;
155 singleParticle.track(samplePt - trackPt, 0);
156 trackPt = singleParticle.position();
158 if (singleParticle.onBoundaryFace())
161 if (
mag(trackPt - samplePt) < smallDist)
166 samplingPts.append(trackPt);
167 samplingCells.append(singleParticle.cell());
168 samplingFaces.append(singleParticle.face());
169 samplingCurveDist.append(
mag(trackPt - start_));
177 samplingPts.append(trackPt);
178 samplingCells.append(singleParticle.cell());
179 samplingFaces.append(-1);
180 samplingCurveDist.append(
mag(trackPt - start_));
187 void Foam::uniformSet::calcSamples
189 DynamicList<point>& samplingPts,
190 DynamicList<label>& samplingCells,
191 DynamicList<label>& samplingFaces,
192 DynamicList<label>& samplingSegments,
193 DynamicList<scalar>& samplingCurveDist
197 if ((nPoints_ < 2) || (
mag(end_ - start_) < SMALL))
200 <<
"Incorrect sample specification. Either too few points or"
201 <<
" start equals end point." <<
endl
202 <<
"nPoints:" << nPoints_
203 <<
" start:" << start_
208 const vector offset = (end_ - start_)/(nPoints_ - 1);
209 const vector normOffset = offset/
mag(offset);
210 const vector smallVec = tol*offset;
211 const scalar smallDist =
mag(smallVec);
214 const bool oldMoving =
const_cast<polyMesh&
>(
mesh()).moving(
false);
215 passiveParticleCloud particleCloud(
mesh());
224 point bPoint(GREAT, GREAT, GREAT);
229 bPoint = bHits[0].hitPoint();
230 bFacei = bHits[0].index();
236 label trackCelli = -1;
237 label trackFacei = -1;
252 if (trackCelli == -1)
258 const_cast<polyMesh&
>(
mesh()).moving(oldMoving);
265 samplingPts.append(start_);
266 samplingCells.append(trackCelli);
267 samplingFaces.append(trackFacei);
268 samplingCurveDist.append(0.0);
279 label startSegmentI = 0;
282 point samplePt = start_;
290 passiveParticle singleParticle(
mesh(), trackPt, trackCelli);
292 bool reachedBoundary = trackToBoundary
305 for (label i = samplingPts.size() - 1; i >= startSegmentI; --i)
307 samplingSegments.append(segmentI);
311 if (!reachedBoundary)
315 Pout<<
"calcSamples : Reached end of samples: "
316 <<
" samplePt now:" << samplePt
317 <<
" sampleI now:" << sampleI
324 bool foundValidB =
false;
326 while (bHitI < bHits.size())
329 (bHits[bHitI].hitPoint() - singleParticle.position())
334 Pout<<
"Finding next boundary : "
335 <<
"bPoint:" << bHits[bHitI].hitPoint()
336 <<
" tracking:" << singleParticle.position()
341 if (dist > smallDist)
361 trackPt = pushIn(bPoint, trackFacei);
362 trackCelli = getBoundaryCell(trackFacei);
366 startSegmentI = samplingPts.size();
369 const_cast<polyMesh&
>(
mesh()).moving(oldMoving);
373 void Foam::uniformSet::genSamples()
376 DynamicList<point> samplingPts;
377 DynamicList<label> samplingCells;
378 DynamicList<label> samplingFaces;
379 DynamicList<label> samplingSegments;
380 DynamicList<scalar> samplingCurveDist;
391 samplingPts.shrink();
392 samplingCells.shrink();
393 samplingFaces.shrink();
394 samplingSegments.shrink();
395 samplingCurveDist.shrink();
400 std::move(samplingPts),
401 std::move(samplingCells),
402 std::move(samplingFaces),
403 std::move(samplingSegments),
404 std::move(samplingCurveDist)
447 nPoints_(
dict.
get<label>(
"nPoints"))