OpenPFC / Build a simulation
Stop, rebuild and continue the same trajectory
Publish a field checkpoint, restore into new fields and a new clock, and compare against an uninterrupted run.
Download runnable lesson (.zip)
Includes the model, inputs, required headers and a short run guide.
A field file becomes a restart only when the rest of the accepted state can be interpreted consistently. This example evolves \(u_t=-u\) with the visible Euler update \(u^{m+1}=(1-h)u^m\), starting from \(1+.2\cos x\). It compares eight uninterrupted steps with three steps, a checkpoint, and five steps after rebuilding the state from disk.
Save an accepted state, then create a new one
auto state = make_state(true);
pfc::Time time({0, steps * dt, dt}, 0);
for (int step = 0; step < split; ++step) advance(state, time);
pfc::sim::CheckpointService checkpoints(
{.every = 0, .directory = "results/checkpoints"}, comm);
checkpoints.set_result_counter(7);
checkpoints.save(state, time);
auto restarted =
make_state(false); // New fields and clock; no accepted values reused.
pfc::Time restart_time({0, steps * dt, dt}, 0);
pfc::sim::CheckpointService loader({}, comm);
loader.load(restarted, restart_time, checkpoints.step_dir(split));
for (int step = restart_time.get_increment(); step < steps; ++step)
advance(restarted, restart_time);CheckpointService publishes all named double fields and metadata. The new registry starts with zero values, so a successful comparison must actually restore the saved samples. A new Time has the same start, end, fixed step and method identity. The result counter, set to seven before saving, is also recovered; it need not equal the step increment.
Compare the right trajectory
The discrete oracle is
\[u^m(x)=(1-h)^m(1+.2\cos x). \tag{1}\]
The continuous solution \(e^{-mh}(1+.2\cos x)\) differs by Euler truncation error. A successful restart should preserve the discrete calculation’s answer; it cannot remove the integrator’s error. Here both paths use the same pointwise updates, so we require exactly equal stored final values.
Read what was published
openpfc run model.cpp input.json --launcher=noneThis source-driven lesson ignores its empty input; edit dt, split and steps in the C++ source. The checkpoint is under results/checkpoints/step_3/; the final comparison is results/restart_rank_<rank>.csv. Use two ranks to exercise collective publication and load. The checks inspect checkpoint metadata, validate every final global sample, and verify the restored result counter.
This chapter uses a fixed step deliberately. The service reconstructs accepted time from the stored increment and the configured fixed-step clock, then checks that it matches the metadata. It is not a demonstration of restarting an arbitrary adaptive history. Adaptive controller memory, method caches and external constitutive history need their own explicit restart contracts. The public checkpoint service checks domain and method identity before loading the field bundle.
The complete C++ model and starting input are available with this lesson.