Skip to content
Snippets Groups Projects
Commit b9b0c148 authored by Armin Damon Riess's avatar Armin Damon Riess
Browse files

Added a few comments

parent 8dc586e3
No related branches found
No related tags found
No related merge requests found
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#include <iomanip> #include <iomanip>
nBodySim::nBodySim(std::string& datafile) { nBodySim::nBodySim(std::string& datafile) {
// reads in data from datafile
std::string dummy; std::string dummy;
std::ifstream file(datafile); std::ifstream file(datafile);
file >> dummy >> dummy >> N_; file >> dummy >> dummy >> N_;
...@@ -41,6 +40,7 @@ nBodySim::nBodySim(std::string& datafile) { ...@@ -41,6 +40,7 @@ nBodySim::nBodySim(std::string& datafile) {
} }
forces_ = new double[3*N_]; forces_ = new double[3*N_];
#pragma omp parallel for
for (unsigned i=0; i < 3*N_; ++i) { for (unsigned i=0; i < 3*N_; ++i) {
forces_[i] = 0.0; forces_[i] = 0.0;
} }
......
...@@ -5,14 +5,16 @@ ...@@ -5,14 +5,16 @@
class nBodySim { class nBodySim {
public: public:
// constructor & destructor // constructor reads in data from datafile
nBodySim(std::string& datafile); nBodySim(std::string& datafile);
// destructor deletes arrays
~nBodySim(); ~nBodySim();
// methods // loops over all pairs of particles and calculates forces
void calculateForces(); void calculateForces();
double* getMasses() { return masses_; } double* getMasses() { return masses_; }
double* getPositions() { return positions_; } double* getPositions() { return positions_; }
double* getForces() { return forces_; } double* getForces() { return forces_; }
// writes data to file, every row is a particle
void write2file(const double* array, std::string filename, unsigned dim) const; void write2file(const double* array, std::string filename, unsigned dim) const;
unsigned getN() const { return N_; } unsigned getN() const { return N_; }
private: private:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment