Skip to content

Commit c0a62d2

Browse files
committed
misc: Clean up and flake8
1 parent 42535d0 commit c0a62d2

14 files changed

Lines changed: 271 additions & 404 deletions

File tree

.github/workflows/docker-petsc.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ permissions:
66
on:
77
push:
88
branches:
9-
- petsc # Push events on petsc branch
9+
# NOTE: specific to this branch, to be updated
10+
- petscsection # Push events on petscsection branch
1011

1112
jobs:
1213
build-and-push:
@@ -39,7 +40,7 @@ jobs:
3940
file: docker/Dockerfile.petsc
4041
push: true
4142
tags: |
42-
devitocodes/devito-petsc:latest
43+
devitocodes/devito-petsc:petscsection
4344
build-args: base=devitocodes/devito:gcc-dev-amd64
4445
platforms: linux/amd64
4546

.github/workflows/pytest-petsc.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ concurrency:
55
cancel-in-progress: true
66

77
on:
8-
# Trigger the workflow on push or pull request,
9-
# but only for the master branch
108
push:
119
branches:
1210
- main

devito/petsc/equations.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,13 @@ def constrain_essential_bcs(expressions, **kwargs):
8181
new_exprs.append(e)
8282
continue
8383

84-
# new_e = uxreplace(e, mapper)
85-
new_e = e.subs(mapper)
86-
84+
new_e = uxreplace(e, mapper)
8785

8886
if e.implicit_dims:
8987
new_e = new_e._rebuild(
9088
implicit_dims=tuple(mapper.get(d, d) for d in e.implicit_dims)
9189
)
9290
new_exprs.append(new_e)
93-
9491
return new_exprs
9592

9693

devito/petsc/iet/builder.py

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def _setup(self):
8888
snes_get_ksp = petsc_call('SNESGetKSP',
8989
[sobjs['snes'], Byref(sobjs['ksp'])])
9090

91-
matvec = self.callback_builder.main_matvec_callback
91+
matvec = self.callback_builder.main_matvec_efunc
9292
matvec_operation = petsc_call(
9393
'MatShellSetOperation',
9494
[sobjs['Jac'], 'MATOP_MULT', MatShellSetOp(matvec.name, void, void)]
@@ -147,7 +147,7 @@ def _create_dmda_calls(self, dmda):
147147
mainctx = self.solver_objs['userctx']
148148

149149
call_struct_callback = petsc_call(
150-
self.callback_builder.user_struct_callback.name, [Byref(mainctx)]
150+
self.callback_builder.user_struct_efunc.name, [Byref(mainctx)]
151151
)
152152

153153
calls_set_app_ctx = petsc_call('DMSetApplicationContext', [dmda, Byref(mainctx)])
@@ -238,7 +238,7 @@ def _setup(self):
238238
snes_get_ksp = petsc_call('SNESGetKSP',
239239
[sobjs['snes'], Byref(sobjs['ksp'])])
240240

241-
matvec = self.callback_builder.main_matvec_callback
241+
matvec = self.callback_builder.main_matvec_efunc
242242
matvec_operation = petsc_call(
243243
'MatShellSetOperation',
244244
[sobjs['Jac'], 'MATOP_MULT', MatShellSetOp(matvec.name, void, void)]
@@ -259,7 +259,7 @@ def _setup(self):
259259
mainctx = sobjs['userctx']
260260

261261
call_struct_callback = petsc_call(
262-
self.callback_builder.user_struct_callback.name, [Byref(mainctx)]
262+
self.callback_builder.user_struct_efunc.name, [Byref(mainctx)]
263263
)
264264

265265
# TODO: maybe don't need to explictly set this
@@ -345,7 +345,7 @@ def _setup(self):
345345
create_submats) + \
346346
tuple(deref_dms) + tuple(xglobals) + tuple(xlocals) + (BlankLine,)
347347
return coupled_setup
348-
348+
349349

350350
class ConstrainedBCMixin:
351351
"""
@@ -359,7 +359,9 @@ def _create_dmda_calls(self, dmda):
359359
dmda_create = self._create_dmda(dmda)
360360
# TODO: probs need to set the dm options prefix the same as snes?
361361
# don't hardcode this probs? - the dm needs to be specific to the solver as well
362-
da_create_section = petsc_call('PetscOptionsSetValue', [Null, String("-da_use_section"), Null])
362+
da_create_section = petsc_call(
363+
'PetscOptionsSetValue', [Null, String("-da_use_section"), Null]
364+
)
363365
dm_set_from_opts = petsc_call('DMSetFromOptions', [dmda])
364366
dm_setup = petsc_call('DMSetUp', [dmda])
365367
dm_mat_type = petsc_call('DMSetMatType', [dmda, 'MATSHELL'])
@@ -372,24 +374,31 @@ def _create_dmda_calls(self, dmda):
372374
self.callback_builder._point_bc_efunc.name, [dmda, sobjs['numBC']]
373375
)
374376

375-
get_local_section = petsc_call('DMGetLocalSection', [dmda, Byref(sobjs['lsection'])])
377+
get_local_section = petsc_call(
378+
'DMGetLocalSection', [dmda, Byref(sobjs['lsection'])]
379+
)
376380

377381
import cgen as c
378382
tmp = c.Line("PetscCall(PetscSectionView(lsection0, NULL));")
379383

380384
get_point_sf = petsc_call('DMGetPointSF', [dmda, Byref(sobjs['sf'])])
381385

382386
create_global_section = petsc_call(
383-
'PetscSectionCreateGlobalSection', [sobjs['lsection'], sobjs['sf'], 'PETSC_TRUE', 'PETSC_FALSE', 'PETSC_FALSE', Byref(sobjs['gsection'])]
387+
'PetscSectionCreateGlobalSection',
388+
[sobjs['lsection'], sobjs['sf'], 'PETSC_TRUE', 'PETSC_FALSE', 'PETSC_FALSE',
389+
Byref(sobjs['gsection'])]
384390
)
385391

386-
dm_set_global_section = petsc_call('DMSetGlobalSection', [dmda, sobjs['gsection']])
387-
388-
dm_create_section_sf = petsc_call('DMCreateSectionSF', [dmda, sobjs['lsection'], sobjs['gsection']])
392+
dm_set_global_section = petsc_call(
393+
'DMSetGlobalSection', [dmda, sobjs['gsection']]
394+
)
389395

396+
dm_create_section_sf = petsc_call(
397+
'DMCreateSectionSF', [dmda, sobjs['lsection'], sobjs['gsection']]
398+
)
390399

391400
call_struct_callback = petsc_call(
392-
self.callback_builder.user_struct_callback.name, [Byref(mainctx)]
401+
self.callback_builder.user_struct_efunc.name, [Byref(mainctx)]
393402
)
394403

395404
calls_set_app_ctx = petsc_call('DMSetApplicationContext', [dmda, Byref(mainctx)])
@@ -411,7 +420,7 @@ def _create_dmda_calls(self, dmda):
411420
dm_set_global_section,
412421
dm_create_section_sf
413422
)
414-
423+
415424

416425
class ConstrainedBCBuilder(ConstrainedBCMixin, BuilderBase):
417426
pass

0 commit comments

Comments
 (0)