Newer
Older
#include "MpiSimulation.hpp"
namespace nbody {
MpiSimulation::MpiSimulation(int& argc, char**& argv) {
MPI::Datatype types[5] = {MPI::LB, MPI::DOUBLE, MPI::DOUBLE, MPI::DOUBLE, MPI::UB};
int blocklengths[5] = {1, 3, 3, 1, 1};
MPI::Aint displacements[5];
Body example;
MPI::Init(argc, argv);
displacements[0] = MPI::Get_address(&example);
displacements[1] = MPI::Get_address(&example.position[0]);
displacements[2] = MPI::Get_address(&example.acceleration[0]);
displacements[3] = MPI::Get_address(&example.mass);
displacements[4] = MPI::Get_address(&example + sizeof(Body));
this->mpiBody = this->mpiBody.Create_struct(5, blocklengths, displacements, types);
this->mpiBody.Commit();
this->mpiSize = MPI::COMM_WORLD.Get_size();
this->mpiRank = MPI::COMM_WORLD.Get_rank();
}
MpiSimulation::~MpiSimulation() {