@@ -934,7 +934,7 @@ def _submat_callback_body(self):
934934
935935 ptr = DummyExpr (objs ['submat_arr' ]._C_symbol , Deref (objs ['Submats' ]), init = True )
936936
937- mat_create = petsc_call ('MatCreate' , [self . objs ['comm' ], Byref (objs ['block' ])])
937+ mat_create = petsc_call ('MatCreate' , [sobjs ['comm' ], Byref (objs ['block' ])])
938938
939939 mat_set_sizes = petsc_call (
940940 'MatSetSizes' , [
@@ -1041,6 +1041,7 @@ def __init__(self, **kwargs):
10411041 self .injectsolve = kwargs .get ('injectsolve' )
10421042 self .objs = kwargs .get ('objs' )
10431043 self .sregistry = kwargs .get ('sregistry' )
1044+ self .comm = kwargs .get ('comm' )
10441045 self .fielddata = self .injectsolve .expr .rhs .fielddata
10451046 self .solver_objs = self ._build ()
10461047
@@ -1080,6 +1081,7 @@ def _build(self):
10801081 'dmda' : DM (sreg .make_name (prefix = 'da' ), dofs = len (targets )),
10811082 'callbackdm' : CallbackDM (sreg .make_name (prefix = 'dm' )),
10821083 }
1084+ base_dict ['comm' ] = self .comm
10831085 self ._target_dependent (base_dict )
10841086 return self ._extend_build (base_dict )
10851087
@@ -1235,7 +1237,7 @@ def _setup(self):
12351237
12361238 solver_params = self .injectsolve .expr .rhs .solver_parameters
12371239
1238- snes_create = petsc_call ('SNESCreate' , [objs ['comm' ], Byref (sobjs ['snes' ])])
1240+ snes_create = petsc_call ('SNESCreate' , [sobjs ['comm' ], Byref (sobjs ['snes' ])])
12391241
12401242 snes_set_dm = petsc_call ('SNESSetDM' , [sobjs ['snes' ], dmda ])
12411243
@@ -1261,7 +1263,7 @@ def _setup(self):
12611263 v for v , dim in zip (target .shape_allocated , target .dimensions ) if dim .is_Space
12621264 )
12631265 local_x = petsc_call ('VecCreateMPIWithArray' ,
1264- ['PETSC_COMM_WORLD' , 1 , local_size , 'PETSC_DECIDE' ,
1266+ [sobjs [ 'comm' ] , 1 , local_size , 'PETSC_DECIDE' ,
12651267 field_from_ptr , Byref (sobjs ['xlocal' ])])
12661268
12671269 # TODO: potentially also need to set the DM and local/global map to xlocal
@@ -1364,11 +1366,12 @@ def _create_dmda_calls(self, dmda):
13641366
13651367 def _create_dmda (self , dmda ):
13661368 objs = self .objs
1369+ sobjs = self .solver_objs
13671370 grid = self .fielddata .grid
13681371 nspace_dims = len (grid .dimensions )
13691372
13701373 # MPI communicator
1371- args = [objs ['comm' ]]
1374+ args = [sobjs ['comm' ]]
13721375
13731376 # Type of ghost nodes
13741377 args .extend (['DM_BOUNDARY_GHOSTED' for _ in range (nspace_dims )])
@@ -1386,7 +1389,10 @@ def _create_dmda(self, dmda):
13861389 # Number of degrees of freedom per node
13871390 args .append (dmda .dofs )
13881391 # "Stencil width" -> size of overlap
1392+ # TODO: Instead, this probably should be
1393+ # extracted from fielddata.target._size_outhalo?
13891394 stencil_width = self .fielddata .space_order
1395+
13901396 args .append (stencil_width )
13911397 args .extend ([objs ['Null' ]]* nspace_dims )
13921398
@@ -1409,7 +1415,7 @@ def _setup(self):
14091415
14101416 solver_params = self .injectsolve .expr .rhs .solver_parameters
14111417
1412- snes_create = petsc_call ('SNESCreate' , [objs ['comm' ], Byref (sobjs ['snes' ])])
1418+ snes_create = petsc_call ('SNESCreate' , [sobjs ['comm' ], Byref (sobjs ['snes' ])])
14131419
14141420 snes_set_dm = petsc_call ('SNESSetDM' , [sobjs ['snes' ], dmda ])
14151421
0 commit comments