Skip to content

Commit

Permalink
Add moving mesh with diameter meshing
Browse files Browse the repository at this point in the history
  • Loading branch information
hkjeldsberg committed Oct 24, 2023
1 parent 5982e2d commit 4abcfb3
Showing 1 changed file with 55 additions and 54 deletions.
109 changes: 55 additions & 54 deletions tests/test_pre_processing.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from os import path, remove
import shutil
from os import path, remove, listdir

from dolfin import Mesh

Expand Down Expand Up @@ -73,53 +74,16 @@ def test_mesh_model_with_one_inlet_and_two_outlets():
remove(output_file)


def test_mesh_model_with_constant_edge_length():
model_path = "tests/test_data/artery/artery.stl"
# Get default input parameters
common_input = read_command_line(model_path)
common_input.update(dict(meshing_method="constant",
edge_length=0.35,
smoothing_method="laplace",
refine_region=False,
visualize=False,
compress_mesh=False,
outlet_flow_extension_length=1,
inlet_flow_extension_length=1
))

# Run pre processing
run_pre_processing(**common_input)

model_name = model_path.replace(".stl", "")

# Check that output files exist
output_files = [model_name + suffix for suffix in ['.vtu', '.xml', '_info.json', '_probe_point.json']]
check_files(output_files)

num_points = 6944
num_cells = 38647
check_mesh(output_files, num_points=num_points, num_cells=num_cells)

# Remove output files
for output_file in output_files:
remove(output_file)


#
#
# def test_moving_domain_meshing():
# def test_mesh_model_with_constant_edge_length():
# model_path = "tests/test_data/artery/artery.stl"
# # Get default input parameters
# common_input = read_command_line(model_path)
# common_input.update(dict(meshing_method="constant",
# edge_length=0.35,
# coarsening_factor = 1.3,
# smoothing_method="laplace",
# moving_mesh=True,
# clamp_boundaries=True,
# refine_region=False,
# visualize=False,
# compress_mesh=False,
# add_boundary_layer=False,
# outlet_flow_extension_length=1,
# inlet_flow_extension_length=1
# ))
Expand All @@ -129,27 +93,64 @@ def test_mesh_model_with_constant_edge_length():
#
# model_name = model_path.replace(".stl", "")
#
# # Check that output files exist (standard output files plus artery_points.np)
# # Check that output files exist
# output_files = [model_name + suffix for suffix in ['.vtu', '.xml', '_info.json', '_probe_point.json']]
# check_files(output_files)
#
# # Check moving domain meshing files
# displacement_file = [model_name + "_points.np"]
# check_files(displacement_file)
#
# extended_folder = model_name + "_extended"
# assert path.exists(extended_folder)
# assert listdir(extended_folder) != []
#
# # num_points = 3982
# # num_cells = 21619
# # check_mesh(output_files, num_points=num_points, num_cells=num_cells)
# num_points = 6944
# num_cells = 38647
# check_mesh(output_files, num_points=num_points, num_cells=num_cells)
#
# # Remove output files
# for output_file in output_files + displacement_file:
# for output_file in output_files:
# remove(output_file)


#
# shutil.rmtree(extended_folder)
#
def test_moving_domain_meshing():
model_path = "tests/test_data/artery/artery.stl"
# Get default input parameters
common_input = read_command_line(model_path)
common_input.update(dict(meshing_method="diameter",
coarsening_factor=1.3,
smoothing_method="laplace",
moving_mesh=True,
clamp_boundaries=True,
refine_region=False,
visualize=False,
compress_mesh=False,
add_boundary_layer=False,
outlet_flow_extension_length=1,
inlet_flow_extension_length=1
))

# Run pre processing
run_pre_processing(**common_input)

model_name = model_path.replace(".stl", "")

# Check that output files exist (standard output files plus artery_points.np)
output_files = [model_name + suffix for suffix in ['.vtu', '.xml', '_info.json', '_probe_point.json']]
check_files(output_files)

# Check moving domain meshing files
displacement_file = [model_name + "_points.np"]
check_files(displacement_file)

extended_folder = model_name + "_extended"
assert path.exists(extended_folder)
assert listdir(extended_folder) != []

num_points = 3180
num_cells = 17065
check_mesh(output_files, num_points=num_points, num_cells=num_cells)

# Remove output files
for output_file in output_files + displacement_file:
remove(output_file)

shutil.rmtree(extended_folder)


def check_files(output_files):
Expand Down

0 comments on commit 4abcfb3

Please sign in to comment.