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::ranges::copy(local_cells_n_square, std::back_inserter(m_local_cells));
65 std::ranges::copy(ghost_cells_n_square, std::back_inserter(m_ghost_cells));
70 std::ranges::copy(exchange_ghosts_comm_n_square.communications,
73 m_collect_ghost_force_comm =
75 auto collect_ghost_force_comm_n_square =
78 collect_ghost_force_comm_n_square.communications,
83 std::ranges::copy(ghost_cells_n_square, std::back_inserter(additional_reds));
84 for (
auto &local_cell : m_regular_decomposition.
local_cells()) {
85 std::vector<Cell *> red_neighbors(local_cell->m_neighbors.red().begin(),
86 local_cell->m_neighbors.red().end());
87 std::vector<Cell *> black_neighbors(local_cell->m_neighbors.black().begin(),
88 local_cell->m_neighbors.black().end());
89 std::ranges::copy(additional_reds, std::back_inserter(red_neighbors));
95 std::vector<ParticleChange> &diff) {
99 for (
auto &c : m_regular_decomposition.
local_cells()) {
100 for (
auto it = c->particles().begin(); it != c->particles().end();) {
102 if (not is_n_square_type(it->type())) {
108 auto p = std::move(*it);
109 it = c->particles().erase(it);
115 first_local_cell->particles().insert(std::move(p));
116 diff.emplace_back(
ModifiedList{first_local_cell->particles()});
121 for (
auto it = c->particles().begin(); it != c->particles().end();) {
123 if (is_n_square_type(it->type())) {
129 auto p = std::move(*it);
130 it = c->particles().erase(it);
137 if (target_cell !=
nullptr) {
138 target_cell->particles().insert(std::move(p));
139 diff.emplace_back(
ModifiedList{target_cell->particles()});
144 first_local_cell->particles().insert(std::move(p));
145 diff.emplace_back(
ModifiedList{first_local_cell->particles()});
152 m_regular_decomposition.
resort(global, diff);
153 m_n_square.
resort(global, diff);
170 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)
void ghost_communicator(GhostCommunicator const &gcr, BoxGeometry const &box_geo, unsigned int data_parts)
Do a ghost communication with the specified data parts.