Newer
Older
MpiSimulation::MpiSimulation(int& argc, char**& 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);
if (this->mpiRank == 0) {
comm.sendBlocking(1, this->bodies);
} else if (this->mpiRank == 1) {
comm.recvBlocking(0, this->bodies);
}
bool MpiSimulation::stateCorrect() {
return this->correctState;
}
MpiSimulation::~MpiSimulation() {
MPI::Finalize();
}
int MpiSimulation::getNumberOfProcesses() {
return this->mpiSize;
}
int MpiSimulation::getProcessId() {
return this->mpiRank;
}