Go to the documentation of this file.
119 const vector tol = SMALL * (rootBox.
max() - rootBox.
min());
122 cubeBox(rootBox, min_, max_);
126 vrt[0] =
point(min_.x(), min_.y(), min_.z());
127 vrt[1] =
point(max_.x(), min_.y(), min_.z());
128 vrt[2] =
point(min_.x(), max_.y(), min_.z());
129 vrt[3] =
point(max_.x(), max_.y(), min_.z());
130 vrt[4] =
point(min_.x(), min_.y(), max_.z());
131 vrt[5] =
point(max_.x(), min_.y(), max_.z());
132 vrt[6] =
point(min_.x(), max_.y(), max_.z());
133 vrt[7] =
point(max_.x(), max_.y(), max_.z());
143 this->vertices(rootBox, vertices);
145 for(
label i=0;i<12;++i)
147 e[i][0] = vertices[edgeNodes_[i][0]];
148 e[i][1] = vertices[edgeNodes_[i][1]];
162 const vector tol = SMALL * (rootBox.
max() - rootBox.
min());
166 cubeBox(rootBox, cBox.
min(), cBox.
max());
174 for(
label pI=1;pI<3;++pI)
183 return cBox.overlaps(tBox);
193 if( !intersectsTriangle(
surface, rootBox, tI) )
196 const vector tol = SMALL * (rootBox.
max() - rootBox.
min());
203 if( isVertexInside(rootBox,
points[ltri[pI]]) )
208 cubeBox(rootBox, bb.
min(), bb.
max());
212 for(
label eI=0;eI<3;++eI)
214 const edge edg(ltri[eI], ltri[(eI+1)%3]);
224 this->edgeVertices(rootBox,
e);
249 const vector tol = SMALL * (rootBox.
max() - rootBox.
min());
252 cubeBox(rootBox,
min,
max);
257 ((
p.x() -
max.x()) > 0.0) ||
258 ((
p.y() -
max.y()) > 0.0) ||
259 ((
p.z() -
max.z()) > 0.0) ||
260 ((
p.x() -
min.x()) < 0.0) ||
261 ((
p.y() -
min.y()) < 0.0) ||
262 ((
p.z() -
min.z()) < 0.0)
275 Info <<
"Checking cube " << *
this <<
endl;
276 Info <<
"level " << short(l) <<
" x: " << px
277 <<
" y: " << py <<
" z:" << pz <<
endl;
280 if( cc.
level() >= this->level() )
288 Info <<
"Divider " << divider <<
endl;
289 Info <<
"Coordinates at level are " << reducedLevel <<
endl;
292 if( reducedLevel == *
this )
299 "bool meshOctreeCubeCoordinates::isPositionInside"
300 "(const label px,const label py,"
301 "const label pz,const direction l)"
302 ) <<
"Cannot find exact position of finer cube" <<
exit(
FatalError);
315 const scalar tol = SMALL * (rootBox.
max().
x() - rootBox.
min().
x());
318 cubeBox(rootBox,
min,
max);
329 if(
mag(v.
x()) > tol )
332 t = (
min.x() -
s.x()) / v.
x();
335 (t > -tol) && (t < (1.0+tol)) &&
336 (i.
y() -
min.y() > -tol) &&
337 (i.
y() -
max.y() < tol) &&
338 (i.
z() -
min.z() > -tol) &&
339 (i.
z() -
max.z() < tol)
344 t = (
max.x() -
s.x()) / v.
x();
347 (t > -tol) && (t < (1.0+tol)) &&
348 (i.
y() -
min.y() > -tol) &&
349 (i.
y() -
max.y() < tol) &&
350 (i.
z() -
min.z() > -tol) &&
351 (i.
z() -
max.z() < tol)
356 if(
mag(v.
y()) > tol)
359 t = (
min.y() -
s.y()) / v.
y();
362 (t > -tol) && (t < (1.0+tol)) &&
363 (i.
x() -
min.x() > -tol) &&
364 (i.
x() -
max.x() < tol) &&
365 (i.
z() -
min.z() > -tol) &&
366 (i.
z() -
max.z() < tol)
371 t = (
max.y() -
s.y()) / v.
y();
374 (t > -tol) && (t < (1.0+tol)) &&
375 (i.
x() -
min.x() > -tol) &&
376 (i.
x() -
max.x() < tol) &&
377 (i.
z() -
min.z() > -tol) &&
378 (i.
z() -
max.z() < tol)
383 if(
mag(v.
z()) > tol )
386 t = (
min.z() -
s.z()) / v.
z();
389 (t > -tol) && (t < (1.0+tol)) &&
390 (i.
x() -
min.x() > -tol) &&
391 (i.
x() -
max.x() < tol) &&
392 (i.
y() -
min.y() > -tol) &&
393 (i.
y() -
max.y() < tol)
398 t = (
max.z() -
s.z()) / v.
z();
401 (t > -tol) && (t < (1.0+tol)) &&
402 (i.
x() -
min.x() > -tol) &&
403 (i.
x() -
max.x() < tol) &&
404 (i.
y() -
min.y() > -tol) &&
405 (i.
y() -
max.y() < tol)
410 if( isVertexInside(rootBox,
s) )
static const label edgeFaces_[12][2]
edge-faces addressing for the octree cube
const point & max() const
Maximum describing the bounding box.
#define forAll(list, i)
Loop across all elements in list.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
static const label faceEdges_[6][4]
face-edges addressing for the octree cube
Ostream & endl(Ostream &os)
Add newline and flush stream.
static const label nodeFaces_[8][3]
node-faces addressing for the cube
bool intersectsLine(const boundBox &, const point &, const point &) const
check if the cube intersects a line
dimensioned< scalar > mag(const dimensioned< Type > &)
bool isVertexInside(const boundBox &, const point &) const
is a vertex inside the cube
label end() const
Return end vertex label.
scalar diff(const triad &A, const triad &B)
Return a quantity of the difference between two triads.
bool isPositionInside(const meshOctreeCubeCoordinates &) const
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Pre-declare SubField and related Field type.
bool intersectsTriangleExact(const triSurf &, const boundBox &, const label) const
const point & min() const
Minimum describing the bounding box.
bool triLineIntersection(const triangle< point, point > &tria, const point &lineStart, const point &lineEnd, point &intersection)
check if a line intersects the triangle, and return the intersection
const double e
Elementary charge.
Vector< scalar > vector
A scalar version of the templated 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))
static const label edgeNodes_[12][2]
edge nodes for an octree cube
static const label faceNodes_[6][4]
cube nodes making each face
errorManipArg< error, int > exit(error &err, const int errNo=1)
bool boundBoxLineIntersection(const point &, const point &, const boundBox &)
check if the line intersects the bounding box
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
label start() const
Return start vertex label.
direction level() const
return level
A 1D vector of objects of type <T> with a fixed size <Size>.
bool intersectsTriangle(const triSurf &, const boundBox &, const label) const
check if the surface triangle intersects the cube
Triangle with additional region number.
A bounding box defined in terms of the points at its extremities.
static const label oppositeFace_[6]
return the opposite face of each cube face
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
vector point
Point is a vector.
void vertices(const boundBox &, FixedList< point, 8 > &) const
calculate vertices
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
void edgeVertices(const boundBox &, FixedList< FixedList< point, 2 >, 12 > &) const
edges of the cube
meshOctreeCubeCoordinates reduceLevelBy(const direction diff) const