diff --git a/src/meshTools/AABBTree/AABBTree.C b/src/meshTools/AABBTree/AABBTree.C index 9f28ec5569..07004f79c3 100644 --- a/src/meshTools/AABBTree/AABBTree.C +++ b/src/meshTools/AABBTree/AABBTree.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2015 OpenFOAM Foundation - Copyright (C) 2016-2017 OpenCFD Ltd. + Copyright (C) 2016-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -396,22 +396,43 @@ Foam::AABBTree::AABBTree // transfer flattened tree to persistent storage DynamicList boundBoxes(2*bbs.size()); DynamicList addressing(2*addr.size()); + forAll(nodes, nodeI) { if (nodes[nodeI].first() < 0) { boundBoxes.append(bbs[nodeI].first()); - addressing.append(addr[nodeI + 1]); + addressing.append(addr[-(nodes[nodeI].first() + 1)]); } if (nodes[nodeI].second() < 0) { boundBoxes.append(bbs[nodeI].second()); - addressing.append(addr[nodeI + 1]); + addressing.append(addr[-(nodes[nodeI].second() + 1)]); } } boundBoxes_.transfer(boundBoxes); addressing_.transfer(addressing); + + + if (0) + { + bitSet checked(objects.size()); + for (const auto& box : addressing_) + { + for (const auto& id : box) + { + checked.set(id); + } + } + + const label unsetSize = checked.count(false); + + if (unsetSize) + { + Info<< "*** Problem: IDs not set: " << unsetSize << endl; + } + } } diff --git a/src/meshTools/AABBTree/AABBTree.H b/src/meshTools/AABBTree/AABBTree.H index 363f4a0a7b..22144b5df7 100644 --- a/src/meshTools/AABBTree/AABBTree.H +++ b/src/meshTools/AABBTree/AABBTree.H @@ -142,8 +142,7 @@ public: AABBTree(); //- Construct from components - // equalBinSize: divide into equal number of elements or - // equal span + // equalBinSize: divide into equal number of elements or equal span AABBTree ( const UList& objects, @@ -171,7 +170,7 @@ public: bool pointInside(const point& pt) const; //- Determine whether a bounding box overlaps the tree bounding - // boxes + //- boxes bool overlaps(const boundBox& bbIn) const;