IO

Input

KitAMR.read_configFunction
read_config(filename::AbstractString) -> Dict{Symbol, Any}

Read .txt configuration file and return a dictionary.

source
KitAMR.listen_for_save!Function
listen_for_save!(; rank)

Start listening for the input from command line. Must be called before calling check_for_save!.

No-op when stdin does not support async reading — e.g. an IOStream under Pkg.test or redirected input — in which case the runtime save command is unavailable for that run.

source
KitAMR.check_for_save!Function
check_for_save!(p4est, ka; rank)

Check whether save is input during the iteration. If the result is true, a saving process will be executed.

source

The periodic status report (and the save hook) is driven once per step by

KitAMR.check!Function
check!(p4est, ka)

Perform a check procedure. Simulation status will be output every ST_CHECK_INTERVAL steps.

source
Todo

A bug exists here, which causes the save input will not be aware of, until one stdout is invoked.

Output

KitAMR.save_resultFunction
save_result(
    p4est::Ptr{P4est.LibP4est.p4est},
    ka::KA{DIM, NDF};
    dir_path
)

Save all results to dir_path. If isempty(dir_path) is true, a folder named result<yyyy-mm-dd_HH-MM> will be made in current path.

source

Animation frames are written incrementally during the run by

KitAMR.check_for_animsave!Function
check_for_animsave!(
    p4est::Union{Ptr{P4est.LibP4est.p4est}, Ptr{P4est.LibP4est.p8est}},
    ka;
    path
) -> Any

Write one animation frame to path when the current sim_time has reached the next frame time (integer multiples of output.anim_dt; the t = 0 state is also written). No-op when animation is disabled (output.anim_dt <= 0, the default). Which cells write their velocity space is controlled by output.vs_output_criterion (see Output). Intended to be called once per step after iterate!; solve! does this when animation = true.

source

Restart / checkpoint

Unlike save_result (which writes macroscopic fields for post-processing), a checkpoint stores the full phase-space state so a run can be resumed — possibly on a different number of MPI ranks. Write one with

KitAMR.save_for_restartFunction
save_for_restart(
    p4est::Union{Ptr{P4est.LibP4est.p4est}, Ptr{P4est.LibP4est.p8est}},
    ka::KA{DIM, NDF};
    dir_path,
    confirm
) -> Union{Nothing, String}

Write a full phase-space checkpoint of the current state to dir_path (default ./restart), from which the run can be resumed with restart — including on a different number of MPI ranks.

Unlike save_result, this stores every velocity cell's distribution function, so the checkpoint can be large. Each rank estimates its byte footprint; rank 0 prints the aggregate size and, when confirm = true and stdin is an interactive terminal, asks for y/n confirmation before writing (non-interactive runs just print the size and proceed). Returns the directory path, or nothing if the user declines.

Files written (see the module comment for the full layout): the p4est forest (p.*), the configuration (solverset.jld2 incl. the initial-condition / user-defined functions, plus output.jld2), the dynamic status (status.jld2), an integrity manifest.jld2, and one compressed restart_<rank>.jld2 per rank carrying the per-cell phase space.

Call after a time step (e.g. inside or after solve!); the saved distribution df is taken as-is, so no slope/macro update is performed.

source

and resume from it with

KitAMR.restartFunction
restart(
    dir_path::String;
    config,
    check_integrity
) -> Tuple{Union{Ptr{P4est.LibP4est.p4est}, Ptr{P4est.LibP4est.p8est}}, KA}

Resume a simulation from a checkpoint written by save_for_restart and return (p4est, ka), ready to hand to solve!. The number of MPI ranks may differ from the run that wrote the checkpoint; the saved field is remapped onto the current partition.

By default the configuration (including the initial-condition and user-defined functions) is loaded from dir_path/solverset.jld2. Those named functions must be defined in the current session (i.e. include the same user-defined-function script before calling restart), otherwise JLD2 cannot resolve them. Alternatively pass config = <your live Configure> to use the configuration from your script verbatim; its DIM/NDF/geometry/quadrature/vs_trees_num are then checked against the manifest.

check_integrity = true (default) verifies, on rank 0, that the manifest, configuration, forest and all per-rank data files are present and mutually consistent, raising a descriptive error on every rank if not.

The loaded distribution df is the restored state — no initial condition is re-applied and no pre-refinement is performed. Reports the resumed status before returning.

source

The configuration (including the initial-condition and user-defined functions) is saved with the checkpoint; the same user-defined-function script must be loaded in the session that calls restart, or a live config passed via the config keyword.