diff --git a/lib/nBodySim.cpp b/lib/nBodySim.cpp index b681ddb18670a399ec7866346277d97f63accdf5..1767c4dda726ee485106abba3b1a02c2d2616e57 100644 --- a/lib/nBodySim.cpp +++ b/lib/nBodySim.cpp @@ -6,7 +6,6 @@ #include <iomanip> nBodySim::nBodySim(std::string& datafile) { - // reads in data from datafile std::string dummy; std::ifstream file(datafile); file >> dummy >> dummy >> N_; @@ -41,6 +40,7 @@ nBodySim::nBodySim(std::string& datafile) { } forces_ = new double[3*N_]; + #pragma omp parallel for for (unsigned i=0; i < 3*N_; ++i) { forces_[i] = 0.0; } diff --git a/lib/nBodySim.hpp b/lib/nBodySim.hpp index c90d70d1d34d16141e941baf0e4a28a4995c4513..88fa964ade9ec7bf567b67c75bf2f2ff9aa395ef 100644 --- a/lib/nBodySim.hpp +++ b/lib/nBodySim.hpp @@ -5,14 +5,16 @@ class nBodySim { public: - // constructor & destructor + // constructor reads in data from datafile nBodySim(std::string& datafile); + // destructor deletes arrays ~nBodySim(); - // methods + // loops over all pairs of particles and calculates forces void calculateForces(); double* getMasses() { return masses_; } double* getPositions() { return positions_; } double* getForces() { return forces_; } + // writes data to file, every row is a particle void write2file(const double* array, std::string filename, unsigned dim) const; unsigned getN() const { return N_; } private: