Skip to content

Commit 5c1b686

Browse files
committed
tests: Add more petsc tests for linear coupled
1 parent fb20781 commit 5c1b686

18 files changed

Lines changed: 190 additions & 128 deletions

File tree

.github/workflows/examples-mpi.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ on:
1717
push:
1818
branches:
1919
- main
20-
- master
20+
- petsc
2121
pull_request:
2222
branches:
2323
- main
24-
- master
24+
- petsc
2525

2626
jobs:
2727
build:

.github/workflows/examples.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ on:
1010
push:
1111
branches:
1212
- main
13-
- master
13+
- petsc
1414
pull_request:
1515
branches:
1616
- main
17-
- master
17+
- petsc
1818

1919
jobs:
2020
tutorials:

.github/workflows/flake8.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ on:
1010
push:
1111
branches:
1212
- main
13-
- master
13+
- petsc
1414
pull_request:
1515
branches:
1616
- main
17-
- master
17+
- petsc
1818

1919
jobs:
2020
flake8:

.github/workflows/pytest-core-mpi.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ on:
1010
push:
1111
branches:
1212
- main
13-
- master
13+
- petsc
1414
pull_request:
1515
branches:
1616
- main
17-
- master
17+
- petsc
1818

1919
jobs:
2020
test-mpi-basic:

.github/workflows/pytest-core-nompi.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ on:
1010
push:
1111
branches:
1212
- main
13-
- master
13+
- petsc
1414
pull_request:
1515
branches:
1616
- main
17-
- master
17+
- petsc
1818

1919
jobs:
2020
pytest:

.github/workflows/pytest-petsc.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ on:
1010
push:
1111
branches:
1212
- main
13-
- master
13+
- petsc
1414
pull_request:
1515
branches:
1616
- main
17-
- master
17+
- petsc
1818

1919
jobs:
2020
pytest:

.github/workflows/tutorials.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ on:
1010
push:
1111
branches:
1212
- main
13-
- master
13+
- petsc
1414
pull_request:
1515
branches:
1616
- main
17-
- master
17+
- petsc
1818

1919
jobs:
2020
tutorials:

devito/passes/iet/engine.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from collections import OrderedDict, defaultdict
22
from functools import partial, singledispatch, wraps
33

4+
from devito.finite_differences.differentiable import Differentiable
45
from devito.ir.iet import (Call, ExprStmt, Iteration, SyncSpot, AsyncCallable,
56
FindNodes, FindSymbols, MapNodes, MetaCall, Transformer,
67
EntryFunction, FixedArgsCallable, Uxreplace,
@@ -10,13 +11,13 @@
1011
from devito.passes import needs_transfer
1112
from devito.symbolics import FieldFromComposite, FieldFromPointer
1213
from devito.tools import DAG, as_tuple, filter_ordered, sorted_priority, timed_pass
13-
from devito.types import (Bundle, CompositeObject, Lock, IncrDimension,
14+
from devito.types import (Array, Bundle, CompositeObject, Lock, IncrDimension,
1415
ModuloDimension, Indirection, Pointer, SharedData,
1516
ThreadArray, Temp, NPThreads, NThreadsBase, Wildcard)
16-
from devito.types.array import ArrayBasic
1717
from devito.types.args import ArgProvider
1818
from devito.types.dense import DiscreteFunction
1919
from devito.types.dimension import AbstractIncrDimension, BlockDimension
20+
from devito.types.array import ArrayBasic
2021

2122
__all__ = ['Graph', 'iet_pass', 'iet_visit']
2223

@@ -414,7 +415,8 @@ def abstract_objects(objects0, sregistry=None):
414415

415416
# Precedence rules make it possible to reconstruct objects that depend on
416417
# higher priority objects
417-
keys = [Bundle, ArrayBasic, DiscreteFunction, AbstractIncrDimension, BlockDimension]
418+
keys = [Bundle, Array, Differentiable, DiscreteFunction,
419+
AbstractIncrDimension, BlockDimension]
418420
priority = {k: i for i, k in enumerate(keys, start=1)}
419421
objects = sorted_priority(objects, priority)
420422

@@ -449,6 +451,7 @@ def _(i, mapper, sregistry):
449451
})
450452

451453

454+
@abstract_object.register(Array)
452455
@abstract_object.register(ArrayBasic)
453456
def _(i, mapper, sregistry):
454457
if isinstance(i, Lock):

devito/petsc/iet/routines.py

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -688,15 +688,11 @@ def zero_memory(self):
688688
return False
689689

690690
def _make_core(self):
691-
injectsolve = self.injectsolve
692-
all_fielddata = injectsolve.expr.rhs.fielddata
693-
694-
for sm in all_fielddata.jacobian.nonzero_submatrices:
695-
# arrays = all_fielddata.arrays[sm.row_target]
691+
for sm in self.fielddata.jacobian.nonzero_submatrices:
696692
self._make_matvec(sm, prefix=f'{sm.name}_MatMult')
697693

698694
self._make_whole_matvec()
699-
self._make_whole_formfunc(all_fielddata)
695+
self._make_whole_formfunc()
700696
self._make_user_struct_callback()
701697
self._create_submatrices()
702698
self._efuncs['PopulateMatContext'] = self.objs['dummyefunc']
@@ -764,15 +760,15 @@ def _whole_matvec_body(self):
764760
retstmt=(Call('PetscFunctionReturn', arguments=[0]),)
765761
)
766762

767-
def _make_whole_formfunc(self, fielddata):
768-
formfuncs = fielddata.residual.formfuncs
763+
def _make_whole_formfunc(self):
764+
formfuncs = self.fielddata.residual.formfuncs
769765
# Compile formfunc `eqns` into an IET via recursive compilation
770766
irs_formfunc, _ = self.rcompile(
771767
formfuncs, options={'mpi': False}, sregistry=self.sregistry,
772768
concretize_mapper=self.concretize_mapper
773769
)
774-
body_formfunc = self._whole_formfunc_body(List(body=irs_formfunc.uiet.body),
775-
fielddata)
770+
body_formfunc = self._whole_formfunc_body(List(body=irs_formfunc.uiet.body))
771+
776772
objs = self.objs
777773
cb = PETScCallable(
778774
self.sregistry.make_name(prefix='WholeFormFunc'),
@@ -783,7 +779,7 @@ def _make_whole_formfunc(self, fielddata):
783779
self._main_formfunc_callback = cb
784780
self._efuncs[cb.name] = cb
785781

786-
def _whole_formfunc_body(self, body, fielddata):
782+
def _whole_formfunc_body(self, body):
787783
linsolve_expr = self.injectsolve.expr.rhs
788784
objs = self.objs
789785
sobjs = self.solver_objs
@@ -796,7 +792,7 @@ def _whole_formfunc_body(self, body, fielddata):
796792
fields = self._dummy_fields(body)
797793
self._struct_params.extend(fields)
798794

799-
# Process body for residual callback, including generating bundles etc
795+
# Process body with bundles for residual callback
800796
bundles = sobjs['bundles']
801797
fbundle = bundles['f']
802798
xbundle = bundles['x']
@@ -1143,7 +1139,6 @@ def _extend_build(self, base_dict):
11431139

11441140
class CoupledObjectBuilder(BaseObjectBuilder):
11451141
def _extend_build(self, base_dict):
1146-
injectsolve = self.injectsolve
11471142
sreg = self.sregistry
11481143
objs = self.objs
11491144
targets = self.fielddata.targets
@@ -1164,8 +1159,7 @@ def _extend_build(self, base_dict):
11641159
dim_labels[i]: PetscInt(dim_labels[i]) for i in range(space_dims)
11651160
})
11661161

1167-
jacobian = injectsolve.expr.rhs.fielddata.jacobian
1168-
submatrices = jacobian.nonzero_submatrices
1162+
submatrices = self.fielddata.jacobian.nonzero_submatrices
11691163

11701164
base_dict['jacctx'] = JacobianStruct(
11711165
name=sreg.make_name(prefix=objs['ljacctx'].name),

devito/petsc/solve.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ def PETScSolve(target_eqns, target=None, solver_parameters=None):
2727
target_eqns : Eq or list of Eq, or dict of Function-like -> Eq or list of Eq
2828
The targets and symbolic equations defining the system to be solved.
2929
30-
- **Single-field problem**:
30+
- Single-field problem:
3131
Pass a single Eq or list of Eq, and specify `target` separately:
3232
PETScSolve(Eq1, target)
3333
PETScSolve([Eq1, Eq2], target)
3434
35-
- **Multi-field (mixed) problem**:
35+
- Multi-field (mixed) problem:
3636
Pass a dictionary mapping each target field to its Eq(s):
3737
PETScSolve({u: Eq1, v: Eq2})
3838
PETScSolve({u: [Eq1, Eq2], v: [Eq3, Eq4]})
@@ -47,8 +47,8 @@ def PETScSolve(target_eqns, target=None, solver_parameters=None):
4747
Returns
4848
-------
4949
Eq
50-
A symbolic equation that wraps the system, solver metadata,
51-
and boundary conditions. This can be passed directly to a Devito Operator.
50+
A symbolic equation that wraps the linear solver.
51+
This can be passed directly to a Devito Operator.
5252
"""
5353
if target is not None:
5454
return InjectSolve(solver_parameters, {target: target_eqns}).build_eq()
@@ -143,9 +143,6 @@ def linear_solve_args(self):
143143

144144
return coupled_targets[0], tuple(funcs), all_data
145145

146-
# def generate_arrays_combined(self, *targets):
147-
# return {target: self.generate_arrays(target) for target in targets}
148-
149146

150147
def generate_time_mapper(funcs):
151148
"""

0 commit comments

Comments
 (0)