Skip to content

Commit

Permalink
Change to adaptive number of boundary points and add test for moving …
Browse files Browse the repository at this point in the history
…domain meshing + data
  • Loading branch information
hkjeldsberg committed Oct 24, 2023
1 parent b7e4a25 commit 88520a3
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/vampy/automatedPreprocessing/preprocessing_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Binary file modified tests/test_data/artery/artery.stl
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
70 changes: 58 additions & 12 deletions tests/test_pre_processing.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os
from os import path
import shutil
from os import path, listdir, remove

from dolfin import Mesh

Expand All @@ -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
Expand All @@ -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():
Expand Down Expand Up @@ -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():
Expand All @@ -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):
Expand All @@ -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()

0 comments on commit 88520a3

Please sign in to comment.