47void Foam::searchableSurfacesQueries::mergeHits
52 const List<pointIndexHit>& surfHits,
54 labelList& allSurfaces,
55 List<pointIndexHit>& allInfo,
56 scalarList& allDistSqr
66 surfDistSqr[i] =
magSqr(surfHits[i].hitPoint() - 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];
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];
200 hitInfo.setSize(start.
size());
202 if (surfacesToTest.
empty())
208 allSurfaces[surfacesToTest[0]].findLineAll(start, end, hitInfo);
216 labelList& pSurfaces = hitSurfaces[pointi];
224 pDistSqr[i] =
magSqr(pHits[i].hitPoint() - start[pointi]);
229 if (surfacesToTest.
size() > 1)
232 for (label testI = 1; testI < surfacesToTest.
size(); testI++)
235 allSurfaces[surfacesToTest[testI]].findLineAll
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].hitPoint();
319 if (hit1[pointi].hit())
321 nearest[pointi] = hit1[pointi].hitPoint();
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].hitPoint();
363 <<
" search-radius:" << nearestDistSqr.
size()
369 nearestSurfaces = -1;
376 forAll(surfacesToTest, testI)
378 allSurfaces[surfacesToTest[testI]].findNearest
388 if (hitInfo[pointi].hit())
390 minDistSqr[pointi] =
magSqr
392 hitInfo[pointi].hitPoint()
395 nearestInfo[pointi] = hitInfo[pointi];
396 nearestSurfaces[pointi] = testI;
421 <<
" search-radius:" << nearestDistSqr.
size()
426 if (regionIndices.
empty())
441 nearestSurfaces = -1;
448 forAll(surfacesToTest, testI)
450 allSurfaces[surfacesToTest[testI]].findNearest
454 regionIndices[testI],
461 if (hitInfo[pointi].hit())
463 minDistSqr[pointi] =
magSqr
465 hitInfo[pointi].hitPoint()
468 nearestInfo[pointi] = hitInfo[pointi];
469 nearestSurfaces[pointi] = testI;
493 <<
" search-radius:" << distSqr.
size()
501 allSurfaces[surfacesToTest[0]].findNearest(start, distSqr, info);
502 allSurfaces[surfacesToTest[0]].getNormal(info, normal);
510 near[i] = info[i].hitPoint();
521 constraint[i].applyConstraint(normal[i]);
525 if (surfacesToTest.
size() >= 2)
532 for (label iter = 0; iter < nIter; iter++)
538 s.findNearest(near, distSqr, info);
539 s.getNormal(info, normal1);
551 if (
mag(normal[i]&normal1[i]) < 1.0-1
e-6)
553 plane pl0(near[i], normal[i],
false);
554 plane pl1(info[i].hitPoint(), normal1[i],
false);
564 scalar magD =
mag(d);
576 normal[i] = normal1[i];
577 constraint[i].applyConstraint(normal1[i]);
584 near[i] = info[i].hitPoint();
585 normal[i] = normal1[i];
586 constraint[i].applyConstraint(normal1[i]);
592 surfi = surfacesToTest.
fcIndex(surfi);
629 forAll(surfacesToTest, testI)
634 forAll(nearestSurfaces, i)
636 if (nearestSurfaces[i] == testI)
645 allSurfaces[surfacesToTest[testI]].getVolumeType(surfPoints, volType);
650 label pointi = surfIndices[i];
651 scalar dist =
mag(
samples[pointi] - nearestInfo[pointi].hitPoint());
665 switch (illegalHandling)
680 <<
"getVolumeType failure,"
681 <<
" neither INSIDE or OUTSIDE."
682 <<
" point:" << surfPoints[i]
684 << allSurfaces[surfacesToTest[testI]].name()
685 <<
" volType:" << vT.
str()
704 for (
const label surfi : surfacesToTest)
706 bb.
add(allSurfaces[surfi].bounds());
Various functions to operate on Lists.
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.
void setSize(const 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 the UList is empty (ie, size() is zero)
void size(const label n)
Older name for setAddressableSize.
label fcIndex(const label i) const noexcept
Vector< Cmpt > & removeCollinear(const Vector< Cmpt > &unitVec)
A bounding box defined in terms of min/max extrema points.
static const boundBox invertedBox
A large inverted boundBox: min/max == +/- ROOTVGREAT.
void add(const boundBox &bb)
Extend to include the second box.
A reference point and direction.
const point & refPoint() const noexcept
const vector & dir() const noexcept
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....
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))
scalar distance(const vector &p1, const vector &p2)
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i)
List< scalar > scalarList
A List of scalars.
label findLower(const ListType &input, const T &val, const label start, const ComparePredicate &comp)
dimensionedScalar sqrt(const dimensionedScalar &ds)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
#define forAll(list, i)
Loop across all elements in list.
A non-counting (dummy) refCount.
scalarField samples(nIntervals, Zero)