PETSc wrappers

List of of the Julia wrappers for the C functions and objects of the PETSc library. This is an incomplete list, based on what has been used in the past. If you are missing a wrapper for a specific function, it can be easily added using the GridapPETSc.PETSC.@wrapper macro.

GridapPETSc.PETSCModule

Low level interface with PETSC, which serve as the back-end in GridapPETSc.

The types and functions defined here are almost 1-to-1 to the corresponding C counterparts. In particular, the types defined can be directly used to call C PETSc routines via ccall. When a C function expects a pointer, use a Ref to the corresponding Julia alias. E.g., if an argument is PetscBool * in the C code, pass an object with type Ref{PetscBool} from the Julia code. Using this rule, PETSC.PetscInitialized can be called as

flag = Ref{PetscBool}()
@check_error_code PetscInitialized(flag)
if flag[] == PETSC_TRUE
  println("Petsc is initialized!")
end
source
GridapPETSc.PETSC.@wrapperMacro
macro wrapper(fn,rt,argts,args,url)

Wrapper macro for PETSc's C functions.

Usage:

To create a wrapper for PETSc's C function VecCreateSeq:

@wrapper(:VecCreateSeq,PetscErrorCode,(MPI.Comm,PetscInt,Ptr{Vec}),(comm,n,vec),"https://petsc.org/release/manualpages/Vec/VecCreateSeq/")

Many more examples can be found in the source code of the PETSc module.

source