Go to the documentation of this file.
57 centres[0] = 0.5*(point1_ + point2_);
60 if (radius1_ > radius2_)
89 const scalar nearestDistSqr,
94 vector v(sample - point1_);
97 scalar parallel = (v & unitDir_);
100 v -= parallel*unitDir_;
102 scalar magV =
mag(v);
103 if (magV < ROOTVSMALL)
113 point disk1Point(point1_ +
min(
max(magV, innerRadius1_), radius1_)*v);
114 vector disk1Normal(-unitDir_);
117 point disk2Point(point2_ +
min(
max(magV, innerRadius2_), radius2_)*v);
118 vector disk2Normal(unitDir_);
122 point nearCone(GREAT, GREAT, GREAT);
123 vector normalCone(1, 0, 0);
126 point iCnearCone(GREAT, GREAT, GREAT);
127 vector iCnormalCone(1, 0, 0);
129 point projPt1 = point1_+ radius1_*v;
130 point projPt2 = point2_+ radius2_*v;
132 vector p1 = (projPt1 - point1_);
133 if (
mag(p1) > ROOTVSMALL)
139 scalar magS =
mag(
b);
143 vector a(sample - projPt1);
145 if (
mag(a) <= ROOTVSMALL)
148 vector a(sample - projPt2);
150 nearCone = (a &
b)*
b+projPt2;
152 normalCone = p1 - b1;
153 normalCone /=
mag(normalCone);
158 nearCone = (a &
b)*
b+projPt1;
161 normalCone = p1 - b1;
162 normalCone /=
mag(normalCone);
165 if (innerRadius1_ > 0 || innerRadius2_ > 0)
168 point iCprojPt1 = point1_+ innerRadius1_*v;
169 point iCprojPt2 = point2_+ innerRadius2_*v;
171 vector iCp1 = (iCprojPt1 - point1_);
175 vector iCb(iCprojPt2 - iCprojPt1);
181 vector iCa(sample - iCprojPt1);
183 if (
mag(iCa) <= ROOTVSMALL)
185 vector iCa(sample - iCprojPt2);
188 iCnearCone = (iCa & iCb)*iCb+iCprojPt2;
189 vector b1 = (iCp1 & iCb)*iCb;
190 iCnormalCone = iCp1 - b1;
191 iCnormalCone /=
mag(iCnormalCone);
196 iCnearCone = (iCa & iCb)*iCb+iCprojPt1;
198 vector b1 = (iCp1 & iCb)*iCb;
199 iCnormalCone = iCp1 - b1;
200 iCnormalCone /=
mag(iCnormalCone);
210 dist[0] =
magSqr(nearCone-sample);
211 dist[1] =
magSqr(disk1Point-sample);
212 dist[2] =
magSqr(disk2Point-sample);
213 dist[3] =
magSqr(iCnearCone-sample);
225 vector v1(nearCone-point1_);
226 scalar para = (v1 & unitDir_);
229 scalar magV1 =
mag(v1);
231 if (para < 0.0 && magV1 >= radius1_)
235 nearCone = disk1Point;
237 else if (para < 0.0 && magV1 < radius1_)
240 nearCone = disk1Point;
241 normalCone = disk1Normal;
243 else if (para > magDir_ && magV1 >= radius2_)
247 nearCone = disk2Point;
249 else if (para > magDir_ && magV1 < radius2_)
252 nearCone = disk2Point;
253 normalCone = disk2Normal;
257 nearNormal = normalCone;
262 nearNormal = disk1Normal;
267 nearNormal = disk2Normal;
272 vector v1(iCnearCone-point1_);
273 scalar para = (v1 & unitDir_);
276 scalar magV1 =
mag(v1);
279 if (para < 0.0 && magV1 >= innerRadius1_)
281 iCnearCone = disk1Point;
283 else if (para < 0.0 && magV1 < innerRadius1_)
285 iCnearCone = disk1Point;
286 iCnormalCone = disk1Normal;
288 else if (para > magDir_ && magV1 >= innerRadius2_)
290 iCnearCone = disk2Point;
292 else if (para > magDir_ && magV1 < innerRadius2_)
294 iCnearCone = disk2Point;
295 iCnormalCone = disk2Normal;
299 nearNormal = iCnormalCone;
327 const scalar innerRadius1,
328 const scalar innerRadius2,
343 scalar s1 = point1Start&(cone.
unitDir_);
344 scalar s2 = point1End&(cone.
unitDir_);
346 if ((s1 < 0.0 && s2 < 0.0) || (s1 > cone.
magDir_ && s2 > cone.
magDir_))
353 scalar magV =
mag(V);
354 if (magV < ROOTVSMALL)
370 scalar tNear = VGREAT;
371 scalar tFar = VGREAT;
377 scalar
s = (V&unitDir_);
381 tPoint2 = -(point2Start&(cone.
unitDir_))/
s;
383 if (tPoint2 < tPoint1)
385 Swap(tPoint1, tPoint2);
387 if (tPoint1 > magV || tPoint2 < 0)
392 if (tPoint1 >= 0 && tPoint1 <= magV)
394 scalar r2 = radius2(cone, start+tPoint1*V);
395 vector p1 = (start+tPoint1*V-point1_);
396 vector p2 = (start+tPoint1*V-point2_);
398 scalar inC_radius_sec = innerRadius1_;
403 inC_radius_sec = innerRadius2_;
406 if (r2 <=
sqr(radius_sec) && r2 >=
sqr(inC_radius_sec))
411 if (tPoint2 >= 0 && tPoint2 <= magV)
417 scalar inC_radius_sec = innerRadius1_;
421 inC_radius_sec = innerRadius2_;
423 scalar r2 = radius2(cone, start+tPoint2*V);
424 if (r2 <=
sqr(radius_sec) && r2 >=
sqr(inC_radius_sec))
452 if (
mag(deltaRadius) <= ROOTVSMALL)
479 scalar sqrSinAlpha =
sqr(deltaRadius)/l2;
483 vector p1 = (delP-(delP&va)*va);
485 a = sqrCosAlpha*((v1-
p*va)&(v1-
p*va))-sqrSinAlpha*
p*
p;
487 2.0*sqrCosAlpha*(a1&p1)
488 -2.0*sqrSinAlpha*(v1&va)*(delP&va);
491 *((delP-(delP&va)*va)&(delP-(delP&va)*va))
492 -sqrSinAlpha*
sqr(delP&va);
495 const scalar disc =
b*
b-4.0*a*
c;
505 else if (disc < ROOTVSMALL)
508 if (
mag(a) > ROOTVSMALL)
512 if (t1 >= 0.0 && t1 <= magV && t1 >= tPoint1 && t1 <= tPoint2)
541 if (
mag(a) > ROOTVSMALL)
543 scalar sqrtDisc =
sqrt(disc);
545 t1 = (-
b - sqrtDisc)/(2.0*a);
546 t2 = (-
b + sqrtDisc)/(2.0*a);
552 if (t1 >= 0.0 && t1 <= magV && t1 >= tPoint1 && t1 <= tPoint2)
565 if (t2>=0 && t2 <= magV && t2 >= tPoint1 && t2 <= tPoint2)
590 if (tNear>=0 && tNear <= magV)
602 else if (tFar>=0 && tFar <= magV)
619 scalar smallDistSqr = SMALL*
magSqr(end-start);
625 scalar d2 =
magSqr(info[i].hitPoint()-start);
627 if (d2 > hitMagSqr+smallDistSqr)
632 for (
label j = sz; j > i; --j)
639 else if (d2 > hitMagSqr-smallDistSqr)
687 if (radius2_ >= radius1_)
712 const scalar radius1,
713 const scalar innerRadius1,
715 const scalar radius2,
716 const scalar innerRadius2
722 innerRadius1_(innerRadius1),
725 innerRadius2_(innerRadius2),
726 magDir_(
mag(point2_-point1_)),
727 unitDir_((point2_-point1_)/magDir_)
729 bounds() = calcBounds();
746 magDir_(
mag(point2_-point1_)),
747 unitDir_((point2_-point1_)/magDir_)
749 bounds() = calcBounds();
763 if (regions_.empty())
766 regions_[0] =
"region0";
783 findNearestAndNormal(
samples[i], nearestDistSqr[i], info[i],
normal);
811 if (!info[i].hit() &&
b.hit())
818 if (innerRadius1_ > 0.0 || innerRadius2_ > 0.0)
838 newEnd = info[i].hitPoint();
893 if (!info[i].hit() &&
b.hit())
898 if (innerRadius1_ > 0.0 || innerRadius2_ > 0.0)
928 if (!info[i].hit() &&
b.hit())
989 if (innerRadius1_ > 0.0 || innerRadius2_ > 0.0)
1021 insertHit(start[i], end[i], info[i], near);
1025 insertHit(start[i], end[i], info[i], far);
1057 findNearestAndNormal
1085 scalar parallel = v & unitDir_;
1086 scalar comp = parallel;
1087 scalar compInner = parallel;
1090 scalar radius_sec = radius1_+comp*(radius2_-radius1_)/magDir_;
1092 scalar radius_sec_inner =
1094 +compInner*(innerRadius2_-innerRadius1_)/magDir_;
1101 else if (parallel > magDir_)
1109 v -= parallel*unitDir_;
1110 if (
mag(v) >= radius_sec_inner &&
mag(v) <= radius_sec)
vectorField pointField
pointField is a vectorField.
static scalar radius2(const searchableCone &cone, const point &pt)
Determine radial coordinate (squared)
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
virtual void findLineAny(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Find any intersection on line from start to end.
void insertHit(const point &start, const point &end, List< pointIndexHit > &info, const pointIndexHit &hit) const
Insert a hit if it differs (by a tolerance) from the existing ones.
void setIndex(const label index)
virtual tmp< pointField > coordinates() const
Get representative set of element coordinates.
#define forAll(list, i)
Loop across all elements in list.
A class for managing temporary objects.
virtual void findNearest(const pointField &sample, const scalarField &nearestDistSqr, List< pointIndexHit > &) const
Find nearest point on cylinder.
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
virtual const wordList & regions() const
Names of regions.
Searching on (optionally hollow) cone.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
bool hit() const
Is there a hit.
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
const scalar radius2_
Outer radius at point2.
dimensioned< scalar > mag(const dimensioned< Type > &)
const vector unitDir_
Normalised vector point2-point1.
Tuple2< scalar, label > nearInfo
Private class for finding nearest.
virtual void getVolumeType(const pointField &, List< volumeType > &) const
Determine type (inside/outside/mixed) for point. unknown if.
scalarField samples(nIntervals, 0)
label findMin(const ListType &, const label start=0)
Find index of min element (and less than given element).
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
const Point & rawPoint() const
Return point with no checking.
const scalar magDir_
Length of vector point2-point1.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Pre-declare SubField and related Field type.
void findNearestAndNormal(const point &sample, const scalar nearestDistSqr, pointIndexHit &nearInfo, vector &normal) const
Find nearest point on cylinder.
const Point & hitPoint() const
Return hit point.
Base class of (analytical or triangulated) surface. Encapsulates all the search routines....
virtual tmp< pointField > points() const
Get the points that define the surface.
virtual ~searchableCone()
Destructor.
const point point1_
'Left' point
A list of keyword definitions, which are a keyword followed by any number of values (e....
Macros for easy insertion into run-time selection tables.
void setPoint(const Point &p)
virtual void rename(const word &newName)
Rename.
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().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))
boundBox calcBounds() const
Return the boundBox of the cylinder.
virtual void findLine(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Find nearest intersection on line from start to end.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
void findLineAll(const searchableCone &cone, const scalar innerRadius1, const scalar innerRadius2, const point &start, const point &end, pointIndexHit &near, pointIndexHit &far) const
Find both intersections with cone. innerRadii supplied externally.
virtual void getRegion(const List< pointIndexHit > &, labelList ®ion) const
From a set of points and indices get the region.
void setSize(const label)
Reset size of List.
searchableCone(const searchableCone &)
Disallow default bitwise copy construct.
virtual void boundingSpheres(pointField ¢res, scalarField &radiusSqr) const
Get bounding spheres (centre and radius squared), one per element.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
bool readScalar(const char *buf, doubleScalar &s)
Read whole of buf as a scalar. Return true if succesful.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
dimensionedScalar sqrt(const dimensionedScalar &ds)
A 1D vector of objects of type <T> with a fixed size <Size>.
virtual void getNormal(const List< pointIndexHit > &, vectorField &normal) const
From a set of points and indices get the normal.
void clear()
Clear the list, i.e. set size to zero.
A bounding box defined in terms of the points at its extremities.
const dimensionedScalar c
Speed of light in a vacuum.
const point point2_
'Right' point
void size(const label)
Override size to be inconsistent with allocated storage.
A 2-tuple for storing two objects of different types.
const scalar radius1_
Outer radius at point1.
defineTypeNameAndDebug(combustionModel, 0)
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
dimensioned< scalar > magSqr(const dimensioned< Type > &)
word name(const complex &)
Return a string representation of a complex.
A normal distribution model.