Skip to content

Commit

Permalink
[geom] Fix batched build_mesh()
Browse files Browse the repository at this point in the history
  • Loading branch information
holl- committed May 24, 2024
1 parent 186d182 commit 33be151
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions phi/geom/_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def __init__(self, vertices: Graph,
# e_face =

def __variable_attrs__(self):
return '_vertices', '_center', '_volume', '_faces', '_valid_mask', '_face_vertices', '_relative_face_distance', '_neighbor_offsets'
return '_vertices', '_polygons', '_vertex_count', '_center', '_volume', '_faces', '_valid_mask', '_face_vertices', '_relative_face_distance', '_neighbor_offsets'

def __value_attrs__(self):
return '_vertices',
Expand Down Expand Up @@ -528,10 +528,12 @@ def build_mesh(bounds: Box = None,
boundaries = {boundary: vertex_map[edge_list] for boundary, edge_list in boundaries.items()}
boundaries = {boundary: edge_list[edge_list[{'~vert': 'start'}] != edge_list[{'~vert': 'end'}]] for boundary, edge_list in boundaries.items()}
# ToDo remove eges which now point to the same vertex
points_np = math.reshaped_numpy(vert_pos, [..., channel])
polygon_list = math.reshaped_numpy(polygons, [..., dual])
boundaries = {b: edges.numpy('edges,~vert') for b, edges in boundaries.items()}
return mesh_from_numpy(points_np, polygon_list, boundaries, cell_dim=cell_dim, face_format=face_format)
def build_single_mesh(vert_pos, polygons, boundaries):
points_np = math.reshaped_numpy(vert_pos, [..., channel])
polygon_list = math.reshaped_numpy(polygons, [..., dual])
boundaries = {b: edges.numpy('edges,~vert') for b, edges in boundaries.items()}
return mesh_from_numpy(points_np, polygon_list, boundaries, cell_dim=cell_dim, face_format=face_format)
return math.map(build_single_mesh, vert_pos, polygons, boundaries, dims=batch)


def build_quadrilaterals(vert_pos, resolution: Shape, obstacles: Dict[str, Geometry]) -> Tuple[Tensor, Tensor, dict]:
Expand Down

0 comments on commit 33be151

Please sign in to comment.