22from firedrake .preconditioners .base import PCBase
33import firedrake .dmhooks as dmhooks
44
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-
105
116__all__ = ['GTMGPC' ]
127
@@ -17,6 +12,11 @@ class GTMGPC(PCBase):
1712 _prefix = "gt_"
1813
1914 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
2020
2121 _ , P = pc .getOperators ()
2222 appctx = self .get_appctx (pc )
@@ -37,7 +37,6 @@ def initialize(self, pc):
3737
3838 # Handle the fine operator if type is python
3939 if P .getType () == "python" :
40- from firedrake .assemble import get_assembler
4140 ictx = P .getPythonContext ()
4241 if ictx is None :
4342 raise ValueError ("No context found on matrix" )
@@ -103,12 +102,11 @@ def initialize(self, pc):
103102
104103 interp_petscmat = appctx .get ("interpolation_matrix" , None )
105104 if interp_petscmat is None :
106- from firedrake .assemble import assemble
107105 # Create interpolation matrix from coarse space to fine space
108106 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
112110
113111 # We set up a PCMG object that uses the constructed interpolation
114112 # matrix to generate the restriction/prolongation operators.
0 commit comments