48 bool Foam::polyLineSet::trackToBoundary
50 passiveParticleCloud& particleCloud,
51 passiveParticle& singleParticle,
53 DynamicList<point>& samplingPts,
54 DynamicList<label>& samplingCells,
55 DynamicList<label>& samplingFaces,
56 DynamicList<scalar>& samplingCurveDist
62 const vector offset = sampleCoords_[sampleI+1] - sampleCoords_[sampleI];
63 const scalar smallDist =
mag(
tol*offset);
65 singleParticle.track(offset, 0);
66 const point trackPt = singleParticle.position();
68 if (singleParticle.onBoundaryFace())
74 mag(trackPt - sampleCoords_[sampleI+1])
82 samplingPts.append(trackPt);
83 samplingCells.append(singleParticle.cell());
84 samplingFaces.append(singleParticle.face());
87 samplingCurveDist.append(1.0*(sampleI+1));
93 samplingPts.append(trackPt);
94 samplingCells.append(singleParticle.cell());
95 samplingFaces.append(-1);
99 mag(trackPt - sampleCoords_[sampleI])
100 /
mag(sampleCoords_[sampleI+1] - sampleCoords_[sampleI]);
101 samplingCurveDist.append(sampleI + dist);
106 if (sampleI == sampleCoords_.size() - 1)
117 void Foam::polyLineSet::calcSamples
119 DynamicList<point>& samplingPts,
120 DynamicList<label>& samplingCells,
121 DynamicList<label>& samplingFaces,
122 DynamicList<label>& samplingSegments,
123 DynamicList<scalar>& samplingCurveDist
127 if (sampleCoords_.size() < 2)
130 <<
"Incorrect sample specification. Too few points:" 133 point oldPoint = sampleCoords_[0];
134 for (label sampleI = 1; sampleI < sampleCoords_.size(); ++sampleI)
136 if (
mag(sampleCoords_[sampleI] - oldPoint) < SMALL)
139 <<
"Incorrect sample specification." 140 <<
" Point " << sampleCoords_[sampleI-1]
141 <<
" at position " << sampleI-1
142 <<
" and point " << sampleCoords_[sampleI]
143 <<
" at position " << sampleI
146 oldPoint = sampleCoords_[sampleI];
150 const bool oldMoving =
const_cast<polyMesh&
>(
mesh()).moving(
false);
151 passiveParticleCloud particleCloud(
mesh());
157 label startSegmentI = 0;
161 point lastSample(GREAT, GREAT, GREAT);
166 label trackCelli = -1;
167 label trackFacei = -1;
172 sampleCoords_[sampleI+1] - sampleCoords_[sampleI];
173 const scalar smallDist =
mag(tol*offset);
179 sampleCoords_[sampleI],
180 sampleCoords_[sampleI+1]
183 point bPoint(GREAT, GREAT, GREAT);
188 bPoint = bHits[0].hitPoint();
189 bFacei = bHits[0].index();
197 sampleCoords_[sampleI],
207 if (isSample && (
mag(lastSample - trackPt) > smallDist))
217 samplingPts.append(trackPt);
218 samplingCells.append(trackCelli);
219 samplingFaces.append(trackFacei);
224 mag(trackPt - sampleCoords_[sampleI])
225 /
mag(sampleCoords_[sampleI+1] - sampleCoords_[sampleI]);
226 samplingCurveDist.append(sampleI + dist);
228 lastSample = trackPt;
231 if (trackCelli == -1)
236 }
while ((trackCelli == -1) && (sampleI < sampleCoords_.size() - 1));
238 if (sampleI == sampleCoords_.size() - 1)
251 passiveParticle singleParticle
258 bool bReached = trackToBoundary
270 for (label i = samplingPts.size() - 1; i >= startSegmentI; --i)
272 samplingSegments.append(segmentI);
282 lastSample = singleParticle.position();
288 if (sampleI == sampleCoords_.size() - 1)
298 startSegmentI = samplingPts.size();
301 const_cast<polyMesh&
>(
mesh()).moving(oldMoving);
305 void Foam::polyLineSet::genSamples()
308 DynamicList<point> samplingPts;
309 DynamicList<label> samplingCells;
310 DynamicList<label> samplingFaces;
311 DynamicList<label> samplingSegments;
312 DynamicList<scalar> samplingCurveDist;
323 samplingPts.shrink();
324 samplingCells.shrink();
325 samplingFaces.shrink();
326 samplingSegments.shrink();
327 samplingCurveDist.shrink();
332 std::move(samplingPts),
333 std::move(samplingCells),
334 std::move(samplingFaces),
335 std::move(samplingSegments),
336 std::move(samplingCurveDist)
351 const polyMesh&
mesh,
352 const meshSearch& searchEngine,
354 const List<point>& sampleCoords
357 sampledSet(
name,
mesh, searchEngine, axis),
358 sampleCoords_(sampleCoords)
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
Various (local, not parallel) searches on polyMesh; uses (demand driven) octree to search...
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Macros for easy insertion into run-time selection tables.
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Component-wise write of a value (N times)
const dimensionedScalar e
Elementary charge.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Holds list of sampling points which is filled at construction time. Various implementations of this b...
A class for handling words, derived from Foam::string.
int debug
Static debugging option.
defineTypeNameAndDebug(combustionModel, 0)
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
vector point
Point is a vector.
messageStream Info
Information stream (stdout output on master, null elsewhere)
static const scalar tol
Tolerance when comparing points relative to difference between start and end points.
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.
List< pointIndexHit > intersections(const point &pStart, const point &pEnd) const
Find all intersections of boundary within segment pStart .. pEnd.