2
2
from firedrake import *
3
3
4
4
5
- def run_facet_split (quadrilateral , pc_type , refine = 2 ):
5
+ def run_facet_split (quadrilateral , pc_type , refine = 2 , betas = None ):
6
+ if betas is None :
7
+ betas = [0 ]
6
8
if pc_type == "lu" :
7
9
parameters = {
8
10
"mat_type" : "matfree" ,
@@ -17,6 +19,7 @@ def run_facet_split(quadrilateral, pc_type, refine=2):
17
19
"pc_fieldsplit_schur_precondition" : "selfp" ,
18
20
"fieldsplit_0_pc_type" : "jacobi" ,
19
21
"fieldsplit_1_pc_type" : "lu" ,
22
+ "fieldsplit_ksp_type" : "preonly" ,
20
23
},
21
24
}
22
25
elif pc_type == "jacobi" :
@@ -37,6 +40,26 @@ def run_facet_split(quadrilateral, pc_type, refine=2):
37
40
"fieldsplit_1_ksp_rtol" : 1E-12 ,
38
41
},
39
42
}
43
+ elif pc_type == "fdm" :
44
+ parameters = {
45
+ "mat_type" : "matfree" ,
46
+ "ksp_type" : "preonly" ,
47
+ "pc_type" : "python" ,
48
+ "pc_python_type" : "firedrake.FacetSplitPC" ,
49
+ "facet" : {
50
+ "mat_type" : "submatrix" ,
51
+ "pc_type" : "fieldsplit" ,
52
+ "pc_fieldsplit_type" : "schur" ,
53
+ "pc_fieldsplit_schur_fact_type" : "full" ,
54
+ "pc_fieldsplit_schur_precondition" : "a11" ,
55
+ "fieldsplit_0_pc_type" : "jacobi" ,
56
+ "fieldsplit_1_pc_type" : "python" ,
57
+ "fieldsplit_1_pc_python_type" : "firedrake.FDMPC" ,
58
+ "fieldsplit_1_fdm_static_condensation" : True ,
59
+ "fieldsplit_1_fdm_pc_type" : "lu" ,
60
+ "fieldsplit_ksp_type" : "preonly" ,
61
+ },
62
+ }
40
63
41
64
r = refine
42
65
variant = "fdm" if quadrilateral else None
@@ -46,15 +69,21 @@ def run_facet_split(quadrilateral, pc_type, refine=2):
46
69
u = TrialFunction (V )
47
70
v = TestFunction (V )
48
71
uh = Function (V )
49
-
50
- a = inner (grad (u ), grad (v )) * dx
51
- L = inner (Constant (0 ), v ) * dx
52
72
x = SpatialCoordinate (mesh )
53
73
u_exact = 42 * x [1 ]
54
74
bcs = [DirichletBC (V , Constant (0 ), 3 ),
55
75
DirichletBC (V , Constant (42 ), 4 )]
56
76
57
- solve (a == L , uh , bcs = bcs , solver_parameters = parameters )
77
+ beta = Constant (0 )
78
+ a = inner (grad (u ), grad (v )) * dx + inner (u * beta , v ) * dx
79
+ L = inner (u_exact * beta , v ) * dx
80
+ problem = LinearVariationalProblem (a , L , uh , bcs = bcs )
81
+ solver = LinearVariationalSolver (problem , solver_parameters = parameters )
82
+ for val in betas :
83
+ beta .assign (val )
84
+ uh .assign (0 )
85
+ solver .solve ()
86
+
58
87
return sqrt (assemble (inner (uh - u_exact , uh - u_exact ) * dx ))
59
88
60
89
@@ -68,3 +97,9 @@ def test_facet_split(quadrilateral, pc_type):
68
97
@pytest .mark .parametrize ("pc_type" , ["lu" , "jacobi" ])
69
98
def test_facet_split_parallel (pc_type ):
70
99
assert run_facet_split (True , pc_type , refine = 3 ) < 1E-10
100
+
101
+
102
+ @pytest .mark .parametrize ("quadrilateral" , [True ])
103
+ @pytest .mark .parametrize ("pc_type" , ["fdm" ])
104
+ def test_facet_split_update (quadrilateral , pc_type ):
105
+ assert run_facet_split (quadrilateral , pc_type , refine = 4 , betas = [1E4 , 0 ]) < 1E-10
0 commit comments