Skip to content

Commit

Permalink
Non-defaulted padding in BoundingBoxTree c++ constructor
Browse files Browse the repository at this point in the history
- Changed argument order to match Python constructor
  • Loading branch information
ordinary-slim committed Oct 2, 2024
1 parent 74b9a22 commit a969271
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
4 changes: 2 additions & 2 deletions cpp/dolfinx/geometry/BoundingBoxTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>& mesh, int tdim,
std::span<const std::int32_t> entities, double padding = 0)
double padding, std::span<const std::int32_t> entities)
: _tdim(tdim)
{
if (tdim < 0 or tdim > mesh.topology()->dim())
Expand Down Expand Up @@ -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<T>& mesh, int tdim, T padding = 0)
BoundingBoxTree(const mesh::Mesh<T>& mesh, int tdim, T padding)
: BoundingBoxTree::BoundingBoxTree(
mesh, tdim, range(mesh.topology_mutable(), tdim), padding)
{
Expand Down
2 changes: 1 addition & 1 deletion cpp/dolfinx/geometry/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ PointOwnershipData<T> determine_point_ownership(const mesh::Mesh<T>& 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:
Expand Down
4 changes: 2 additions & 2 deletions python/dolfinx/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down
11 changes: 5 additions & 6 deletions python/dolfinx/wrappers/geometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,16 @@ void declare_bbtree(nb::module_& m, std::string type)
"__init__",
[](dolfinx::geometry::BoundingBoxTree<T>* bbt,
const dolfinx::mesh::Mesh<T>& mesh, int dim,
double padding,
nb::ndarray<const std::int32_t, nb::ndim<1>, nb::c_contig>
entities,
double padding)
entities)
{
new (bbt) dolfinx::geometry::BoundingBoxTree<T>(
mesh, dim,
std::span<const std::int32_t>(entities.data(), entities.size()),
padding);
padding,
std::span<const std::int32_t>(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<T>::num_bboxes)
.def(
Expand Down

0 comments on commit a969271

Please sign in to comment.