92 auto const &box_geo = *system.box_geo;
93 auto &cell_structure = *system.cell_structure;
97 auto const is_inside_exclusion_range = [&](
Utils::Vector3d const &p1_pos,
99 double excluded_distance;
109 auto const d_min = box_geo.get_mi_vector(p2.pos(), p1_pos).norm();
110 return d_min < excluded_distance;
125 std::erase(all_ids, p_id);
129 auto const owner_rank =
130 boost::mpi::all_reduce(m_comm, (p1_ptr !=
nullptr) ? m_comm.rank() : -1,
131 boost::mpi::maximum<int>());
132 boost::mpi::broadcast(m_comm, p1_pos, owner_rank);
134 bool local_touched =
false;
135 for (
auto const p2_id : all_ids) {
136 auto const p2_ptr = cell_structure.get_local_particle(p2_id);
138 if (p2_ptr !=
nullptr and not p2_ptr->is_ghost() and
139 is_inside_exclusion_range(p1_pos, *p2_ptr)) {
140 local_touched =
true;
144 return boost::mpi::all_reduce(m_comm, local_touched, std::logical_or<>());
151 std::vector<int> particle_ids;
154 mutable_system.on_observable_calc();
155 auto const local_ids =
157 assert(p1_ptr ==
nullptr or !!local_ids);
159 particle_ids = std::move(*local_ids);
163 bool local_touched =
false;
164 if (p1_ptr !=
nullptr) {
165 auto const &p1 = *p1_ptr;
168 for (
auto const p2_id : particle_ids) {
169 if (
auto const p2_ptr = cell_structure.get_local_particle(p2_id)) {
170 if (is_inside_exclusion_range(p1.pos(), *p2_ptr)) {
171 local_touched =
true;
176 if (m_comm.rank() != 0) {
177 m_comm.send(0, 1, local_touched);
179 }
else if (m_comm.rank() == 0) {
180 m_comm.recv(boost::mpi::any_source, 1, local_touched);
182 boost::mpi::broadcast(m_comm, local_touched, 0);
183 return local_touched;
188 assert(boost::mpi::all_reduce(m_comm,
static_cast<int>(p !=
nullptr),
189 std::plus<>()) == 1);
191 if (m_comm.rank() == 0) {
193 type_local = p->type();
195 m_comm.recv(boost::mpi::any_source, 42, type_local);
198 m_comm.send(0, 42, p->type());
200 boost::mpi::broadcast(m_comm, type_local, 0);
std::optional< std::vector< int > > get_short_range_neighbors(System::System const &system, int const pid, double const distance)
Get ids of particles that are within a certain distance of another particle.
std::vector< int > get_particle_ids_parallel()
Particles creation and deletion.
Struct holding all information for one particle.