@@ -66,10 +66,7 @@ def shape(request):
6666
6767@pytest .fixture (params = ["injection" , "restriction" , "prolongation" ])
6868def 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
@@ -126,7 +123,6 @@ def run_prolongation(hierarchy, shape, space, degrees, exact=exact_primal):
126123
127124 mesh = hierarchy [0 ]
128125 V = FunctionSpace (mesh , Ve )
129-
130126 actual = assemble (interpolate (exact (mesh , shape , degree ), V ))
131127
132128 for mesh in hierarchy [1 :]:
@@ -167,19 +163,35 @@ def functional(victim, dual):
167163 assert numpy .allclose (fine_functional , coarse_functional )
168164
169165
170- def test_grid_transfer ( hierarchy , shape , space , degrees , transfer_type ):
171- if not hierarchy .nested and transfer_type == "injection" :
166+ def run_transfer ( mh , shp , family , deg , transfer_op ):
167+ if not mh .nested and mh . refinements_per_level > 1 :
172168 pytest .skip ("Not implemented" )
173- if transfer_type == "injection" :
174- if space in {"DG" , "DQ" } and complex_mode :
169+ if transfer_op == "injection" :
170+ if not mh .nested :
171+ pytest .skip ("Supermesh projections not implemented yet" )
172+ if family in {"DG" , "DQ" } and complex_mode :
175173 with pytest .raises (NotImplementedError ):
176- run_injection (hierarchy , shape , space , degrees )
174+ run_injection (mh , shp , family , deg )
177175 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 )
176+ run_injection (mh , shp , family , deg )
177+ elif transfer_op == "restriction" :
178+ run_restriction (mh , shp , family , deg )
179+ elif transfer_op == "prolongation" :
180+ run_prolongation (mh , shp , family , deg )
181+ else :
182+ raise ValueError (f"Invalid transfer { transfer_op } " )
183+
184+
185+ def test_grid_transfer (hierarchy , shape , space , degrees , transfer_type ):
186+ run_transfer (hierarchy , shape , space , degrees , transfer_type )
187+
188+
189+ @pytest .mark .parallel (nprocs = 2 )
190+ def test_grid_transfer_parallel (hierarchy , transfer_type ):
191+ space = "CG"
192+ degrees = (1 , 2 , 3 )
193+ shape = "scalar"
194+ run_transfer (hierarchy , shape , space , degrees , transfer_type )
183195
184196
185197@pytest .mark .parallel ([1 , 2 ])
@@ -191,35 +203,18 @@ def test_grid_transfer_symmetric(transfer_type):
191203 space = "Lagrange"
192204 degrees = (1 ,)
193205 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 )
206+ run_transfer (hierarchy , shape , space , degrees , transfer_type )
204207
205208
206- @pytest .mark .parallel (nprocs = 2 )
207- def test_grid_transfer_parallel (hierarchy , transfer_type ):
208- space = "CG"
209- degrees = (1 , 2 , 3 )
209+ @pytest .mark .parametrize ("transfer_type" , ["prolongation" , "restriction" , "injection" ])
210+ def test_grid_transfer_KMV (transfer_type ):
211+ base = UnitSquareMesh (3 , 3 )
212+ hierarchy = MeshHierarchy (base , 1 )
213+
214+ space = "KMV"
215+ degrees = (2 , 5 )
210216 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 )
217+ run_transfer (hierarchy , shape , space , degrees , transfer_type )
223218
224219
225220@pytest .fixture (params = ["interval-interval" ,
@@ -283,16 +278,7 @@ def test_grid_transfer_deformed(deformed_hierarchy, deformed_transfer_type):
283278 shape = "scalar"
284279 if not deformed_hierarchy .nested and deformed_transfer_type == "injection" :
285280 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 )
281+ run_transfer (deformed_transfer_type , deformed_hierarchy , shape , space , degrees [:1 ])
296282
297283
298284@pytest .fixture (params = ["interval" , "triangle" , "quadrilateral" , "tetrahedron" ], scope = "module" )
0 commit comments