47void Foam::searchableSurfacesQueries::mergeHits
52 const List<pointIndexHit>& surfHits,
54 labelList& allSurfaces,
55 List<pointIndexHit>& allInfo,
56 scalarList& allDistSqr
66 surfDistSqr[i] = surfHits[i].hitPoint().distSqr(start);
71 label index =
findLower(allDistSqr, surfDistSqr[i]);
85 label next = index + 1;
87 if (next < allDistSqr.size())
97 label sz = allSurfaces.size();
98 allSurfaces.setSize(sz+1);
99 allInfo.setSize(allSurfaces.size());
100 allDistSqr.setSize(allSurfaces.size());
102 for (label j = sz-1; j > index; --j)
104 allSurfaces[j+1] = allSurfaces[j];
105 allInfo[j+1] = allInfo[j];
106 allDistSqr[j+1] = allDistSqr[j];
109 allSurfaces[index+1] = testI;
110 allInfo[index+1] = surfHits[i];
111 allDistSqr[index+1] = surfDistSqr[i];
123 const PtrList<searchableSurface>& allSurfaces,
128 List<pointIndexHit>& hitInfo
131 hitSurfaces.setSize(start.size());
133 hitInfo.setSize(start.size());
139 List<pointIndexHit> intersectInfo(start.size());
141 forAll(surfacesToTest, testI)
144 allSurfaces[surfacesToTest[testI]].findLineAny(
p0, p1, intersectInfo);
150 if (intersectInfo[i].hit())
152 hitInfo[hitMap[i]] = intersectInfo[i];
153 hitSurfaces[hitMap[i]] = testI;
159 hitMap[newI] = hitMap[i];
174 hitMap.setSize(newI);
177 intersectInfo.setSize(newI);
184 const PtrList<searchableSurface>& allSurfaces,
189 List<List<pointIndexHit>>& hitInfo
199 hitSurfaces.setSize(start.size());
200 hitInfo.setSize(start.size());
202 if (surfacesToTest.empty())
208 allSurfaces[surfacesToTest[0]].findLineAll(start, end, hitInfo);
216 labelList& pSurfaces = hitSurfaces[pointi];
217 pSurfaces.setSize(pHits.size());
221 pDistSqr.setSize(pHits.size());
224 pDistSqr[i] = pHits[i].hitPoint().distSqr(start[pointi]);
229 if (surfacesToTest.size() > 1)
232 for (label testI = 1; testI < surfacesToTest.size(); testI++)
235 allSurfaces[surfacesToTest[testI]].findLineAll
277 surface1.setSize(start.size());
279 hit1.setSize(start.size());
286 forAll(surfacesToTest, testI)
289 allSurfaces[surfacesToTest[testI]].findLine
296 forAll(nearestInfo, pointi)
298 if (nearestInfo[pointi].hit())
300 hit1[pointi] = nearestInfo[pointi];
301 surface1[pointi] = testI;
302 nearest[pointi] = hit1[pointi].point();
319 if (hit1[pointi].hit())
321 nearest[pointi] = hit1[pointi].point();
326 nearest[pointi] =
end[pointi];
330 forAll(surfacesToTest, testI)
333 allSurfaces[surfacesToTest[testI]].findLine(end, nearest, nearestInfo);
335 forAll(nearestInfo, pointi)
337 if (nearestInfo[pointi].hit())
339 hit2[pointi] = nearestInfo[pointi];
340 surface2[pointi] = testI;
341 nearest[pointi] = hit2[pointi].point();
363 <<
" search-radius:" << nearestDistSqr.size()
369 nearestSurfaces = -1;
376 forAll(surfacesToTest, testI)
378 allSurfaces[surfacesToTest[testI]].findNearest
388 if (hitInfo[pointi].hit())
391 hitInfo[pointi].point().distSqr(
samples[pointi]);
393 nearestInfo[pointi] = hitInfo[pointi];
394 nearestSurfaces[pointi] = testI;
419 <<
" search-radius:" << nearestDistSqr.size()
424 if (regionIndices.empty())
439 nearestSurfaces = -1;
446 forAll(surfacesToTest, testI)
448 allSurfaces[surfacesToTest[testI]].findNearest
452 regionIndices[testI],
459 if (hitInfo[pointi].hit())
462 hitInfo[pointi].point().distSqr(
samples[pointi]);
464 nearestInfo[pointi] = hitInfo[pointi];
465 nearestSurfaces[pointi] = testI;
486 if (start.size() != distSqr.size())
489 <<
" search-radius:" << distSqr.size()
497 allSurfaces[surfacesToTest[0]].findNearest(start, distSqr, info);
498 allSurfaces[surfacesToTest[0]].getNormal(info, normal);
506 near[i] = info[i].point();
511 constraint.
setSize(near.size());
517 constraint[i].applyConstraint(normal[i]);
521 if (surfacesToTest.size() >= 2)
528 for (label iter = 0; iter < nIter; iter++)
535 s.getNormal(info, normal1);
547 if (
mag(normal[i]&normal1[i]) < 1.0-1
e-6)
549 plane pl0(near[i], normal[i],
false);
550 plane pl1(info[i].
point(), normal1[i],
false);
556 vector d(r.refPoint()-near[i]);
557 d.removeCollinear(
n);
560 scalar magD =
mag(d);
572 normal[i] = normal1[i];
573 constraint[i].applyConstraint(normal1[i]);
580 near[i] = info[i].point();
581 normal[i] = normal1[i];
582 constraint[i].applyConstraint(normal1[i]);
588 surfi = surfacesToTest.fcIndex(surfi);
625 forAll(surfacesToTest, testI)
630 forAll(nearestSurfaces, i)
632 if (nearestSurfaces[i] == testI)
635 surfIndices.append(i);
641 allSurfaces[surfacesToTest[testI]].getVolumeType(surfPoints, volType);
646 label pointi = surfIndices[i];
647 scalar dist =
samples[pointi].dist(nearestInfo[pointi].hitPoint());
661 switch (illegalHandling)
676 <<
"getVolumeType failure,"
677 <<
" neither INSIDE or OUTSIDE."
678 <<
" point:" << surfPoints[i]
680 << allSurfaces[surfacesToTest[testI]].name()
681 <<
" volType:" << vT.str()
700 for (
const label surfi : surfacesToTest)
702 bb.add(allSurfaces[surfi].
bounds());
Various functions to operate on Lists.
Dynamically sized Field. Similar to DynamicList, but inheriting from a Field instead of a List.
void clear() noexcept
Clear the addressed list, i.e. set the size to zero.
void append(const T &val)
Append an element at the end of the list.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void clear() noexcept
Clear the addressed list, i.e. set the size to zero.
void append(const T &val)
Copy append an element to the end of this list.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void setSize(label n)
Alias for resize().
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
bool empty() const noexcept
True if List is empty (ie, size() is zero).
void size(const label n)
Older name for setAddressableSize.
Vector< Cmpt > & removeCollinear(const Vector< Cmpt > &unitVec)
Inplace removal of components that are collinear to the given unit vector.
A bounding box defined in terms of min/max extrema points.
void add(const boundBox &bb)
Extend to include the second box.
A reference point and direction.
const point & refPoint() const noexcept
Return the reference point.
const vector & dir() const noexcept
Return the direction.
Geometric class that creates a 3D plane and can return the intersection point between a line and the ...
ray planeIntersect(const plane &plane2) const
Return the cutting line between this plane and another.
Accumulates point constraints through successive applications of the applyConstraint function.
Base class of (analytical or triangulated) surface. Encapsulates all the search routines....
virtual void findNearest(const pointField &sample, const scalarField &nearestDistSqr, List< pointIndexHit > &) const =0
A collection of tools for searchableSurfaces.
static void findNearestIntersection(const PtrList< searchableSurface > &allSurfaces, const labelList &surfacesToTest, const pointField &start, const pointField &end, labelList &surface1, List< pointIndexHit > &hit1, labelList &surface2, List< pointIndexHit > &hit2)
Find intersections of edge nearest to both endpoints.
static void signedDistance(const PtrList< searchableSurface > &allSurfaces, const labelList &surfacesToTest, const pointField &samples, const scalarField &nearestDistSqr, const volumeType illegalHandling, labelList &nearestSurfaces, scalarField &distance)
Find signed distance to nearest surface. Outside is positive.
static void findAnyIntersection(const PtrList< searchableSurface > &, const labelList &surfacesToTest, const pointField &start, const pointField &end, labelList &surfaces, List< pointIndexHit > &)
Find any intersection. Return hit point information and.
static void findAllIntersections(const PtrList< searchableSurface > &, const labelList &surfacesToTest, const pointField &start, const pointField &end, labelListList &surfaces, List< List< pointIndexHit > > &surfaceHits)
Find all intersections in order from start to end. Returns for.
static void findNearest(const PtrList< searchableSurface > &, const labelList &surfacesToTest, const pointField &, const scalarField &nearestDistSqr, labelList &surfaces, List< pointIndexHit > &)
Find nearest. Return -1 (and a miss()) or surface and nearest.
static boundBox bounds(const PtrList< searchableSurface > &allSurfaces, const labelUList &surfacesToTest)
Find the boundBox of the selected surfaces.
An enumeration wrapper for classification of a location as being inside/outside of a volume.
const word & str() const
The string representation of the volume type enumeration.
@ OUTSIDE
A location outside the volume.
@ INSIDE
A location inside the volume.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
const volScalarField & p0
#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 bounding specifications. At the moment, mostly for tables.
scalar distance(const vector &p1, const vector &p2)
List< labelList > labelListList
List of labelList.
List< label > labelList
A List of labels.
label findLower(const ListType &input, const T &val, const label start, const ComparePredicate &comp)
Binary search to find the index of the last element in a sorted list that is less than value.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
dimensionedScalar sqrt(const dimensionedScalar &ds)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i), works like std::iota() but returning a...
Field< vector > vectorField
Specialisation of Field<T> for vector.
vector point
Point is a vector.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
vectorField pointField
pointField is a vectorField.
errorManipArg< error, int > exit(error &err, const int errNo=1)
UList< label > labelUList
A UList of labels.
List< scalar > scalarList
List of scalar.
#define forAll(list, i)
Loop across all elements in list.
scalarField samples(nIntervals, Zero)