Skip to content

Checkpoint / Restart

hippoLBM can save the full simulation state to a binary dump file at regular intervals and reload it later to continue a run. A dump file stores the distribution functions \(f_i\), the obstacle field, the LBM parameters (tau, nu, Fext, …), the timestep counter and the physical time. The domain geometry (bounds, resolution, periodicity) is also embedded, so the restart file is self-contained, except for the bounce-back planes (see below). The data are compressed with zlib.

Saving checkpoints

Add simulation_dump_freq to the global block:

1
2
3
4
global:
  simulation_dump_freq: 3000    # a checkpoint every 3000 iterations
  simulation_end_iteration: 30000
  output_directory: "MySimDir"

A dump file is then written every 3000 iterations to <output_directory>/CheckPointRestart/hippoLBM_<timestep>.dump, for example MySimDir/CheckPointRestart/hippoLBM_0000003000.dump.

Note

The checkpoint is written at the end of the iteration, after the collision and streaming steps, so the file always contains a physically consistent state.

Final checkpoint

display_last_output: true writes both a ParaView output and a dump file at the very end of the simulation, regardless of simulation_dump_freq:

1
2
3
global:
  simulation_end_iteration: 30000
  display_last_output: true

write_dump

For finer control, override the write_dump operator:

1
2
3
4
write_dump:
  filename: "checkpoint_%010d.dump"
  output_directory: "MySimDir"
  compression_level: 6
Slot Type Default Description
filename string "hippoLBM_%010d.dump" filename pattern (printf-style, receives the timestep)
output_directory string "hippoLBMOutputDir" base output directory
compression_level int 1 zlib compression level, from 1 (fastest, larger file) to 9 (smallest, slower)
display_filename bool true print the filename in the log

Restarting from a checkpoint

Replace the do_domain block by a read_dump call. The operator rebuilds the full simulation state — grid, fields, parameters, timestep and physical time — from the file:

1
2
3
do_domain:
  - read_dump:
     filename: "MySimDir/CheckPointRestart/hippoLBM_0000003000.dump"

Note

The default initialization and the set_distributions block are automatically skipped on restart (read_dump sets do_set_distributions to false): the distribution functions of the checkpoint are used directly. You do not need to remove your set_distributions block.

The boundary conditions, analysis operators and global settings are read from the input file as usual, so you can change simulation_end_iteration to extend the run:

do_domain:
  - read_dump:
     filename: "MySimDir/CheckPointRestart/hippoLBM_0000003000.dump"

boundary_conditions:
  - neumann:
     U: [0.001, 0, 0]
     regions: [plan_xy_l]
  - neumann:
     U: [0.0, 0, 0]
     regions: [plan_xy_0]

global:
  simulation_end_iteration: 60000   # continue for 30000 more iterations
  simulation_dump_freq: 3000
  simulation_paraview_freq: 500
  output_directory: "MySimDir"

read_dump

Slot Type Default Description
filename string required path to the .dump file
skip_params bool false if true, the LBM parameters of the checkpoint are ignored and those of the lbm_parameters block are used (restart with a different viscosity or forcing)
display_info bool true print a summary of the checkpoint (timestep, grid size, parameters)
periodic [bool;3] optional override the periodicity stored in the dump

Restart with a different viscosity

do_domain:
  - read_dump:
     filename: "MySimDir/CheckPointRestart/hippoLBM_0000003000.dump"
     skip_params: true

set_lbm_parameters:
  - lbm_parameters:
     nuth: 5e-4

Bounce-back planes

The bounce_back_planes of domain are not stored in the dump. When the simulation uses bounce-back domain walls, declare them again after read_dump with add_bounce_back_bcs:

+setup_obstacles:
  - add_bounce_back_bcs:
     bounce_back_planes: [plan_xy_0, plan_xy_l]

Inspecting a dump file

check_dump reads a dump file, prints its header (version, timestep, grid size, number of MPI ranks, fields, LBM parameters), checks its internal consistency, and stops the run. Use it to verify that a checkpoint is not corrupted before a restart:

1
2
3
simulation:
  - check_dump:
     filename: "MySimDir/CheckPointRestart/hippoLBM_0000003000.dump"

The regression test regression_lbm_checkpoint_restart restarts a Couette flow from regression-test/data/couette_0000003000.dump.