/** * Begin the simulation. */ void startSimulation() { uint32_t currentStep = init(); tInit.toggleEnd(); if (output) { std::cout << "initialization time: " << tInit.printInterval() << " = " << (int) (tInit.getInterval() / 1000.) << " sec" << std::endl; } TimeIntervall tSimCalculation; TimeIntervall tRound; double roundAvg = 0.0; /* dump initial step if simulation starts without restart */ if (currentStep == 0) dumpOneStep(currentStep); else currentStep--; //we dump before calculation, thus we must go on step back if we do a restart movingWindowCheck(currentStep); //if we restart at any step check if we must slide /* dump 0% output */ dumpTimes(tSimCalculation, tRound, roundAvg, currentStep); while (currentStep < runSteps) { tRound.toggleStart(); runOneStep(currentStep); tRound.toggleEnd(); roundAvg += tRound.getInterval(); currentStep++; /*output after a round*/ dumpTimes(tSimCalculation, tRound, roundAvg, currentStep); movingWindowCheck(currentStep); /*dump after simulated step*/ dumpOneStep(currentStep); } //simulatation end Environment<>::get().Manager().waitForAllTasks(); tSimCalculation.toggleEnd(); if (output) { std::cout << "calculation simulation time: " << tSimCalculation.printInterval() << " = " << (int) (tSimCalculation.getInterval() / 1000.) << " sec" << std::endl; } }
/** * Begin the simulation. */ void startSimulation() { init(); // translate checkpointPeriod string into checkpoint intervals seqCheckpointPeriod = pluginSystem::toTimeSlice( checkpointPeriod ); for (uint32_t nthSoftRestart = 0; nthSoftRestart <= softRestarts; ++nthSoftRestart) { resetAll(0); uint32_t currentStep = fillSimulation(); Environment<>::get().SimulationDescription().setCurrentStep( currentStep ); tInit.toggleEnd(); if (output) { std::cout << "initialization time: " << tInit.printInterval() << " = " << (int) (tInit.getInterval() / 1000.) << " sec" << std::endl; } TimeIntervall tSimCalculation; TimeIntervall tRound; double roundAvg = 0.0; /* Since in the main loop movingWindow is called always before the dump, we also call it here for consistency. * This becomes only important, if movingWindowCheck does more than merely checking for a slide. * TO DO in a new feature: Turn this into a general hook for pre-checks (window slides are just one possible action). */ movingWindowCheck(currentStep); /* dump initial step if simulation starts without restart */ if (!restartRequested) { dumpOneStep(currentStep); } /* dump 0% output */ dumpTimes(tSimCalculation, tRound, roundAvg, currentStep); /** \todo currently we assume this is the only point in the simulation * that is allowed to manipulate `currentStep`. Else, one needs to * add and act on changed values via * `SimulationDescription().getCurrentStep()` in this loop */ while (currentStep < Environment<>::get().SimulationDescription().getRunSteps()) { tRound.toggleStart(); runOneStep(currentStep); tRound.toggleEnd(); roundAvg += tRound.getInterval(); /* NEXT TIMESTEP STARTS HERE */ currentStep++; Environment<>::get().SimulationDescription().setCurrentStep( currentStep ); /* output times after a round */ dumpTimes(tSimCalculation, tRound, roundAvg, currentStep); movingWindowCheck(currentStep); /* dump at the beginning of the simulated step */ dumpOneStep(currentStep); } // simulatation end Environment<>::get().Manager().waitForAllTasks(); tSimCalculation.toggleEnd(); if (output) { std::cout << "calculation simulation time: " << tSimCalculation.printInterval() << " = " << (int) (tSimCalculation.getInterval() / 1000.) << " sec" << std::endl; } } // softRestarts loop }