From 51663eaa6b72f99d7dc28129ca5a997f33eb405b Mon Sep 17 00:00:00 2001 From: Alexandru Fikl Date: Wed, 11 Mar 2020 19:05:46 -0500 Subject: [PATCH 1/3] refine_uniformly without adjacency too --- meshmode/mesh/refinement/__init__.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/meshmode/mesh/refinement/__init__.py b/meshmode/mesh/refinement/__init__.py index 0d7b29b3..3aeda0e8 100644 --- a/meshmode/mesh/refinement/__init__.py +++ b/meshmode/mesh/refinement/__init__.py @@ -934,14 +934,16 @@ class Refiner(object): # }}} -def refine_uniformly(mesh, iterations): +def refine_uniformly(mesh, iterations, with_adjacency=True): + if with_adjacency: refiner = Refiner(mesh) - for i in range(iterations): - flags = np.ones(mesh.nelements, dtype=bool) - refiner.refine(flags) - mesh = refiner.get_current_mesh() + else: + refiner = RefinerWithoutAdjacency(mesh) - return mesh + for _ in range(iterations): + refiner.refine_uniformly() + + return refiner.get_current_mesh() # vim: foldmethod=marker -- GitLab From 382d49ef9bf6da6939fe20b40bac082ad8da2516 Mon Sep 17 00:00:00 2001 From: Alexandru Fikl Date: Thu, 12 Mar 2020 10:34:10 -0500 Subject: [PATCH 2/3] add a simple test for refine_uniformly --- test/test_refinement.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/test_refinement.py b/test/test_refinement.py index 8914bc57..5e10a946 100644 --- a/test/test_refinement.py +++ b/test/test_refinement.py @@ -293,6 +293,18 @@ def test_refinement_connection( or eoc_rec.max_error() < 1e-14) +@pytest.mark.parametrize("with_adjacency", [True, False]) +def test_uniform_refinement(ctx_factory, with_adjacency): + make_mesh = partial(generate_box_mesh, ( + np.linspace(0.0, 1.0, 2), + np.linspace(0.0, 1.0, 3), + np.linspace(0.0, 1.0, 2)), order=4) + mesh = make_mesh() + + from meshmode.mesh.refinement import refine_uniformly + mesh = refine_uniformly(mesh, 1, with_adjacency=with_adjacency) + + if __name__ == "__main__": import sys if len(sys.argv) > 1: -- GitLab From a320c3b7cb4a63c9a2a8018509e615edb3fe46c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Kl=C3=B6ckner?= Date: Thu, 12 Mar 2020 16:45:42 +0100 Subject: [PATCH 3/3] Apply suggestion to meshmode/mesh/refinement/__init__.py --- meshmode/mesh/refinement/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meshmode/mesh/refinement/__init__.py b/meshmode/mesh/refinement/__init__.py index 3aeda0e8..e911a406 100644 --- a/meshmode/mesh/refinement/__init__.py +++ b/meshmode/mesh/refinement/__init__.py @@ -934,7 +934,7 @@ class Refiner(object): # }}} -def refine_uniformly(mesh, iterations, with_adjacency=True): +def refine_uniformly(mesh, iterations, with_adjacency=False): if with_adjacency: refiner = Refiner(mesh) else: -- GitLab