Skip to content

Commit dde83a8

Browse files
committed
test mesh independence
1 parent f356c0f commit dde83a8

File tree

1 file changed

+22
-21
lines changed

1 file changed

+22
-21
lines changed

tests/firedrake/regression/test_bddc.py

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,15 @@
66
def bddc_params():
77
chol = {
88
"pc_type": "cholesky",
9-
"pc_factor_mat_solver_type": "petsc",
10-
"pc_factor_mat_ordering_type": "natural",
9+
"pc_factor_mat_solver_type": DEFAULT_DIRECT_SOLVER,
1110
}
1211
sp = {
1312
"mat_type": "is",
1413
"pc_type": "python",
1514
"pc_python_type": "firedrake.BDDCPC",
1615
"bddc_pc_bddc_neumann": chol,
1716
"bddc_pc_bddc_dirichlet": chol,
18-
"bddc_pc_bddc_coarse": DEFAULT_DIRECT_SOLVER,
17+
"bddc_pc_bddc_coarse": chol,
1918
}
2019
return sp
2120

@@ -126,21 +125,23 @@ def solve_riesz_map(mesh, family, degree, variant, bcs, condense=False, vector=F
126125

127126

128127
@pytest.fixture(params=(2, 3), ids=("square", "cube"))
129-
def mesh(request):
128+
def mh(request):
130129
dim = request.param
131-
nx = 4
132-
msh = UnitSquareMesh(nx, nx, quadrilateral=True)
130+
nx = 3
131+
base = UnitSquareMesh(nx, nx, quadrilateral=True)
132+
mh = MeshHierarchy(base, 1)
133133
if dim == 3:
134-
msh = ExtrudedMesh(msh, nx)
135-
return msh
134+
mh = ExtrudedMeshHierarchy(mh, height=1, base_layer=nx)
135+
return mh
136136

137137

138138
@pytest.mark.parallel
139139
@pytest.mark.parametrize("degree", range(1, 3))
140140
@pytest.mark.parametrize("variant", ("spectral", "fdm"))
141-
def test_vertex_dofs(mesh, variant, degree):
141+
def test_vertex_dofs(mh, variant, degree):
142142
"""Check that we extract the right number of vertex dofs from a high order Lagrange space."""
143143
from firedrake.preconditioners.bddc import get_restricted_dofs
144+
mesh = mh[-1]
144145
P1 = FunctionSpace(mesh, "Lagrange", 1, variant=variant)
145146
V0 = FunctionSpace(mesh, "Lagrange", degree, variant=variant)
146147
v = get_restricted_dofs(V0, "vertex")
@@ -149,31 +150,31 @@ def test_vertex_dofs(mesh, variant, degree):
149150

150151
@pytest.mark.parallel
151152
@pytest.mark.parametrize("family,degree", [("Q", 4)])
152-
def test_bddc_fdm(mesh, family, degree):
153+
def test_bddc_fdm(mh, family, degree):
154+
"""Test h-independence of condition number by measuring iteration counts"""
153155
variant = "fdm"
154156
bcs = True
155-
tdim = mesh.topological_dimension
156-
expected = 6 if tdim == 2 else 11
157-
assert solve_riesz_map(mesh, family, degree, variant, bcs) <= expected
157+
its = [solve_riesz_map(m, family, degree, variant, bcs) for m in mh]
158+
assert (np.diff(its) <= 1).all()
158159

159160

160161
@pytest.mark.parallel
161162
@pytest.mark.parametrize("family,degree", [("Q", 4)])
162163
@pytest.mark.parametrize("vector", (False, True), ids=("scalar", "vector"))
163-
def test_bddc_aij_quad(mesh, family, degree, vector):
164+
def test_bddc_aij_quad(mh, family, degree, vector):
165+
"""Test h-independence of condition number by measuring iteration counts"""
164166
variant = None
165167
bcs = True
166-
tdim = mesh.topological_dimension
167-
expected = 7 if tdim == 2 else 11
168-
assert solve_riesz_map(mesh, family, degree, variant, bcs, vector=vector) <= expected
168+
its = [solve_riesz_map(m, family, degree, variant, bcs, vector=vector) for m in mh]
169+
assert (np.diff(its) <= 1).all()
169170

170171

171172
@pytest.mark.parallel
172173
@pytest.mark.parametrize("family,degree", [("CG", 3), ("N1curl", 3), ("N1div", 3)])
173174
def test_bddc_aij_simplex(family, degree):
174-
nx = 4
175-
mesh = UnitCubeMesh(nx, nx, nx)
175+
"""Test h-independence of condition number by measuring iteration counts"""
176176
variant = None
177177
bcs = True
178-
expected = {"CG": 13, "N1curl": 14, "N1div": 12}[family]
179-
assert solve_riesz_map(mesh, family, degree, variant, bcs) <= expected
178+
meshes = [UnitCubeMesh(nx, nx, nx) for nx in (3, 6)]
179+
its = [solve_riesz_map(m, family, degree, variant, bcs) for m in meshes]
180+
assert (np.diff(its) <= 1).all()

0 commit comments

Comments
 (0)