57 centres[0] = 0.5*(point1_ + point2_);
82 const scalar nearestDistSqr
87 vector v(sample - point1_);
90 scalar parallel = (v & unitDir_);
93 v -= parallel*unitDir_;
96 if (magV < ROOTVSMALL)
110 else if (parallel >= magDir_)
124 if (magV < ROOTVSMALL)
128 scalar magE1 =
mag(e1);
131 e1 =
point(0,1,0) ^ unitDir_;
135 cylPt = sample + radius_*e1;
139 cylPt = sample + (radius_-magV)*v;
142 if (parallel < 0.5*magDir_)
145 point end1Pt = point1_ +
min(magV, radius_)*v;
159 point end2Pt = point2_ +
min(magV, radius_)*v;
182 Foam::scalar Foam::searchableCylinder::radius2(
const point& pt)
const 184 const vector x = (pt-point1_) ^ unitDir_;
191 void Foam::searchableCylinder::findLineAll
202 vector point1Start(start-point1_);
203 vector point2Start(start-point2_);
204 vector point1End(end-point1_);
207 scalar s1 = point1Start&unitDir_;
208 scalar s2 = point1End&unitDir_;
210 if ((s1 < 0 && s2 < 0) || (s1 > magDir_ && s2 > magDir_))
217 scalar magV =
mag(V);
218 if (magV < ROOTVSMALL)
234 scalar tNear = VGREAT;
235 scalar tFar = VGREAT;
238 scalar
s = (V&unitDir_);
242 tPoint2 = -(point2Start&unitDir_)/s;
243 if (tPoint2 < tPoint1)
245 Swap(tPoint1, tPoint2);
247 if (tPoint1 > magV || tPoint2 < 0)
253 if (tPoint1 >= 0 && tPoint1 <= magV)
255 if (radius2(start+tPoint1*V) <=
sqr(radius_))
260 if (tPoint2 >= 0 && tPoint2 <= magV)
262 if (radius2(start+tPoint2*V) <=
sqr(radius_))
286 const vector x = point1Start ^ unitDir_;
288 const scalar d =
sqr(radius_);
291 const scalar a = (y&
y);
292 const scalar
b = 2*(x&
y);
293 const scalar
c = (x&
x)-d;
295 const scalar disc = b*b-4*a*
c;
305 else if (disc < ROOTVSMALL)
308 if (
mag(a) > ROOTVSMALL)
316 if (t1 >= 0 && t1 <= magV && t1 >= tPoint1 && t1 <= tPoint2)
349 if (
mag(a) > ROOTVSMALL)
351 scalar sqrtDisc =
sqrt(disc);
353 t1 = (-b - sqrtDisc)/(2*a);
354 t2 = (-b + sqrtDisc)/(2*a);
360 if (t1 >= 0 && t1 <= magV && t1 >= tPoint1 && t1 <= tPoint2)
373 if (t2 >= 0 && t2 <= magV && t2 >= tPoint1 && t2 <= tPoint2)
407 if (tNear >= 0 && tNear <= magV)
420 else if (tFar >= 0 && tFar <= magV)
479 Foam::searchableCylinder::searchableCylinder
490 magDir_(
mag(point2_-point1_)),
491 unitDir_((point2_-point1_)/magDir_),
494 bounds() = calcBounds();
498 Foam::searchableCylinder::searchableCylinder
505 point1_(dict.
lookup(
"point1")),
506 point2_(dict.
lookup(
"point2")),
507 magDir_(
mag(point2_-point1_)),
508 unitDir_((point2_-point1_)/magDir_),
511 bounds() = calcBounds();
525 if (regions_.empty())
528 regions_[0] =
"region0";
534 void Foam::searchableCylinder::findNearest
545 info[i] = findNearest(samples[i], nearestDistSqr[i]);
563 findLineAll(start[i], end[i], info[i], b);
564 if (!info[i].hit() && b.
hit())
585 findLineAll(start[i], end[i], info[i], b);
586 if (!info[i].hit() && b.
hit())
594 void Foam::searchableCylinder::findLineAll
606 findLineAll(start[i], end[i], near, far);
662 vector v(info[i].hitPoint() - point1_);
665 scalar parallel = (v & unitDir_);
668 v -= parallel*unitDir_;
669 scalar magV =
mag(v);
673 if ((magV-radius_) <
mag(parallel))
676 normal[i] = -unitDir_;
683 else if (parallel <= 0.5*magDir_)
686 if (magV >= radius_ || (radius_-magV) < parallel)
693 normal[i] = -unitDir_;
696 else if (parallel <= magDir_)
699 if (magV >= radius_ || (radius_-magV) < (magDir_-parallel))
706 normal[i] = unitDir_;
711 if ((magV-radius_) < (parallel-magDir_))
714 normal[i] = unitDir_;
737 const point& pt = points[pointI];
742 scalar parallel = v & unitDir_;
749 else if (parallel > magDir_)
757 v -= parallel*unitDir_;
759 if (
mag(v) > radius_)
dimensionedScalar sqrt(const dimensionedScalar &ds)
virtual ~searchableCylinder()
Destructor.
virtual void findLine(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Find first intersection on segment from start to end.
virtual void getNormal(const List< pointIndexHit > &, vectorField &normal) const
From a set of points and indices get the normal.
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
vector point
Point is a vector.
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 ))
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Base class of (analytical or triangulated) surface. Encapsulates all the search routines. WIP.
dimensioned< scalar > mag(const dimensioned< Type > &)
dimensioned< scalar > magSqr(const dimensioned< Type > &)
const Point & rawPoint() const
Return point with no checking.
virtual tmp< pointField > points() const
Get the points that define the surface.
void size(const label)
Override size to be inconsistent with allocated storage.
bool hit() const
Is there a hit.
A list of keyword definitions, which are a keyword followed by any number of values (e...
vectorField pointField
pointField is a vectorField.
virtual void getRegion(const List< pointIndexHit > &, labelList ®ion) const
From a set of points and indices get the region.
virtual void boundingSpheres(pointField ¢res, scalarField &radiusSqr) const
Get bounding spheres (centre and radius squared), one per element.
void clear()
Clear the list, i.e. set size to zero.
void setSize(const label)
Reset size of List.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
virtual void getVolumeType(const pointField &, List< volumeType > &) const
Determine type (inside/outside/mixed) for point. unknown if.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
bool readScalar(const char *buf, doubleScalar &s)
Read whole of buf as a scalar. Return true if succesful.
Macros for easy insertion into run-time selection tables.
virtual void findLineAny(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Return any intersection on segment from start to end.
void setIndex(const label index)
virtual tmp< pointField > coordinates() const
Get representative set of element coordinates.
A bounding box defined in terms of the points at its extremities.
virtual const wordList & regions() const
Names of regions.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
void setPoint(const Point &p)
const dimensionedScalar c
Speed of light in a vacuum.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
A class for managing temporary objects.
defineTypeNameAndDebug(combustionModel, 0)