Migrating from OpenPFC 0.1 to 0.2¶
This is the user-facing replacement list for the 0.2 architecture. The
historical milestone table used during the refactor is in
docs/archive/.
Use this page when porting an application or example off the 0.1 Model /
Simulator / App path.
0.2 production physics (tungsten, aluminumNew) already runs on the generic
pfc::ui::SpectralETDSession<Physics, Stack> (over pfc::sim::SpectralETDSystem)
and pfc::sim::run. There is no
pfc::Model, pfc::Simulator, or pfc::ui::App.
Architecture in one paragraph¶
A 0.2 run owns a domain (pfc::Domain + pfc::Box3i), a stack
(SpectralCPUStack, GPUSpectralStack, FDCPUStack, or FDGPUStack), optional
SimulationState for named fields, a Time object, and a thin loop
(pfc::sim::run / SimulationDriver). Physics is a callable step(t) (or a
composed stepper). JSON still describes domain, time, method/backend,
plan_options, initial conditions, writers, and checkpoint /
restart_from.
Removed symbols → replacements¶
0.1 |
0.2 |
|---|---|
|
Physics struct or lambda; for stiff spectral models a |
|
|
|
|
|
|
|
|
|
Apply modifiers in the |
|
Writer on the |
|
|
|
Deleted — wrap physics as |
|
Deleted — call the physics stepper from |
|
|
|
|
|
|
|
|
|
App-local |
|
|
|
|
|
|
|
|
|
|
|
|
from_json<Domain> shares the Lx/Ly/Lz/dx/dy/dz/origin schema
with the old from_json<World>.
Code shape¶
0.1
class DiffusionModel : public pfc::Model {
void initialize(double dt) override;
void step(double t) override;
};
pfc::Simulator sim(model, time);
sim.add_initial_conditions(std::make_unique<Constant>(0.0));
while (!pfc::done(sim)) pfc::step(sim);
0.2
pfc::Domain domain = pfc::ui::from_json<pfc::Domain>(settings);
pfc::Time time = pfc::ui::from_json<pfc::Time>(settings);
pfc::sim::stacks::SpectralCPUStack stack(std::move(domain), rank, nproc);
auto &psi = stack.u();
pfc::Constant ic(0.0);
ic.apply(psi.vec(), psi.domain(), psi.box(), 0.0);
pfc::sim::run(
time,
[&](double t) { physics.step(t); },
/* on_start */ {},
/* apply BCs */ {},
/* on_save */ [&](const pfc::Time &clock) { writer.write(pfc::time::increment(clock), psi.vec()); });
JSON sessions:
auto session = pfc::ui::make_simulation_session<pfc::sim::stacks::SpectralCPUStack>(
settings, rank, nproc, comm);
session.run([&](double t) { /* step stack.u() */ });
Production tungsten/aluminum keep JSON ICs, BCs, writers, and
checkpoint/restart_from inside their ETD session types.
JSON keys that still work¶
Unchanged: Lx/Ly/Lz, dx/dy/dz, origin/origo, t0/t1/dt/saveat,
method (spectral|fd), backend (cpu|cuda|hip), plan_options,
fields[], initial_conditions[], boundary_conditions[], checkpoint,
restart_from.
Changed:
There is no
pfc::ui::App. Drivers construct a session and callrun().simulator.integrator.methodstill overlaysTime::method()(overlay_simulator_integrator_method/apply_simulator_section_from_json).simulator.incrementmay overlayTime::set_increment.simulator.result_counteris ignored; dump indices come fromTimeor the checkpoint bundle.restart_fromcannot be combined withsimulator.incrementorsimulator.result_counter.
Field modifiers¶
Implement one method:
void apply(pfc::field::FieldOutput<double> field, const pfc::Domain &domain,
const pfc::Box3i &box, double time) override;
JSON catalogs (default_field_modifier_catalog(),
parse_initial_conditions_from_json) still resolve type strings. Apply the
returned modifiers on the host buffer that matches box.
Checkpoints¶
pfc::ui::make_checkpoint_service(settings, comm) builds a
CheckpointService. Sessions call restore_from_config(state, time) after
declaring fields, and maybe_save(state, time) from the physics step. There is
no Gen-1 restore_gen1_from_checkpoint.
Where to look¶
Task |
Header / example |
|---|---|
Time loop |
|
JSON → session |
|
JSON FD heat |
|
JSON ICs / writers |
|
Spectral-ETD JSON session |
|
Tungsten production |
|
Spectral example |
|
Custom JSON IC |
|
API catalog |
|
Adapters A0–A2¶
ID |
Status in 0.2 |
|---|---|
A1 |
Deleted |
A2 |
Deleted |
A0 |
Deleted — use |