From 4abcfb3fc24157a5dc9b7530cec01f16709255e9 Mon Sep 17 00:00:00 2001 From: Henrik Kjedsberg Date: Tue, 24 Oct 2023 21:51:48 +0200 Subject: [PATCH] Add moving mesh with diameter meshing --- tests/test_pre_processing.py | 109 ++++++++++++++++++----------------- 1 file changed, 55 insertions(+), 54 deletions(-) diff --git a/tests/test_pre_processing.py b/tests/test_pre_processing.py index 63eeca5a..061a403b 100644 --- a/tests/test_pre_processing.py +++ b/tests/test_pre_processing.py @@ -1,4 +1,5 @@ -from os import path, remove +import shutil +from os import path, remove, listdir from dolfin import Mesh @@ -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 # )) @@ -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):