def test_compute_collisions_point_2d(): # reference = {1: set([226]), # 2: set([136, 137])} p = numpy.array([0.3, 0.3, 0.0]) mesh = UnitSquareMesh(MPI.comm_world, 16, 16) for dim in range(1, 3): tree = BoundingBoxTree(mesh, mesh.topology.dim) entities = tree.compute_collisions_point(p) for e in entities: ent = MeshEntity(mesh, dim, e) mp = ent.midpoint() x = (mp[0], mp[1]) print("test: {}".format(x))
def test_compute_collisions_point_2d(): reference = {1: set([226]), 2: set([136, 137])} p = Point(0.3, 0.3) mesh = UnitSquareMesh(16, 16) for dim in range(1, 3): tree = BoundingBoxTree() tree.build(mesh, dim) entities = tree.compute_collisions(p) for e in entities: ent = MeshEntity(mesh, dim, e) mp = ent.midpoint() x = (mp.x(), mp.y()) print("test: {}".format(x))
def _single_mesh_entity_plot(self, cell_index, tdim): 'Plot labels of mesh entities of topological dim. that are in cell.' # Compute cell->entity connectivity unless cell-cell. Don't need patch if self.tdim == tdim: entity_indices = [cell_index] else: entity_indices = Cell(self.mesh, cell_index).entities(tdim) color = self.mesh_entity_colors[tdim] labels = self.mesh_entity_labels[tdim] # Loop through entities of the cell for entity_index in entity_indices: entity = MeshEntity(self.mesh, tdim, entity_index) # Midpoint is label location x = entity.midpoint() x = [x[i] for i in range(self.gdim)] if (self.order == 'global') and self.mpi_size > 1: args = x + [str(entity.global_index())] else: args = x + [str(entity_index)] # Create new label if entitiy not labeled already if not (entity_index in labels): labels[entity_index] = self.axes.text(*args, color=color)
def _single_mesh_entity_plot(self, cell_index, tdim): 'Plot labels of mesh entities of topological dim. that are in cell.' # Compute cell->entity connectivity unless cell-cell. Don't need patch if self.tdim == tdim: entity_indices = [cell_index] else: entity_indices = Cell(self.mesh, cell_index).entities(tdim) color = self.mesh_entity_colors[tdim] labels = self.mesh_entity_labels[tdim] # Loop through entities of the cell for entity_index in entity_indices: entity = MeshEntity(self.mesh, tdim, entity_index) # Midpoint is label location x = entity.midpoint() x = [x[i] for i in range(self.gdim)] if (self.order == 'global') and self.mpi_size > 1: args = x + [str(entity.global_index())] else: args = x + [str(entity_index)] # Create new label if entitiy not labeled already if not(entity_index in labels): labels[entity_index] = self.axes.text(*args, color=color)