@@ -212,31 +212,31 @@ def setup_preconditioner(self, Dirichlet_recombination=True, left_preconditioner
212212 Dirichlet_recombination (bool): Basis conversion for right preconditioner. Useful for Chebychev and Ultraspherical methods. 10/10 would recommend.
213213 left_preconditioner (bool): If True, it will interleave the variables and reverse the Kronecker product
214214 """
215- sp = self .spectral .sparse_lib
216215 N = np .prod (self .init [0 ][1 :])
217216
218- Id = sp .eye (N )
219- Pl_lhs = {comp : {comp : Id } for comp in self .components }
220- self .Pl = self ._setup_operator (Pl_lhs )
221-
222217 if left_preconditioner :
223218 # reverse Kronecker product
224-
225219 if self .spectral .useGPU :
226- R = self . Pl . get (). tolil () * 0
220+ import scipy . sparse as sp
227221 else :
228- R = self .Pl .tolil () * 0
222+ sp = self .spectral .sparse_lib
223+
224+ R = sp .lil_matrix ((self .ncomponents * N ,) * 2 , dtype = int )
229225
230226 for j in range (self .ncomponents ):
231227 for i in range (N ):
232- R [i * self .ncomponents + j , j * N + i ] = 1.0
228+ R [i * self .ncomponents + j , j * N + i ] = 1
233229
234- self .Pl = self .spectral .sparse_lib .csc_matrix (R )
230+ self .Pl = self .spectral .sparse_lib .csc_matrix (R , dtype = complex )
231+ else :
232+ Id = self .spectral .sparse_lib .eye (N )
233+ Pl_lhs = {comp : {comp : Id } for comp in self .components }
234+ self .Pl = self ._setup_operator (Pl_lhs )
235235
236236 if Dirichlet_recombination and type (self .axes [- 1 ]).__name__ in ['ChebychevHelper' , 'UltrasphericalHelper' ]:
237237 _Pr = self .spectral .get_Dirichlet_recombination_matrix (axis = - 1 )
238238 else :
239- _Pr = Id
239+ _Pr = self . spectral . sparse_lib . eye ( N )
240240
241241 Pr_lhs = {comp : {comp : _Pr } for comp in self .components }
242242 self .Pr = self ._setup_operator (Pr_lhs ) @ self .Pl .T
@@ -393,7 +393,7 @@ def solve_system(self, rhs, dt, u0=None, *args, skip_itransform=False, **kwargs)
393393
394394 def setUpFieldsIO (self ):
395395 Rectilinear .setupMPI (
396- comm = self .comm ,
396+ comm = self .comm . commMPI if self . useGPU else self . comm ,
397397 iLoc = [me .start for me in self .local_slice (False )],
398398 nLoc = [me .stop - me .start for me in self .local_slice (False )],
399399 )
0 commit comments