33 namespace searchableSurfaces
61 const scalar nearestDistSqr
66 const vector n(sample - centre_);
69 if (nearestDistSqr >=
sqr(magN - radius_))
71 if (magN < rootVSmall)
73 info.rawPoint() = centre_ +
vector(1,0,0)*radius_;
77 info.rawPoint() = centre_ +
n/magN*radius_;
88 void Foam::searchableSurfaces::sphere::findLineAll
100 scalar magSqrDir =
magSqr(dir);
102 if (magSqrDir > rootVSmall)
104 const vector toCentre(centre_-start);
105 scalar magSqrToCentre =
magSqr(toCentre);
109 scalar v = (toCentre & dir);
111 scalar disc =
sqr(radius_) - (magSqrToCentre -
sqr(v));
117 scalar nearParam = v-d;
119 if (nearParam >= 0 &&
sqr(nearParam) <= magSqrDir)
122 near.setPoint(start + nearParam*dir);
126 scalar farParam = v+d;
128 if (farParam >= 0 &&
sqr(farParam) <= magSqrDir)
131 far.setPoint(start + farParam*dir);
194 if (regions_.empty())
197 regions_[0] =
"region0";
211 centres[0] = centre_;
221 void Foam::searchableSurfaces::sphere::findNearest
232 info[i] = findNearest(
samples[i], nearestDistSqr[i]);
251 findLineAll(start[i], end[i], info[i],
b);
252 if (!info[i].hit() &&
b.hit())
274 findLineAll(start[i], end[i], info[i],
b);
275 if (!info[i].hit() &&
b.hit())
283 void Foam::searchableSurfaces::sphere::findLineAll
290 info.setSize(start.
size());
295 findLineAll(start[i], end[i], near, far);
351 normal[i] = info[i].hitPoint() - centre_;
353 normal[i] /=
mag(normal[i])+vSmall;
376 if (
magSqr(pt - centre_) <=
sqr(radius_))
#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...
InfoProxy< IOobject > info() const
Return info proxy.
void size(const label)
Override size to be inconsistent with allocated storage.
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...
bool hit() const
Is there a hit.
A bounding box defined in terms of the points at its extremities.
bool overlaps(const boundBox &) const
Overlaps/touches boundingBox?
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 with a sphere shape, which can be used with snappyHexMesh.
virtual ~sphere()
Destructor.
sphere(const IOobject &io, const point &, const scalar radius)
Construct from components.
virtual void getVolumeType(const pointField &, List< volumeType > &) const
Determine type (inside/outside/mixed) for point. unknown if.
virtual void findLine(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Find first intersection on segment from start to end.
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 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.
addToRunTimeSelectionTable(searchableSurface, box, dictionary)
defineTypeNameAndDebug(box, 0)
addBackwardCompatibleToRunTimeSelectionTable(searchableSurface, box, dictionary, searchableBox, "searchableBox")
PointIndexHit< point > pointIndexHit
const dimensionSet dimLength
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)
void sqrt(LagrangianPatchField< scalar > &f, const LagrangianPatchField< scalar > &f1)
scalarField samples(nIntervals, 0)