diff --git a/meshmode/mesh/refinement/__init__.py b/meshmode/mesh/refinement/__init__.py index 0d7b29b31d57387063a907e14f8f961a02e05d7a..e911a4060ab7f452c1fd3b0088e7a12aa5a42932 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=False): + 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 diff --git a/test/test_refinement.py b/test/test_refinement.py index 8914bc5716315b68624f5a4c541e315e26a59214..5e10a9462ae7b1aa195227a58950ec69482775ff 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: