3939#include  " picongpu/random/seed/ISeed.hpp" 
4040#include  " picongpu/simulation/control/DomainAdjuster.hpp" 
4141#include  " picongpu/simulation/control/MovingWindow.hpp" 
42+ #include  " picongpu/simulation/control/checkpointingState.hpp" 
4243#include  " picongpu/simulation/stage/AtomicPhysics.hpp" 
4344#include  " picongpu/simulation/stage/Collision.hpp" 
4445#include  " picongpu/simulation/stage/CurrentBackground.hpp" 
6970#include  < pmacc/particles/traits/FilterByIdentifier.hpp> 
7071#include  < pmacc/random/RNGProvider.hpp> 
7172#include  < pmacc/random/methods/methods.hpp> 
73+ #include  < pmacc/simulationControl/Checkpointing.hpp> 
7274#include  < pmacc/simulationControl/SimulationHelper.hpp> 
7375#include  < pmacc/types.hpp> 
7476#include  < pmacc/verify.hpp> 
@@ -91,6 +93,8 @@ namespace picongpu
9193{
9294    using  namespace  pmacc ; 
9395
96+     using  SimHelper = SimulationHelper<simDim, simulationControl::Checkpointing<checkpointingEnabled>>;
97+ 
9498    /* *
9599     * Global simulation controller class. 
96100     * 
@@ -99,7 +103,7 @@ namespace picongpu
99103     * 
100104     * @tparam DIM the dimension (2-3) for the simulation 
101105     */  
102-     class  Simulation  : public  SimulationHelper <simDim> 
106+     class  Simulation  : public  SimHelper 
103107    {
104108    public: 
105109        /* *
@@ -109,7 +113,7 @@ namespace picongpu
109113
110114        void  pluginRegisterHelp (po::options_description& desc) override 
111115        {
112-             SimulationHelper<simDim> ::pluginRegisterHelp (desc);
116+             SimHelper ::pluginRegisterHelp
113117
114118            //  clang-format off
115119            desc.add_options ()(
@@ -159,7 +163,7 @@ namespace picongpu
159163        void  startSimulation () override 
160164        {
161165            if (!skipSimulation)
162-                 SimulationHelper<simDim> ::startSimulation ();
166+                 SimHelper ::startSimulation
163167        }
164168
165169        nlohmann::json metadata () const 
@@ -283,7 +287,7 @@ namespace picongpu
283287            log<picLog::DOMAINS>(" rank %1%; localsize %2%; localoffset %3%;" toString ()
284288                % gridSizeLocal.toString () % gridOffset.toString ();
285289
286-             SimulationHelper<simDim> ::pluginLoad ();
290+             SimHelper ::pluginLoad
287291
288292            GridLayout<simDim> layout (gridSizeLocal, GuardSize::toRT () * SuperCellSize::toRT ());
289293            cellDescription = std::make_unique<MappingDesc>(layout.sizeND (), DataSpace<simDim>(GuardSize::toRT ()));
@@ -304,7 +308,7 @@ namespace picongpu
304308        {
305309            DataConnector& dc = Environment<>::get ().DataConnector ();
306310
307-             SimulationHelper<simDim> ::pluginUnload ();
311+             SimHelper ::pluginUnload
308312
309313            /* * unshare all registered ISimulationData sets
310314             * 
@@ -456,36 +460,10 @@ namespace picongpu
456460            if (initialiserController)
457461            {
458462                initialiserController->printInformation ();
459-                 if (this ->restartRequested )
460-                 {
461-                     /*  we do not require '--checkpoint.restart.step' if a master checkpoint file is found */ 
462-                     if (this ->restartStep  < 0 )
463-                     {
464-                         std::vector<uint32_t > checkpoints = readCheckpointMasterFile ();
465- 
466-                         if (checkpoints.empty ())
467-                         {
468-                             if (this ->tryRestart  == false )
469-                             {
470-                                 throw  std::runtime_error (
471-                                     " Restart failed. You must provide the " 
472-                                     " '--checkpoint.restart.step' argument. See picongpu --help." 
473-                             }
474-                             else 
475-                             {
476-                                 //  no checkpoint found: start simulation from scratch
477-                                 this ->restartRequested  = false ;
478-                             }
479-                         }
480-                         else 
481-                             this ->restartStep  = checkpoints.back ();
482-                     }
483-                 }
484- 
485-                 if (this ->restartRequested )
463+                 if (this ->checkpointing .checkRestart (step))
486464                {
487-                     initialiserController-> restart (( uint32_t )  this ->restartStep ,  this -> restartDirectory );
488-                     step =  this ->restartStep ;
465+                     step =  static_cast < uint32_t >( this ->checkpointing . getRestartStep () );
466+                     initialiserController-> restart ( step,  this ->checkpointing . getRestartDir ()) ;
489467                }
490468                else 
491469                {
@@ -547,13 +525,13 @@ namespace picongpu
547525        void  dumpOneStep (uint32_t  currentStep) override 
548526        {
549527            fieldBackground->toDumpState (currentStep);
550-             SimulationHelper<simDim> ::dumpOneStep (currentStep);
528+             SimHelper ::dumpOneStep
551529        }
552530
553531        void  notifyPlugins (uint32_t  currentStep) override 
554532        {
555533            fieldBackground->toPluginState (currentStep);
556-             SimulationHelper<simDim> ::notifyPlugins (currentStep);
534+             SimHelper ::notifyPlugins
557535        }
558536
559537        void  movingWindowCheck (uint32_t  currentStep) override 
0 commit comments