Go to the documentation of this file.
68 centres[0] = 0.5*(point1_ + point2_);
81 auto& pts = tpts.ref();
93 const scalar nearestDistSqr
101 scalar parallel = (v & unitDir_);
104 v -= parallel*unitDir_;
105 scalar magV =
mag(v);
107 if (magV < ROOTVSMALL)
119 info.setPoint(point1_ +
min(magV, radius_)*v);
121 else if (parallel >= magDir_)
124 info.setPoint(point2_ +
min(magV, radius_)*v);
135 if (magV < ROOTVSMALL)
139 scalar magE1 =
mag(e1);
142 e1 =
point(0,1,0) ^ unitDir_;
146 cylPt =
sample + radius_*e1;
150 cylPt =
sample + (radius_-magV)*v;
153 if (parallel < 0.5*magDir_)
156 point end1Pt = point1_ +
min(magV, radius_)*v;
160 info.setPoint(cylPt);
164 info.setPoint(end1Pt);
170 point end2Pt = point2_ +
min(magV, radius_)*v;
174 info.setPoint(cylPt);
178 info.setPoint(end2Pt);
193 Foam::scalar Foam::searchableCylinder::radius2(
const point& pt)
const
195 const vector x = (pt-point1_) ^ unitDir_;
202 void Foam::searchableCylinder::findLineAll
213 vector point1Start(start-point1_);
214 vector point2Start(start-point2_);
218 scalar s1 = point1Start&unitDir_;
219 scalar s2 = point1End&unitDir_;
221 if ((s1 < 0 && s2 < 0) || (s1 > magDir_ && s2 > magDir_))
228 scalar magV =
mag(V);
229 if (magV < ROOTVSMALL)
245 scalar tNear = VGREAT;
246 scalar tFar = VGREAT;
249 scalar
s = (V&unitDir_);
253 tPoint2 = -(point2Start&unitDir_)/
s;
254 if (tPoint2 < tPoint1)
256 std::swap(tPoint1, tPoint2);
258 if (tPoint1 > magV || tPoint2 < 0)
264 if (tPoint1 >= 0 && tPoint1 <= magV)
266 if (radius2(start+tPoint1*V) <=
sqr(radius_))
271 if (tPoint2 >= 0 && tPoint2 <= magV)
273 if (radius2(start+tPoint2*V) <=
sqr(radius_))
297 const vector x = point1Start ^ unitDir_;
299 const scalar d =
sqr(radius_);
302 const scalar a = (
y&
y);
303 const scalar
b = 2*(
x&
y);
304 const scalar
c = (
x&
x)-d;
306 const scalar disc =
b*
b-4*a*
c;
316 else if (disc < ROOTVSMALL)
319 if (
mag(a) > ROOTVSMALL)
327 if (t1 >= 0 && t1 <= magV && t1 >= tPoint1 && t1 <= tPoint2)
360 if (
mag(a) > ROOTVSMALL)
362 scalar sqrtDisc =
sqrt(disc);
364 t1 = (-
b - sqrtDisc)/(2*a);
365 t2 = (-
b + sqrtDisc)/(2*a);
371 if (t1 >= 0 && t1 <= magV && t1 >= tPoint1 && t1 <= tPoint2)
384 if (t2 >= 0 && t2 <= magV && t2 >= tPoint1 && t2 <= tPoint2)
418 if (tNear >= 0 && tNear <= magV)
420 near.setPoint(start+tNear*V);
426 far.setPoint(start+tFar*V);
431 else if (tFar >= 0 && tFar <= magV)
433 near.setPoint(start+tFar*V);
484 return boundBox(
min,
max);
490 Foam::searchableCylinder::searchableCylinder
501 magDir_(
mag(point2_-point1_)),
502 unitDir_((point2_-point1_)/magDir_),
505 bounds() = calcBounds();
509 Foam::searchableCylinder::searchableCylinder
518 magDir_(
mag(point2_-point1_)),
519 unitDir_((point2_-point1_)/magDir_),
520 radius_(
dict.
get<scalar>(
"radius"))
522 bounds() = calcBounds();
530 if (regions_.empty())
533 regions_[0] =
"region0";
539 void Foam::searchableCylinder::findNearest
550 info[i] = findNearest(
samples[i], nearestDistSqr[i]);
568 findLineAll(start[i],
end[i], info[i],
b);
569 if (!info[i].hit() &&
b.hit())
590 findLineAll(start[i],
end[i], info[i],
b);
591 if (!info[i].hit() &&
b.hit())
599 void Foam::searchableCylinder::findLineAll
611 findLineAll(start[i],
end[i], near, far);
660 normal.setSize(info.size());
667 vector v(info[i].hitPoint() - point1_);
670 const scalar parallel = (v & unitDir_);
673 v -= parallel*unitDir_;
674 scalar magV =
mag(v);
678 if ((magV-radius_) <
mag(parallel))
681 normal[i] = -unitDir_;
688 else if (parallel <= 0.5*magDir_)
691 if (magV >= radius_ || (radius_-magV) < parallel)
698 normal[i] = -unitDir_;
701 else if (parallel <= magDir_)
704 if (magV >= radius_ || (radius_-magV) < (magDir_-parallel))
711 normal[i] = unitDir_;
716 if ((magV-radius_) < (parallel-magDir_))
719 normal[i] = unitDir_;
748 const scalar parallel = (v & unitDir_);
751 if (parallel < 0 || parallel > magDir_)
758 v -= parallel*unitDir_;
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
virtual void boundingSpheres(pointField ¢res, scalarField &radiusSqr) const
Get bounding spheres (centre and radius squared), one per element.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
virtual const wordList & regions() const
Names of regions.
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.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))
A class for managing temporary objects.
static constexpr const zero Zero
Global zero (0)
virtual void findLine(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Find first intersection on segment from start to end.
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
virtual tmp< pointField > coordinates() const
Get representative set of element coordinates.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
#define forAll(list, i)
Loop across all elements in list.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
virtual void getRegion(const List< pointIndexHit > &, labelList ®ion) const
From a set of points and indices get the region.
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
bool hit() const noexcept
Is there a hit?
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
void setSize(const label n)
Alias for resize()
Base class of (analytical or triangulated) surface. Encapsulates all the search routines....
addNamedToRunTimeSelectionTable(topoSetCellSource, badQualityToCell, word, badQuality)
scalarField samples(nIntervals, Zero)
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Macros for easy insertion into run-time selection tables.
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
Vector< scalar > vector
A scalar version of the templated Vector.
virtual tmp< pointField > points() const
Get the points that define the surface.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
PointIndexHit< point > pointIndexHit
A PointIndexHit for 3D points.
dimensionedScalar sqrt(const dimensionedScalar &ds)
virtual void findLineAny(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Return any intersection on segment from start to end.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
void clear()
Clear the list, i.e. set size to zero.
static tmp< T > New(Args &&... args)
Construct tmp of T with forwarding arguments.
A location inside the volume.
A bounding box defined in terms of min/max extrema points.
const dimensionedScalar c
Speed of light in a vacuum.
vector point
Point is a vector.
defineTypeNameAndDebug(combustionModel, 0)
virtual void getNormal(const List< pointIndexHit > &, vectorField &normal) const
From a set of points and indices get the normal.
A location outside the volume.
virtual void getVolumeType(const pointField &points, List< volumeType > &volType) const
Determine type (inside/outside/mixed) for point.
Minimal example by using system/controlDict.functions: