diff --git a/src/ArborX_DistributedSearchTree.hpp b/src/ArborX_DistributedSearchTree.hpp index cb23757a2..69351ab98 100644 --- a/src/ArborX_DistributedSearchTree.hpp +++ b/src/ArborX_DistributedSearchTree.hpp @@ -40,6 +40,8 @@ class DistributedSearchTree template DistributedSearchTree(MPI_Comm comm, Primitives const &primitives); + ~DistributedSearchTree() { MPI_Comm_free(&_comm); } + /** Returns the smallest axis-aligned box able to contain all the objects * stored in the tree or an invalid box if the tree is empty. */ @@ -105,9 +107,12 @@ template template DistributedSearchTree::DistributedSearchTree( MPI_Comm comm, Primitives const &primitives) - : _comm(comm) - , _bottom_tree(primitives) + : _bottom_tree(primitives) { + // Create new context for the library to isolate library's communication from + // user's + MPI_Comm_dup(comm, &_comm); + int comm_rank; MPI_Comm_rank(_comm, &comm_rank); int comm_size;