mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
STYLE: octree pushPoint with local constexpr (more readable code)
This commit is contained in:
committed by
Andrew Heather
parent
3384747f9b
commit
fc9311ba0d
@ -688,9 +688,7 @@ Foam::point Foam::dynamicIndexedOctree<Type>::pushPoint
|
||||
{
|
||||
if (pushInside != bb.contains(perturbedPt))
|
||||
{
|
||||
auto fatal = FatalErrorInFunction;
|
||||
|
||||
fatal
|
||||
FatalErrorInFunction
|
||||
<< "pushed point:" << pt
|
||||
<< " to:" << perturbedPt
|
||||
<< " wanted side:" << pushInside
|
||||
@ -699,7 +697,7 @@ Foam::point Foam::dynamicIndexedOctree<Type>::pushPoint
|
||||
|
||||
if (debug > 1)
|
||||
{
|
||||
fatal << abort(FatalError);
|
||||
FatalError << abort(FatalError);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -734,72 +732,72 @@ Foam::point Foam::dynamicIndexedOctree<Type>::pushPoint
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
if (faceID & treeBoundBox::LEFTBIT)
|
||||
{
|
||||
if (pushInside)
|
||||
constexpr direction dir(0); // vector::X
|
||||
|
||||
if (faceID & treeBoundBox::LEFTBIT)
|
||||
{
|
||||
perturbedPt[0] = bb.min()[0] + (perturbVec[0] + ROOTVSMALL);
|
||||
perturbedPt[dir] =
|
||||
(
|
||||
pushInside
|
||||
? (bb.min()[dir] + (perturbVec[dir] + ROOTVSMALL))
|
||||
: (bb.min()[dir] - (perturbVec[dir] + ROOTVSMALL))
|
||||
);
|
||||
}
|
||||
else
|
||||
else if (faceID & treeBoundBox::RIGHTBIT)
|
||||
{
|
||||
perturbedPt[0] = bb.min()[0] - (perturbVec[0] + ROOTVSMALL);
|
||||
}
|
||||
}
|
||||
else if (faceID & treeBoundBox::RIGHTBIT)
|
||||
{
|
||||
if (pushInside)
|
||||
{
|
||||
perturbedPt[0] = bb.max()[0] - (perturbVec[0] + ROOTVSMALL);
|
||||
}
|
||||
else
|
||||
{
|
||||
perturbedPt[0] = bb.max()[0] + (perturbVec[0] + ROOTVSMALL);
|
||||
perturbedPt[dir] =
|
||||
(
|
||||
pushInside
|
||||
? (bb.max()[dir] - (perturbVec[dir] + ROOTVSMALL))
|
||||
: (bb.max()[dir] + (perturbVec[dir] + ROOTVSMALL))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (faceID & treeBoundBox::BOTTOMBIT)
|
||||
{
|
||||
if (pushInside)
|
||||
constexpr direction dir(1); // vector::Y
|
||||
|
||||
if (faceID & treeBoundBox::BOTTOMBIT)
|
||||
{
|
||||
perturbedPt[1] = bb.min()[1] + (perturbVec[1] + ROOTVSMALL);
|
||||
perturbedPt[dir] =
|
||||
(
|
||||
pushInside
|
||||
? (bb.min()[dir] + (perturbVec[dir] + ROOTVSMALL))
|
||||
: (bb.min()[dir] - (perturbVec[dir] + ROOTVSMALL))
|
||||
);
|
||||
}
|
||||
else
|
||||
else if (faceID & treeBoundBox::TOPBIT)
|
||||
{
|
||||
perturbedPt[1] = bb.min()[1] - (perturbVec[1] + ROOTVSMALL);
|
||||
}
|
||||
}
|
||||
else if (faceID & treeBoundBox::TOPBIT)
|
||||
{
|
||||
if (pushInside)
|
||||
{
|
||||
perturbedPt[1] = bb.max()[1] - (perturbVec[1] + ROOTVSMALL);
|
||||
}
|
||||
else
|
||||
{
|
||||
perturbedPt[1] = bb.max()[1] + (perturbVec[1] + ROOTVSMALL);
|
||||
perturbedPt[dir] =
|
||||
(
|
||||
pushInside
|
||||
? (bb.max()[dir] - (perturbVec[dir] + ROOTVSMALL))
|
||||
: (bb.max()[dir] + (perturbVec[dir] + ROOTVSMALL))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (faceID & treeBoundBox::BACKBIT)
|
||||
{
|
||||
if (pushInside)
|
||||
constexpr direction dir(2); // vector::Z
|
||||
|
||||
if (faceID & treeBoundBox::BACKBIT)
|
||||
{
|
||||
perturbedPt[2] = bb.min()[2] + (perturbVec[2] + ROOTVSMALL);
|
||||
perturbedPt[dir] =
|
||||
(
|
||||
pushInside
|
||||
? (bb.min()[dir] + (perturbVec[dir] + ROOTVSMALL))
|
||||
: (bb.min()[dir] - (perturbVec[dir] + ROOTVSMALL))
|
||||
);
|
||||
}
|
||||
else
|
||||
else if (faceID & treeBoundBox::FRONTBIT)
|
||||
{
|
||||
perturbedPt[2] = bb.min()[2] - (perturbVec[2] + ROOTVSMALL);
|
||||
}
|
||||
}
|
||||
else if (faceID & treeBoundBox::FRONTBIT)
|
||||
{
|
||||
if (pushInside)
|
||||
{
|
||||
perturbedPt[2] = bb.max()[2] - (perturbVec[2] + ROOTVSMALL);
|
||||
}
|
||||
else
|
||||
{
|
||||
perturbedPt[2] = bb.max()[2] + (perturbVec[2] + ROOTVSMALL);
|
||||
perturbedPt[dir] =
|
||||
(
|
||||
pushInside
|
||||
? (bb.max()[dir] - (perturbVec[dir] + ROOTVSMALL))
|
||||
: (bb.max()[dir] + (perturbVec[dir] + ROOTVSMALL))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -807,9 +805,7 @@ Foam::point Foam::dynamicIndexedOctree<Type>::pushPoint
|
||||
{
|
||||
if (pushInside != bb.contains(perturbedPt))
|
||||
{
|
||||
auto fatal = FatalErrorInFunction;
|
||||
|
||||
fatal
|
||||
FatalErrorInFunction
|
||||
<< "pushed point:" << pt << " on face:" << faceString(faceID)
|
||||
<< " to:" << perturbedPt
|
||||
<< " wanted side:" << pushInside
|
||||
@ -818,7 +814,7 @@ Foam::point Foam::dynamicIndexedOctree<Type>::pushPoint
|
||||
|
||||
if (debug > 1)
|
||||
{
|
||||
fatal << abort(FatalError);
|
||||
FatalError << abort(FatalError);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -839,15 +835,13 @@ Foam::point Foam::dynamicIndexedOctree<Type>::pushPointIntoFace
|
||||
{
|
||||
if (bb.posBits(pt) != 0)
|
||||
{
|
||||
auto fatal = FatalErrorInFunction;
|
||||
|
||||
fatal
|
||||
FatalErrorInFunction
|
||||
<< " bb:" << bb << endl
|
||||
<< "does not contain point " << pt << nl;
|
||||
|
||||
if (debug > 1)
|
||||
{
|
||||
fatal << abort(FatalError);
|
||||
FatalError << abort(FatalError);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -968,9 +962,7 @@ Foam::point Foam::dynamicIndexedOctree<Type>::pushPointIntoFace
|
||||
{
|
||||
if (faceID != bb.faceBits(facePoint))
|
||||
{
|
||||
auto fatal = FatalErrorInFunction;
|
||||
|
||||
fatal
|
||||
FatalErrorInFunction
|
||||
<< "Pushed point from " << pt
|
||||
<< " on face:" << ptFaceID << " of bb:" << bb << nl
|
||||
<< "onto " << facePoint
|
||||
@ -980,21 +972,19 @@ Foam::point Foam::dynamicIndexedOctree<Type>::pushPointIntoFace
|
||||
|
||||
if (debug > 1)
|
||||
{
|
||||
fatal << abort(FatalError);
|
||||
FatalError << abort(FatalError);
|
||||
}
|
||||
}
|
||||
if (bb.posBits(facePoint) != 0)
|
||||
{
|
||||
auto fatal = FatalErrorInFunction;
|
||||
|
||||
fatal
|
||||
FatalErrorInFunction
|
||||
<< " bb:" << bb << nl
|
||||
<< "does not contain perturbed point "
|
||||
<< facePoint << nl;
|
||||
|
||||
if (debug > 1)
|
||||
{
|
||||
fatal << abort(FatalError);
|
||||
FatalError << abort(FatalError);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1239,9 +1229,7 @@ bool Foam::dynamicIndexedOctree<Type>::walkToNeighbour
|
||||
|
||||
if (!subBb.contains(facePoint))
|
||||
{
|
||||
auto fatal = FatalErrorInFunction;
|
||||
|
||||
fatal
|
||||
FatalErrorInFunction
|
||||
<< "When searching for " << facePoint
|
||||
<< " ended up in node:" << nodeI
|
||||
<< " octant:" << octant
|
||||
@ -1249,7 +1237,7 @@ bool Foam::dynamicIndexedOctree<Type>::walkToNeighbour
|
||||
|
||||
if (debug > 1)
|
||||
{
|
||||
fatal << abort(FatalError);
|
||||
FatalError << abort(FatalError);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1274,9 +1262,7 @@ bool Foam::dynamicIndexedOctree<Type>::walkToNeighbour
|
||||
|
||||
if (nodeI == oldNodeI && octant == oldOctant)
|
||||
{
|
||||
auto fatal = FatalErrorInFunction;
|
||||
|
||||
fatal
|
||||
FatalErrorInFunction
|
||||
<< "Did not go to neighbour when searching for " << facePoint
|
||||
<< nl
|
||||
<< " starting from face:" << faceString(faceID)
|
||||
@ -1286,15 +1272,13 @@ bool Foam::dynamicIndexedOctree<Type>::walkToNeighbour
|
||||
|
||||
if (debug > 1)
|
||||
{
|
||||
fatal << abort(FatalError);
|
||||
FatalError << abort(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
if (!subBb.contains(facePoint))
|
||||
{
|
||||
auto fatal = FatalErrorInFunction;
|
||||
|
||||
fatal
|
||||
FatalErrorInFunction
|
||||
<< "When searching for " << facePoint
|
||||
<< " ended up in node:" << nodeI
|
||||
<< " octant:" << octant
|
||||
@ -1302,7 +1286,7 @@ bool Foam::dynamicIndexedOctree<Type>::walkToNeighbour
|
||||
|
||||
if (debug > 1)
|
||||
{
|
||||
fatal << abort(FatalError);
|
||||
FatalError << abort(FatalError);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1380,16 +1364,14 @@ void Foam::dynamicIndexedOctree<Type>::traverseNode
|
||||
|
||||
if (octantBb.posBits(start) != 0)
|
||||
{
|
||||
auto fatal = FatalErrorInFunction;
|
||||
|
||||
fatal
|
||||
FatalErrorInFunction
|
||||
<< "Node:" << nodeI << " octant:" << octant
|
||||
<< " bb:" << octantBb << nl
|
||||
<< "does not contain point " << start << nl;
|
||||
|
||||
if (debug > 1)
|
||||
{
|
||||
fatal << abort(FatalError);
|
||||
FatalError << abort(FatalError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user