Skip to content

Commit

Permalink
add input interface
Browse files Browse the repository at this point in the history
  • Loading branch information
malihass committed May 6, 2024
1 parent 2bcc7c3 commit fd39ce0
Show file tree
Hide file tree
Showing 10 changed files with 1,175 additions and 32 deletions.
42 changes: 42 additions & 0 deletions applications/write_block_rect_mesh.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import argparse
import os
import sys

import numpy as np

from bird import BIRD_BLOCK_RECT_MESH_TEMP_DIR
from bird.meshing.block_rect_mesh import (
assemble_geom,
assemble_mesh,
writeBlockMeshDict,
)


def main():
parser = argparse.ArgumentParser(description="Block rectangular meshing")
parser.add_argument(
"-i",
"--input_file",
type=str,
metavar="",
required=True,
help="Input file for meshing and geometry parameters",
default="input.json",
)
parser.add_argument(
"-o",
"--output_folder",
type=str,
metavar="",
required=True,
help="Output folder for blockMeshDict",
default="system",
)
args = parser.parse_args()
geomDict = assemble_geom(args.input_file)
meshDict = assemble_mesh(args.input_file)
writeBlockMeshDict(args.output_folder, geomDict, meshDict)


if __name__ == "__main__":
main()
6 changes: 6 additions & 0 deletions bird/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
BIRD_BLOCK_CYL_CASE_TEMP_DIR = os.path.join(
BIRD_MESH_DIR, "block_cyl_case_templates"
)
BIRD_BLOCK_RECT_MESH_TEMP_DIR = os.path.join(
BIRD_MESH_DIR, "block_rect_mesh_templates"
)
BIRD_BLOCK_RECT_CASE_TEMP_DIR = os.path.join(
BIRD_MESH_DIR, "block_rect_case_templates"
)
BIRD_STIR_TANK_MESH_TEMP_DIR = os.path.join(
BIRD_MESH_DIR, "stir_tank_mesh_templates"
)
Expand Down
32 changes: 0 additions & 32 deletions bird/meshing/_mesh_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,38 +32,6 @@ 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):
# Add blocks that connect end points
if iend == 0:
# Make sure to not add endPoint if already there
if list(end_block) not in fluid_blocks:
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
# Add blocks until next end point is found
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 = []
Expand Down
Loading

0 comments on commit fd39ce0

Please sign in to comment.