StagBL is a C library designed to allow optimized, massively-parallel Stokes solvers for geodynamics application codes based on finite-volume methods on regular, orthogonal grids, usually coupled to a particle-based advection scheme.
It aims to be as lightweight as possible while still providing the flexibility and extensibility required for scientific application codes. This accomplished with careful design and interfaces to powerful external libraries. In particular, its parallel staggered-grid data structure leverages the DMStag component within PETSc.
Development of StagBL is supported by the Platform for Advanced Scientific Computing.
- PETSc
- Python (for configuration)
See StagBL on Read the Docs for additional information.
Clone a custom branch of PETSc
git clone https://bitbucket.org/psanan/petsc -b psanan/stagbl-working-base petsc-stagbl
Configure PETSc with some direct solver packages (SuiteSparse, SuperLU_dist, MUMPS), build, and check. See the PETSc website for full information.
An example configuration command for a local GNU/Linux system is
cd petsc-stagbl
unset PETSC_DIR PETSC_ARCH
./configure --download-mpich --with-debugging=0 --download-suitesparse --download-superlu_dist --download-mumps --download-metis --download-parmetis --download-scalapack --FOPTFLAGS='-g -O3' --COPTFLAGS='-g -O3' --CXXOPTFLAGS='-g -O3'
# Build and check as instructed
export PETSC_DIR=$PWD # this directory
export PETSC_ARCH=xxx # replace 'xxx' with the value shown during configuration.
cd ..
On an OS X system, first install XCode, and check that your compilers work
printf '#include<stdio.h>\nint main(){printf("OK!\\n");}' > t.c && /usr/bin/gcc t.c && ./a.out && rm t.c a.out
printf '#include<iostream>\nint main(){std::cout<<"OK!"<<std::endl;}' > t.cpp && /usr/bin/g++ t.cpp && ./a.out && rm t.cpp a.out
Next, install a Fortran compiler like gfortran. If you use MacPorts, Homebrew, Nix, etc. you can use those (recommended), or you can install it using these instructions. Test your compiler works
printf 'program t\nprint"(a)","OK!"\nend program' > t.f90 && gfortran t.f90 && ./a.out && rm t.f90 a.out
Then, configure as
cd petsc-stagbl
unset PETSC_DIR PETSC_ARCH
./configure --with-fc=gfortran --with-cc=/usr/bin/gcc --with-cxx=/usr/bin/g++ --download-mpich --download-hdf5 --download-metis --download-parmetis --download-scalapack --download-mumps --download-suitesparse --download-superlu_dist --with-debugging=no --FOPTFLAGS='-g -O3' --COPTFLAGS='-g -O3' --CXXOPTFLAGS='-g -O3' --download-cmake
# Build and check as instructed
export PETSC_DIR=$PWD # this directory
export PETSC_ARCH=xxx # replace 'xxx' with the value shown during configuration.
cd ..
In either case, note the values of PETSC_ARCH
and PETSC_DIR
defined during configuration.
You may want to define this in a login file, or otherwise record them for next time you log in.
Clone this repository, including submodules (using git 2.13 or later)
git clone --recurse-submodules https://github.com/stagbl/stagbl
Configure and build StagBL, making sure PETSC_ARCH and PETSC_DIR are defined, as above. (If you forget these values, PETSC_DIR is where you configured PETSc from, and PETSC_ARCH is the name of the directory, e.g. arch-linux-c-opt or arch-darwin-c-opt, that was created there during the configuration process).
cd stagbl
./configure.py # follow instructions to make
cd demos
make 2d
./stagbldemo2d
paraview out_element_0000.vtr &
In parallel, try
$PETSC_DIR/$PETSC_ARCH/bin/mpiexec -np 4 ./stagbldemo2d -mode sinker -stag_grid_x 30 -stag_grid_y 50
paraview out_element_0000.vtr &