Skip to content

Commit c7b3ad3

Browse files
committed
tests
1 parent c09bb79 commit c7b3ad3

File tree

1 file changed

+15
-26
lines changed

1 file changed

+15
-26
lines changed

tests/firedrake/multigrid/test_poisson_gmg_extruded.py

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
import pytest
33

44

5-
def run_poisson(typ):
6-
if typ == "mg":
5+
def run_poisson(solver_type, periodic=False):
6+
if solver_type == "mg":
77
parameters = {"snes_type": "ksponly",
88
"ksp_type": "preonly",
99
"pc_type": "mg",
1010
"pc_mg_type": "full",
1111
"mg_levels_ksp_type": "chebyshev",
1212
"mg_levels_ksp_max_it": 2,
1313
"mg_levels_pc_type": "jacobi"}
14-
elif typ == "fas":
14+
elif solver_type == "fas":
1515
parameters = {"snes_type": "fas",
1616
"snes_fas_type": "full",
1717
"fas_coarse_snes_type": "ksponly",
@@ -25,7 +25,7 @@ def run_poisson(typ):
2525
"fas_levels_ksp_convergence_test": "skip",
2626
"snes_max_it": 1,
2727
"snes_convergence_test": "skip"}
28-
elif typ == "newtonfas":
28+
elif solver_type == "newtonfas":
2929
parameters = {"snes_type": "newtonls",
3030
"ksp_type": "preonly",
3131
"pc_type": "none",
@@ -47,22 +47,21 @@ def run_poisson(typ):
4747
"npc_snes_max_it": 1,
4848
"npc_snes_convergence_test": "skip"}
4949
else:
50-
raise RuntimeError("Unknown parameter set '%s' request", typ)
50+
raise RuntimeError("Unknown parameter set '%s' request", solver_type)
5151

5252
N = 10
5353
base = UnitIntervalMesh(N)
5454
basemh = MeshHierarchy(base, 2)
55-
mh = ExtrudedMeshHierarchy(basemh, height=1, base_layer=N)
55+
mh = ExtrudedMeshHierarchy(basemh, height=1, base_layer=N, periodic=periodic)
5656

5757
V = FunctionSpace(mh[-1], 'CG', 2)
5858

5959
u = Function(V)
6060
f = Function(V)
6161
v = TestFunction(V)
6262
F = inner(grad(u), grad(v))*dx - inner(f, v)*dx
63-
bcs = [DirichletBC(V, 0, "on_boundary"),
64-
DirichletBC(V, 0, "top"),
65-
DirichletBC(V, 0, "bottom")]
63+
subs = ("on_boundary",) if periodic else ("on_boundary", "top", "bottom")
64+
bcs = [DirichletBC(V, 0, sub) for sub in subs]
6665
# Choose a forcing function such that the exact solution is not an
6766
# eigenmode. This stresses the preconditioner much more. e.g. 10
6867
# iterations of ilu fails to converge this problem sufficiently.
@@ -77,22 +76,12 @@ def run_poisson(typ):
7776
return norm(assemble(exact - u))
7877

7978

80-
@pytest.mark.parametrize("typ",
81-
["mg", "fas", "newtonfas"])
82-
def test_poisson_gmg(typ):
83-
assert run_poisson(typ) < 4e-6
79+
@pytest.mark.parallel([1, 3])
80+
@pytest.mark.parametrize("solver_type", ["mg", "fas", "newtonfas"])
81+
def test_poisson_gmg(solver_type):
82+
assert run_poisson(solver_type) < 4e-6
8483

8584

86-
@pytest.mark.parallel
87-
def test_poisson_gmg_parallel_mg():
88-
assert run_poisson("mg") < 4e-6
89-
90-
91-
@pytest.mark.parallel
92-
def test_poisson_gmg_parallel_fas():
93-
assert run_poisson("fas") < 4e-6
94-
95-
96-
@pytest.mark.parallel
97-
def test_poisson_gmg_parallel_newtonfas():
98-
assert run_poisson("newtonfas") < 4e-6
85+
@pytest.mark.parallel([1, 3])
86+
def test_poisson_gmg_periodic():
87+
assert run_poisson("mg", periodic=True) < 4e-6

0 commit comments

Comments
 (0)