diff --git a/bird/meshing/_mesh_tools.py b/bird/meshing/_mesh_tools.py index 61618b2f..57b3b158 100644 --- a/bird/meshing/_mesh_tools.py +++ b/bird/meshing/_mesh_tools.py @@ -32,6 +32,35 @@ def make_walls_from_topo(topo): return {"WallR": WallR, "WallL": WallL} +def make_fluid_blocks_from_corner(corners): + assert isinstance(corners, list) + fluid_blocks = [] + for multi_block in corners: + n_end_block = len(multi_block) + for iend, end_block in enumerate(multi_block): + + if iend == 0: + fluid_blocks.append(list(end_block)) + else: + # Find direction to previous end point + prev_block=multi_block[iend-1] + line=np.array(end_block, dtype=int) - np.array(prev_block, dtype=int) + nnz = np.nonzero(line) + assert len(nnz) == 1 + direction = np.array(line / np.linalg.norm(line), dtype=int) + blocks_line = [] + found_next = False + count = 0 + while not found_next: + count += int(1) + new_block = np.array(prev_block, dtype=int) + count*direction + if np.linalg.norm(new_block - np.array(end_block, dtype=int))<1: + found_next = True + blocks_line.append(list(np.array(prev_block, dtype=int) + count*direction)) + fluid_blocks += blocks_line + + return fluid_blocks + def make_bound_from_topo(topo): BoundaryNames = [] BoundaryType = []