Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
ebc791e
WIP: add interface to SciMLBase for ODEProblem
ranocha Apr 25, 2026
84ba441
WIP
ranocha Apr 26, 2026
2da9283
WIP
ranocha Apr 26, 2026
4678837
WIP
ranocha Apr 26, 2026
87273ed
WIP
ranocha Apr 26, 2026
d3b4af3
WIP
ranocha Apr 27, 2026
9208c0d
WIP
ranocha Apr 27, 2026
11abc0a
WIP
ranocha Apr 27, 2026
b930a5d
WIP
ranocha Apr 27, 2026
5eb16a3
WIP
ranocha Apr 27, 2026
ebe01d5
WIP
ranocha Apr 27, 2026
f56fd46
WIP
ranocha Apr 27, 2026
f2c5f99
WIP
ranocha Apr 27, 2026
16998b6
WIP
ranocha Apr 27, 2026
bdda94f
WIP
ranocha Apr 27, 2026
2c500b8
WIP
ranocha Apr 28, 2026
dc61f93
WIP
ranocha Apr 28, 2026
a490c0a
WIP
ranocha Apr 28, 2026
34867fd
WIP: examples/ex51_sciml.jl
ranocha May 4, 2026
89bf003
fix
ranocha May 4, 2026
f361a7f
ex51_sciml.jl: adaptive
ranocha May 4, 2026
55e6601
test ex51_sciml.jl
ranocha May 4, 2026
a029127
more SciML tests
ranocha May 4, 2026
9dd02cb
remove DataStructures.jl
ranocha May 4, 2026
6f40d76
remove DiffEqBase.jl requirement
ranocha May 4, 2026
a8bb5ec
save_everystep = true as default
ranocha May 4, 2026
b51eb49
docs
ranocha May 4, 2026
26e3c32
ex16_sciml.jl
ranocha May 4, 2026
b4c6f7f
improve
ranocha Jun 17, 2026
e6532ec
Merge branch 'main' into hr/interface
ranocha Jun 19, 2026
0088175
clean up
ranocha Jun 19, 2026
3a4d5b3
improve docs and add Float32 support
ranocha Jun 19, 2026
92f1c48
MPI for explicit methods
ranocha Jun 19, 2026
d348983
improve compatibility with Trixi.jl
ranocha Jun 19, 2026
996222e
fix MPI
ranocha Jun 19, 2026
a85af58
add comments and fix MPI saveat
ranocha Jun 19, 2026
038b1ed
add new test file
ranocha Jun 19, 2026
44d707e
clean up tests
ranocha Jun 19, 2026
61e778c
clean up tests
ranocha Jun 19, 2026
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
6 changes: 3 additions & 3 deletions CITATION.bib
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ @software{petsc_jl
author = {Kaus, Boris and
Shah, Viral B. and
Kozdon, Jeremy E. and
Churavy, Valentin and
Churavy, Valentin and
Ranocha, Hendrik and
Schnetter, Erik and
Byrne, Simon},
title = {PETSc.jl: Julia bindings for PETSc},
year = 2026,
title = {{PETSc.jl}: {J}ulia bindings for {PETSc}},
year = {2026},
publisher = {Zenodo},
doi = {10.5281/zenodo.18274810},
url = {https://github.com/JuliaParallel/PETSc.jl}
Expand Down
8 changes: 6 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "PETSc"
uuid = "ace2c81b-2b5f-4b1e-a30d-d662738edfe0"
version = "0.4.10"
authors = ["Boris Kaus <kaus@uni-mainz.de>", "Viral B. Shah <virals@gmail.com>", "Valentin Churavy <v.churavy@gmail.com>", "Erik Schnetter <eschnetter@perimeterinstitute.ca>", "Jeremy E. Kozdon <jeremy@kozdon.net>", "Simon Byrne <simonbyrne@gmail.com>"]
authors = ["Boris Kaus <kaus@uni-mainz.de>", "Viral B. Shah <virals@gmail.com>", "Jeremy E. Kozdon <jeremy@kozdon.net>", "Valentin Churavy <v.churavy@gmail.com>", "Hendrik Ranocha <hendrik.ranocha@uni-mainz.de>", "Erik Schnetter <eschnetter@perimeterinstitute.ca>", "Simon Byrne <simonbyrne@gmail.com>"]

[deps]
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
Expand All @@ -19,9 +19,11 @@ UnicodePlots = "b8865327-cd53-5732-bb35-84acbb429228"

[weakdeps]
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"

[extensions]
PETScCUDAExt = "CUDA"
PETScSciMLExt = "SciMLBase"

[compat]
CUDA = "5, 6"
Expand All @@ -34,6 +36,7 @@ OffsetArrays = "1.0"
PETSc_jll = "3.22"
Pkg = "^1.10"
Preferences = "1"
SciMLBase = "2"
SparseArrays = "1.10"
Statistics = "^1.10"
UnicodePlots = "3.0"
Expand All @@ -46,9 +49,10 @@ KernelAbstractions = "63c18a36-062a-441e-b654-da1e3ab1ce7c"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
SparseDiffTools = "47a9eef4-7e08-11e9-0b38-333d64bd3804"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
UnicodePlots = "b8865327-cd53-5732-bb35-84acbb429228"

[targets]
test = ["ForwardDiff", "UnicodePlots", "Test", "Plots", "SparseDiffTools", "Printf", "Random", "CairoMakie", "KernelAbstractions"]
test = ["CairoMakie", "ForwardDiff", "KernelAbstractions", "Plots", "Printf", "Random", "SciMLBase", "SparseDiffTools", "Test", "UnicodePlots"]
41 changes: 32 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,21 @@
[![DOI](https://zenodo.org/badge/38933145.svg)](https://doi.org/10.5281/zenodo.18274809)


`PETSc.jl` provides an interface to the Portable, Extensible Toolkit for Scientific Computation ([PETSc](https://petsc.org)) library, allowing the combination of Julia features (such as automatic differentiation) with the PETSc's infrastructure, including linear, nonlinear, and optimization solvers, timesteppers, domain management (DM), and more, in a distributed-memory (MPI) environment.
PETSc.jl provides an interface to the Portable, Extensible Toolkit for Scientific Computation ([PETSc](https://petsc.org)) library, allowing the combination of Julia features (such as automatic differentiation) with the PETSc's infrastructure, including linear, nonlinear, and optimization solvers, timesteppers, domain management (DM), and more, in a distributed-memory (MPI) environment.

This package comprises two main components:
This package comprises three main components:

1. An automatically generated, low-level interface for large parts of the PETSc API (see `PETSc.LibPETSc`).
2. A curated, high-level, more Julianic interface for selected functionality.
2. A curated, high-level, more Julian interface for selected functionality.
3. A package extension based on [SciMLBase.jl](https://github.com/SciML/SciMLBase.jl) that allows solving problems such as `ODEProblem`s with PETSc's algorithms.

The low-level interface covers nearly the entire PETSc API, but may be awkward to work with and likely requires previous experience with PETSc to use effectively. The high level interface is designed to be more familiar and convenient for Julia users, and allows, for example, to set matrix entries with `A[1,2] = 3.0`, rather than having to call `LibPETSc.MatSetValue`. It, however, exposes only a small portion of the functionality of the underlying library.
The low-level interface covers nearly the entire PETSc API, but may be awkward to work with and likely requires previous experience with PETSc to use effectively.
The high-level interface is designed to be more familiar and convenient for Julia users, and allows, for example, to set matrix entries with `A[1,2] = 3.0`, rather than having to call `LibPETSc.MatSetValue`.
However, it exposes only a small portion of the functionality of the underlying library.
The SciML package extension is work in progress and currently supports only (in-place) `ODEProblem`s.

## Installation
This package can be added with the julia command:
This package can be added with the Julia command:
```julia
julia>]add PETSc
```
Expand Down Expand Up @@ -45,10 +49,29 @@ julia>using PETSc
julia>[PETSc.petsclibs...]
```

## Windows users
The package currently does not work on windows, mainly because `MicrosoftMPI_jll` does not function when used along with the precompiled version used in `PETSc_jll`. Windows users are therefore advised to install the [Windows Subsystem for Linux](https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux) (WSL) and run PETSc through there.
## Windows users
The package currently does not work on Windows, mainly because `MicrosoftMPI_jll` does not function when used along with the precompiled version used in `PETSc_jll`.
Windows users are therefore advised to install the [Windows Subsystem for Linux](https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux) (WSL) and run PETSc through there.

## Getting started
Have a look at the [documentation](https://juliaparallel.org/PETSc.jl/stable/), at the [examples](./examples/) directory or at the tests in the [test](./test) directory. We do keep the tests up to date, so that is a good starting point.
Have a look at the [documentation](https://juliaparallel.org/PETSc.jl/stable/), at the [examples](./examples/) directory or at the tests in the [test](./test) directory.
We do keep the tests up to date, so that is a good starting point.

cause Note that we do not have tests in place for the whole library at this stage. The best supported parts are `DMDA`, `DMStag`, `DMPlex`, `KSP`, `SNES`, `Vec`, and `Mat`. Other DM types (DMForest, DMNetwork, DMSwarm) do not yet have a high-level interface; users will have to rely on the low-level `LibPETSc` interface for those.
Note that we do not have tests in place for the whole library at this stage. The best supported parts are `DMDA`, `DMStag`, `DMPlex`, `KSP`, `SNES`, `Vec`, and `Mat`. Other DM types (DMForest, DMNetwork, DMSwarm) do not yet have a high-level interface; users will have to rely on the low-level `LibPETSc` interface for those.

## SciML integration

PETSc.jl ships a package extension (`PETScSciMLExt`) that lets you solve in-place `ODEProblem`s with PETSc's TS time integrators through the standard SciML interface.
The extension activates automatically when SciMLBase.jl is loaded, e.g., when other ODE solver packages from the SciML ecosystem are used.

```julia
using PETSc, SciMLBase

f!(du, u, p, t) = (du[1] = -u[1]; nothing)
prob = ODEProblem(f!, [1.0], (0.0, 1.0))

sol = solve(prob, PETSc.TSRK("3bs"))
sol = solve(prob, PETSc.TSImplicit("bdf", ["-snes_fd"]); dt = 1e-3)
```

See the [SciML Integration](https://juliaparallel.github.io/PETSc.jl/dev/man/sciml/) documentation page for the full API, all supported algorithm types, keyword arguments, and current limitations.
1 change: 1 addition & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195"
PETSc = "ace2c81b-2b5f-4b1e-a30d-d662738edfe0"
SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
9 changes: 8 additions & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ makedocs(;
modules=[PETSc],
sitename="PETSc.jl",
checkdocs=:exports, # Only check exported functions, skip LibPETSc internals
warnonly=true, # Warn but don't error for any documentation issues
# Warn (don't error) for the documentation issues the large auto-wrapped
# LibPETSc API trips, but let `@example` / `@repl` block failures error the
# build so the executed code examples (e.g. man/sciml.md) stay functional.
warnonly=[
:autodocs_block, :cross_references, :docs_block, :eval_block,
:footnote, :linkcheck, :linkcheck_remotes, :meta_block, :missing_docs,
],
format=Documenter.HTML(;
prettyurls=get(ENV, "CI", "false") == "true",
size_threshold_warn = nothing, # Disable size warnings for large low-level API pages
Expand All @@ -14,6 +20,7 @@ makedocs(;
"Home" => "index.md",
"Installation" => "man/installation.md",
"Getting Started" => "man/getting_started.md",
"SciML Integration" => "man/sciml.md",
"High-level interface" => Any[
"Vec" => "man/vec.md",
"Mat" => "man/mat.md",
Expand Down
Loading
Loading