2
2
from firedrake .preconditioners .base import PCBase
3
3
import firedrake .dmhooks as dmhooks
4
4
5
- from firedrake .parameters import parameters
6
- from firedrake .interpolation import Interpolate
7
- from firedrake .solving_utils import _SNESContext
8
- from firedrake .matrix_free .operators import ImplicitMatrixContext
9
-
10
5
11
6
__all__ = ['GTMGPC' ]
12
7
@@ -17,6 +12,11 @@ class GTMGPC(PCBase):
17
12
_prefix = "gt_"
18
13
19
14
def initialize (self , pc ):
15
+ from firedrake import TestFunction , parameters
16
+ from firedrake .assemble import get_assembler
17
+ from firedrake .interpolation import Interpolator
18
+ from firedrake .solving_utils import _SNESContext
19
+ from firedrake .matrix_free .operators import ImplicitMatrixContext
20
20
21
21
_ , P = pc .getOperators ()
22
22
appctx = self .get_appctx (pc )
@@ -37,7 +37,6 @@ def initialize(self, pc):
37
37
38
38
# Handle the fine operator if type is python
39
39
if P .getType () == "python" :
40
- from firedrake .assemble import get_assembler
41
40
ictx = P .getPythonContext ()
42
41
if ictx is None :
43
42
raise ValueError ("No context found on matrix" )
@@ -103,12 +102,11 @@ def initialize(self, pc):
103
102
104
103
interp_petscmat = appctx .get ("interpolation_matrix" , None )
105
104
if interp_petscmat is None :
106
- from firedrake .assemble import assemble
107
105
# Create interpolation matrix from coarse space to fine space
108
106
fine_space = ctx .J .arguments ()[0 ].function_space ()
109
- coarse_test , coarse_trial = coarse_operator . arguments ( )
110
- interp = assemble ( Interpolate ( coarse_trial , fine_space ) )
111
- interp_petscmat = interp . petscmat
107
+ interpolator = Interpolator ( TestFunction ( coarse_space ), fine_space )
108
+ interpolation_matrix = interpolator . callable ( )
109
+ interp_petscmat = interpolation_matrix . handle
112
110
113
111
# We set up a PCMG object that uses the constructed interpolation
114
112
# matrix to generate the restriction/prolongation operators.
0 commit comments