Skip to content

Quick start ​

One step of a solver with SELAH: the stepper builds the stage states and the update; you fill the ghost cells and write the residual. This is the loop of Tutorial 4, on a periodic 1-D advection.

fortran
allocate(q(1:1, 0:NI+1, 0:2, 0:2, 1:NB))              ! (v,i,j,k,b): 1 component, NI x 1 x 1 cells, 1 ghost
bx = box_interior(LAYOUT_V_FIRST, 1_I4P, NI, 1_I4P, 1_I4P, 1_I4P, NB)
call st%initialize(scheme, FORM_BUTCHER, lb=lbound(q), ub=ubound(q))
fortran
call st%begin_step(bx, q)
do k=1, st%stages()
   call st%begin_stage(k, bx, dt, q)               ! the stepper builds the state of stage k
   u => st%stage_state()                           ! Butcher form: its own register
   r => st%rhs_register()                          ! where the residual of stage k goes
   call fill_ghosts(u)                             ! the caller: ghost cells of the stage state
   call residual(u, r, dx)                         ! the caller: r = -du/dx
   call st%end_stage(k, bx, dt, q)
enddo
call st%finish_step(bx, dt, q)                     ! q^{n+1}
  • box_interior describes the field: layout, components, cells per block, ghost cells, active blocks.
  • initialize takes the scheme, the storage form and the field's bounds, and allocates the registers.
  • Between begin_stage(k) and end_stage(k) the stage is yours: the ghost cells of the stage state, and its residual in rhs_register().

The whole program, and its output (fourth order, as SSP(5,4) promises):

text
$ stepper
steps   8: error  8.933E-06
steps  16: error  5.581E-07
steps  32: error  3.488E-08
observed orders:  4.00  4.00

Build and test ​

bash
fobis fetch && fobis build --mode tests-gnu && bash scripts/run_tests.sh
fobis build --mode tests-gnu-r4 && for t in exe-r4/selah_*; do $t > /dev/null || echo "FAIL $t"; done
bash scripts/run_vv.sh          # the verification report: data, figures, tables

Next: the Concepts, the Tutorial, or the Cookbook.

GPL-3.0-or-later, BSD-2-Clause, BSD-3-Clause or MIT, at your choice