22#ifdef COLLISION_DETECTION
23#ifdef VIRTUAL_SITES_RELATIVE
34#include "communication.hpp"
36#include "system/System.hpp"
43#include <boost/mpi/collectives.hpp>
44#include <boost/mpi/operations.hpp>
56 throw std::domain_error(
"Parameter 'distance' must be > 0");
62 throw std::domain_error(
"Collision detection particle type for virtual "
63 "sites needs to be >=0");
68 throw std::domain_error(
"Collision detection particle type to be glued "
74 throw std::domain_error(
"Collision detection particle type to attach "
75 "the virtual site to needs to be >=0");
80 throw std::domain_error(
"Collision detection particle type after gluing "
87 System::System &system, std::vector<CollisionPair> &local_collision_queue) {
90 auto const &box_geo = *system.
box_geo;
103 auto const global_max_seen_particle = boost::mpi::all_reduce(
104 ::comm_cart, cell_structure.get_max_local_particle_id(),
105 boost::mpi::maximum<int>());
107 int current_vs_pid = global_max_seen_particle + 1;
110 for (
auto &c : global_collision_queue) {
113 Particle *p1 = cell_structure.get_local_particle(c.first);
114 Particle *p2 = cell_structure.get_local_particle(c.second);
148 auto const vec21 = box_geo.get_mi_vector(p1->
pos(), p2->
pos());
149 auto const dist = vec21.norm();
159 assert(ratio != -1.);
160 auto const pos = p2->
pos() + vec21 * ratio;
161 auto const &attach_vs_to =
167 const int bondG[] = {c.second};
179 if (attach_vs_to.is_ghost()) {
184 min_global_cut, current_vs_pid, pos,
187 p1 = cell_structure.get_local_particle(c.first);
188 p2 = cell_structure.get_local_particle(c.second);
193 int const bondG[] = {current_vs_pid - 1};
197#ifdef ADDITIONAL_CHECKS
199 "Nodes disagree about current_vs_pid");
203 if (not global_collision_queue.empty()) {
205 cell_structure.update_ghosts_and_resort_particle(
Vector implementation and trait types for boost qvm interoperability.
Data structures for bonded interactions.
int part_type_vs
particle type for virtual sites created on collision
double dist_glued_part_to_vs
Distance from the particle which is to be glued to the new virtual site.
int bond_centers
bond type used between centers of colliding particles
double distance_sq
Square of distance at which particle are bound.
double distance
Distance at which particle are bound.
int part_type_to_attach_vs_to
The particle type to which virtuals site are attached (the large particle)
int bond_vs
bond type used between virtual sites
int part_type_after_glueing
Particle type to which the newly glued particle is converted.
void initialize(System::System &system)
void handle_collisions(System::System &system, std::vector< CollisionPair > &local_collision_queue)
int part_type_to_be_glued
The particle type being glued (the small particle)
void update_used_propagations()
Update the global propagation bitmask.
auto get_min_global_cut() const
Get min_global_cut.
std::shared_ptr< CellStructure > cell_structure
std::shared_ptr< BoxGeometry > box_geo
std::shared_ptr< InteractionsNonBonded > nonbonded_ias
boost::mpi::communicator comm_cart
The communicator.
This file contains the defaults for ESPResSo.
@ DATA_PART_PROPERTIES
Particle::p.
@ DATA_PART_BONDS
Particle::bonds.
void place_vs_and_relate_to_particle(CellStructure &cell_structure, BoxGeometry const &box_geo, int const part_type_vs, double const min_global_cut, int const current_vs_pid, Utils::Vector3d const &pos, int const relate_to)
auto gather_collision_queue(std::vector< CollisionPair > const &local)
auto & get_part(CellStructure &cell_structure, int id)
bool all_compare(boost::mpi::communicator const &comm, T const &value)
Compare values on all nodes.
DEVICE_QUALIFIER constexpr T sqr(T x)
Calculates the SQuaRe of x.
Various procedures concerning interactions between particles.
Struct holding all information for one particle.
auto const & type() const
auto const & bonds() const