Debian Codegraph @

python/test/unit/mesh/test_manifold_point_search.py

raw
1
2 import numpy
3 from dolfin import *
4
5
6 def test_manifold_point_search():
7 # Simple two-triangle surface in 3d
8 vertices = [
9 (0.0, 0.0, 1.0),
10 (1.0, 1.0, 1.0),
11 (1.0, 0.0, 0.0),
12 (0.0, 1.0, 0.0),
13 ]
14 cells = [
15 (0, 1, 2),
16 (0, 1, 3),
17 ]
18 mesh = Mesh()
19 me = MeshEditor()
20 me.open(mesh, "triangle", 2, 3)
21 me.init_vertices(len(vertices))
22 for i, v in enumerate(vertices):
23 me.add_vertex(i, numpy.array(v, dtype='float'))
24 me.init_cells(len(cells))
25 for i, c in enumerate(cells):
26 me.add_cell(i, numpy.array(c, dtype='uint'))
27 me.close()
28
29 mesh.init_cell_orientations(Expression(("0.0", "0.0", "1.0"), degree=0))
30
31 bb = mesh.bounding_box_tree()
32 p = Point(0.5, 0.25, 0.75)
33 assert bb.compute_first_entity_collision(p) == 0
34
35 p = Point(0.25, 0.5, 0.75)
36 assert bb.compute_first_entity_collision(p) == 1