dolfinx icon indicating copy to clipboard operation
dolfinx copied to clipboard

BoundingBoxTree tolerances

Open nate-sime opened this issue 3 years ago • 0 comments

Originally we have a constexpr double rtol in bbox collision detection

https://github.com/FEniCS/dolfinx/blob/main/cpp/dolfinx/geometry/utils.cpp#L41

More recently a "padding" was introduced to the size of bounding boxes which is essentially used as an absolute tolerance

https://github.com/FEniCS/dolfinx/blob/main/cpp/dolfinx/geometry/BoundingBoxTree.h#L39 https://github.com/FEniCS/dolfinx/blob/main/cpp/dolfinx/geometry/BoundingBoxTree.cpp#L253-L256

Can we give a BoundingBoxTree this rtol at instantiation?

It's causing me problems with meshes that have cell diameters differing by six orders of magnitude.

You can reproduce the issue with the following:

import numpy as np
import dolfinx
import dolfinx.geometry
from mpi4py import MPI

mesh = dolfinx.UnitCubeMesh(
	MPI.COMM_WORLD, 1, 1, 1, 
	cell_type=dolfinx.cpp.mesh.CellType.hexahedron)

tree = dolfinx.geometry.BoundingBoxTree(
	mesh, mesh.topology.dim, padding=0.0)
c = dolfinx.geometry.compute_collisions_point(
	tree, np.array([0.0, 0.0, -1e-14], dtype=np.double))

print(f"Number of cells found should be zero. Found cells: {c}")

Number of cells found should be zero. Found cells: [0]

nate-sime avatar Aug 11 '21 18:08 nate-sime