diff --git a/src/OpenFOAM/algorithms/dynamicIndexedOctree/dynamicIndexedOctree.C b/src/OpenFOAM/algorithms/dynamicIndexedOctree/dynamicIndexedOctree.C index b1909bc78a..8b1d4274ac 100644 --- a/src/OpenFOAM/algorithms/dynamicIndexedOctree/dynamicIndexedOctree.C +++ b/src/OpenFOAM/algorithms/dynamicIndexedOctree/dynamicIndexedOctree.C @@ -685,13 +685,19 @@ Foam::point Foam::dynamicIndexedOctree::pushPoint { if (pushInside != bb.contains(perturbedPt)) { - FatalErrorInFunction + auto fatal = FatalErrorInFunction; + + fatal << "pushed point:" << pt << " to:" << perturbedPt << " wanted side:" << pushInside << " obtained side:" << bb.contains(perturbedPt) - << " of bb:" << bb - << abort(FatalError); + << " of bb:" << bb << nl; + + if (debug > 1) + { + fatal << abort(FatalError); + } } } @@ -798,13 +804,19 @@ Foam::point Foam::dynamicIndexedOctree::pushPoint { if (pushInside != bb.contains(perturbedPt)) { - FatalErrorInFunction + auto fatal = FatalErrorInFunction; + + fatal << "pushed point:" << pt << " on face:" << faceString(faceID) << " to:" << perturbedPt << " wanted side:" << pushInside << " obtained side:" << bb.contains(perturbedPt) - << " of bb:" << bb - << abort(FatalError); + << " of bb:" << bb << nl; + + if (debug > 1) + { + fatal << abort(FatalError); + } } } @@ -824,9 +836,16 @@ Foam::point Foam::dynamicIndexedOctree::pushPointIntoFace { if (bb.posBits(pt) != 0) { - FatalErrorInFunction + auto fatal = FatalErrorInFunction; + + fatal << " bb:" << bb << endl - << "does not contain point " << pt << abort(FatalError); + << "does not contain point " << pt << nl; + + if (debug > 1) + { + fatal << abort(FatalError); + } } } @@ -946,21 +965,34 @@ Foam::point Foam::dynamicIndexedOctree::pushPointIntoFace { if (faceID != bb.faceBits(facePoint)) { - FatalErrorInFunction + auto fatal = FatalErrorInFunction; + + fatal << "Pushed point from " << pt - << " on face:" << ptFaceID << " of bb:" << bb << endl + << " on face:" << ptFaceID << " of bb:" << bb << nl << "onto " << facePoint << " on face:" << faceID << " which is not consistent with geometric face " - << bb.faceBits(facePoint) - << abort(FatalError); + << bb.faceBits(facePoint) << nl; + + if (debug > 1) + { + fatal << abort(FatalError); + } } if (bb.posBits(facePoint) != 0) { - FatalErrorInFunction - << " bb:" << bb << endl + auto fatal = FatalErrorInFunction; + + fatal + << " bb:" << bb << nl << "does not contain perturbed point " - << facePoint << abort(FatalError); + << facePoint << nl; + + if (debug > 1) + { + fatal << abort(FatalError); + } } } @@ -1204,12 +1236,18 @@ bool Foam::dynamicIndexedOctree::walkToNeighbour if (!subBb.contains(facePoint)) { - FatalErrorInFunction + auto fatal = FatalErrorInFunction; + + fatal << "When searching for " << facePoint << " ended up in node:" << nodeI << " octant:" << octant - << " with bb:" << subBb - << abort(FatalError); + << " with bb:" << subBb << nl; + + if (debug > 1) + { + fatal << abort(FatalError); + } } } @@ -1233,24 +1271,36 @@ bool Foam::dynamicIndexedOctree::walkToNeighbour if (nodeI == oldNodeI && octant == oldOctant) { - FatalErrorInFunction + auto fatal = FatalErrorInFunction; + + fatal << "Did not go to neighbour when searching for " << facePoint - << endl + << nl << " starting from face:" << faceString(faceID) << " node:" << nodeI << " octant:" << octant - << " bb:" << subBb - << abort(FatalError); + << " bb:" << subBb << nl; + + if (debug > 1) + { + fatal << abort(FatalError); + } } if (!subBb.contains(facePoint)) { - FatalErrorInFunction + auto fatal = FatalErrorInFunction; + + fatal << "When searching for " << facePoint << " ended up in node:" << nodeI << " octant:" << octant - << " bb:" << subBb - << abort(FatalError); + << " bb:" << subBb << nl; + + if (debug > 1) + { + fatal << abort(FatalError); + } } } @@ -1327,10 +1377,17 @@ void Foam::dynamicIndexedOctree::traverseNode if (octantBb.posBits(start) != 0) { - FatalErrorInFunction + auto fatal = FatalErrorInFunction; + + fatal << "Node:" << nodeI << " octant:" << octant - << " bb:" << octantBb << endl - << "does not contain point " << start << abort(FatalError); + << " bb:" << octantBb << nl + << "does not contain point " << start << nl; + + if (debug > 1) + { + fatal << abort(FatalError); + } } } @@ -2209,13 +2266,15 @@ Foam::labelList Foam::dynamicIndexedOctree::findBox const treeBoundBox& searchBox ) const { + if (nodes_.empty()) + { + return labelList(); + } + // Storage for labels of shapes inside bb. Size estimate. labelHashSet elements(shapes_.size() / 100); - if (nodes_.size()) - { - findBox(0, searchBox, elements); - } + findBox(0, searchBox, elements); return elements.toc(); } @@ -2228,13 +2287,15 @@ Foam::labelList Foam::dynamicIndexedOctree::findSphere const scalar radiusSqr ) const { + if (nodes_.empty()) + { + return labelList(); + } + // Storage for labels of shapes inside bb. Size estimate. labelHashSet elements(shapes_.size() / 100); - if (nodes_.size()) - { - findSphere(0, centre, radiusSqr, elements); - } + findSphere(0, centre, radiusSqr, elements); return elements.toc(); } diff --git a/src/OpenFOAM/algorithms/indexedOctree/indexedOctree.C b/src/OpenFOAM/algorithms/indexedOctree/indexedOctree.C index 64346e1d25..eecf3a99cd 100644 --- a/src/OpenFOAM/algorithms/indexedOctree/indexedOctree.C +++ b/src/OpenFOAM/algorithms/indexedOctree/indexedOctree.C @@ -710,13 +710,19 @@ Foam::point Foam::indexedOctree::pushPoint { if (pushInside != bb.contains(perturbedPt)) { - FatalErrorInFunction + auto fatal = FatalErrorInFunction; + + fatal << "pushed point:" << pt << " to:" << perturbedPt << " wanted side:" << pushInside << " obtained side:" << bb.contains(perturbedPt) - << " of bb:" << bb - << abort(FatalError); + << " of bb:" << bb << nl; + + if (debug > 1) + { + fatal << abort(FatalError); + } } } @@ -820,13 +826,19 @@ Foam::point Foam::indexedOctree::pushPoint { if (pushInside != bb.contains(perturbedPt)) { - FatalErrorInFunction + auto fatal = FatalErrorInFunction; + + fatal << "pushed point:" << pt << " on face:" << faceString(faceID) << " to:" << perturbedPt << " wanted side:" << pushInside << " obtained side:" << bb.contains(perturbedPt) - << " of bb:" << bb - << abort(FatalError); + << " of bb:" << bb << nl; + + if (debug > 1) + { + fatal << abort(FatalError); + } } } @@ -846,9 +858,16 @@ Foam::point Foam::indexedOctree::pushPointIntoFace { if (bb.posBits(pt) != 0) { - FatalErrorInFunction + auto fatal = FatalErrorInFunction; + + fatal << " bb:" << bb << endl - << "does not contain point " << pt << abort(FatalError); + << "does not contain point " << pt << nl; + + if (debug > 1) + { + fatal << abort(FatalError); + } } } @@ -968,21 +987,34 @@ Foam::point Foam::indexedOctree::pushPointIntoFace { if (faceID != bb.faceBits(facePoint)) { - FatalErrorInFunction + auto fatal = FatalErrorInFunction; + + fatal << "Pushed point from " << pt - << " on face:" << ptFaceID << " of bb:" << bb << endl + << " on face:" << ptFaceID << " of bb:" << bb << nl << "onto " << facePoint << " on face:" << faceID << " which is not consistent with geometric face " - << bb.faceBits(facePoint) - << abort(FatalError); + << bb.faceBits(facePoint) << nl; + + if (debug > 1) + { + fatal << abort(FatalError); + } } if (bb.posBits(facePoint) != 0) { - FatalErrorInFunction - << " bb:" << bb << endl + auto fatal = FatalErrorInFunction; + + fatal + << " bb:" << bb << nl << "does not contain perturbed point " - << facePoint << abort(FatalError); + << facePoint << nl; + + if (debug > 1) + { + fatal << abort(FatalError); + } } } @@ -1224,12 +1256,18 @@ bool Foam::indexedOctree::walkToNeighbour if (!subBb.contains(facePoint)) { - FatalErrorInFunction + auto fatal = FatalErrorInFunction; + + fatal << "When searching for " << facePoint << " ended up in node:" << nodeI << " octant:" << octant - << " with bb:" << subBb - << abort(FatalError); + << " with bb:" << subBb << nl; + + if (debug > 1) + { + fatal << abort(FatalError); + } } } @@ -1253,24 +1291,36 @@ bool Foam::indexedOctree::walkToNeighbour if (nodeI == oldNodeI && octant == oldOctant) { - FatalErrorInFunction + auto fatal = FatalErrorInFunction; + + fatal << "Did not go to neighbour when searching for " << facePoint - << endl + << nl << " starting from face:" << faceString(faceID) << " node:" << nodeI << " octant:" << octant - << " bb:" << subBb - << abort(FatalError); + << " bb:" << subBb << nl; + + if (debug > 1) + { + fatal << abort(FatalError); + } } if (!subBb.contains(facePoint)) { - FatalErrorInFunction + auto fatal = FatalErrorInFunction; + + fatal << "When searching for " << facePoint << " ended up in node:" << nodeI << " octant:" << octant - << " bb:" << subBb - << abort(FatalError); + << " bb:" << subBb << nl; + + if (debug > 1) + { + fatal << abort(FatalError); + } } } @@ -1358,10 +1408,17 @@ void Foam::indexedOctree::traverseNode if (octantBb.posBits(start) != 0) { - FatalErrorInFunction + auto fatal = FatalErrorInFunction; + + fatal << "Node:" << nodeI << " octant:" << octant - << " bb:" << octantBb << endl - << "does not contain point " << start << abort(FatalError); + << " bb:" << octantBb << nl + << "does not contain point " << start << nl; + + if (debug > 1) + { + fatal << abort(FatalError); + } } } @@ -2489,13 +2546,15 @@ Foam::labelList Foam::indexedOctree::findBox const treeBoundBox& searchBox ) const { + if (nodes_.empty()) + { + return labelList(); + } + // Storage for labels of shapes inside bb. Size estimate. labelHashSet elements(shapes_.size() / 100); - if (nodes_.size()) - { - findBox(0, searchBox, elements); - } + findBox(0, searchBox, elements); return elements.toc(); } @@ -2508,13 +2567,15 @@ Foam::labelList Foam::indexedOctree::findSphere const scalar radiusSqr ) const { + if (nodes_.empty()) + { + return labelList(); + } + // Storage for labels of shapes inside bb. Size estimate. labelHashSet elements(shapes_.size() / 100); - if (nodes_.size()) - { - findSphere(0, centre, radiusSqr, elements); - } + findSphere(0, centre, radiusSqr, elements); return elements.toc(); }