Skip to content

JuliaParallel/PETSc.jl

Repository files navigation

PETSc.jl

Build Status doc stable doc dev DOI

PETSc.jl provides an interface to the Portable, Extensible Toolkit for Scientific Computation (PETSc) 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:

  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.

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.

Installation

This package can be added with the julia command:

julia>]add PETSc

The installation can be tested with

julia>]test PETSc

PETSc binaries

By default, the package uses a pre-built binary of PETSc (see PETSc_jll) along with a default installation of MPI.jl, so you don't have to install it on your machine.

If you want to use the package with custom builds of the PETSc library, this can be done by using the function set_petsclib which requires you to point to the correct dynamic library (which should be compatible with the MPI version used by MPI.jl)

using PETSc

# Create custom library instance
petsclib = set_petsclib("/path/to/custom/libpetsc.so"; 
                       PetscScalar=Float64, PetscInt=Int64)
# Use it like any precompiled library
PETSc.initialize(petsclib, log_view=true)
# ... your code ...
PETSc.finalize(petsclib)

To get an overview of available precompiled libraries:

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 (WSL) and run PETSc through there.

Getting started

Have a look at the documentation, at the examples directory or at the tests in the test directory. We do keep the tests up to date, so that is a good starting point.

Note, that we do not have tests in place for the whole library at this stage. The best supported parts are DMDA,DMStag, KSP,SNES,Vec and Mat interfaces, while other parts such as DMPlex do not have a high-level interface or tests yet. Users will thus have to rely on the low-level interface.

About

Julia wrappers for the PETSc library

Topics

Resources

License

Stars

Watchers

Forks

Contributors 23

Languages