Skip to content
Draft

pyop3 #3318

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
544 commits
Select commit Hold shift + click to select a range
f6d5587
WIP
connorjward Jun 27, 2025
ff224de
Something appears to be going wrong
connorjward Jun 27, 2025
c75a600
identified the bug, now have something to work with
connorjward Jun 27, 2025
c4be1e1
More work to get nests nice
connorjward Jun 30, 2025
d82b7d0
It only ****ing works!
connorjward Jun 30, 2025
b95b65c
Add BufferRef type
connorjward Jun 30, 2025
b46fb94
fixup
connorjward Jun 30, 2025
e3912ae
fixup
connorjward Jun 30, 2025
0c09e0c
WIP on VoM, needs new PETSc
connorjward Jul 1, 2025
0ccb9e9
Merge remote-tracking branch 'origin/master' into connorjward/pyop3-d…
connorjward Jul 1, 2025
df7feb6
Merge remote-tracking branch 'origin/master' into connorjward/pyop3-d…
connorjward Jul 1, 2025
d91077d
fixup
connorjward Jul 1, 2025
5319880
WIP
connorjward Jul 1, 2025
1f3d752
VoM wip
connorjward Jul 2, 2025
544d99b
wip
connorjward Jul 2, 2025
32abb2f
First VoM test passes
connorjward Jul 3, 2025
4fd4c67
More tests pass, now do parloops
connorjward Jul 3, 2025
6ae3a56
parloops work and progress on block shape
connorjward Jul 3, 2025
55eb803
Merge remote-tracking branch 'origin/master' into connorjward/pyop3-d…
connorjward Jul 8, 2025
1792b5b
VoM progress, now a baij issue
connorjward Jul 8, 2025
a4f688e
Progress on VoM
connorjward Jul 8, 2025
b266ac6
Fix buffer slice
connorjward Jul 8, 2025
24be6af
Fix input_ordering
connorjward Jul 9, 2025
baebc28
Extruded + VoM passes a test
connorjward Jul 9, 2025
2f9f58a
Wow a lot of VoM tests passing, including some periodic mesh bits
connorjward Jul 10, 2025
62fef66
Subset assignment now works due to having nodal axes
connorjward Jul 10, 2025
81e7c23
test_function passes
connorjward Jul 15, 2025
3c71a43
Some boundary condition bits working again
connorjward Jul 16, 2025
7dd309a
WIP on RFS
connorjward Jul 16, 2025
3ef042c
WIP on RFS and axis component regions
connorjward Jul 17, 2025
87b12bc
WIP
connorjward Jul 17, 2025
b49662f
WIP
connorjward Jul 18, 2025
a21a998
Fix mixed space layout tabulation
connorjward Jul 18, 2025
078bca6
Merge branch 'connorjward/pyop3-develop' into connorjward/pyop3-devel…
connorjward Jul 18, 2025
8dd7fa4
Add a bunch of expression stuff so we can do ragged slices, it's magi…
connorjward Jul 18, 2025
e1b3596
Progress on RFS
Jul 21, 2025
c3800b9
WIP
Jul 21, 2025
2b653a9
WIP
Jul 22, 2025
7f291a1
WIP
connorjward Jul 22, 2025
2000980
wip
Jul 23, 2025
4ce104c
Add some layout tests
Jul 23, 2025
e2bcd9b
Gosh this nearly works
Jul 23, 2025
42ae9c8
my lord
Jul 23, 2025
24ad7e5
Oh my god I can't believe it
Jul 23, 2025
14a5f26
WIP
Jul 23, 2025
45d344e
wip
Jul 23, 2025
46672a1
wip
Jul 23, 2025
b6a806f
wip
Jul 24, 2025
8d55765
Fixed the segfault!
Jul 25, 2025
17f36ce
Work on evaluate, iter and tidy layout tests
Jul 26, 2025
6551ce7
Move files around
Jul 26, 2025
eed016d
More file moves
Jul 26, 2025
ef74734
more moves
Jul 26, 2025
b9ea2cf
Move bits
Jul 26, 2025
8c1882c
add file
Jul 28, 2025
a37b704
Tidying
connorjward Jul 28, 2025
c67851f
Add exscan for layout tabulation
connorjward Jul 28, 2025
98dde3a
Layout tabulation for ragged works better now
connorjward Jul 28, 2025
ccc2975
wip
connorjward Jul 28, 2025
d2f13e1
Now do regions
connorjward Jul 28, 2025
0ebe3de
wip
Jul 29, 2025
e315501
Region tabulation appears to work
connorjward Jul 29, 2025
45a60dd
wooo
connorjward Jul 29, 2025
4305135
wip
connorjward Jul 29, 2025
cfc6bec
wip
connorjward Jul 29, 2025
1a32464
Layout tests all pass now
Jul 30, 2025
a7fabf8
Move things about
Jul 30, 2025
db7f1be
more cleanup
Jul 30, 2025
04d0fde
cleanup
Jul 30, 2025
ff16ea7
cleanup
Jul 30, 2025
c729702
cleanup
Jul 30, 2025
6919da7
Add comment
Jul 30, 2025
4a3cbef
cleanup
Jul 31, 2025
97cd0f1
docs
Jul 31, 2025
e284200
Import cleanup
Aug 5, 2025
438ca02
wip
Aug 5, 2025
b2d553e
WIP
Aug 5, 2025
0ee4f31
WIP
Aug 6, 2025
e8f11dd
Progress!!!
Aug 6, 2025
1258efe
First restricted function space test passes!
Aug 7, 2025
16b1eeb
fixups
Aug 7, 2025
6e0d1cc
Add scoped_cache, kinda works I think
Aug 7, 2025
3da9279
Caching changes
Aug 7, 2025
f8fc6f1
Attempt (and fail) to speed things up
Aug 7, 2025
a8b4666
Cache hash computations
Aug 11, 2025
652e689
cleanup
Aug 11, 2025
1e08c7d
fixup
Aug 11, 2025
cdb5ed9
fixup
Aug 11, 2025
99519ce
Fixes
connorjward Aug 11, 2025
d5406d5
Fix real space test
connorjward Aug 11, 2025
78562d0
Fixes, including cell_node_list
connorjward Aug 11, 2025
540db0f
parloop cleanup
connorjward Aug 11, 2025
e21b621
WIP towards fixing facet integrals
connorjward Aug 11, 2025
9038529
Progress on facet integrals and mixed improvements
connorjward Aug 13, 2025
fbfcac8
fixes
connorjward Aug 13, 2025
e367065
Facet fixes, more to go
connorjward Aug 13, 2025
a34912b
Fix test_facets test, bad support numbering
connorjward Aug 14, 2025
b0a5d30
More misc fixes
connorjward Aug 14, 2025
69c5b93
Interior facet fixups
connorjward Aug 14, 2025
82bfa4c
cleanup
connorjward Aug 14, 2025
2e49a8a
Fixes for mixed matrices and more
connorjward Aug 14, 2025
457b9ca
Assign fixes
connorjward Aug 14, 2025
a19d858
Unskip some tests
connorjward Aug 15, 2025
61981a5
Merge remote-tracking branch 'origin/main' into connorjward/pyop3-dev…
connorjward Aug 15, 2025
7b45aa3
Remove test skips
connorjward Aug 15, 2025
c8402dd
Test cleanup and post merge fixes
connorjward Aug 18, 2025
669ccd6
fixe
connorjward Aug 18, 2025
f51935d
Fixes
connorjward Aug 18, 2025
e79780c
fixes
connorjward Aug 18, 2025
1d7464d
Nasty hack for mixed proxy spaces
connorjward Aug 18, 2025
d4c2b38
WIP, thinking about lgmaps
connorjward Aug 18, 2025
4e39d46
bits
Aug 19, 2025
6debe7b
Fix assemble
connorjward Aug 19, 2025
a7e086f
fixup
connorjward Aug 19, 2025
61f8ecc
fixup
connorjward Aug 19, 2025
b4ff865
fixup
connorjward Aug 19, 2025
e2af3fd
Issues with subset indices
connorjward Aug 19, 2025
deeaf13
fixup
Aug 19, 2025
cb919c4
fixup
Aug 19, 2025
af53229
Get facet split PC working
connorjward Aug 20, 2025
e4415dc
Facet fixes
connorjward Aug 20, 2025
b93e72e
Fix a bunch of adjoint tests
connorjward Aug 22, 2025
f90de09
Performance fix for finding candidates
connorjward Sep 1, 2025
4c28eb3
WIP on Function.at
connorjward Sep 1, 2025
2e82cd0
Fixes
connorjward Sep 2, 2025
97925a7
noodling
connorjward Sep 2, 2025
ef5e758
Beign adding axis forests
connorjward Sep 2, 2025
9055869
Axis forests work as expected
Sep 2, 2025
dbca2e5
Small bits, having weird stokes_mini failure
connorjward Sep 3, 2025
c7a47bd
Fix for test_bcs
connorjward Sep 3, 2025
89752b0
Fix domain bug
Sep 3, 2025
2bfdf39
fixup
Sep 3, 2025
edd1039
Small parsing fix
Sep 7, 2025
489fc12
Small fixes
Sep 7, 2025
816327f
Progress on getting output working
Sep 17, 2025
6b64b63
Fix supermeshing
connorjward Sep 18, 2025
cc4c214
Tweaks to component indexing
Sep 18, 2025
c42b212
Refactor packing code
Sep 18, 2025
1854b13
Back to something that works for the simplest of cases
Sep 18, 2025
af89092
Interior facet fixups
Sep 18, 2025
391d7de
Specialise reshape on integral type
Sep 18, 2025
fe57081
Refactor attempt for interior facets, passes simple tests
Sep 19, 2025
66957e3
Cleaner approach
Sep 19, 2025
3c957d2
Bits and pieces for hexes
Sep 19, 2025
2f76a0d
More progress, hard to match axes
Sep 19, 2025
3781380
Wow, hex interior facet assembly passes!
Sep 19, 2025
32750fc
Fixes for interpolate, still things going wrong
connorjward Sep 22, 2025
bf0ac17
All interpolation tests pass pretty much
connorjward Sep 22, 2025
a6a740b
Chasing comms, more to do
connorjward Sep 22, 2025
1353cda
largest_comm
connorjward Sep 22, 2025
a4b0585
Now try and get a simple parallel test passing
connorjward Sep 23, 2025
733b6bd
Distinguish local_size and size better
connorjward Sep 23, 2025
692aa52
More parallel fixes
connorjward Sep 23, 2025
7f53bd8
Parallel tests are passing
connorjward Sep 23, 2025
000eaea
Some multigrid tests passing
connorjward Sep 23, 2025
e68bc2d
A parallel multigrid test passes
Sep 25, 2025
a6e5676
Multigrid progress, now failing because of patchpc
Sep 29, 2025
b5b67e8
More multigrid fixes, promising
Sep 29, 2025
3e655bc
Hit some warnings
Sep 29, 2025
13e393d
Progress on PCPATCH
Sep 30, 2025
0ff963a
Progress on PCPatch
Oct 3, 2025
5faefb8
Initial PCPatch tests passing
connorjward Oct 6, 2025
02c2736
Small fixes
connorjward Oct 6, 2025
d6547a1
Replace all occurrences of '.dat.vec' with '.vec'
connorjward Oct 6, 2025
180b47e
Merge remote-tracking branch 'origin/main' into connorjward/pyop3-dev…
connorjward Oct 6, 2025
001653a
Post-merge fixups
connorjward Oct 6, 2025
24ab195
Hacking around extruded meshes
connorjward Oct 13, 2025
1b5210d
Try hacking away at extruded dm_renumbering, it's harder now
Oct 15, 2025
7dedd3a
At last, got things working!
Oct 16, 2025
3b29dd3
Removing breakpoints
Oct 16, 2025
be55be3
Always apply entity permutations when packing
Oct 17, 2025
df23bb6
Extruded cell assembly back passing
Oct 20, 2025
a1aa15e
Begin hacking at iteration sets
Oct 20, 2025
5a31787
Refactor measure_set
Oct 21, 2025
085fdb6
wip
Oct 21, 2025
45f31ea
WIP on numbering stuff, I hate it
connorjward Oct 21, 2025
a6aa286
WIP
Oct 22, 2025
d7e45b6
Seems to work apart from for subdomains
connorjward Oct 22, 2025
baf06b5
Now _dm_renumbering is the same as before! key change was to redo the…
connorjward Oct 22, 2025
03cdef3
Things work at last!
connorjward Oct 22, 2025
a917121
Add support for unmarked subdomain
connorjward Oct 22, 2025
5e73858
WIP
Oct 22, 2025
d35a661
Some interior facet stuff passing for extruded, the approach is sound
Oct 23, 2025
979cdc2
Facet integrals definitively working for extruded meshes
Oct 23, 2025
79d648b
fixes
Oct 24, 2025
c1e2226
fixes for interpolation
Oct 24, 2025
79f6e4e
Merge remote-tracking branch 'origin/main' into connorjward/pyop3-dev…
Oct 24, 2025
f61978e
Fix most interpolations
Oct 28, 2025
c182a0a
Final few fixups, all interpolate tests now pass
Oct 28, 2025
7d2aafa
Partial fix for matnest
Oct 28, 2025
8986229
WIP on VoM
Oct 28, 2025
50e178a
VoM wip
Oct 29, 2025
84b3ae8
VoM fixes, now failing for extruded
Oct 29, 2025
a0df37b
Extruded vom works trivially
Oct 29, 2025
8ec9e21
Most serial multigrid is working
Oct 30, 2025
975d524
WIP towards fixing things for cell closures
Oct 31, 2025
1ef6c87
WIP on parallel solving
Nov 2, 2025
8e54815
progress, passes in serial
Nov 2, 2025
7f6f164
fix
Nov 3, 2025
8c478e8
maybe fix fieldsplit
connorjward Nov 5, 2025
271ac34
Potentially have a fix!
Nov 5, 2025
0df64e1
Parallel numbering fixes
Nov 7, 2025
005ba8b
Things now appear to work
Nov 7, 2025
5d56c62
WIP subsets in parallel
Nov 10, 2025
8bbb362
Fix lgmaps and mask_lgmap
Nov 12, 2025
8c66d24
Fix index sets
Nov 12, 2025
80fd929
Fix star forest concatenation (and more)
Nov 13, 2025
9b7bf41
Parallel fixes
Nov 14, 2025
adf9bdf
Some fixes for quads in parallel
Nov 14, 2025
e9cc3cf
Finally!
Nov 14, 2025
ae74243
Some nullspace fixes
Nov 14, 2025
10a21d8
Merge remote-tracking branch 'origin/main' into connorjward/pyop3
Nov 17, 2025
6f5ec6f
Post-merge fixes
connorjward Nov 17, 2025
9556206
cython fixup guess, works locally
connorjward Nov 17, 2025
51c11b1
Fix VoM
connorjward Nov 17, 2025
8a87a85
cython fixup
connorjward Nov 17, 2025
dc9ffb3
Remove refs to pyrsistent
connorjward Nov 17, 2025
3a85fb0
First submesh test passing
connorjward Nov 18, 2025
c1442c8
Progress on facets for submeshes
connorjward Nov 18, 2025
dbd0762
Facet test passing, had to think hard about cython
Nov 19, 2025
8899e02
Ignore generated cython files
Nov 19, 2025
b29443f
Swap order of map composition
Nov 19, 2025
d3802de
Another submesh test passes
Nov 20, 2025
15e93b1
Finally figured it out!
Nov 20, 2025
861ed19
Submesh assembly works in most cases now
Nov 21, 2025
a401ea0
cleanup
Nov 24, 2025
c4ea16b
Progress on mixed interps
Nov 24, 2025
e5f26e5
Use petsctools for C API
Nov 24, 2025
a5a70e5
Merge remote-tracking branch 'origin/main' into connorjward/pyop3
Nov 24, 2025
14f6921
Post merge fixups
Nov 24, 2025
14e5cf6
fixup
Nov 24, 2025
41ae289
fixup
Nov 24, 2025
76a949e
cleanup
Nov 25, 2025
d91f3e5
Do not zero for WRITE
Nov 25, 2025
b4e6187
VoM fixes
Nov 25, 2025
4d0fb80
Fixes
Nov 26, 2025
f147017
Parallel fix, also in petsctools
Nov 26, 2025
28b33df
Fixes so parallel tests at least collected
Nov 27, 2025
37b4d07
Write up pyop3 configuration
Nov 27, 2025
33be2cc
Remove PyOP2, failures expected
Nov 27, 2025
0fa0395
Avoid pyop2 imports
Nov 27, 2025
22bbc77
Include C files in distribution
Nov 27, 2025
ce667c4
Remove pyop2 script ref
Nov 27, 2025
fad5c8e
fixup
Nov 27, 2025
502286b
More pyop2 removals
Nov 28, 2025
e855d1e
Fix hexahedra
Nov 28, 2025
34f1aae
Remove some variable layer extrusion tests
Nov 28, 2025
775caa7
Fix tsfc tests
Nov 28, 2025
37a2451
add pyop3 tests to test suite (failing)
Nov 28, 2025
565e34d
VoM fixes
Nov 28, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 19 additions & 18 deletions .github/workflows/core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -240,76 +240,77 @@ jobs:
firedrake-run-split-tests 1 1 -n 8 "$EXTRA_PYTEST_ARGS" firedrake-repo/tests/tsfc
timeout-minutes: 10

- name: Run PyOP2 tests
# TODO: parallel tests as well
- name: Run pyop3 tests
if: inputs.run_tests && (success() || steps.install.conclusion == 'success')
run: |
. venv/bin/activate
: # Use pytest-xdist here so we can have a single collated output (not possible
: # for parallel tests)
firedrake-run-split-tests 1 1 -n 8 "$EXTRA_PYTEST_ARGS" firedrake-repo/tests/pyop2
firedrake-run-split-tests 2 4 "$EXTRA_PYTEST_ARGS" firedrake-repo/tests/pyop2
firedrake-run-split-tests 3 2 "$EXTRA_PYTEST_ARGS" firedrake-repo/tests/pyop2
firedrake-run-split-tests 4 2 "$EXTRA_PYTEST_ARGS" firedrake-repo/tests/pyop2
firedrake-run-split-tests 1 1 -n 8 "$EXTRA_PYTEST_ARGS" firedrake-repo/tests/pyop3
timeout-minutes: 10


- name: Run Firedrake tests (nprocs = 1)
if: inputs.run_tests && (success() || steps.install.conclusion == 'success')
run: |
. venv/bin/activate
: # Use pytest-xdist here so we can have a single collated output (not possible
: # for parallel tests)
firedrake-run-split-tests 1 1 -n 8 "$EXTRA_PYTEST_ARGS" firedrake-repo/tests/firedrake
timeout-minutes: 90
# UNDO ME
timeout-minutes: 180

- name: Run tests (nprocs = 2)
if: inputs.run_tests && (success() || steps.install.conclusion == 'success')
run: |
. venv/bin/activate
firedrake-run-split-tests 2 4 "$EXTRA_PYTEST_ARGS" firedrake-repo/tests/firedrake
timeout-minutes: 60
# UNDO ME
timeout-minutes: 120

- name: Run tests (nprocs = 3)
if: inputs.run_tests && (success() || steps.install.conclusion == 'success')
run: |
. venv/bin/activate
firedrake-run-split-tests 3 2 "$EXTRA_PYTEST_ARGS" firedrake-repo/tests/firedrake
timeout-minutes: 60
# UNDO ME
timeout-minutes: 120

- name: Run tests (nprocs = 4)
if: inputs.run_tests && (success() || steps.install.conclusion == 'success')
run: |
. venv/bin/activate
firedrake-run-split-tests 4 2 "$EXTRA_PYTEST_ARGS" firedrake-repo/tests/firedrake
timeout-minutes: 15
# UNDO ME
timeout-minutes: 30

- name: Run tests (nprocs = 5)
if: inputs.run_tests && (success() || steps.install.conclusion == 'success')
run: |
. venv/bin/activate
firedrake-run-split-tests 5 1 "$EXTRA_PYTEST_ARGS" firedrake-repo/tests/firedrake
timeout-minutes: 15
# UNDO ME
timeout-minutes: 30

- name: Run tests (nprocs = 6)
if: inputs.run_tests && (success() || steps.install.conclusion == 'success')
run: |
. venv/bin/activate
firedrake-run-split-tests 6 1 "$EXTRA_PYTEST_ARGS" firedrake-repo/tests/firedrake
timeout-minutes: 15
# UNDO ME
timeout-minutes: 30

- name: Run tests (nprocs = 7)
if: inputs.run_tests && (success() || steps.install.conclusion == 'success')
run: |
. venv/bin/activate
firedrake-run-split-tests 7 1 "$EXTRA_PYTEST_ARGS" firedrake-repo/tests/firedrake
timeout-minutes: 15
# UNDO ME
timeout-minutes: 30

- name: Run tests (nprocs = 8)
if: inputs.run_tests && (success() || steps.install.conclusion == 'success')
run: |
. venv/bin/activate
firedrake-run-split-tests 8 1 "$EXTRA_PYTEST_ARGS" firedrake-repo/tests/firedrake
timeout-minutes: 15
# UNDO ME
timeout-minutes: 30

- name: Run Gusto smoke tests
# Only test Gusto in real mode
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ PyOP2.egg-info
sparsity.so
sparsity.c
sparsity.cpython*.so
*_cy.c
# Docs
pyop2.coffee.rst
pyop2.rst
Expand Down
2 changes: 1 addition & 1 deletion demos/boussinesq/boussinesq.py.rst
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ implements a boundary condition that fixes a field at a single point. ::
# Take the basis function with the largest abs value at bc_point
v = TestFunction(V)
F = assemble(interpolate(inner(v, v), Fvom))
with F.dat.vec as Fvec:
with F.vec_ro as Fvec:
max_index, _ = Fvec.max()
nodes = V.dof_dset.lgmap.applyInverse([max_index])
nodes = nodes[nodes >= 0]
Expand Down
2 changes: 1 addition & 1 deletion demos/multicomponent/multicomponent.py.rst
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ mathematically valid to do this)::
# Take the basis function with the largest abs value at bc_point
v = TestFunction(V)
F = assemble(interpolate(inner(v, v), Fvom))
with F.dat.vec as Fvec:
with F.vec as Fvec:
max_index, _ = Fvec.max()
nodes = V.dof_dset.lgmap.applyInverse([max_index])
nodes = nodes[nodes >= 0]
Expand Down
6 changes: 3 additions & 3 deletions demos/netgen/netgen_mesh.py.rst
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ Then a SLEPc Eigenvalue Problem Solver (`EPS`) is initialised and set up to use
E.setST(ST)
E.solve()
vr, vi = Asc.getVecs()
with uh.dat.vec_wo as vr:
with uh.vec_wo as vr:
lam = E.getEigenpair(0, vr, vi)
return (lam, uh, V)

Expand All @@ -198,8 +198,8 @@ In order to do so we begin by computing the value of the indicator using a piece
part = .2
mark = Function(W)
# Filling in the marked element vector using eta.
with mark.dat.vec as markedVec:
with eta.dat.vec as etaVec:
with mark.vec as markedVec:
with eta.vec as etaVec:
sum_eta = etaVec.sum()
if sum_eta < tolerance:
return markedVec
Expand Down
6 changes: 3 additions & 3 deletions demos/parallel-printing/parprint.py.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ To print the solution vector in serial one could write ``print(u.dat.data)``
but then in parallel each processor would show its data separately.
So using PETSc we do a "view" of the solution vector::

with u.dat.vec_ro as vu:
with u.vec_ro as vu:
vu.view()

Here ``vu`` is an instance of the PETSc.Vec class and ``vu.view()`` is the
equivalent of ``VecView(vu,NULL)`` using PETSc's C API. This Vec is "global",
meaning that each degree of freedom is stored on a unique process. The context manager
in the above usage (i.e. ``with ...``) allows Firedrake to generate a global Vec
by halo exchanges if needed. Here we only need read-only access here so we use
``u.dat.vec_ro``; note ``u.dat.vec`` would allow read-write access.
``u.vec_ro``; note ``u.vec`` would allow read-write access.

Finally we compute and print the numerical error, relative to the exact
solution, in two norms. The :math:`L^2` norm is computed with
Expand All @@ -88,7 +88,7 @@ gets the max over the process-owned entries. So again we use the ``PETSc.Vec``
approach::

udiffabs = Function(V).interpolate(abs(udiff))
with udiffabs.dat.vec_ro as v:
with udiffabs.vec_ro as v:
L_inf_err = v.max()[1]
PETSc.Sys.Print('L_2 error norm = %g, L_inf error norm = %g' \
% (L_2_err,L_inf_err))
Expand Down
4 changes: 2 additions & 2 deletions docs/source/ensemble_parallelism.rst
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,10 @@ on each ensemble member.
Internally, the :class:`~.EnsembleFunction` creates a ``PETSc.Vec``
on the ``Ensemble.global_comm`` which contains the data for all
local components on all ensemble members. This ``Vec`` can be accessed
with a context manager, similarly to the ``Function.dat.vec`` context
with a context manager, similarly to the ``Function.vec`` context
managers used to access :class:`~.Function` data. There are also
analogous ``vec_ro`` and ``vec_wo`` context managers for read/write
only accesses. However note that, unlike the ``Function.dat.vec``
only accesses. However note that, unlike the ``Function.vec``
context managers, the ``EnsembleFunction.vec`` context managers
need braces i.e. ``vec()`` not ``vec``.

Expand Down
2 changes: 1 addition & 1 deletion docs/source/external_operators.rst
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ of `N` can be assembled:
integral_types = set(['cell'])
assembly_opts = kwargs.get('assembly_opts')
J = self._matrix_builder((), assembly_opts, integral_types)
with dNdu.dat.vec as vec:
with dNdu.vec_ro as vec:
J.petscmat.setDiagonal(vec)
return J

Expand Down
16 changes: 8 additions & 8 deletions docs/source/petsc-interface.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ read-write access to the PETSc object. For read-only access, we use:

.. code-block:: python3

with assemble(linear_form).dat.vec_ro as v:
with assemble(linear_form).vec_ro as v:
petsc_vec_ro = v

For write-only access, use ``.vec_wo``, and for read-write access, use:

.. code-block:: python3

with assemble(linear_form).dat.vec as v:
with assemble(linear_form).vec as v:
petsc_vec = v

These context managers ensure that if PETSc writes to the vector,
Expand Down Expand Up @@ -140,10 +140,10 @@ newly defined class to compute the matrix action:

# Now do the same for the linear forms for u and v, making a copy

with assemble(u_form).dat.vec_ro as u_vec:
with assemble(u_form).vec_ro as u_vec:
u = u_vec.copy()

with assemble(v_form).dat.vec_ro as v_vec:
with assemble(v_form).vec_ro as v_vec:
v = v_vec.copy()


Expand Down Expand Up @@ -179,8 +179,8 @@ Now we can solve a system using this ``ksp`` object:

rhs = assemble(rhs_form)

with rhs.dat.vec_ro as b:
with solution.dat.vec as x:
with rhs.vec_ro as b:
with solution.vec as x:
ksp.solve(b, x)


Expand Down Expand Up @@ -307,8 +307,8 @@ before going on to solve the system as before:

rhs = assemble(rhs_form)

with rhs.dat.vec_ro as b:
with solution.dat.vec as x:
with rhs.vec_ro as b:
with solution.vec as x:
ksp.solve(b, x)


Expand Down
6 changes: 4 additions & 2 deletions firedrake/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@
from ufl import *
from finat.ufl import *

from pyop2 import op2 # noqa: F401
from pyop2.mpi import COMM_WORLD, COMM_SELF # noqa: F401
from pyop3.mpi import COMM_WORLD, COMM_SELF # noqa: F401

from pyop3 import READ, WRITE, RW, INC # noqa: F401

# Register possible citations
import firedrake.citations # noqa: F401
Expand All @@ -65,6 +66,7 @@
from firedrake.exceptions import *
from firedrake.function import *
from firedrake.functionspace import *
from firedrake.functionspaceimpl import InvalidFunctionSpaceLayoutException

Check failure on line 69 in firedrake/__init__.py

View workflow job for this annotation

GitHub Actions / test / Lint codebase

F401

firedrake/__init__.py:69:1: F401 'firedrake.functionspaceimpl.InvalidFunctionSpaceLayoutException' imported but unused
from firedrake.interpolation import *
from firedrake.linear_solver import *
from firedrake.preconditioners import *
Expand Down
2 changes: 1 addition & 1 deletion firedrake/adjoint/ensemble_reduced_functional.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pyadjoint.reduced_functional import AbstractReducedFunctional, ReducedFunctional
from pyadjoint.enlisting import Enlist
from pyop2.mpi import MPI
from pyop3.mpi import MPI

from firedrake.function import Function
from firedrake.cofunction import Cofunction
Expand Down
4 changes: 2 additions & 2 deletions firedrake/adjoint_utils/blocks/assembly.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ def compute_action_adjoint(self, adj_input, arity_form, form=None,
# Get PETSc matrix
dform_mat = assembled_dform.petscmat
# Action of the adjoint (Hermitian transpose)
with adj_input.dat.vec_ro as v_vec:
with adj_output.dat.vec as res_vec:
with adj_input.vec_ro as v_vec:
with adj_output.vec_wo as res_vec:
dform_mat.multHermitian(v_vec, res_vec)
return adj_output, dform
else:
Expand Down
4 changes: 2 additions & 2 deletions firedrake/adjoint_utils/blocks/solving.py
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ def __init__(self, source, target_space, target, bcs=[], **kwargs):

def apply_mixedmass(self, a):
b = firedrake.Function(self.target_space.dual())
with a.dat.vec_ro as vsrc, b.dat.vec_wo as vrhs:
with a.vec_ro as vsrc, b.vec_wo as vrhs:
self.mixed_mass.mult(vsrc, vrhs)
return b

Expand All @@ -905,7 +905,7 @@ def _recompute_component_transpose(self, inputs):
tmp = firedrake.Function(self.target_space)
# Adjoint of step 2 (mass is self-adjoint)
self.projector.apply_massinv(tmp, inputs[0])
with tmp.dat.vec_ro as vtmp, out.dat.vec_wo as vout:
with tmp.vec_ro as vtmp, out.vec_wo as vout:
self.mixed_mass.multTranspose(vtmp, vout) # Adjoint of step 1
return out

Expand Down
2 changes: 1 addition & 1 deletion firedrake/adjoint_utils/checkpointing.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""A module providing support for disk checkpointing of the adjoint tape."""
from pyadjoint import get_working_tape, OverloadedType, disk_checkpointing_callback
from pyadjoint.tape import TapePackageData
from pyop2.mpi import COMM_WORLD
from pyop3.mpi import COMM_WORLD
import tempfile
import os
import shutil
Expand Down
2 changes: 1 addition & 1 deletion firedrake/adjoint_utils/constant.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def _ad_copy(self):
return self._constant_from_values()

def _ad_dim(self):
return self.dat.cdim
return self.dat.data_ro.size

def _ad_imul(self, other):
self.assign(self._constant_from_values(self.dat.data_ro.reshape(-1) * other))
Expand Down
4 changes: 2 additions & 2 deletions firedrake/adjoint_utils/ensemble_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def wrapper(self, *args, **kwargs):

@staticmethod
def _ad_to_list(m):
with m.vec_ro() as gvec:
with m.vec_ro as gvec:
lvec = PETSc.Vec().createSeq(gvec.size,
comm=PETSc.COMM_SELF)
PETSc.Scatter().toAll(gvec).scatter(
Expand All @@ -40,7 +40,7 @@ def _ad_to_list(m):

@staticmethod
def _ad_assign_numpy(dst, src, offset):
with dst.vec_wo() as vec:
with dst.vec_wo as vec:
begin, end = vec.owner_range
vec.array[:] = src[offset + begin: offset + end]
offset += vec.size
Expand Down
16 changes: 5 additions & 11 deletions firedrake/adjoint_utils/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,15 +276,9 @@ def _ad_dot(self, other, options=None):

@staticmethod
def _ad_assign_numpy(dst, src, offset):
range_begin, range_end = dst.dat.dataset.layout_vec.getOwnershipRange()
m_a_local = src[offset + range_begin:offset + range_end]
if dst.function_space().ufl_element().family() == "Real":
# Real space keeps a redundant copy of the data on every rank
comm = dst.function_space().mesh()._comm
dst.dat.data_wo[...] = comm.bcast(m_a_local, root=0)
else:
dst.dat.data_wo[...] = m_a_local.reshape(dst.dat.data_wo.shape)
offset += dst.dat.dataset.layout_vec.size
range_begin, range_end = dst.function_space().template_vec.getOwnershipRange()
dst.dat.data_wo = src[offset + range_begin:offset + range_end]
offset += range_end - range_begin
return dst, offset

@staticmethod
Expand Down Expand Up @@ -327,11 +321,11 @@ def _applyBinary(self, f, y):
self.dat.data_wo[i] = f(self.dat.data_ro[i], y.dat.data_ro[i])

def _ad_from_petsc(self, vec):
with self.dat.vec_wo as self_v:
with self.vec_wo as self_v:
vec.copy(result=self_v)

def _ad_to_petsc(self, vec=None):
with self.dat.vec_ro as self_v:
with self.vec_ro as self_v:
if vec:
self_v.copy(result=vec)
else:
Expand Down
Loading
Loading