Running a simulation

The whole lifecycle of a run is four calls:

p4est, ka = initialize(config)   # build the solver state from a `Configure`
solve!(p4est, ka)                # run the time-stepping loop to completion
save_result(p4est, ka)           # write the converged field
finalize!(p4est, ka)             # release the C-managed memory

initialize is documented under Initialization, save_result under IO, and finalize! under Finalization. The callbacks referenced from a Configure (initial condition, refinement flags, velocity-space output) are collected on the User-defined functions page.

solve! encapsulates the per-step loop and exposes all of its parameters as keyword arguments:

KitAMR.solve!Function
solve!(
    p4est::Union{Ptr{P4est.LibP4est.p4est}, Ptr{P4est.LibP4est.p8est}},
    ka::KA;
    ps_interval,
    vs_interval,
    partition_interval,
    ps_recursive,
    vs_balance,
    max_steps,
    break_on_convergence,
    listen_for_save,
    animation,
    anim_path,
    status_check,
    progress
) -> KA

Run the kinetic solver's time-stepping loop to completion, so a simulation is just p4est, ka = initialize(config) followed by solve!(p4est, ka). Encapsulates the canonical per-step sequence (replacing the hand-written loop in the examples):

adaptive_mesh_refinement! → limit_Δt! → slope! → flux! → iterate!
    → check_for_animsave! → check! → (convergence break)

Returns ka.

Keyword arguments

(Initial mesh pre-refinement is now done by initialize via its prerefine_* keyword arguments, not here.)

AMR / load balancing (forwarded to adaptive_mesh_refinement! each step):

  • ps_interval=40, vs_interval=80, partition_interval=40
  • ps_recursive::Bool=false, vs_balance::Bool=false

Loop control:

  • max_steps=typemax(Int) — hard cap on the number of steps.
  • break_on_convergence::Bool=true — stop when check_for_convergence holds.

Lifecycle / IO (toggle false to manage these yourself):

  • listen_for_save::Bool=truelisten_for_save! before the loop.
  • animation::Bool=true, anim_path::String="./animation" — per-step check_for_animsave!.
  • status_check::Bool=true — per-step check! (periodic status print + save hook).
  • progress::Bool=true — show a ProgressMeter bar (rank 0 only) whose length is one ST_CHECK_INTERVAL window, i.e. how far the current step is from the next check!; it completes and restarts at each check.
source

Each stage that solve! runs is itself a public function, so you can write a custom loop instead of (or around) solve!: adaptive_mesh_refinement!, limit_Δt!, slope!, flux!, iterate!, check_for_animsave!, check!, check_for_convergence, reached_max_time.