- edited description
BoundingBoxTree.compute_closest_entity gives wrong distance in 2D
BoundingBoxTree.compute_closest_entity gives wrong distances in 2D. In 3D (at least for UnitCubeMesh) it seems to be OK.
Example:
from dolfin import *
mesh = UnitSquareMesh(4,4)
bmesh = BoundaryMesh(mesh, "exterior")
bbtree = BoundingBoxTree()
bbtree.build(bmesh)
vertex_distance_to_boundary = MeshFunction("double", mesh, 0)
for v_idx in xrange(mesh.num_vertices()):
v = Vertex(mesh, v_idx)
_, distance = bbtree.compute_closest_entity(v.point())
vertex_distance_to_boundary[v_idx] = distance
plot(vertex_distance_to_boundary)
interactive()
In this example, distance to the boundary should be plotted.
see also http://fenicsproject.org/qa/1446/distance-to-boundary .
Comments (11)
-
reporter -
reporter -
assigned issue to
-
assigned issue to
-
Please modify your report to be explicit in what you expect the output to be, and what it actually is.
-
- changed milestone to 1.3
-
reporter I expect the value plotted to be distance to the boundary of the domain. I get the following:
-
Please have your report print numbers for comparison.
-
reporter Ok, here.
from dolfin import * mesh = UnitSquareMesh(4,4) bmesh = BoundaryMesh(mesh, "exterior") bbtree = BoundingBoxTree() bbtree.build(bmesh) vertex_distance_to_boundary = MeshFunction("double", mesh, 0) for v_idx in xrange(mesh.num_vertices()): v = Vertex(mesh, v_idx) p = [v.point()[i] for i in range(3)] _, distance = bbtree.compute_closest_entity(v.point()) vertex_distance_to_boundary[v_idx] = distance print p, distance
and result:
[0.0, 0.0, 0.0] 0.0 [0.25, 0.0, 0.0] 0.0 [0.5, 0.0, 0.0] 0.0 [0.75, 0.0, 0.0] 0.0 [1.0, 0.0, 0.0] 0.0 [0.0, 0.25, 0.0] 0.0 [0.25, 0.25, 0.0] 0.0 [0.5, 0.25, 0.0] 0.0 [0.75, 0.25, 0.0] 0.0 [1.0, 0.25, 0.0] 0.0 [0.0, 0.5, 0.0] 0.0 [0.25, 0.5, 0.0] 0.25 [0.5, 0.5, 0.0] 0.0 [0.75, 0.5, 0.0] 0.25 [1.0, 0.5, 0.0] 0.0 [0.0, 0.75, 0.0] 0.0 [0.25, 0.75, 0.0] 0.0 [0.5, 0.75, 0.0] 0.0 [0.75, 0.75, 0.0] 0.0 [1.0, 0.75, 0.0] 0.0 [0.0, 1.0, 0.0] 0.0 [0.25, 1.0, 0.0] 0.0 [0.5, 1.0, 0.0] 0.0 [0.75, 1.0, 0.0] 0.0 [1.0, 1.0, 0.0] 0.0
-
Thanks. I'll look into this but let me just comment that this has not been tested at all (bounding box tree for surface embedded in higher dimensions), so it's not surprising that it breaks.
-
- changed status to resolved
Fix issue 139: BoundingBoxTree.compute_closest_entity gives wrong distance in 2D
→ <<cset 91bad31c2228>>
-
This should be fixed now (fix merged into
next
). -
- removed milestone
Removing milestone: 1.3 (automated comment)
- Log in to comment