47bool Foam::uniformSet::nextSample
49 const point& currentPt,
51 const scalar smallDist,
56 bool pointFound =
false;
58 const vector normOffset(offset/
mag(offset));
63 for (; sampleI < nPoints_; ++sampleI)
65 const scalar
s = (samplePt - currentPt) & normOffset;
81bool Foam::uniformSet::trackToBoundary
94 const vector offset((end_ - start_)/(nPoints_ - 1));
95 const scalar smallDist =
mag(tol_*offset);
97 point trackPt = singleParticle.position();
102 if (!nextSample(trackPt, offset, smallDist, samplePt, sampleI))
107 Pout<<
"trackToBoundary : Reached end : samplePt now:"
108 << samplePt <<
" sampleI now:" << sampleI <<
endl;
113 if (
mag(samplePt - trackPt) < smallDist)
118 Pout<<
"trackToBoundary : samplePt corresponds to trackPt : "
119 <<
" trackPt:" << trackPt <<
" samplePt:" << samplePt
123 samplingPts.append(trackPt);
124 samplingCells.append(singleParticle.cell());
125 samplingFaces.append(-1);
126 samplingCurveDist.append(
mag(trackPt - start_));
129 if (!nextSample(trackPt, offset, smallDist, samplePt, sampleI))
134 Pout<<
"trackToBoundary : Reached end : "
135 <<
" samplePt now:" << samplePt
136 <<
" sampleI now:" << sampleI
147 Pout<<
"Searching along trajectory from "
148 <<
" trackPt:" << trackPt
149 <<
" trackCelli:" << singleParticle.cell()
150 <<
" to:" << samplePt <<
endl;
153 singleParticle.track(samplePt - trackPt, 0);
154 trackPt = singleParticle.position();
156 if (singleParticle.onBoundaryFace())
159 if (
mag(trackPt - samplePt) < smallDist)
164 samplingPts.append(trackPt);
165 samplingCells.append(singleParticle.cell());
166 samplingFaces.append(singleParticle.face());
167 samplingCurveDist.append(
mag(trackPt - start_));
175 samplingPts.append(trackPt);
176 samplingCells.append(singleParticle.cell());
177 samplingFaces.append(-1);
178 samplingCurveDist.append(
mag(trackPt - start_));
185void Foam::uniformSet::calcSamples
195 if ((nPoints_ < 2) || (
mag(end_ - start_) < SMALL))
198 <<
"Incorrect sample specification. Either too few points or"
199 <<
" start equals end point." <<
endl
200 <<
"nPoints:" << nPoints_
201 <<
" start:" << start_
206 const vector offset((end_ - start_)/(nPoints_ - 1));
207 const vector normOffset(offset/
mag(offset));
208 const vector smallVec(tol_*offset);
209 const scalar smallDist =
mag(smallVec);
212 const bool oldMoving =
const_cast<polyMesh&
>(
mesh()).moving(
false);
222 point bPoint(GREAT, GREAT, GREAT);
227 bPoint = bHits[0].hitPoint();
228 bFacei = bHits[0].index();
234 label trackCelli = -1;
235 label trackFacei = -1;
237 const bool isSample =
250 if (trackCelli == -1)
263 samplingPts.append(start_);
264 samplingCells.append(trackCelli);
265 samplingFaces.append(trackFacei);
266 samplingCurveDist.append(0.0);
277 label startSegmentI = 0;
280 point samplePt = start_;
290 bool reachedBoundary = trackToBoundary
303 for (label i = samplingPts.size() - 1; i >= startSegmentI; --i)
305 samplingSegments.append(segmentI);
309 if (!reachedBoundary)
313 Pout<<
"calcSamples : Reached end of samples: "
314 <<
" samplePt now:" << samplePt
315 <<
" sampleI now:" << sampleI
322 bool foundValidB =
false;
324 while (bHitI < bHits.size())
327 (bHits[bHitI].hitPoint() - singleParticle.position())
332 Pout<<
"Finding next boundary : "
333 <<
"bPoint:" << bHits[bHitI].point()
334 <<
" tracking:" << singleParticle.position()
339 if (dist > smallDist)
342 bPoint = bHits[bHitI].hitPoint();
343 bFacei = bHits[bHitI].index();
361 trackPt = pushIn(bPoint, trackFacei);
362 trackCelli = getBoundaryCell(trackFacei);
366 startSegmentI = samplingPts.size();
373void Foam::uniformSet::genSamples()
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)
419 const polyMesh&
mesh,
420 const meshSearch& searchEngine,
427 sampledSet(
name,
mesh, searchEngine, axis),
449 nPoints_(
dict.get<label>(
"nPoints"))
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
bool get(const label i) const
label nPoints() const noexcept
Return the number of points.
const word & axis() const
The sort axis name.
const word & name() const noexcept
The coord-set name.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Various (local, not parallel) searches on polyMesh; uses (demand driven) octree to search.
A Cloud of passive particles.
Mesh consisting of general polyhedral cells.
Holds list of sampling points which is filled at construction time. Various implementations of this b...
const meshSearch & searchEngine() const noexcept
sampledSet(const word &name, const polyMesh &mesh, const meshSearch &searchEngine, const coordSet::coordFormat axisType)
Construct from components.
const polyMesh & mesh() const noexcept
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.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))
Namespace for handling debugging switches.
MinMax< scalar > scalarMinMax
A scalar min/max range.
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
vector point
Point is a vector.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
errorManipArg< error, int > exit(error &err, const int errNo=1)