32#include <boost/mpi/collectives/all_to_all.hpp>
40void AtomDecomposition::configure_neighbors() {
45 for (
int n = 0; n < m_comm.size(); n++) {
46 if (m_comm.rank() == n) {
50 if (n < m_comm.rank()) {
69 if (m_comm.size() == 1) {
70 plan.collective = CollectiveSection{CollectivePattern::None, {}};
80 cell_ptrs.reserve(
static_cast<std::size_t
>(m_comm.size()));
81 for (
int n = 0; n < m_comm.size(); ++n) {
82 cell_ptrs.push_back(&cells.at(
static_cast<std::size_t
>(n)).particles());
85 CollectiveSection{CollectivePattern::Broadcast, std::move(
cell_ptrs)};
89void AtomDecomposition::configure_comms() {
90 m_halo_plan = make_halo_plan();
96void AtomDecomposition::mark_cells() {
97 m_local_cells.resize(1, std::addressof(local()));
98 m_ghost_cells.clear();
99 for (
int n = 0; n < m_comm.size(); n++) {
100 if (n != m_comm.rank()) {
101 m_ghost_cells.push_back(std::addressof(cells.at(n)));
107 std::vector<ParticleChange> &
diff) {
111 p.pos_at_last_verlet_update() = p.pos();
120 std::vector<std::vector<Particle>> send_buf(m_comm.size());
121 for (
auto it = local().particles().begin();
134 std::vector<std::vector<Particle>> recv_buf(m_comm.size());
135 boost::mpi::all_to_all(m_comm, send_buf, recv_buf);
140 for (
auto &
parts : recv_buf) {
141 for (
auto &p :
parts) {
142 local().
particles().insert(std::move(p));
152 : m_comm(
std::
move(comm)), cells(m_comm.size()), m_box(box_geo) {
156 configure_neighbors();
172 c->m_is_boundary =
true;
174#ifdef ESPRESSO_ADDITIONAL_CHECKS
181 "AtomDecomposition"));
Vector implementation and trait types for boost qvm interoperability.
Utils::Vector3d max_range() const override
AtomDecomposition(BoxGeometry const &m_box)
Utils::Vector3d max_cutoff() const override
void resort(bool global_flag, std::vector< ParticleChange > &diff) override
std::span< Cell *const > local_cells() const override
std::span< Cell *const > ghost_cells() const override
void fold_position(Utils::Vector3d &pos, Utils::Vector3i &image_box) const
Fold coordinates to primary simulation box in-place.
neighbors_type m_neighbors
auto & particles()
Particles.
static DEVICE_QUALIFIER constexpr Vector< T, N > broadcast(typename Base::value_type const &value) noexcept
Create a vector that has all entries set to the same value.
cudaStream_t stream[1]
CUDA streams for parallel computing on CPU and GPU.
void mark_boundary_cells(std::span< Cell *const > local_cells, std::span< Cell *const > ghost_cells, std::function< bool(Cell const *, Cell const *)> wrap_predicate=nullptr)
Classify each local cell as interior or boundary.
bool report_violations(std::vector< std::string > const &violations, char const *context)
Print violations to stderr and return whether the list was empty.
std::vector< std::string > validate_halo_plan(HaloPlan const &plan, std::span< Cell *const > local_cells, std::span< Cell *const > ghost_cells)
Validate a HaloPlan for correctness.
boost::mpi::communicator comm