46 bool Foam::polyLineSet::trackToBoundary
48 passiveParticleCloud& particleCloud,
49 passiveParticle& singleParticle,
51 DynamicList<point>& samplingPts,
52 DynamicList<label>& samplingCells,
53 DynamicList<label>& samplingFaces,
54 DynamicList<scalar>& samplingCurveDist
57 particle::TrackingData<passiveParticleCloud> trackData(particleCloud);
60 const point& trackPt = singleParticle.position();
65 const vector offset = sampleCoords_[sampleI+1] - sampleCoords_[sampleI];
66 const scalar smallDist =
mag(tol*offset);
68 point oldPos = trackPt;
72 singleParticle.stepFraction() = 0;
73 singleParticle.track(sampleCoords_[sampleI+1], trackData);
77 !singleParticle.onBoundary()
78 && (
mag(trackPt - oldPos) < smallDist)
81 if (singleParticle.onBoundary())
87 mag(trackPt - sampleCoords_[sampleI+1])
95 samplingPts.append(trackPt);
96 samplingCells.append(singleParticle.cell());
97 samplingFaces.append(facei);
100 samplingCurveDist.append(1.0*(sampleI+1));
106 samplingPts.append(trackPt);
107 samplingCells.append(singleParticle.cell());
108 samplingFaces.append(-1);
112 mag(trackPt - sampleCoords_[sampleI])
113 /
mag(sampleCoords_[sampleI+1] - sampleCoords_[sampleI]);
114 samplingCurveDist.append(sampleI + dist);
119 if (sampleI == sampleCoords_.size() - 1)
130 void Foam::polyLineSet::calcSamples
132 DynamicList<point>& samplingPts,
133 DynamicList<label>& samplingCells,
134 DynamicList<label>& samplingFaces,
135 DynamicList<label>& samplingSegments,
136 DynamicList<scalar>& samplingCurveDist
140 if (sampleCoords_.size() < 2)
143 <<
"Incorrect sample specification. Too few points:" 146 point oldPoint = sampleCoords_[0];
147 for (
label sampleI = 1; sampleI < sampleCoords_.size(); sampleI++)
149 if (
mag(sampleCoords_[sampleI] - oldPoint) < SMALL)
152 <<
"Incorrect sample specification." 153 <<
" Point " << sampleCoords_[sampleI-1]
154 <<
" at position " << sampleI-1
155 <<
" and point " << sampleCoords_[sampleI]
156 <<
" at position " << sampleI
159 oldPoint = sampleCoords_[sampleI];
163 const bool oldMoving =
const_cast<polyMesh&
>(
mesh()).moving(
false);
164 passiveParticleCloud particleCloud(
mesh());
170 label startSegmentI = 0;
174 point lastSample(GREAT, GREAT, GREAT);
179 label trackCelli = -1;
180 label trackFacei = -1;
185 sampleCoords_[sampleI+1] - sampleCoords_[sampleI];
186 const scalar smallDist =
mag(tol*offset);
192 sampleCoords_[sampleI],
193 sampleCoords_[sampleI+1]
196 point bPoint(GREAT, GREAT, GREAT);
201 bPoint = bHits[0].hitPoint();
202 bFacei = bHits[0].index();
210 sampleCoords_[sampleI],
220 if (isSample && (
mag(lastSample - trackPt) > smallDist))
230 samplingPts.append(trackPt);
231 samplingCells.append(trackCelli);
232 samplingFaces.append(trackFacei);
237 mag(trackPt - sampleCoords_[sampleI])
238 /
mag(sampleCoords_[sampleI+1] - sampleCoords_[sampleI]);
239 samplingCurveDist.append(sampleI + dist);
241 lastSample = trackPt;
244 if (trackCelli == -1)
249 }
while ((trackCelli == -1) && (sampleI < sampleCoords_.size() - 1));
251 if (sampleI == sampleCoords_.size() - 1)
264 passiveParticle singleParticle
271 bool bReached = trackToBoundary
283 for (
label i = samplingPts.size() - 1; i >= startSegmentI; --i)
285 samplingSegments.append(segmentI);
295 lastSample = singleParticle.position();
301 if (sampleI == sampleCoords_.size() - 1)
311 startSegmentI = samplingPts.size();
314 const_cast<polyMesh&
>(
mesh()).moving(oldMoving);
318 void Foam::polyLineSet::genSamples()
321 DynamicList<point> samplingPts;
322 DynamicList<label> samplingCells;
323 DynamicList<label> samplingFaces;
324 DynamicList<label> samplingSegments;
325 DynamicList<scalar> samplingCurveDist;
336 samplingPts.shrink();
337 samplingCells.shrink();
338 samplingFaces.shrink();
339 samplingSegments.shrink();
340 samplingCurveDist.shrink();
365 sampleCoords_(sampleCoords)
385 sampleCoords_(dict.
lookup(
"points"))
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)
List< pointIndexHit > intersections(const point &pStart, const point &pEnd) const
Find all intersections of boundary within segment pStart .. pEnd.
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.
virtual ~polyLineSet()
Destructor.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Vector< scalar > vector
A scalar version of the templated Vector.
Macros for easy insertion into run-time selection tables.
static const scalar tol
Tolerance when comparing points relative to difference between.
Holds list of sampling points which is filled at construction time. Various implementations of this b...
A class for handling words, derived from string.
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
defineTypeNameAndDebug(combustionModel, 0)
vector point
Point is a vector.
dimensioned< scalar > mag(const dimensioned< Type > &)
polyLineSet(const word &name, const polyMesh &mesh, const meshSearch &searchEngine, const word &axis, const List< point > &samplePoints)
Construct from components.
Mesh consisting of general polyhedral cells.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.