46 bool Foam::uniformSet::nextSample
48 const point& currentPt,
50 const scalar smallDist,
55 bool pointFound =
false;
57 const vector normOffset = offset/
mag(offset);
62 for (; sampleI < nPoints_; sampleI++)
64 scalar
s = (samplePt - currentPt) & normOffset;
80 bool Foam::uniformSet::trackToBoundary
82 passiveParticleCloud& particleCloud,
83 passiveParticle& singleParticle,
86 DynamicList<point>& samplingPts,
87 DynamicList<label>& samplingCells,
88 DynamicList<label>& samplingFaces,
89 DynamicList<scalar>& samplingCurveDist
93 const vector offset = (end_ - start_)/(nPoints_ - 1);
94 const vector smallVec = tol*offset;
95 const scalar smallDist =
mag(smallVec);
97 point trackPt = singleParticle.position();
99 particle::TrackingData<passiveParticleCloud> trackData(particleCloud);
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);
264 samplingPts.append(start_);
265 samplingCells.append(trackCelli);
266 samplingFaces.append(trackFacei);
267 samplingCurveDist.append(0.0);
278 label startSegmentI = 0;
281 point samplePt = start_;
289 passiveParticle singleParticle(
mesh(), trackPt, trackCelli);
291 bool reachedBoundary = trackToBoundary
304 for (
label i = samplingPts.size() - 1; i >= startSegmentI; --i)
306 samplingSegments.append(segmentI);
310 if (!reachedBoundary)
314 Pout<<
"calcSamples : Reached end of samples: " 315 <<
" samplePt now:" << samplePt
316 <<
" sampleI now:" << sampleI
323 bool foundValidB =
false;
325 while (bHitI < bHits.size())
328 (bHits[bHitI].hitPoint() - singleParticle.position())
333 Pout<<
"Finding next boundary : " 334 <<
"bPoint:" << bHits[bHitI].hitPoint()
335 <<
" tracking:" << singleParticle.position()
340 if (dist > smallDist)
360 trackPt = pushIn(bPoint, trackFacei);
361 trackCelli = getBoundaryCell(trackFacei);
365 startSegmentI = samplingPts.size();
368 const_cast<polyMesh&
>(
mesh()).moving(oldMoving);
372 void Foam::uniformSet::genSamples()
375 DynamicList<point> samplingPts;
376 DynamicList<label> samplingCells;
377 DynamicList<label> samplingFaces;
378 DynamicList<label> samplingSegments;
379 DynamicList<scalar> samplingCurveDist;
390 samplingPts.shrink();
391 samplingCells.shrink();
392 samplingFaces.shrink();
393 samplingSegments.shrink();
394 samplingCurveDist.shrink();
443 start_(dict.
lookup(
"start")),
Various (local, not parallel) searches on polyMesh; uses (demand driven) octree to search...
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
errorManipArg< error, int > exit(error &err, const int errNo=1)
const double e
Elementary charge.
A list of keyword definitions, which are a keyword followed by any number of values (e...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Vector< scalar > vector
A scalar version of the templated Vector.
Macros for easy insertion into run-time selection tables.
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Holds list of sampling points which is filled at construction time. Various implementations of this b...
A class for handling words, derived from string.
label readLabel(Istream &is)
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
defineTypeNameAndDebug(combustionModel, 0)
vector point
Point is a vector.
prefixOSstream Pout(cout, "Pout")
dimensioned< scalar > mag(const dimensioned< Type > &)
Mesh consisting of general polyhedral cells.
List< pointIndexHit > intersections(const point &pStart, const point &pEnd) const
Find all intersections of boundary within segment pStart .. pEnd.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.