45 double cutoff_regular,
double skin,
46 std::function<
bool()> get_ghost_flags,
49 std::set<int> n_square_types)
50 : m_comm(std::move(comm)), m_box(box_geo), m_cutoff_regular(cutoff_regular),
52 m_comm, cutoff_regular + skin, m_box, local_box, std::nullopt)),
54 m_n_square_types(std::move(n_square_types)),
55 m_get_global_ghost_flags(std::move(get_ghost_flags)) {
60 std::copy(local_cells_n_square.begin(), local_cells_n_square.end(),
61 std::back_inserter(m_local_cells));
66 std::copy(ghost_cells_n_square.begin(), ghost_cells_n_square.end(),
67 std::back_inserter(m_ghost_cells));
72 std::copy(exchange_ghosts_comm_n_square.communications.begin(),
73 exchange_ghosts_comm_n_square.communications.end(),
76 m_collect_ghost_force_comm =
78 auto collect_ghost_force_comm_n_square =
80 std::copy(collect_ghost_force_comm_n_square.communications.begin(),
81 collect_ghost_force_comm_n_square.communications.end(),
86 std::copy(ghost_cells_n_square.begin(), ghost_cells_n_square.end(),
87 std::back_inserter(additional_reds));
88 for (
auto &local_cell : m_regular_decomposition.
local_cells()) {
89 std::vector<Cell *> red_neighbors(local_cell->m_neighbors.red().begin(),
90 local_cell->m_neighbors.red().end());
91 std::vector<Cell *> black_neighbors(local_cell->m_neighbors.black().begin(),
92 local_cell->m_neighbors.black().end());
93 std::copy(additional_reds.begin(), additional_reds.end(),
94 std::back_inserter(red_neighbors));
100 std::vector<ParticleChange> &diff) {
104 for (
auto &c : m_regular_decomposition.
local_cells()) {
105 for (
auto it = c->particles().begin(); it != c->particles().end();) {
107 if (not is_n_square_type(it->type())) {
113 auto p = std::move(*it);
114 it = c->particles().erase(it);
120 first_local_cell->particles().insert(std::move(p));
121 diff.emplace_back(
ModifiedList{first_local_cell->particles()});
126 for (
auto it = c->particles().begin(); it != c->particles().end();) {
128 if (is_n_square_type(it->type())) {
134 auto p = std::move(*it);
135 it = c->particles().erase(it);
142 if (target_cell !=
nullptr) {
143 target_cell->particles().insert(std::move(p));
144 diff.emplace_back(
ModifiedList{target_cell->particles()});
149 first_local_cell->particles().insert(std::move(p));
150 diff.emplace_back(
ModifiedList{first_local_cell->particles()});
157 m_regular_decomposition.
resort(global, diff);
158 m_n_square.
resort(global, diff);
175 boost::mpi::reduce(m_comm, count_local, count_global, std::plus<>{}, 0);
HybridDecomposition(boost::mpi::communicator comm, double cutoff_regular, double skin, std::function< bool()> get_ghost_flags, BoxGeometry const &box_geo, LocalBox const &local_box, std::set< int > n_square_types)