Skip to content

Commit 7a61760

Browse files
authored
BUG: use native prolongation for KMV elements (#4747)
* BUG: use native prolongation for KMV elements
1 parent 0b2e523 commit 7a61760

File tree

2 files changed

+38
-51
lines changed

2 files changed

+38
-51
lines changed

firedrake/mg/embedded.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
__all__ = ("TransferManager", )
1111

1212

13-
native_families = frozenset(["Lagrange", "Discontinuous Lagrange", "Real", "Q", "DQ", "BrokenElement", "Crouzeix-Raviart"])
13+
native_families = frozenset(["Lagrange", "Discontinuous Lagrange", "Real", "Q", "DQ", "BrokenElement", "Crouzeix-Raviart", "Kong-Mulder-Veldhuizen"])
1414
alfeld_families = frozenset(["Hsieh-Clough-Tocher", "Reduced-Hsieh-Clough-Tocher", "Johnson-Mercier",
1515
"Alfeld-Sorokina", "Arnold-Qin", "Reduced-Arnold-Qin", "Christiansen-Hu",
1616
"Guzman-Neilan", "Guzman-Neilan Bubble"])

tests/firedrake/multigrid/test_grid_transfer.py

Lines changed: 37 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,7 @@ def shape(request):
6666

6767
@pytest.fixture(params=["injection", "restriction", "prolongation"])
6868
def transfer_type(request, hierarchy):
69-
if not hierarchy.nested and request.param == "injection":
70-
return pytest.mark.xfail(reason="Supermesh projections not implemented yet")(request.param)
71-
else:
72-
return request.param
69+
return request.param
7370

7471

7572
@pytest.fixture
@@ -167,19 +164,35 @@ def functional(victim, dual):
167164
assert numpy.allclose(fine_functional, coarse_functional)
168165

169166

170-
def test_grid_transfer(hierarchy, shape, space, degrees, transfer_type):
171-
if not hierarchy.nested and transfer_type == "injection":
167+
def run_transfer(mh, shp, family, deg, transfer_op):
168+
if not mh.nested and mh.refinements_per_level > 1:
172169
pytest.skip("Not implemented")
173-
if transfer_type == "injection":
174-
if space in {"DG", "DQ"} and complex_mode:
170+
if transfer_op == "injection":
171+
if not mh.nested:
172+
pytest.skip("Supermesh projections not implemented yet")
173+
if family in {"DG", "DQ"} and complex_mode:
175174
with pytest.raises(NotImplementedError):
176-
run_injection(hierarchy, shape, space, degrees)
175+
run_injection(mh, shp, family, deg)
177176
else:
178-
run_injection(hierarchy, shape, space, degrees)
179-
elif transfer_type == "restriction":
180-
run_restriction(hierarchy, shape, space, degrees)
181-
elif transfer_type == "prolongation":
182-
run_prolongation(hierarchy, shape, space, degrees)
177+
run_injection(mh, shp, family, deg)
178+
elif transfer_op == "restriction":
179+
run_restriction(mh, shp, family, deg)
180+
elif transfer_op == "prolongation":
181+
run_prolongation(mh, shp, family, deg)
182+
else:
183+
raise ValueError(f"Invalid transfer {transfer_op}")
184+
185+
186+
def test_grid_transfer(hierarchy, shape, space, degrees, transfer_type):
187+
run_transfer(hierarchy, shape, space, degrees, transfer_type)
188+
189+
190+
@pytest.mark.parallel(nprocs=2)
191+
def test_grid_transfer_parallel(hierarchy, transfer_type):
192+
space = "CG"
193+
degrees = (1, 2, 3)
194+
shape = "scalar"
195+
run_transfer(hierarchy, shape, space, degrees, transfer_type)
183196

184197

185198
@pytest.mark.parallel([1, 2])
@@ -191,35 +204,18 @@ def test_grid_transfer_symmetric(transfer_type):
191204
space = "Lagrange"
192205
degrees = (1,)
193206
shape = "symmetric-tensor"
194-
if transfer_type == "injection":
195-
if space in {"DG", "DQ"} and complex_mode:
196-
with pytest.raises(NotImplementedError):
197-
run_injection(hierarchy, shape, space, degrees)
198-
else:
199-
run_injection(hierarchy, shape, space, degrees)
200-
elif transfer_type == "restriction":
201-
run_restriction(hierarchy, shape, space, degrees)
202-
elif transfer_type == "prolongation":
203-
run_prolongation(hierarchy, shape, space, degrees)
207+
run_transfer(hierarchy, shape, space, degrees, transfer_type)
204208

205209

206-
@pytest.mark.parallel(nprocs=2)
207-
def test_grid_transfer_parallel(hierarchy, transfer_type):
208-
space = "CG"
209-
degrees = (1, 2, 3)
210+
@pytest.mark.parametrize("transfer_type", ["prolongation", "restriction", "injection"])
211+
def test_grid_transfer_KMV(transfer_type):
212+
base = UnitSquareMesh(3, 3)
213+
hierarchy = MeshHierarchy(base, 1)
214+
215+
space = "KMV"
216+
degrees = (2, 5)
210217
shape = "scalar"
211-
if not hierarchy.nested and hierarchy.refinements_per_level > 1:
212-
pytest.skip("Not implemented")
213-
if transfer_type == "injection":
214-
if space in {"DG", "DQ"} and complex_mode:
215-
with pytest.raises(NotImplementedError):
216-
run_injection(hierarchy, shape, space, degrees)
217-
else:
218-
run_injection(hierarchy, shape, space, degrees)
219-
elif transfer_type == "restriction":
220-
run_restriction(hierarchy, shape, space, degrees)
221-
elif transfer_type == "prolongation":
222-
run_prolongation(hierarchy, shape, space, degrees)
218+
run_transfer(hierarchy, shape, space, degrees, transfer_type)
223219

224220

225221
@pytest.fixture(params=["interval-interval",
@@ -283,16 +279,7 @@ def test_grid_transfer_deformed(deformed_hierarchy, deformed_transfer_type):
283279
shape = "scalar"
284280
if not deformed_hierarchy.nested and deformed_transfer_type == "injection":
285281
pytest.skip("Not implemented")
286-
if deformed_transfer_type == "injection":
287-
if space in {"DG", "DQ"} and complex_mode:
288-
with pytest.raises(NotImplementedError):
289-
run_injection(deformed_hierarchy, shape, space, degrees[:1])
290-
else:
291-
run_injection(deformed_hierarchy, shape, space, degrees[:1])
292-
elif deformed_transfer_type == "restriction":
293-
run_restriction(deformed_hierarchy, shape, space, degrees)
294-
elif deformed_transfer_type == "prolongation":
295-
run_prolongation(deformed_hierarchy, shape, space, degrees)
282+
run_transfer(deformed_hierarchy, shape, space, degrees[:1], deformed_transfer_type)
296283

297284

298285
@pytest.fixture(params=["interval", "triangle", "quadrilateral", "tetrahedron"], scope="module")

0 commit comments

Comments
 (0)