@@ -127,8 +127,20 @@ def test_macro_grid_transfer(hierarchy, space, degrees, variant, transfer_type):
127127 run_prolongation (hierarchy , space , degrees , variant )
128128
129129
130+ mg_params = {
131+ "mat_type" : "matfree" ,
132+ "ksp_type" : "cg" ,
133+ "ksp_monitor" : None ,
134+ "pc_type" : "mg" ,
135+ "mg_levels_ksp_type" : "chebyshev" ,
136+ "mg_levels_pc_type" : "jacobi" ,
137+ "mg_coarse_pc_type" : "python" ,
138+ "mg_coarse_pc_python_type" : "firedrake.AssembledPC" ,
139+ }
140+
141+
130142@pytest .mark .parametrize ("degree" , (1 ,))
131- def test_macro_multigrid (hierarchy , degree , variant ):
143+ def test_macro_multigrid_poisson (hierarchy , degree , variant ):
132144 mesh = hierarchy [- 1 ]
133145 V = FunctionSpace (mesh , "CG" , degree , variant = variant )
134146 u = TrialFunction (V )
@@ -138,19 +150,35 @@ def test_macro_multigrid(hierarchy, degree, variant):
138150 bcs = [DirichletBC (V , 0 , "on_boundary" )]
139151
140152 uh = Function (V )
141- sp = {
142- "mat_type" : "matfree" ,
143- "ksp_type" : "cg" ,
144- "pc_type" : "mg" ,
145- "mg_levels_ksp_type" : "chebyshev" ,
146- "mg_levels_pc_type" : "jacobi" ,
147- "mg_coarse_pc_type" : "python" ,
148- "mg_coarse_pc_python_type" : "firedrake.AssembledPC" ,
149- }
150153 problem = LinearVariationalProblem (a , L , uh , bcs = bcs )
151- solver = LinearVariationalSolver (problem , solver_parameters = sp )
154+ solver = LinearVariationalSolver (problem , solver_parameters = mg_params )
152155 solver .solve ()
153156 expected = 10
154157 if mesh .geometric_dimension () == 3 and variant == "alfeld" :
155158 expected = 14
156159 assert solver .snes .ksp .getIterationNumber () <= expected
160+
161+
162+ @pytest .fixture ()
163+ def square_hierarchy ():
164+ refine = 4
165+ base = UnitSquareMesh (3 , 3 )
166+ return MeshHierarchy (base , refine )
167+
168+
169+ @pytest .mark .parametrize ("family" , ("HCT-red" , "HCT" ))
170+ def test_macro_multigrid_biharmonic (square_hierarchy , family ):
171+ mesh = square_hierarchy [- 1 ]
172+ V = FunctionSpace (mesh , family , 3 )
173+ u = TrialFunction (V )
174+ v = TestFunction (V )
175+ a = inner (div (grad (u )), div (grad (v ))) * dx
176+ L = inner (Constant (1 ), v ) * dx
177+ bcs = [DirichletBC (V , 0 , "on_boundary" )]
178+
179+ uh = Function (V )
180+ problem = LinearVariationalProblem (a , L , uh , bcs = bcs )
181+ solver = LinearVariationalSolver (problem , solver_parameters = mg_params )
182+ solver .solve ()
183+ expected = 16
184+ assert solver .snes .ksp .getIterationNumber () <= expected
0 commit comments