34 namespace searchableSurfaces
68 <<
"Span should have two positive and one zero entry. Now:"
71 else if (span[dir] < vSmall)
89 <<
"Span should have two positive and one zero entry. Now:"
101 const scalar nearestDistSqr
114 info.rawPoint()[normalDir_] = origin_[normalDir_];
119 if (dir != normalDir_)
121 if (info.rawPoint()[dir] < origin_[dir])
123 info.rawPoint()[dir] = origin_[dir];
125 else if (info.rawPoint()[dir] > origin_[dir]+span_[dir])
127 info.rawPoint()[dir] = origin_[dir]+span_[dir];
134 if (
magSqr(info.rawPoint() - sample) > nearestDistSqr)
157 const vector dir(end-start);
159 if (
mag(dir[normalDir_]) < vSmall)
166 scalar t = (origin_[normalDir_]-start[normalDir_]) / dir[normalDir_];
175 info.rawPoint() = start+t*dir;
176 info.rawPoint()[normalDir_] = origin_[normalDir_];
181 if (dir != normalDir_)
183 if (info.rawPoint()[dir] < origin_[dir])
189 else if (info.rawPoint()[dir] > origin_[dir]+span_[dir])
203 treeBoundBox bb(origin_, origin_+span_);
204 bb.min()[normalDir_] -= 1
e-6;
205 bb.max()[normalDir_] += 1
e-6;
207 if (!bb.contains(info.hitPoint()))
210 <<
"bb:" << bb <<
endl
211 <<
"origin_:" << origin_ <<
endl
212 <<
"span_:" << span_ <<
endl
213 <<
"normalDir_:" << normalDir_ <<
endl
214 <<
"hitPoint:" << info.hitPoint()
225 Foam::searchableSurfaces::plate::plate
235 normalDir_(calcNormal(span_))
240 <<
" origin:" << origin_
241 <<
" origin+span:" << origin_+span_
250 Foam::searchableSurfaces::plate::plate
259 normalDir_(calcNormal(span_))
264 <<
" origin:" << origin_
265 <<
" origin+span:" << origin_+span_
284 if (regions_.empty())
287 regions_[0] =
"region0";
306 centres[0] = origin_ + 0.5*span_;
322 pts[2] = origin_ + span_;
324 if (span_.x() < span_.y() && span_.x() < span_.z())
326 pts[1] = origin_ +
point(0, span_.y(), 0);
327 pts[3] = origin_ +
point(0, 0, span_.z());
329 else if (span_.y() < span_.z())
331 pts[1] = origin_ +
point(span_.x(), 0, 0);
332 pts[3] = origin_ +
point(0, 0, span_.z());
336 pts[1] = origin_ +
point(span_.x(), 0, 0);
337 pts[3] = origin_ +
point(0, span_.y(), 0);
348 (origin_.x() + span_.x()) >= bb.
min().
x()
349 && origin_.x() <= bb.
max().
x()
350 && (origin_.y() + span_.y()) >= bb.
min().
y()
351 && origin_.y() <= bb.
max().
y()
352 && (origin_.z() + span_.z()) >= bb.
min().
z()
353 && origin_.z() <= bb.
max().
z()
358 void Foam::searchableSurfaces::plate::findNearest
369 info[i] = findNearest(
samples[i], nearestDistSqr[i]);
374 void Foam::searchableSurfaces::plate::findLine
385 info[i] = findLine(start[i], end[i]);
397 findLine(start, end, info);
409 findLine(start, end, nearestInfo);
411 info.setSize(start.
size());
414 if (nearestInfo[pointi].hit())
416 info[pointi].setSize(1);
417 info[pointi][0] = nearestInfo[pointi];
421 info[pointi].
clear();
448 normal[i][normalDir_] = 1.0;
460 <<
"Volume type not supported for plate."
#define forAll(list, i)
Loop across all elements in list.
Macros for easy insertion into run-time selection tables.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
void size(const label)
Override size to be inconsistent with allocated storage.
void clear()
Clear the list, i.e. set size to zero.
void setSize(const label)
Reset size of List.
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
static const char *const componentNames[]
static const direction nComponents
Number of components in this vector space.
A bounding box defined in terms of the points at its extremities.
const point & min() const
Minimum point defining the bounding box.
const point & max() const
Maximum point defining the bounding box.
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Base class of (analytical or triangulated) surface. Encapsulates all the search routines....
const boundBox & bounds() const
Return const reference to boundBox.
Surface geometry of a finite plane, aligned with the coordinate axes, which can be used with snappyHe...
virtual void getVolumeType(const pointField &, List< volumeType > &) const
Determine type (inside/outside/mixed) for point. unknown if.
virtual bool overlaps(const boundBox &bb) const
Does any part of the surface overlap the supplied bound box?
virtual void findLineAny(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Return any intersection on segment from start to end.
virtual ~plate()
Destructor.
virtual void boundingSpheres(pointField ¢res, scalarField &radiusSqr) const
Get bounding spheres (centre and radius squared), one per element.
virtual void getNormal(const List< pointIndexHit > &, vectorField &normal) const
From a set of points and indices get the normal.
virtual void getRegion(const List< pointIndexHit > &, labelList ®ion) const
From a set of points and indices get the region.
virtual const wordList & regions() const
Names of regions.
virtual tmp< pointField > coordinates() const
Get representative set of element coordinates.
virtual void findLineAll(const pointField &start, const pointField &end, List< List< pointIndexHit >> &) const
Get all intersections in order from start to end.
virtual tmp< pointField > points() const
Get the points that define the surface.
A class for managing temporary objects.
T & ref() const
Return non-const reference or generate a fatal error.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define InfoInFunction
Report an information message using Foam::Info.
addToRunTimeSelectionTable(searchableSurface, box, dictionary)
defineTypeNameAndDebug(box, 0)
addBackwardCompatibleToRunTimeSelectionTable(searchableSurface, box, dictionary, searchableBox, "searchableBox")
errorManipArg< error, int > exit(error &err, const int errNo=1)
PointIndexHit< point > pointIndexHit
Ostream & endl(Ostream &os)
Add newline and flush stream.
errorManip< error > abort(error &err)
const dimensionSet dimLength
vectorField pointField
pointField is a vectorField.
vector point
Point is a vector.
void mag(LagrangianPatchField< scalar > &f, const LagrangianPatchField< Type > &f1)
Vector< scalar > vector
A scalar version of the templated Vector.
void sqr(LagrangianPatchField< typename outerProduct< Type, Type >::type > &f, const LagrangianPatchField< Type > &f1)
void magSqr(LagrangianPatchField< scalar > &f, const LagrangianPatchField< Type > &f1)
scalarField samples(nIntervals, 0)