p4est 2.8.6
p4est is a software library for parallel adaptive mesh refinement.
Documentation for selected 3D example programs

The p4est library comes with various example programs.

They are kept under the subdirectory example. Most have both a 2D and a 3D version. When the library is configured --enable-mpi, they can all be run in parallel on any number of MPI ranks, even on small computers.

Before proceeding with the examples on this page, it is highly recommended to get familiar with the programs, starting from 2D examples in Documentation for selected 2D example programs.

One first helpful program to try out is called p4est_simple (2D version) and p8est_simple (3D version), both under simple. On this page, we showcase some results of 3D example programs further below on this page, and we encourage everyone to play with the command line arguments.

The historic simple example

The example can be found in simple/simple3.c. It is a 3D version of simple/simple2.c The refinement pattern is generated by some hardcoded prescriptions based on a octants's tree number, refinement level and coordinates. Please see the documentation under the link for a full list of configurations.

This program creates/refines & coarsens/balances/partitions one of several available geometries specified on the command line. As a result, the output VTK files document all the steps of the mesh manipulation process.

  • Example: unit

    Create a connectivity structure for a stand-alone unit cube.

    Usage:

    p8est_simple unit 5 or with MPI: mpirun -np 4 p8est_simple unit 5

    • No. of trees: 1
    • Maximum refinement level: chosen on the command line as 5
  • Example: periodic

    Further enriching the upper example, this example program creates a connectivity structure of a unit cube with all-periodic boundary conditions.

    Usage:

    p8est_simple periodic 5 or with MPI: mpirun -np 4 p8est_simple periodic 5

    • No. of trees: 1
    • Maximum refinement level: chosen on the command line as 5
  • Example: two wraps

    Further developing the ideas above, this example program creates a connectivity structure of two wrap-up cubes (each of which is a tree). The visually not connected far ends of the two cubes are periodically identical.

    Usage:

    p8est_simple twowraps 5 or with MPI: mpirun -np 7 p8est_simple twowraps 5

    • No. of trees: 2
    • Maximum refinement level: chosen on the command line as 5