diff --git a/src/vampy/automatedPreprocessing/preprocessing_common.py b/src/vampy/automatedPreprocessing/preprocessing_common.py index 32efc885..917a4ad7 100644 --- a/src/vampy/automatedPreprocessing/preprocessing_common.py +++ b/src/vampy/automatedPreprocessing/preprocessing_common.py @@ -801,7 +801,7 @@ def add_flow_extension(surface, centerlines, is_inlet, extension_length=2.0, ext flowExtensionsFilter.SetInputData(surface) flowExtensionsFilter.SetCenterlines(centerlines) flowExtensionsFilter.SetAdaptiveExtensionLength(1) - flowExtensionsFilter.SetAdaptiveNumberOfBoundaryPoints(0) + flowExtensionsFilter.SetAdaptiveNumberOfBoundaryPoints(1) flowExtensionsFilter.SetExtensionRatio(extension_length) flowExtensionsFilter.SetTransitionRatio(1.0) flowExtensionsFilter.SetCenterlineNormalEstimationDistanceRatio(1.0) diff --git a/tests/test_data/artery/artery.stl b/tests/test_data/artery/artery.stl index d5a651ec..8e203b4f 100644 Binary files a/tests/test_data/artery/artery.stl and b/tests/test_data/artery/artery.stl differ diff --git a/tests/test_data/artery/artery_moved/artery_moved_00.stl b/tests/test_data/artery/artery_moved/artery_moved_00.stl new file mode 100644 index 00000000..8e203b4f Binary files /dev/null and b/tests/test_data/artery/artery_moved/artery_moved_00.stl differ diff --git a/tests/test_data/artery/artery_moved/artery_moved_01.stl b/tests/test_data/artery/artery_moved/artery_moved_01.stl new file mode 100644 index 00000000..a5811fbd Binary files /dev/null and b/tests/test_data/artery/artery_moved/artery_moved_01.stl differ diff --git a/tests/test_data/artery/artery_moved/artery_moved_02.stl b/tests/test_data/artery/artery_moved/artery_moved_02.stl new file mode 100644 index 00000000..658eb538 Binary files /dev/null and b/tests/test_data/artery/artery_moved/artery_moved_02.stl differ diff --git a/tests/test_data/artery/artery_moved/artery_moved_03.stl b/tests/test_data/artery/artery_moved/artery_moved_03.stl new file mode 100644 index 00000000..c80aec83 Binary files /dev/null and b/tests/test_data/artery/artery_moved/artery_moved_03.stl differ diff --git a/tests/test_data/artery/artery_moved/artery_moved_04.stl b/tests/test_data/artery/artery_moved/artery_moved_04.stl new file mode 100644 index 00000000..6d0fa975 Binary files /dev/null and b/tests/test_data/artery/artery_moved/artery_moved_04.stl differ diff --git a/tests/test_pre_processing.py b/tests/test_pre_processing.py index 0e2ff1a2..e35dd948 100644 --- a/tests/test_pre_processing.py +++ b/tests/test_pre_processing.py @@ -1,5 +1,5 @@ -import os -from os import path +import shutil +from os import path, listdir, remove from dolfin import Mesh @@ -16,7 +16,7 @@ def test_mesh_model_with_one_inlet(): smoothing_method="taubin", refine_region=False, coarsening_factor=1.3, - visualize=True, + visualize=False, compress_mesh=False, outlet_flow_extension_length=1, inlet_flow_extension_length=1 @@ -31,13 +31,13 @@ def test_mesh_model_with_one_inlet(): output_files = [model_name + suffix for suffix in ['.vtu', '.xml', '_info.json', '_probe_point.json']] check_files(output_files) - num_points = 3473 - num_cells = 19208 + num_points = 3524 + num_cells = 19465 check_mesh(output_files, num_points=num_points, num_cells=num_cells) # Remove output files for output_file in output_files: - os.remove(output_file) + remove(output_file) def test_mesh_model_with_one_inlet_and_two_outlets(): @@ -65,13 +65,13 @@ def test_mesh_model_with_one_inlet_and_two_outlets(): check_files(output_files) # Check that mesh is not empty with VTK/morphMan and FEniCS and contains correct amount of points and cells - num_points = 13247 - num_cells = 74861 + num_points = 12908 + num_cells = 72688 check_mesh(output_files, num_points=num_points, num_cells=num_cells) # Remove output files for output_file in output_files: - os.remove(output_file) + remove(output_file) def test_mesh_model_with_constant_edge_length(): @@ -97,13 +97,58 @@ def test_mesh_model_with_constant_edge_length(): output_files = [model_name + suffix for suffix in ['.vtu', '.xml.gz', '_info.json', '_probe_point.json']] check_files(output_files) - num_points = 6964 - num_cells = 38531 + 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: - os.remove(output_file) + remove(output_file) + + +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="constant", + edge_length=0.35, + smoothing_method="laplace", + moving_mesh=True, + clamp_boundaries=True, + refine_region=False, + visualize=False, + compress_mesh=True, + 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.gz', '_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) + + # Remove output files + for output_file in output_files + displacement_file: + remove(output_file) + + shutil.rmtree(extended_folder) def check_files(output_files): @@ -128,3 +173,4 @@ def check_mesh(output_files, num_points, num_cells): test_mesh_model_with_one_inlet() test_mesh_model_with_one_inlet_and_two_outlets() test_mesh_model_with_constant_edge_length() + test_moving_domain_meshing()