From a2895e9bc64fc4d147c09f21613dc150a282f895 Mon Sep 17 00:00:00 2001 From: Mehdi Slimani Date: Wed, 2 Oct 2024 09:00:45 +0000 Subject: [PATCH] Non-defaulted padding in BoundingBoxTree c++ constructor - Changed argument order to match Python constructor --- cpp/dolfinx/geometry/BoundingBoxTree.h | 4 ++-- cpp/dolfinx/geometry/utils.h | 2 +- python/dolfinx/geometry.py | 4 ++-- python/dolfinx/wrappers/geometry.cpp | 11 +++++------ 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/cpp/dolfinx/geometry/BoundingBoxTree.h b/cpp/dolfinx/geometry/BoundingBoxTree.h index 64ede45a057..01e0db723f3 100644 --- a/cpp/dolfinx/geometry/BoundingBoxTree.h +++ b/cpp/dolfinx/geometry/BoundingBoxTree.h @@ -224,7 +224,7 @@ class BoundingBoxTree /// @param[in] padding Value to pad (extend) the the bounding box of /// each entity by. BoundingBoxTree(const mesh::Mesh& mesh, int tdim, - std::span entities, double padding = 0) + double padding, std::span entities) : _tdim(tdim) { if (tdim < 0 or tdim > mesh.topology()->dim()) @@ -266,7 +266,7 @@ class BoundingBoxTree /// build the bounding box tree for /// @param[in] padding Value to pad (extend) the the bounding box of /// each entity by. - BoundingBoxTree(const mesh::Mesh& mesh, int tdim, T padding = 0) + BoundingBoxTree(const mesh::Mesh& mesh, int tdim, T padding) : BoundingBoxTree::BoundingBoxTree( mesh, tdim, range(mesh.topology_mutable(), tdim), padding) { diff --git a/cpp/dolfinx/geometry/utils.h b/cpp/dolfinx/geometry/utils.h index 0c772937f02..c629c3ba598 100644 --- a/cpp/dolfinx/geometry/utils.h +++ b/cpp/dolfinx/geometry/utils.h @@ -697,7 +697,7 @@ PointOwnershipData determine_point_ownership(const mesh::Mesh& mesh, } // Create a global bounding-box tree to find candidate processes with // cells that could collide with the points - BoundingBoxTree bb(mesh, tdim, cells, padding); + BoundingBoxTree bb(mesh, tdim, padding, cells); BoundingBoxTree global_bbtree = bb.create_global_tree(comm); // Compute collisions: diff --git a/python/dolfinx/geometry.py b/python/dolfinx/geometry.py index c97d8ca23d6..f27316043d8 100644 --- a/python/dolfinx/geometry.py +++ b/python/dolfinx/geometry.py @@ -128,11 +128,11 @@ def bb_tree( dtype = mesh.geometry.x.dtype if np.issubdtype(dtype, np.float32): return BoundingBoxTree( - _cpp.geometry.BoundingBoxTree_float32(mesh._cpp_object, dim, entities, padding) + _cpp.geometry.BoundingBoxTree_float32(mesh._cpp_object, dim, padding, entities) ) elif np.issubdtype(dtype, np.float64): return BoundingBoxTree( - _cpp.geometry.BoundingBoxTree_float64(mesh._cpp_object, dim, entities, padding) + _cpp.geometry.BoundingBoxTree_float64(mesh._cpp_object, dim, padding, entities) ) else: raise NotImplementedError(f"Type {dtype} not supported.") diff --git a/python/dolfinx/wrappers/geometry.cpp b/python/dolfinx/wrappers/geometry.cpp index 2419e7e511b..cc81cd3d208 100644 --- a/python/dolfinx/wrappers/geometry.cpp +++ b/python/dolfinx/wrappers/geometry.cpp @@ -33,17 +33,16 @@ void declare_bbtree(nb::module_& m, std::string type) "__init__", [](dolfinx::geometry::BoundingBoxTree* bbt, const dolfinx::mesh::Mesh& mesh, int dim, + double padding, nb::ndarray, nb::c_contig> - entities, - double padding) + entities) { new (bbt) dolfinx::geometry::BoundingBoxTree( mesh, dim, - std::span(entities.data(), entities.size()), - padding); + padding, + std::span(entities.data(), entities.size())); }, - nb::arg("mesh"), nb::arg("dim"), nb::arg("entities"), - nb::arg("padding") = 0.0) + nb::arg("mesh"), nb::arg("dim"), nb::arg("padding"), nb::arg("entities")) .def_prop_ro("num_bboxes", &dolfinx::geometry::BoundingBoxTree::num_bboxes) .def(