68 centres[0] = 0.5*(point1_ + point2_);
81 auto&
pts = tpts.ref();
93 const scalar nearestDistSqr
98 vector v(sample - point1_);
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);
183 if (info.point().distSqr(sample) < nearestDistSqr)
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.hitPoint(start+tNear*V);
425 far.hitPoint(start+tFar*V);
429 else if (tFar >= 0 && tFar <= magV)
431 near.hitPoint(start+tFar*V);
487 Foam::searchableCylinder::searchableCylinder
498 magDir_(
mag(point2_-point1_)),
499 unitDir_((point2_-point1_)/magDir_),
502 bounds() = calcBounds();
506 Foam::searchableCylinder::searchableCylinder
515 magDir_(
mag(point2_-point1_)),
516 unitDir_((point2_-point1_)/magDir_),
517 radius_(
dict.
get<scalar>(
"radius"))
519 bounds() = calcBounds();
527 if (regions_.empty())
530 regions_[0] =
"region0";
536 void Foam::searchableCylinder::findNearest
540 List<pointIndexHit>& info
547 info[i] = findNearest(
samples[i], nearestDistSqr[i]);
556 List<pointIndexHit>& info
559 info.setSize(start.size());
565 findLineAll(start[i],
end[i], info[i],
b);
566 if (!info[i].hit() &&
b.hit())
578 List<pointIndexHit>& info
581 info.setSize(start.size());
587 findLineAll(start[i],
end[i], info[i],
b);
588 if (!info[i].hit() &&
b.hit())
596 void Foam::searchableCylinder::findLineAll
600 List<List<pointIndexHit>>& info
603 info.setSize(start.size());
608 findLineAll(start[i],
end[i], near, far);
642 const List<pointIndexHit>& info,
646 region.setSize(info.size());
667 const scalar parallel = (v & unitDir_);
670 v -= parallel*unitDir_;
671 scalar magV =
mag(v);
675 if ((magV-radius_) <
mag(parallel))
678 normal[i] = -unitDir_;
685 else if (parallel <= 0.5*magDir_)
688 if (magV >= radius_ || (radius_-magV) < parallel)
695 normal[i] = -unitDir_;
698 else if (parallel <= magDir_)
701 if (magV >= radius_ || (radius_-magV) < (magDir_-parallel))
708 normal[i] = unitDir_;
713 if ((magV-radius_) < (parallel-magDir_))
716 normal[i] = unitDir_;
731 List<volumeType>& volType
745 const scalar parallel = (v & unitDir_);
748 if (parallel < 0 || parallel > magDir_)
755 v -= parallel*unitDir_;
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
void size(const label n)
Older name for setAddressableSize.
virtual tmp< pointField > coordinates() const
Get representative set of element coordinates.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
A list of keyword definitions, which are a keyword followed by a number of values (eg...
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.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
scalarField samples(nIntervals, Zero)
dimensionedScalar sqrt(const dimensionedScalar &ds)
PointIndexHit< point > pointIndexHit
A PointIndexHit with a 3D point.
A bounding box defined in terms of min/max extrema points.
This class describes the interaction of an object (often a face) and a point. It carries the info of ...
Base class of (analytical or triangulated) surface. Encapsulates all the search routines. WIP.
virtual const wordList & regions() const
Names of regions.
Macros for easy insertion into run-time selection tables.
addNamedToRunTimeSelectionTable(topoSetCellSource, badQualityToCell, word, badQuality)
#define forAll(list, i)
Loop across all elements in list.
vectorField pointField
pointField is a vectorField.
void setSize(const label n)
Alias for resize()
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
virtual tmp< pointField > points() const
Get the points that define the surface.
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
A location inside the volume.
A location outside the volume.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
virtual void findLine(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Find first intersection on segment from start to end.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
defineTypeNameAndDebug(combustionModel, 0)
virtual void boundingSpheres(pointField ¢res, scalarField &radiusSqr) const
Get bounding spheres (centre and radius squared), one per element.
vector point
Point is a vector.
const dimensionedScalar c
Speed of light in a vacuum.
List< label > labelList
A List of labels.
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
A class for managing temporary objects.
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))
Defines the attributes of an object for which implicit objectRegistry management is supported...
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
virtual void getVolumeType(const pointField &points, List< volumeType > &volType) const
Determine type (inside/outside/mixed) for point.
addToRunTimeSelectionTable(functionObject, pointHistory, dictionary)
virtual void findLineAny(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Return any intersection on segment from start to end.
static constexpr const zero Zero
Global zero (0)