diff --git a/lib/nBodySim.cpp b/lib/nBodySim.cpp index eeb28e3989b151c90007834929735d9e1fa6e508..93d225b2e0d1b7a031358f580a36715e505c11f0 100644 --- a/lib/nBodySim.cpp +++ b/lib/nBodySim.cpp @@ -181,7 +181,7 @@ void nBodySim::write2file(const double* array, std::string filename, unsigned di void nBodySim::saveState2file(unsigned step, std::string filename) const { std::ofstream file(filename); // save step number - file << "step = " << step; + file << "step: " << step << std::endl; // save number of particles file << nParticles_ << std::endl; // save masses diff --git a/main.cpp b/main.cpp index 5224b2965021278f4c274d5ad3f8d7fbdc1621a1..525473ddf8cba4c8de78d284fe5aec64b086d982 100644 --- a/main.cpp +++ b/main.cpp @@ -56,12 +56,14 @@ int main(int argc, char** argv) { try { sim.runSimulation(dt, nSteps); } catch (std::exception& e) { + // save state of simulation + sim.saveState2file(nSteps, "../out/errstate.txt"); std::cerr << e.what() << std::endl; return 1; } // save state of simulation - sim.saveState2file(nSteps, "../out/state.txt"); + sim.saveState2file(nSteps, "../out/endstate.txt"); return 0; } \ No newline at end of file