45 const scalar nearestDistSqr
50 const vector n(sample - centre_);
53 if (nearestDistSqr >=
sqr(magN - radius_))
55 if (magN < rootVSmall)
57 info.rawPoint() = centre_ +
vector(1,0,0)*radius_;
61 info.rawPoint() = centre_ +
n/magN*radius_;
72 void Foam::searchableSphere::findLineAll
84 scalar magSqrDir =
magSqr(dir);
86 if (magSqrDir > rootVSmall)
88 const vector toCentre(centre_-start);
89 scalar magSqrToCentre =
magSqr(toCentre);
93 scalar v = (toCentre & dir);
95 scalar disc =
sqr(radius_) - (magSqrToCentre -
sqr(v));
101 scalar nearParam = v-d;
103 if (nearParam >= 0 &&
sqr(nearParam) <= magSqrDir)
106 near.setPoint(start + nearParam*dir);
110 scalar farParam = v+d;
112 if (farParam >= 0 &&
sqr(farParam) <= magSqrDir)
115 far.setPoint(start + farParam*dir);
178 if (regions_.empty())
181 regions_[0] =
"region0";
195 centres[0] = centre_;
205 void Foam::searchableSphere::findNearest
216 info[i] = findNearest(
samples[i], nearestDistSqr[i]);
235 findLineAll(start[i], end[i], info[i],
b);
236 if (!info[i].hit() &&
b.hit())
258 findLineAll(start[i], end[i], info[i],
b);
259 if (!info[i].hit() &&
b.hit())
267 void Foam::searchableSphere::findLineAll
274 info.setSize(start.
size());
279 findLineAll(start[i], end[i], near, far);
335 normal[i] = info[i].hitPoint() - centre_;
337 normal[i] /=
mag(normal[i])+vSmall;
360 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 keyword definitions, which are a keyword followed by any number of values (e....
Surface geometry with a sphere shape, which can be used with snappyHexMesh.
searchableSphere(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 ~searchableSphere()
Destructor.
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.
Base class of (analytical or triangulated) surface. Encapsulates all the search routines....
const boundBox & bounds() const
Return const reference to boundBox.
addToRunTimeSelectionTable(polyPatch, mergedCyclicPolyPatch, word)
dimensionedSymmTensor sqr(const dimensionedVector &dv)
PointIndexHit< point > pointIndexHit
const dimensionSet dimLength
vector point
Point is a vector.
Vector< scalar > vector
A scalar version of the templated Vector.
dimensionedScalar sqrt(const dimensionedScalar &ds)
dimensioned< scalar > mag(const dimensioned< Type > &)
defineTypeNameAndDebug(combustionModel, 0)
dimensioned< scalar > magSqr(const dimensioned< Type > &)
scalarField samples(nIntervals, 0)