From 2c198ca76e04ef1bd752828c6fded2c8771d49c2 Mon Sep 17 00:00:00 2001 From: simbilod Date: Mon, 30 Dec 2024 10:48:18 -0800 Subject: [PATCH 1/4] add test fuse case --- tests/test_fuse.py | 46 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/tests/test_fuse.py b/tests/test_fuse.py index 46c6f64..60154c2 100644 --- a/tests/test_fuse.py +++ b/tests/test_fuse.py @@ -7,6 +7,8 @@ import numpy as np from meshwell.utils import compare_meshes from pathlib import Path +from shapely.geometry import box +from meshwell.resolution import ThresholdField def test_fuse(): @@ -61,5 +63,47 @@ def test_fuse(): compare_meshes(Path("mesh_unfused.msh")) +def test_different_resolutions_same_physical(): + model = Model() + + # Create two different boxes + box1 = box(0, 0, 1, 1) + box2 = box(2, 0, 3, 1) + + # Create resolution specifications + resolution1 = ThresholdField( + apply_to="surfaces", sizemin=0.1, sizemax=0.5, distmax=0.2 + ) + + resolution2 = ThresholdField( + apply_to="surfaces", sizemin=0.2, sizemax=1.0, distmax=0.4 + ) + + # Create two polysurfaces with same physical name but different resolutions + surface1 = PolySurface( + polygons=box1, + model=model, + physical_name="test_surface", + resolutions=[resolution1], + ) + + surface2 = PolySurface( + polygons=box2, + model=model, + physical_name="test_surface", + resolutions=[resolution2], + ) + + # Mesh the model + model.mesh( + entities_list=[surface1, surface2], + default_characteristic_length=0.5, + filename="test_different_resolutions_same_physical.msh", + ) + + compare_meshes(Path("test_different_resolutions_same_physical.msh")) + + if __name__ == "__main__": - test_fuse() + # test_fuse() + test_different_resolutions_same_physical() From 40d1b196af7d5c969e4961018f4c1264f9ebb291 Mon Sep 17 00:00:00 2001 From: simbilod Date: Mon, 30 Dec 2024 10:48:51 -0800 Subject: [PATCH 2/4] update reference --- tests/generate_references.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/generate_references.sh b/tests/generate_references.sh index f48a9f2..4b058c0 100644 --- a/tests/generate_references.sh +++ b/tests/generate_references.sh @@ -6,7 +6,7 @@ source .venv/bin/activate # Install reference version of the package in editable mode sudo apt-get install libglu1-mesa -uv pip install git+https://github.com/simbilod/meshwell.git@be4fc001cd573982690c178eb9334b41f64decdd[dev] +uv pip install git+https://github.com/simbilod/meshwell.git@2c198ca76e04ef1bd752828c6fded2c8771d49c2[dev] # Execute all Python files in the current directory python generate_references.py --references-path ./references/ From ee10c5ab5da9c1311f5925907e08e494157c702d Mon Sep 17 00:00:00 2001 From: simbilod Date: Mon, 30 Dec 2024 11:03:34 -0800 Subject: [PATCH 3/4] freeze tthread number for determnistic test --- tests/test_fuse.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_fuse.py b/tests/test_fuse.py index 60154c2..b265f88 100644 --- a/tests/test_fuse.py +++ b/tests/test_fuse.py @@ -64,7 +64,7 @@ def test_fuse(): def test_different_resolutions_same_physical(): - model = Model() + model = Model(n_threads=1) # Create two different boxes box1 = box(0, 0, 1, 1) @@ -72,11 +72,11 @@ def test_different_resolutions_same_physical(): # Create resolution specifications resolution1 = ThresholdField( - apply_to="surfaces", sizemin=0.1, sizemax=0.5, distmax=0.2 + apply_to="curves", sizemin=0.01, sizemax=0.05, distmax=0.2 ) resolution2 = ThresholdField( - apply_to="surfaces", sizemin=0.2, sizemax=1.0, distmax=0.4 + apply_to="curves", sizemin=0.1, sizemax=0.2, distmax=0.2 ) # Create two polysurfaces with same physical name but different resolutions @@ -97,7 +97,7 @@ def test_different_resolutions_same_physical(): # Mesh the model model.mesh( entities_list=[surface1, surface2], - default_characteristic_length=0.5, + default_characteristic_length=10, filename="test_different_resolutions_same_physical.msh", ) From 2a05b86c3f695bbff603d4e132e9ce8d24bcb66d Mon Sep 17 00:00:00 2001 From: simbilod Date: Mon, 30 Dec 2024 11:04:07 -0800 Subject: [PATCH 4/4] reference commit --- tests/generate_references.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/generate_references.sh b/tests/generate_references.sh index 4b058c0..f6fa81f 100644 --- a/tests/generate_references.sh +++ b/tests/generate_references.sh @@ -6,7 +6,7 @@ source .venv/bin/activate # Install reference version of the package in editable mode sudo apt-get install libglu1-mesa -uv pip install git+https://github.com/simbilod/meshwell.git@2c198ca76e04ef1bd752828c6fded2c8771d49c2[dev] +uv pip install git+https://github.com/simbilod/meshwell.git@ee10c5ab5da9c1311f5925907e08e494157c702d[dev] # Execute all Python files in the current directory python generate_references.py --references-path ./references/