80 void Foam::searchableBox::projectOntoCoordPlane
88 info.point()[dir] = planePt[dir];
91 if (planePt[dir] ==
min()[dir])
95 else if (planePt[dir] ==
max()[dir])
97 info.setIndex(dir*2+1);
102 <<
"Point on plane " << planePt
103 <<
" is not on coordinate " <<
min()[dir]
104 <<
" nor " <<
max()[dir] <<
nl 115 const scalar nearestDistSqr
131 bool outside =
false;
138 if (info.point()[dir] <
min()[dir])
140 projectOntoCoordPlane(dir,
min(), info);
143 else if (info.point()[dir] >
max()[dir])
145 projectOntoCoordPlane(dir,
max(), info);
148 else if (info.point()[dir] > bbMid[dir])
150 near[dir] =
max()[dir];
154 near[dir] =
min()[dir];
167 if (dist.x() < dist.y())
169 if (dist.x() < dist.z())
171 projNorm = vector::X;
176 if (dist.y() < dist.z())
182 projectOntoCoordPlane(projNorm, near, info);
188 if (info.point().distSqr(sample) > nearestDistSqr)
200 Foam::searchableBox::searchableBox
212 <<
"Illegal bounding box specification : " 221 Foam::searchableBox::searchableBox
224 const dictionary&
dict 227 searchableSurface(
io),
235 <<
"Illegal bounding box specification : " 248 if (regions_.empty())
251 regions_[0] =
"region0";
260 auto& ctrs = tctrs.ref();
267 ctrs[i] = fcs[i].centre(
pts);
280 centres.setSize(size());
281 radiusSqr.setSize(size());
289 const face&
f = fcs[i];
291 centres[i] =
f.centre(
pts);
292 for (
const label pointi :
f)
296 radiusSqr[i] =
Foam::max(radiusSqr[i], centres[i].distSqr(pt));
314 const scalar nearestDistSqr
317 return findNearest(centre(), sample, nearestDistSqr);
324 const scalar nearestDistSqr
327 const point bbMid(centre());
331 bool outside =
false;
338 if (info.point()[dir] <
min()[dir])
340 projectOntoCoordPlane(dir,
min(), info);
343 else if (info.point()[dir] >
max()[dir])
345 projectOntoCoordPlane(dir,
max(), info);
348 else if (info.point()[dir] > bbMid[dir])
350 near[dir] =
max()[dir];
354 near[dir] =
min()[dir];
366 SortableList<scalar> sortedDist(3);
367 sortedDist[0] = dist[0];
368 sortedDist[1] = dist[1];
369 sortedDist[2] = dist[2];
373 projectOntoCoordPlane(sortedDist.indices()[0], near, info);
375 projectOntoCoordPlane(sortedDist.indices()[1], near, info);
381 if (info.point().distSqr(sample) > nearestDistSqr)
394 treeBoundBox& tightest,
413 if (posBits(start) == 0)
415 if (posBits(
end) == 0)
423 foundInter = intersects(
end, start, info.point());
429 foundInter = intersects(start,
end, info.point());
440 if (info.point()[dir] ==
min()[dir])
442 info.setIndex(2*dir);
445 else if (info.point()[dir] ==
max()[dir])
447 info.setIndex(2*dir+1);
452 if (info.index() == -1)
455 <<
"point " << info.point()
456 <<
" on segment " << start <<
end 457 <<
" should be on face of " << *
this 472 return findLine(start,
end);
476 void Foam::searchableBox::findNearest
485 const point bbMid(centre());
489 info[i] = findNearest(bbMid,
samples[i], nearestDistSqr[i]);
498 List<pointIndexHit>& info
501 info.setSize(start.size());
505 info[i] = findLine(start[i],
end[i]);
514 List<pointIndexHit>& info
517 info.setSize(start.size());
521 info[i] = findLineAny(start[i],
end[i]);
530 List<List<pointIndexHit>>& info
533 info.setSize(start.size());
536 DynamicList<pointIndexHit> hits;
548 ROOTSMALL*dirVec + vector::uniform(ROOTVSMALL)
561 point pt = inter.hitPoint() + smallVec[pointi];
563 while (((pt-start[pointi])&dirVec[pointi]) <= magSqrDirVec[pointi])
573 || (inter.index() == hits.last().index())
580 pt = inter.hitPoint() + smallVec[pointi];
583 info[pointi].transfer(hits);
587 info[pointi].clear();
595 const List<pointIndexHit>& info,
599 region.setSize(info.size());
630 List<volumeType>& volType
virtual const wordList & regions() const
Names of regions.
static void readBoxDim(const dictionary &dict, treeBoundBox &bb)
void size(const label n)
Older name for setAddressableSize.
errorManipArg< error, int > exit(error &err, const int errNo=1)
void resize(const label len)
Adjust allocated size of list.
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.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
virtual tmp< pointField > coordinates() const
Get representative set of element coordinates.
pointIndexHit findLineAny(const point &start, const point &end) const
Find any intersection of line between start and end.
constexpr char nl
The newline '\n' character (0x0a)
virtual void boundingSpheres(pointField ¢res, scalarField &radiusSqr) const
Get bounding spheres (centre and radius squared), one per element.
virtual tmp< pointField > points() const
Get the points that define the surface.
scalarField samples(nIntervals, Zero)
PointIndexHit< point > pointIndexHit
A PointIndexHit with a 3D point.
static const FixedList< vector, 6 > faceNormals
The unit normal per face.
This class describes the interaction of an object (often a face) and a point. It carries the info of ...
::Foam::direction nComponents(const expressions::valueTypeCode) noexcept
The number of components associated with given valueTypeCode.
Base class of (analytical or triangulated) surface. Encapsulates all the search routines. WIP.
const point & min() const noexcept
Minimum describing the bounding box.
static const faceList faces
Face to point addressing, using octant corner points.
virtual const boundBox & bounds() const
Return const reference to boundBox.
Macros for easy insertion into run-time selection tables.
addNamedToRunTimeSelectionTable(topoSetCellSource, badQualityToCell, word, badQuality)
#define forAll(list, i)
Loop across all elements in list.
pointIndexHit findLine(const point &start, const point &end) const
Find nearest intersection of line between start and end.
virtual void getNormal(const List< pointIndexHit > &, vectorField &normal) const
From a set of points and indices get the normal.
bool readEntry(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX, IOobjectOption::readOption readOpt=IOobjectOption::MUST_READ) const
Find entry and assign to T val. FatalIOError if it is found and the number of tokens is incorrect...
List< face > faceList
List of faces.
const point & max() const noexcept
Maximum describing the bounding box.
vectorField pointField
pointField is a vectorField.
void setSize(const label n)
Alias for resize()
line< point, const point & > linePointRef
A line using referred points.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Reading is optional [identical to LAZY_READ].
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
virtual void findLineAll(const pointField &start, const pointField &end, List< List< pointIndexHit >> &) const
Get all intersections in order from start to end.
A location inside the volume.
treeBoundBox()=default
Default construct: an inverted bounding box.
A location outside the volume.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
errorManip< error > abort(error &err)
pointIndexHit findNearestOnEdge(const point &sample, const scalar nearestDistSqr) const
Calculate nearest point on edge.
bool ln(const fileName &src, const fileName &dst)
Create a softlink. dst should not exist. Returns true if successful.
InfoProxy< IOobject > info() const noexcept
Return info proxy, for printing information to a stream.
bool contains(const vector &dir, const point &) const
Contains point (inside or on edge) and moving in direction.
void cmptMag(FieldField< Field, Type > &cf, const FieldField< Field, Type > &f)
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry if present, and assign to T val. FatalIOError if it is found and the number of tokens i...
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
defineTypeNameAndDebug(combustionModel, 0)
vector point
Point is a vector.
virtual void getRegion(const List< pointIndexHit > &, labelList ®ion) const
From a set of points and indices get the region.
PtrList< volScalarField > & Y
bool good() const
Bounding box is non-inverted.
tmp< pointField > points() const
Vertex coordinates. In octant coding.
Standard boundBox with extra functionality for use in octree.
Field< vector > vectorField
Specialisation of Field<T> for vector.
List< label > labelList
A List of labels.
virtual void getVolumeType(const pointField &points, List< volumeType > &volType) const
Determine type (inside/outside) for points.
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
A class for managing temporary objects.
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Defines the attributes of an object for which implicit objectRegistry management is supported...
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
addToRunTimeSelectionTable(functionObject, pointHistory, dictionary)
static constexpr const zero Zero
Global zero (0)
readOption
Enumeration defining read preferences.