Skip to content

Commit

Permalink
Merge branch 'python' into lbgpu_node_vel
Browse files Browse the repository at this point in the history
  • Loading branch information
KaiSzuttor committed Jul 10, 2019
2 parents 6c5ace0 + 326c261 commit 81b9c33
Show file tree
Hide file tree
Showing 37 changed files with 736 additions and 2,221 deletions.
39 changes: 39 additions & 0 deletions src/core/LocalBox.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#ifndef ESPRESSO_LOCALBOX_HPP
#define ESPRESSO_LOCALBOX_HPP

#include <utils/Vector.hpp>

template <class T> class LocalBox {
Utils::Vector<T, 3> m_local_box_l = {1, 1, 1};
Utils::Vector<T, 3> m_lower_corner = {0, 0, 0};
Utils::Vector<T, 3> m_upper_corner = {1, 1, 1};
Utils::Array<int, 6> m_boundaries = {};

public:
LocalBox() = default;
LocalBox(Utils::Vector<T, 3> const &lower_corner,
Utils::Vector<T, 3> const &local_box_length,
Utils::Array<int, 6> const &boundaries)
: m_local_box_l(local_box_length), m_lower_corner(lower_corner),
m_upper_corner(lower_corner + local_box_length),
m_boundaries(boundaries) {}

/** Left (bottom, front) corner of this nodes local box. */
Utils::Vector<T, 3> const &my_left() const { return m_lower_corner; }
/** Right (top, back) corner of this nodes local box. */
Utils::Vector<T, 3> const &my_right() const { return m_upper_corner; }
/** Dimensions of the box a single node is responsible for. */
Utils::Vector<T, 3> const &length() const { return m_local_box_l; }
/** @brief Boundary information for the local box.
*
* This returns for each of the faces of the local box if
* it is a boundary of the simulation box. The format is
* as follows:
* (x low, x high, y low, y high, z low, z high).
*
* @return Array with boundary information.
*/
Utils::Array<int, 6> const &boundary() const { return m_boundaries; }
};

#endif
21 changes: 6 additions & 15 deletions src/core/communication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
#include <boost/serialization/array.hpp>
#include <boost/serialization/string.hpp>
#include <boost/serialization/utility.hpp>
#include <utils/mpi/cart_comm.hpp>

using namespace std;

Expand Down Expand Up @@ -217,11 +218,12 @@ void mpi_init() {
#endif

MPI_Comm_size(MPI_COMM_WORLD, &n_nodes);
MPI_Dims_create(n_nodes, 3, node_grid.data());
node_grid = Utils::Mpi::dims_create<3>(n_nodes);

mpi_reshape_communicator({{node_grid[0], node_grid[1], node_grid[2]}},
/* periodicity */ {{1, 1, 1}});
MPI_Cart_coords(comm_cart, this_node, 3, node_pos.data());
comm_cart =
Utils::Mpi::cart_create(comm_cart, node_grid, /* reorder */ false);

this_node = comm_cart.rank();

Communication::m_callbacks =
std::make_unique<Communication::MpiCallbacks>(comm_cart);
Expand All @@ -236,17 +238,6 @@ void mpi_init() {
on_program_start();
}

void mpi_reshape_communicator(std::array<int, 3> const &node_grid,
std::array<int, 3> const &periodicity) {
MPI_Comm temp_comm;
MPI_Cart_create(MPI_COMM_WORLD, 3, const_cast<int *>(node_grid.data()),
const_cast<int *>(periodicity.data()), 0, &temp_comm);
comm_cart =
boost::mpi::communicator(temp_comm, boost::mpi::comm_take_ownership);

this_node = comm_cart.rank();
}

/****************** REQ_PLACE/REQ_PLACE_NEW ************/

void mpi_place_particle(int node, int id, const Utils::Vector3d &pos) {
Expand Down
8 changes: 0 additions & 8 deletions src/core/communication.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,6 @@ auto mpi_call(Tag tag, TagArg &&tag_arg, R (*fp)(Args...), ArgRef &&... args) {
/** Process requests from master node. Slave nodes main loop. */
void mpi_loop();

/**
* @brief Replace the MPI communicator by a new one with the given periodicity
* and node grid.
*/
void mpi_reshape_communicator(std::array<int, 3> const &node_grid,
std::array<int, 3> const &periodicity = {
{1, 1, 1}});

/** Issue REQ_PLACE: move particle to a position on a node.
* Also calls \ref on_particle_change.
* \param id the particle to move.
Expand Down
Loading

0 comments on commit 81b9c33

Please sign in to comment.