ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
collision.cpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2011-2022 The ESPResSo project
3 *
4 * This file is part of ESPResSo.
5 *
6 * ESPResSo is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * ESPResSo is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include "collision.hpp"
21
22#ifdef COLLISION_DETECTION
23#include "BoxGeometry.hpp"
24#include "Particle.hpp"
26#include "cell_system/Cell.hpp"
28#include "communication.hpp"
29#include "errorhandling.hpp"
31#include "system/System.hpp"
32#include "virtual_sites.hpp"
33
34#include <utils/Vector.hpp>
35#include <utils/constants.hpp>
36#include <utils/math/sqr.hpp>
39
40#include <boost/mpi/collectives.hpp>
41#include <boost/serialization/serialization.hpp>
42
43#include <algorithm>
44#include <array>
45#include <cmath>
46#include <stdexcept>
47#include <string>
48#include <utility>
49#include <vector>
50
51/// Data type holding the info about a single collision
53 int pp1; // 1st particle id
54 int pp2; // 2nd particle id
55};
56
57namespace boost {
58namespace serialization {
59template <typename Archive>
60void serialize(Archive &ar, CollisionPair &c, const unsigned int) {
61 ar & c.pp1;
62 ar & c.pp2;
63}
64} // namespace serialization
65} // namespace boost
66
67/// During force calculation, colliding particles are recorded in the queue.
68/// The queue is processed after force calculation, when it is safe to add
69/// particles.
70static std::vector<CollisionPair> local_collision_queue;
71
72/// Parameters for collision detection
74
75namespace {
76Particle &get_part(CellStructure &cell_structure, int id) {
77 auto const p = cell_structure.get_local_particle(id);
78
79 if (not p) {
80 throw std::runtime_error("Could not handle collision because particle " +
81 std::to_string(id) + " was not found.");
82 }
83
84 return *p;
85}
86} // namespace
87
88/** @brief Return true if a bond between the centers of the colliding
89 * particles needs to be placed. At this point, all modes need this.
90 */
91static bool bind_centers() {
92 // Note that the glue to surface mode adds bonds between the centers
93 // but does so later in the process. This is needed to guarantee that
94 // a particle can only be glued once, even if queued twice in a single
95 // time step
98}
99
100static int get_bond_num_partners(int bond_id) {
101 return number_of_partners(*bonded_ia_params.at(bond_id));
102}
103
105 // If mode is OFF, no further checks
107 return;
108 }
109 // Validate distance
111 if (collision_params.distance <= 0.) {
112 throw std::domain_error("Parameter 'distance' must be > 0");
113 }
114
115 // Cache square of cutoff
117 }
118
119#ifndef VIRTUAL_SITES_RELATIVE
120 // The collision modes involving virtual sites also require the creation of a
121 // bond between the colliding
122 // If we don't have virtual sites, virtual site binding isn't possible.
125 throw std::runtime_error("collision modes based on virtual sites require "
126 "the VIRTUAL_SITES_RELATIVE feature");
127 }
128#endif
129
130#ifdef VIRTUAL_SITES
131 // Check vs placement parameter
133 if ((collision_params.vs_placement < 0.) or
135 throw std::domain_error(
136 "Parameter 'vs_placement' must be between 0 and 1");
137 }
138 }
139#endif
140
141 auto &system = System::get_system();
142 auto &nonbonded_ias = *system.nonbonded_ias;
143
144 // Check if bonded ia exist
147 throw std::runtime_error(
148 "Bond in parameter 'bond_centers' was not added to the system");
149 }
150
153 throw std::runtime_error(
154 "Bond in parameter 'bond_vs' was not added to the system");
155 }
156
157 // If the bond type to bind particle centers is not a pair bond...
158 // Check that the bonds have the right number of partners
161 throw std::runtime_error("The bond type to be used for binding particle "
162 "centers needs to be a pair bond");
163 }
164
165 // The bond between the virtual sites can be pair or triple
169 throw std::runtime_error("The bond type to be used for binding virtual "
170 "sites needs to be a pair or three-particle bond");
171 }
172
177 throw std::runtime_error(
178 "Insufficient bonds defined for three particle binding");
179 }
180
184 i++) {
185 if (get_bond_num_partners(i) != 2) {
186 throw std::runtime_error(
187 "The bonds for three particle binding need to be angle bonds.");
188 }
189 }
190 }
191
192 // Create particle types
193
196 throw std::domain_error("Collision detection particle type for virtual "
197 "sites needs to be >=0");
198 }
199 nonbonded_ias.make_particle_type_exist(collision_params.vs_particle_type);
200 }
201
204 throw std::domain_error("Collision detection particle type for virtual "
205 "sites needs to be >=0");
206 }
207 nonbonded_ias.make_particle_type_exist(collision_params.vs_particle_type);
208
210 throw std::domain_error("Collision detection particle type to be glued "
211 "needs to be >=0");
212 }
213 nonbonded_ias.make_particle_type_exist(
215
217 throw std::domain_error("Collision detection particle type to attach "
218 "the virtual site to needs to be >=0");
219 }
220 nonbonded_ias.make_particle_type_exist(
222
224 throw std::domain_error("Collision detection particle type after gluing "
225 "needs to be >=0");
226 }
227 nonbonded_ias.make_particle_type_exist(
229 }
230
231 system.on_short_range_ia_change();
232}
233
235
236void queue_collision(const int part1, const int part2) {
237 local_collision_queue.push_back({part1, part2});
238}
239
240/** @brief Calculate position of vs for GLUE_TO_SURFACE mode.
241 * Returns id of particle to bind vs to.
242 */
243static auto const &glue_to_surface_calc_vs_pos(Particle const &p1,
244 Particle const &p2,
245 BoxGeometry const &box_geo,
247 double c;
248 auto const vec21 = box_geo.get_mi_vector(p1.pos(), p2.pos());
249 auto const dist = vec21.norm();
250
251 // Find out, which is the particle to be glued.
255 } else if ((p2.type() == collision_params.part_type_to_be_glued) and
258 } else {
259 throw std::runtime_error("This should never be thrown. Bug.");
260 }
261 pos = p2.pos() + vec21 * c;
263 return p1;
264
265 return p2;
266}
267
269 Particle const &p2,
270 BoxGeometry const &box_geo,
271 Utils::Vector3d &pos1,
272 Utils::Vector3d &pos2) {
273 auto const vec21 = box_geo.get_mi_vector(p1.pos(), p2.pos());
274 pos1 = p1.pos() - vec21 * collision_params.vs_placement;
275 pos2 = p1.pos() - vec21 * (1. - collision_params.vs_placement);
276}
277
278// Considers three particles for three_particle_binding and performs
279// the binding if the criteria are met
281 Particle const &p2,
282 BoxGeometry const &box_geo) {
283 // If p1 and p2 are not closer or equal to the cutoff distance, skip
284 // p1:
285 if (box_geo.get_mi_vector(p.pos(), p1.pos()).norm() >
287 return;
288 // p2:
289 if (box_geo.get_mi_vector(p.pos(), p2.pos()).norm() >
291 return;
292
293 // Check, if there already is a three-particle bond centered on p
294 // with p1 and p2 as partners. If so, skip this triplet.
295 // Note that the bond partners can appear in any order.
296
297 /* Check if a bond is a bond placed by the collision detection */
298 auto is_collision_bond = [](BondView const &bond) {
299 return (bond.bond_id() >= collision_params.bond_three_particles) and
300 (bond.bond_id() <=
303 };
304 /* Check if the bond is between the particles we are currently considering */
305 auto has_same_partners = [id1 = p1.id(),
306 id2 = p2.id()](BondView const &bond) {
307 auto const partner_ids = bond.partner_ids();
308
309 return ((partner_ids[0] == id1) and (partner_ids[1] == id2)) or
310 ((partner_ids[0] == id2) and (partner_ids[1] == id1));
311 };
312
313 auto const &bonds = p.bonds();
314 if (std::any_of(bonds.begin(), bonds.end(), [=](auto const &bond) {
315 return is_collision_bond(bond) and has_same_partners(bond);
316 })) {
317 return;
318 }
319
320 // If we are still here, we need to create angular bond
321 // First, find the angle between the particle p, p1 and p2
322
323 /* vector from p to p1 */
324 auto const vec1 = box_geo.get_mi_vector(p.pos(), p1.pos()).normalize();
325 /* vector from p to p2 */
326 auto const vec2 = box_geo.get_mi_vector(p.pos(), p2.pos()).normalize();
327
328 auto const cosine = std::clamp(vec1 * vec2, -TINY_COS_VALUE, TINY_COS_VALUE);
329
330 // Bond angle
331 auto const phi = acos(cosine);
332
333 // We find the bond id by dividing the range from 0 to pi in
334 // three_particle_angle_resolution steps and by adding the id
335 // of the bond for zero degrees.
336 auto const bond_id = static_cast<int>(
337 floor(0.5 + phi / Utils::pi() *
340
341 // Create the bond
342 const std::array<int, 2> bondT = {{p1.id(), p2.id()}};
343 p.bonds().insert({bond_id, bondT});
344}
345
346#ifdef VIRTUAL_SITES_RELATIVE
348 BoxGeometry const &box_geo,
349 double const min_global_cut,
350 int const current_vs_pid,
351 Utils::Vector3d const &pos,
352 int const relate_to) {
353 Particle new_part;
354 new_part.id() = current_vs_pid;
355 new_part.pos() = pos;
356 auto p_vs = cell_structure.add_particle(std::move(new_part));
357 vs_relate_to(*p_vs, get_part(cell_structure, relate_to), box_geo,
358 min_global_cut);
359 p_vs->type() = collision_params.vs_particle_type;
360}
361
363 int const current_vs_pid,
364 CollisionPair const &c) {
366 case 1: {
367 // Create bond between the virtual particles
368 const int bondG[] = {current_vs_pid - 2};
369 // Only add bond if vs was created on this node
370 if (auto p = cell_structure.get_local_particle(current_vs_pid - 1))
371 p->bonds().insert({collision_params.bond_vs, bondG});
372 break;
373 }
374 case 2: {
375 // Create 1st bond between the virtual particles
376 const int bondG[] = {c.pp1, c.pp2};
377 // Only add bond if vs was created on this node
378 if (auto p = cell_structure.get_local_particle(current_vs_pid - 1))
379 p->bonds().insert({collision_params.bond_vs, bondG});
380 if (auto p = cell_structure.get_local_particle(current_vs_pid - 2))
381 p->bonds().insert({collision_params.bond_vs, bondG});
382 break;
383 }
384 }
385}
386
387static void glue_to_surface_bind_part_to_vs(Particle const *const p1,
388 Particle const *const p2,
389 int const vs_pid_plus_one,
390 CollisionPair const &,
391 CellStructure &cell_structure) {
392 // Create bond between the virtual particles
393 const int bondG[] = {vs_pid_plus_one - 1};
394
396 get_part(cell_structure, p1->id())
397 .bonds()
398 .insert({collision_params.bond_vs, bondG});
399 } else {
400 get_part(cell_structure, p2->id())
401 .bonds()
402 .insert({collision_params.bond_vs, bondG});
403 }
404}
405
406#endif // VIRTUAL_SITES_RELATIVE
407
408std::vector<CollisionPair> gather_global_collision_queue() {
409 std::vector<CollisionPair> res = local_collision_queue;
410 if (comm_cart.size() > 1) {
412 boost::mpi::broadcast(comm_cart, res, 0);
413 }
414 return res;
415}
416
418 Particle &p2,
419 BoxGeometry const &box_geo) {
420 auto handle_cell = [&p1, &p2, &box_geo](Cell *c) {
421 for (auto &p : c->particles()) {
422 // Skip collided particles themselves
423 if ((p.id() == p1.id()) or (p.id() == p2.id())) {
424 continue;
425 }
426
427 // We need all cyclical permutations, here (bond is placed on 1st
428 // particle, order of bond partners does not matter, so we don't need
429 // non-cyclic permutations).
430 // @ref coldet_do_three_particle_bond checks the bonding criterion and if
431 // the involved particles are not already bonded before it binds them.
432 if (!p.is_ghost()) {
433 coldet_do_three_particle_bond(p, p1, p2, box_geo);
434 }
435
436 if (!p1.is_ghost()) {
437 coldet_do_three_particle_bond(p1, p, p2, box_geo);
438 }
439
440 if (!p2.is_ghost()) {
441 coldet_do_three_particle_bond(p2, p, p1, box_geo);
442 }
443 }
444 };
445
446 /* Search the base cell ... */
447 handle_cell(basecell);
448
449 /* ... and all the neighbors. */
450 for (auto &n : basecell->neighbors().all()) {
451 handle_cell(n);
452 }
453}
454
455// Goes through the collision queue and for each pair in it
456// looks for a third particle by using the domain decomposition
457// cell system. If found, it performs three particle binding
459 CellStructure &cell_structure, BoxGeometry const &box_geo,
460 std::vector<CollisionPair> const &gathered_queue) {
461
462 for (auto &c : gathered_queue) {
463 // If we have both particles, at least as ghosts, Get the corresponding cell
464 // indices
465 if (cell_structure.get_local_particle(c.pp1) and
466 cell_structure.get_local_particle(c.pp2)) {
467 Particle &p1 = *cell_structure.get_local_particle(c.pp1);
468 Particle &p2 = *cell_structure.get_local_particle(c.pp2);
469 auto cell1 = cell_structure.find_current_cell(p1);
470 auto cell2 = cell_structure.find_current_cell(p2);
471
472 if (cell1)
473 three_particle_binding_do_search(cell1, p1, p2, box_geo);
474 if (cell2 and cell1 != cell2)
475 three_particle_binding_do_search(cell2, p1, p2, box_geo);
476
477 } // If local particles exist
478 } // Loop over total collisions
479}
480
481// Handle the collisions stored in the queue
482void handle_collisions(CellStructure &cell_structure) {
483 auto &system = System::get_system();
484 auto const &box_geo = *system.box_geo;
485 // Note that the glue to surface mode adds bonds between the centers
486 // but does so later in the process. This is needed to guarantee that
487 // a particle can only be glued once, even if queued twice in a single
488 // time step
489 if (bind_centers()) {
490 for (auto &c : local_collision_queue) {
491 // put the bond to the non-ghost particle; at least one partner always is
492 if (cell_structure.get_local_particle(c.pp1)->is_ghost()) {
493 std::swap(c.pp1, c.pp2);
494 }
495
496 const int bondG[] = {c.pp2};
497
498 get_part(cell_structure, c.pp1)
499 .bonds()
500 .insert({collision_params.bond_centers, bondG});
501 }
502 }
503
504// Virtual sites based collision schemes
505#ifdef VIRTUAL_SITES_RELATIVE
506 auto const min_global_cut = system.get_min_global_cut();
509 // Gather the global collision queue, because only one node has a collision
510 // across node boundaries in its queue.
511 // The other node might still have to change particle properties on its
512 // non-ghost particle
513 auto gathered_queue = gather_global_collision_queue();
514
515 // Sync max_seen_part
516 auto const global_max_seen_particle = boost::mpi::all_reduce(
517 comm_cart, cell_structure.get_max_local_particle_id(),
518 boost::mpi::maximum<int>());
519
520 int current_vs_pid = global_max_seen_particle + 1;
521
522 // Iterate over global collision queue
523 for (auto &c : gathered_queue) {
524
525 // Get particle pointers
526 Particle *p1 = cell_structure.get_local_particle(c.pp1);
527 Particle *p2 = cell_structure.get_local_particle(c.pp2);
528
529 // Only nodes take part in particle creation and binding
530 // that see both particles
531
532 // If we cannot access both particles, both are ghosts,
533 // or one is ghost and one is not accessible
534 // we only increase the counter for the ext id to use based on the
535 // number of particles created by other nodes
536 if (((!p1 or p1->is_ghost()) and (!p2 or p2->is_ghost())) or !p1 or !p2) {
537 // Increase local counters
539 current_vs_pid++;
540 }
541 // For glue to surface, we have only one vs
542 current_vs_pid++;
544 if (p1)
547 }
548 if (p2)
551 }
552 } // mode glue to surface
553
554 } else { // We consider the pair because one particle
555 // is local to the node and the other is local or ghost
556 // If we are in the two vs mode
557 // Virtual site related to first particle in the collision
559 Utils::Vector3d pos1, pos2;
560
561 // Enable rotation on the particles to which vs will be attached
564
565 // Positions of the virtual sites
566 bind_at_point_of_collision_calc_vs_pos(*p1, *p2, box_geo, pos1, pos2);
567
568 auto handle_particle = [&](Particle *p, Utils::Vector3d const &pos) {
569 if (not p->is_ghost()) {
570 place_vs_and_relate_to_particle(cell_structure, box_geo,
571 min_global_cut, current_vs_pid,
572 pos, p->id());
573 // Particle storage locations may have changed due to
574 // added particle
575 p1 = cell_structure.get_local_particle(c.pp1);
576 p2 = cell_structure.get_local_particle(c.pp2);
577 }
578 };
579
580 // place virtual sites on the node where the base particle is not a
581 // ghost
582 handle_particle(p1, pos1);
583 // Increment counter
584 current_vs_pid++;
585
586 handle_particle(p2, pos2);
587 // Increment counter
588 current_vs_pid++;
589 // Create bonds between the vs.
590
591 bind_at_poc_create_bond_between_vs(cell_structure, current_vs_pid, c);
592 } // mode VS
593
595 // If particles are made inert by a type change on collision:
596 // We skip the pair if one of the particles has already reacted
597 // but we still increase the particle counters, as other nodes
598 // can not always know whether or not a vs is placed
603 current_vs_pid++;
604 continue;
605 }
606 }
607
609 Particle const &attach_vs_to =
610 glue_to_surface_calc_vs_pos(*p1, *p2, box_geo, pos);
611
612 // Add a bond between the centers of the colliding particles
613 // The bond is placed on the node that has p1
614 if (!p1->is_ghost()) {
615 const int bondG[] = {c.pp2};
616 get_part(cell_structure, c.pp1)
617 .bonds()
618 .insert({collision_params.bond_centers, bondG});
619 }
620
621 // Change type of particle being attached, to make it inert
624 }
627 }
628
629 // Vs placement happens on the node that has p1
630 if (!attach_vs_to.is_ghost()) {
631 place_vs_and_relate_to_particle(cell_structure, box_geo,
632 min_global_cut, current_vs_pid, pos,
633 attach_vs_to.id());
634 // Particle storage locations may have changed due to
635 // added particle
636 p1 = cell_structure.get_local_particle(c.pp1);
637 p2 = cell_structure.get_local_particle(c.pp2);
638 current_vs_pid++;
639 } else { // Just update the books
640 current_vs_pid++;
641 }
642 glue_to_surface_bind_part_to_vs(p1, p2, current_vs_pid, c,
643 cell_structure);
644 }
645 } // we considered the pair
646 } // Loop over all collisions in the queue
647#ifdef ADDITIONAL_CHECKS
648 if (!Utils::Mpi::all_compare(comm_cart, current_vs_pid)) {
649 throw std::runtime_error("Nodes disagree about current_vs_pid");
650 }
651#endif
652
653 // If any node had a collision, all nodes need to resort
654 if (!gathered_queue.empty()) {
658 }
659 system.update_used_propagations();
660 } // are we in one of the vs_based methods
661#endif // defined VIRTUAL_SITES_RELATIVE
662
663 // three-particle-binding part
665 auto gathered_queue = gather_global_collision_queue();
666 three_particle_binding_domain_decomposition(cell_structure, box_geo,
667 gathered_queue);
668 } // if TPB
669
670 local_collision_queue.clear();
671}
672
673#endif // COLLISION_DETECTION
Vector implementation and trait types for boost qvm interoperability.
__shared__ int pos[MAXDEPTH *THREADS5/WARPSIZE]
__shared__ float res[]
BondedInteractionsMap bonded_ia_params
Field containing the parameters of the bonded ia types.
Data structures for bonded interactions.
int number_of_partners(Bonded_IA_Parameters const &iaparams)
Return the number of bonded partners for the specified bond.
Immutable view on a bond.
Definition BondList.hpp:45
mapped_type at(key_type const &key) const
bool contains(key_type const &key) const
Utils::Vector< T, 3 > get_mi_vector(const Utils::Vector< T, 3 > &a, const Utils::Vector< T, 3 > &b) const
Get the minimum-image vector between two coordinates.
Definition Cell.hpp:98
neighbors_type & neighbors()
All neighbors of the cell.
Definition Cell.hpp:116
int part_type_after_glueing
Particle type to which the newly glued particle is converted.
Definition collision.hpp:77
void initialize()
Validates parameters and creates particle types if needed.
int part_type_to_be_glued
For mode "glue to surface": The particle type being glued.
Definition collision.hpp:72
double vs_placement
Placement of virtual sites for MODE_VS.
Definition collision.hpp:90
int bond_centers
bond type used between centers of colliding particles
Definition collision.hpp:62
CollisionModeType mode
collision protocol
Definition collision.hpp:55
int three_particle_angle_resolution
Number of angle bonds to use (angular resolution) different angle bonds with different equilibrium an...
Definition collision.hpp:84
int part_type_to_attach_vs_to
For mode "glue to surface": The particle type to which the virtual site is attached.
Definition collision.hpp:75
double dist_glued_part_to_vs
For mode "glue to surface": The distance from the particle which is to be glued to the new virtual si...
Definition collision.hpp:70
int bond_three_particles
First bond type (for zero degrees) used for the three-particle bond (angle potential)
Definition collision.hpp:80
double distance
distance at which particles are bound
Definition collision.hpp:57
int bond_vs
bond type used between virtual sites
Definition collision.hpp:64
int vs_particle_type
particle type for virtual sites created on collision
Definition collision.hpp:66
cell_range all()
All neighbors.
Definition Cell.hpp:71
static void coldet_do_three_particle_bond(Particle &p, Particle const &p1, Particle const &p2, BoxGeometry const &box_geo)
static void place_vs_and_relate_to_particle(CellStructure &cell_structure, BoxGeometry const &box_geo, double const min_global_cut, int const current_vs_pid, Utils::Vector3d const &pos, int const relate_to)
void prepare_local_collision_queue()
void queue_collision(const int part1, const int part2)
Add the collision between the given particle ids to the collision queue.
static bool bind_centers()
Return true if a bond between the centers of the colliding particles needs to be placed.
Definition collision.cpp:91
static void three_particle_binding_domain_decomposition(CellStructure &cell_structure, BoxGeometry const &box_geo, std::vector< CollisionPair > const &gathered_queue)
static void three_particle_binding_do_search(Cell *basecell, Particle &p1, Particle &p2, BoxGeometry const &box_geo)
std::vector< CollisionPair > gather_global_collision_queue()
static std::vector< CollisionPair > local_collision_queue
During force calculation, colliding particles are recorded in the queue. The queue is processed after...
Definition collision.cpp:70
void handle_collisions(CellStructure &cell_structure)
Handle the collisions recorded in the queue.
static auto const & glue_to_surface_calc_vs_pos(Particle const &p1, Particle const &p2, BoxGeometry const &box_geo, Utils::Vector3d &pos)
Calculate position of vs for GLUE_TO_SURFACE mode.
static void glue_to_surface_bind_part_to_vs(Particle const *const p1, Particle const *const p2, int const vs_pid_plus_one, CollisionPair const &, CellStructure &cell_structure)
static int get_bond_num_partners(int bond_id)
Collision_parameters collision_params
Parameters for collision detection.
Definition collision.cpp:73
static void bind_at_poc_create_bond_between_vs(CellStructure &cell_structure, int const current_vs_pid, CollisionPair const &c)
static void bind_at_point_of_collision_calc_vs_pos(Particle const &p1, Particle const &p2, BoxGeometry const &box_geo, Utils::Vector3d &pos1, Utils::Vector3d &pos2)
@ BIND_CENTERS
Create bond between centers of colliding particles.
@ GLUE_TO_SURF
Glue a particle to a specific spot on another particle.
@ OFF
Deactivate collision detection.
@ BIND_THREE_PARTICLES
Three particle binding mode.
@ BIND_VS
Create a bond between the centers of the colliding particles, plus two virtual sites at the point of ...
Collision_parameters collision_params
Parameters for collision detection.
Definition collision.cpp:73
boost::mpi::communicator comm_cart
The communicator.
#define TINY_COS_VALUE
Tiny angle cutoff for cosine calculations.
Definition config.hpp:75
This file contains the errorhandling code for severe errors, like a broken bond or illegal parameter ...
@ DATA_PART_PROPERTIES
Particle::p.
@ DATA_PART_BONDS
Particle::bonds.
System & get_system()
bool all_compare(boost::mpi::communicator const &comm, T const &value)
Compare values on all nodes.
void gather_buffer(std::vector< T, Allocator > &buffer, boost::mpi::communicator const &comm, int root=0)
Gather buffer with different size on each node.
DEVICE_QUALIFIER constexpr T pi()
Ratio of diameter and circumference of a circle.
Definition constants.hpp:36
DEVICE_QUALIFIER constexpr T sqr(T x)
Calculates the SQuaRe of x.
Definition sqr.hpp:26
Particle & get_part(CellStructure &cell_structure, int id)
Definition collision.cpp:76
void serialize(Archive &ar, std::tuple< T... > &pack, unsigned int const)
Serialize std::tuple.
Various procedures concerning interactions between particles.
Describes a cell structure / cell system.
Particle * get_local_particle(int id)
Get a local particle by id.
Cell * find_current_cell(const Particle &p)
Find cell a particle is stored in.
void update_ghosts_and_resort_particle(unsigned data_parts)
Update ghost particles, with particle resort if needed.
void set_resort_particles(Cells::Resort level)
Increase the local resort level at least to level.
Particle * add_particle(Particle &&p)
Add a particle.
int get_max_local_particle_id() const
Get the maximal particle id on this node.
Data type holding the info about a single collision.
Definition collision.cpp:52
Struct holding all information for one particle.
Definition Particle.hpp:393
auto const & type() const
Definition Particle.hpp:416
auto const & bonds() const
Definition Particle.hpp:426
bool is_ghost() const
Definition Particle.hpp:438
auto const & pos() const
Definition Particle.hpp:429
void set_can_rotate_all_axes()
Definition Particle.hpp:471
auto const & id() const
Definition Particle.hpp:412
void vs_relate_to(Particle &p_vs, Particle const &p_relate_to, BoxGeometry const &box_geo, double min_global_cut)
Setup a virtual site to track a real particle.