Skip to content

Commit 5fc3bcd

Browse files
committed
compiler: Fix multi-field petscsolve in parallel
1 parent ec819f3 commit 5fc3bcd

4 files changed

Lines changed: 14 additions & 9 deletions

File tree

devito/petsc/iet/callbacks.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,13 +1255,16 @@ def _submat_callback_body(self):
12551255
row_idx = DummyExpr(objs['rowidx'], IntDiv(i, objs['dof']))
12561256
col_idx = DummyExpr(objs['colidx'], Mod(i, objs['dof']))
12571257

1258-
# Query global size from each sub-DM via a temporary Vec.
1258+
# Query global and local sizes from each sub-DM via a temporary Vec.
12591259
get_row_vec = petsc_call(
12601260
'DMGetGlobalVector', [objs['Subdms'].indexed[objs['rowidx']], Byref(tvec)]
12611261
)
12621262
get_row_size = petsc_call(
12631263
'VecGetSize', [tvec, Byref(objs['subblockrows'])]
12641264
)
1265+
get_row_local_size = petsc_call(
1266+
'VecGetLocalSize', [tvec, Byref(objs['sublocalrows'])]
1267+
)
12651268
restore_row_vec = petsc_call(
12661269
'DMRestoreGlobalVector', [objs['Subdms'].indexed[objs['rowidx']], Byref(tvec)]
12671270
)
@@ -1271,15 +1274,19 @@ def _submat_callback_body(self):
12711274
get_col_size = petsc_call(
12721275
'VecGetSize', [tvec, Byref(objs['subblockcols'])]
12731276
)
1277+
get_col_local_size = petsc_call(
1278+
'VecGetLocalSize', [tvec, Byref(objs['sublocalcols'])]
1279+
)
12741280
restore_col_vec = petsc_call(
12751281
'DMRestoreGlobalVector', [objs['Subdms'].indexed[objs['colidx']], Byref(tvec)]
12761282
)
12771283

1278-
mat_create = petsc_call('MatCreate', [sobjs['comm'], Byref(objs['block'])])
1284+
petsc_obj_comm = Call('PetscObjectComm', arguments=[PetscObjectCast(objs['J'])])
1285+
mat_create = petsc_call('MatCreate', [petsc_obj_comm, Byref(objs['block'])])
12791286

12801287
mat_set_sizes = petsc_call(
12811288
'MatSetSizes', [
1282-
objs['block'], 'PETSC_DECIDE', 'PETSC_DECIDE',
1289+
objs['block'], objs['sublocalrows'], objs['sublocalcols'],
12831290
objs['subblockrows'], objs['subblockcols']
12841291
]
12851292
)
@@ -1329,9 +1336,11 @@ def _submat_callback_body(self):
13291336
col_idx,
13301337
get_row_vec,
13311338
get_row_size,
1339+
get_row_local_size,
13321340
restore_row_vec,
13331341
get_col_vec,
13341342
get_col_size,
1343+
get_col_local_size,
13351344
restore_col_vec,
13361345
mat_create,
13371346
mat_set_sizes,

devito/petsc/iet/type_builder.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,8 @@ def _extend_build(self, base_dict):
290290
'submat_arr': PointerMat(name='submat_arr'),
291291
'subblockrows': PetscInt('subblockrows'),
292292
'subblockcols': PetscInt('subblockcols'),
293+
'sublocalrows': PetscInt('sublocalrows'),
294+
'sublocalcols': PetscInt('sublocalcols'),
293295
'rowidx': PetscInt('rowidx'),
294296
'colidx': PetscInt('colidx'),
295297
'J': Mat('J'),

devito/petsc/solve.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ def linear_solve_args(self):
142142
residual = Residual(target, exprs, arrays, self.time_mapper, jacobian.scdiag)
143143
initial_guess = InitialGuess(target, exprs, arrays, self.time_mapper)
144144

145-
# TODO: Extend this to mixed case
146145
constrain_bc = (
147146
ConstrainBC(target, exprs, arrays)
148147
if self.constrain_bcs

devito/petsc/types/object.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -402,11 +402,6 @@ class NofSubMats(Scalar, LocalType):
402402
pass
403403

404404

405-
# Can this be attached to the consrain bc object in metadata maybe? probs
406-
# shoulnd't be here
407-
Counter = PetscInt(name='count')
408-
409-
410405
FREE_PRIORITY = {
411406
JacobianStruct: 0,
412407
PETScArrayObject: 1,

0 commit comments

Comments
 (0)