22#ifdef ESPRESSO_COLLISION_DETECTION
23#ifdef ESPRESSO_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");
63 throw std::domain_error(
"Parameter 'vs_placement' must be between 0 and 1");
70 if (n_partners != 1 and n_partners != 2) {
71 throw std::runtime_error(
"The bond type to be used for binding virtual "
72 "sites needs to be a pair bond");
77 throw std::domain_error(
"Collision detection particle type for virtual "
78 "sites needs to be >=0");
84 System::System &system, std::vector<CollisionPair> &local_collision_queue) {
87 auto const &box_geo = *system.
box_geo;
98 auto const global_max_seen_particle = boost::mpi::all_reduce(
99 ::comm_cart, cell_structure.get_max_local_particle_id(),
100 boost::mpi::maximum<int>());
102 int current_vs_pid = global_max_seen_particle + 1;
105 for (
auto const &[pid1, pid2] : global_collision_queue) {
108 Particle *p1 = cell_structure.get_local_particle(pid1);
109 Particle *p2 = cell_structure.get_local_particle(pid2);
131 auto const vec21 = box_geo.get_mi_vector(p1->
pos(), p2->
pos());
135 auto handle_particle = [&
136#if defined(__clang__) and defined(__cray__) or defined(__INTEL_LLVM_COMPILER)
138 pid1 = pid1, pid2 = pid2
141 if (not p->is_ghost()) {
143 min_global_cut, current_vs_pid, pos,
147 p1 = cell_structure.get_local_particle(pid1);
148 p2 = cell_structure.get_local_particle(pid2);
153 handle_particle(p1, pos1);
157 handle_particle(p2, pos2);
163 if (n_partners == 1) {
165 const int bondG[] = {current_vs_pid - 2};
167 if (
auto p = cell_structure.get_local_particle(current_vs_pid - 1))
168 p->bonds().insert({
bond_vs, bondG});
170 if (n_partners == 2) {
172 const int bondG[] = {pid1, pid2};
174 if (
auto p = cell_structure.get_local_particle(current_vs_pid - 1))
175 p->bonds().insert({
bond_vs, bondG});
176 if (
auto p = cell_structure.get_local_particle(current_vs_pid - 2))
177 p->bonds().insert({
bond_vs, bondG});
181#ifdef ESPRESSO_ADDITIONAL_CHECKS
183 "Nodes disagree about current_vs_pid");
187 if (not global_collision_queue.empty()) {
189 cell_structure.update_ghosts_and_resort_particle(
Vector implementation and trait types for boost qvm interoperability.
Data structures for bonded interactions.
int number_of_partners(Bonded_IA_Parameters const &iaparams)
Get the number of bonded partners for the specified bond.
bool contains(key_type const &key) const
mapped_type const & at(key_type const &key) const
void handle_collisions(System::System &system, std::vector< CollisionPair > &local_collision_queue)
int part_type_vs
particle type for virtual sites created on collision
double distance
Distance at which particle are bound.
int bond_vs
bond type used between virtual sites
int bond_centers
bond type used between centers of colliding particles
double distance_sq
Square of distance at which particle are bound.
double vs_placement
Barycenter of the virtual site.
void initialize(System::System &system)
void make_particle_type_exist(int type)
Make sure the interaction parameter list is large enough to cover interactions for this particle type...
void update_used_propagations()
Update the global propagation bitmask.
std::shared_ptr< BondedInteractionsMap > bonded_ias
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.
@ 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)
void add_bind_centers(std::vector< CollisionPair > &collision_queue, System::System &system, int bond_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.
constexpr auto const & pos() const
constexpr void set_can_rotate_all_axes()
constexpr bool is_ghost() const