A Julia package that bridges MultiGridBarrier.jl and SafePETSc.jl for distributed multigrid barrier computations.
MultiGridBarrierPETSc.jl extends MultiGridBarrier's API to work with PETSc's distributed Mat and Vec types, enabling efficient parallel computation of multigrid barrier methods across multiple MPI ranks.
using MultiGridBarrierPETSc
MultiGridBarrierPETSc.Init() # Initialize MPI, PETSc, and MUMPS solver
# Solve a 2D finite element problem with PETSc distributed types
sol = fem2d_petsc_solve(Float64; L=3, p=1.0, verbose=false)
# Convert to native types for plotting
using MultiGridBarrier
sol_native = petsc_to_native(sol)
plot(sol_native)- Drop-in Replacement: Seamlessly use PETSc types with MultiGridBarrier's API
- Distributed Computing: Leverage PETSc's distributed linear algebra for large-scale problems
- Type Conversion: Easy conversion between native Julia arrays and PETSc distributed types
- MPI-Aware: All operations correctly handle MPI collective requirements
- Automatic MUMPS: Direct solver automatically configured for accurate Newton iterations
using Pkg
Pkg.add("MultiGridBarrierPETSc")Prerequisites:
- Julia 1.10 or later
- MPI installation (OpenMPI, MPICH, or Intel MPI)
- PETSc with MUMPS (automatically installed via PETSc_jll.jl, or custom build for HPC)
See the Installation Guide for detailed instructions.
- User Guide: Workflows, examples, and best practices
- API Reference: Complete function documentation
- Examples: Runnable example scripts
# Basic solve example
julia -e 'using MPI; run(`$(MPI.mpiexec()) -n 4 $(Base.julia_cmd()) examples/basic_solve.jl`)'
# Round-trip conversion example
julia -e 'using MPI; run(`$(MPI.mpiexec()) -n 4 $(Base.julia_cmd()) examples/roundtrip_conversion.jl`)'Add --project or other Julia options as needed for your environment.
Run the test suite with 4 MPI ranks:
julia --project=. -e 'using Pkg; Pkg.test()'| Native Julia Type | PETSc Distributed Type | Storage |
|---|---|---|
Matrix{T} |
Mat{T, MPIDENSE} |
Dense distributed |
Vector{T} |
Vec{T} |
Dense distributed |
SparseMatrixCSC{T,Int} |
Mat{T, MPIAIJ} |
Sparse distributed |
- MultiGridBarrier.jl: Core multigrid barrier method
- SafePETSc.jl: Safe PETSc bindings
- MPI.jl: Julia MPI bindings
If you use this package in your research, please cite:
@software{multigridbarrierpetsc,
author = {Loisel, Sebastien},
title = {MultiGridBarrierPETSc.jl: Distributed Multigrid Barrier Methods},
year = {2024},
url = {https://github.com/sloisel/MultiGridBarrierPETSc.jl}
}To develop this package locally:
git clone https://github.com/sloisel/MultiGridBarrierPETSc.jl
cd MultiGridBarrierPETSc.jl
julia --project -e 'using Pkg; Pkg.instantiate()'
julia --project -e 'using Pkg; Pkg.test()'MIT License - see LICENSE file for details.
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.