Tutorial
Ten chapters that take a field solver from one Runge–Kutta step written by hand to a production loop on the GPU. Each chapter is a complete program in docs/examples/src/. The code on these pages is that program, and the output is what it printed when the documentation was built (bash scripts/docs_examples.sh regenerates both, and CI fails when they drift).
The model problem is the linear advection gideon_fd_d1_c2: SELAH is the source of the time operators, GIDEON of the space operators, and a solver built on SELAH takes its residual from a space-operator library rather than writing the stencil itself. Its semi-discrete solution is known exactly,
| Chapter | You learn |
|---|---|
| 1. A step by hand | what a Runge–Kutta step is in SELAH's terms: the flat kernels selah_stage_state and selah_step_update |
| 2. The catalogue | the schemes, their coefficients, storage forms and register counts; the splittings |
| 3. A field and a box | the block-structured field, ghost cells, the two layouts, what a kernel touches and what it leaves alone |
| 4. The stepper | driving one step stage by stage: what the stepper does, and what the caller does |
| 5. Low-storage forms | the same scheme with 2 registers instead of s + 1, and the same answer |
| 6. Splittings | partitions, flows and stage_partition on a Hamiltonian oscillator |
| 7. Masks | solid cells the integrator must not touch |
| 8. The flux register | stage_weight: the conservation identity behind AMR refluxing |
| 9. On the GPU | the same solver on device memory, with FUNDAL |
| 10. Production | your own register pool, stage 1 without a copy, the fused step residual |
Building the examples
Every program is compiled the way your own program would be: against the static library that FoBiS builds, which carries PENF and FUNDAL.
fobis fetch # PENF, FUNDAL and GIDEON into src/third_party
fobis build --mode static-gnu # lib/gnu/static/libselah.a and its modules
gfortran -cpp -DFUNDAL_NO_MPI -I lib/gnu/static/mod -I src/third_party/FUNDAL/src/lib \
docs/examples/src/stepper.F90 lib/gnu/static/libselah.a -o stepper
./stepperbash scripts/docs_examples.sh does this for every example, and rewrites the snippets and outputs these pages include.