Skip to content
Snippets Groups Projects
MpiBodyComm.cpp 782 B
Newer Older
#include "MpiBodyComm.hpp"

namespace nbody {
	MpiBodyComm::MpiBodyComm() {
		this->bodies.push_back(Body());
		this->bodies.back().mass = 0.0;
		this->datatypes[0] = MPI::DOUBLE;
		this->datatypes[1] = MPI::DOUBLE;
		this->datatypes[2] = MPI::DOUBLE;
		this->blocklengths[0] = 3;
		this->blocklengths[1] = 3;
		this->blocklengths[2] = 1;
		this->displacements[0] = MPI::Get_address(&(this->bodies[0].position[0]));
		this->displacements[1] = MPI::Get_address(&(this->bodies[0].velocity[0]));
		this->displacements[2] = MPI::Get_address(&(this->bodies[0].mass));
		this->commBodyType = this->commBodyType.Create_struct(3, this->blocklengths, this->displacements, this->datatypes);
		this->commBodyType.Commit();
	}

	MpiBodyComm::~MpiBodyComm() {
		this->commBodyType.Free();
	}

}