#include "../datastructures/Body.hpp" #include "MpiSimulation.hpp" #include "../datastructures/Tree.hpp" namespace nbody { MpiSimulation::MpiSimulation(int& argc, char**& argv) { MPI::Init(argc, argv); this->mpiSize = MPI::COMM_WORLD.Get_size(); this->mpiRank = MPI::COMM_WORLD.Get_rank(); this->correctState = true; if (this->mpiRank == 0) { if (argc != 2) { this->correctState = false; } else { this->bodies = Tree::dubinskiParse(string(argv[1])); if (bodies.empty()) { this->correctState = false; } } } MPI::COMM_WORLD.Bcast(&this->correctState, 1, MPI::BOOL, 0); MpiBodyComm comm; comm.testing(this->bodies, this->mpiRank); } bool MpiSimulation::stateCorrect() { return this->correctState; } MpiSimulation::~MpiSimulation() { MPI::Finalize(); } int MpiSimulation::getNumberOfProcesses() { return this->mpiSize; } int MpiSimulation::getProcessId() { return this->mpiRank; } }