built restart utilities
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "simulation/simulation.h"
|
||||
#include "mpi.h"
|
||||
#include <numeric>
|
||||
#include <random>
|
||||
#include <vector>
|
||||
@@ -20,6 +21,7 @@
|
||||
#include "poisson_solver/poisson_solver.h"
|
||||
|
||||
#include "IO/simulation_output.h"
|
||||
#include "IO/restart.h"
|
||||
|
||||
#include "generators/electric_field_generator.h"
|
||||
#include "generators/injector_generator.h"
|
||||
@@ -29,6 +31,7 @@
|
||||
#include "generators/species_generator.h"
|
||||
#include "generators/poisson_solver_generator.h"
|
||||
#include "generators/gravity_field_generator.h"
|
||||
#include "generators/restart_generator.h"
|
||||
|
||||
#include "tools/simulation_time.h"
|
||||
|
||||
@@ -59,16 +62,25 @@ void Simulation::init(Parameter& parameter) {
|
||||
poisson_solver_ = generator::buildPoissonSolver(parameter);
|
||||
electric_field_->updateDynamicField(poisson_solver_->staticElectricField());
|
||||
|
||||
DEBUG_LEVEL_0("Init cpu synchronizer.");
|
||||
cpu_synchronizer_ = std::make_shared<CpuSynchronizer>();
|
||||
DEBUG_LEVEL_3("Init done.");
|
||||
|
||||
Restart restarter = generator::buildRestart(parameter);
|
||||
restarter.restart(tracked_species_, poisson_solver_.get(), random_.get());
|
||||
// poisson solver is restarted -> set the electric field from the potential
|
||||
electric_field_->updateDynamicField(poisson_solver_->staticElectricField());
|
||||
|
||||
// make sure every proc is done with loading its restart info before
|
||||
// writing the metadata
|
||||
MPI_Barrier(MPI_COMM_WORLD);
|
||||
|
||||
DEBUG_LEVEL_0("Init output.");
|
||||
output_ = generator::buildSimulationOutput(
|
||||
parameter.jsonObjectFromBase({"Output"}), tracked_species_);
|
||||
|
||||
DEBUG_LEVEL_0("Output meta data.");
|
||||
output_->writeMetaData(tracked_species_, poisson_solver_);
|
||||
|
||||
DEBUG_LEVEL_0("Init cpu synchronizer.");
|
||||
cpu_synchronizer_ = std::make_shared<CpuSynchronizer>();
|
||||
DEBUG_LEVEL_3("Init done.");
|
||||
}
|
||||
|
||||
int eventsThisCpu(int events_all_cpus) {
|
||||
@@ -115,9 +127,28 @@ void Simulation::start() {
|
||||
int leftover_events_time_resolution = time_resolution_this_cpu;
|
||||
|
||||
const double delta_t = time_resolution_events*injector_->timePassed();
|
||||
|
||||
if(delta_t != timer_->getDeltaT()) {
|
||||
std::stringstream out;
|
||||
out << "Old delta t: " << timer_->getDeltaT();
|
||||
out << "; new delta t: " << delta_t;
|
||||
out << ". Currently not supported (leads to errors in the density calculated from "
|
||||
"the loaded data)";
|
||||
ERROR(out.str());
|
||||
}
|
||||
|
||||
timer_->setDeltaT(delta_t);
|
||||
injector_->initInjectionTimeDistribution(delta_t);
|
||||
|
||||
// // debugging(
|
||||
// for(auto& pair : tracked_species_) {
|
||||
// std::stringstream out;
|
||||
// out << pair.second->name() << ": ";
|
||||
// out << pair.second->densityForDrawing()->particleNumber();
|
||||
// DEBUG_LEVEL_0(out.str());
|
||||
// }
|
||||
// // )debugging
|
||||
|
||||
int num_cpu_syncs = 0;
|
||||
bool reset = true;
|
||||
|
||||
@@ -147,6 +178,15 @@ void Simulation::start() {
|
||||
num_cpu_syncs += 1;
|
||||
SimulationTimer::eventStopPoint(std::string("CpuSync"));
|
||||
|
||||
// // debugging(
|
||||
// for(auto& pair : tracked_species_) {
|
||||
// std::stringstream out;
|
||||
// out << pair.second->name() << ": ";
|
||||
// out << pair.second->densityForDrawing()->particleNumber();
|
||||
// DEBUG_LEVEL_0(out.str());
|
||||
// }
|
||||
// // )debugging
|
||||
|
||||
SIM_INFO("Poisson step.");
|
||||
SimulationTimer::eventStartPoint(std::string("PoissonStep"));
|
||||
poisson_solver_->solvePotential(chargedensity(), reset);
|
||||
|
||||
Reference in New Issue
Block a user