From b9b0c14847cbcf32c750d0dcbffceeb982a0b70b Mon Sep 17 00:00:00 2001
From: "armindamon.riess" <armindamon.riess@uzh.ch>
Date: Wed, 30 Nov 2022 10:32:58 +0100
Subject: [PATCH] Added a few comments

---
 lib/nBodySim.cpp | 2 +-
 lib/nBodySim.hpp | 6 ++++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/lib/nBodySim.cpp b/lib/nBodySim.cpp
index b681ddb..1767c4d 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 c90d70d..88fa964 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:
-- 
GitLab