24#include "communication.hpp"
26#include "system/System.hpp"
31#include <boost/mpi.hpp>
32#include <boost/serialization/access.hpp>
33#include <boost/variant.hpp>
37#include <unordered_set>
44using Action = boost::variant<DeleteBond, DeleteAngleBond, DeleteAllBonds>;
50void BondBreakage::queue_breakage(
int particle_id,
53 m_queue.emplace_back(
QueueEntry{particle_id, bond_partners, bond_type});
58 Queue res = local_queue;
70 auto is_angle_bond = [](
auto const &bond_partners) {
71 return bond_partners[1];
83#ifdef VIRTUAL_SITES_RELATIVE
92 if (not p1->is_virtual() or not p2->is_virtual()) {
94 "breakage action has to be configured for the "
95 "bond on the virtual site. Encountered a particle "
96 "that is not virtual.";
106 p2->vs_relative().to_particle_id},
108 p1->vs_relative().to_particle_id},
117 if (not vs->is_virtual()) {
119 "breakage action has to be configured for the "
120 "bond on the virtual site. Encountered a particle "
121 "that is not virtual.";
141 auto &bond_list = p.
bonds();
142 auto it = std::find(bond_list.begin(), bond_list.end(), view);
143 if (it != bond_list.end()) {
152 std::vector<std::pair<int, int>> to_delete;
153 for (
auto b : p.
bonds()) {
154 if (b.partner_ids().size() == 1 and b.partner_ids()[0] == other_pid)
155 to_delete.emplace_back(b.bond_id(), other_pid);
157 for (
auto const &b : to_delete) {
163class execute :
public boost::static_visitor<> {
168 : cell_structure{cell_structure} {}
193 for (
auto const &e : global_queue) {
195 assert(breakage_specs.count(e.bond_type) != 0);
196 auto const &spec = breakage_specs.at(e.bond_type);
201 for (
auto const &a : actions) {
202 boost::apply_visitor(execute(cell_structure), a);
execute(CellStructure &cell_structure)
void operator()(DeleteAngleBond const &d) const
void operator()(DeleteBond const &d) const
void operator()(DeleteAllBonds const &d) const
Immutable view on a bond.
void on_particle_change()
Called every time a particle property changes.
std::shared_ptr< CellStructure > cell_structure
boost::mpi::communicator comm_cart
The communicator.
This file contains the errorhandling code for severe errors, like a broken bond or illegal parameter ...
#define runtimeErrorMsg()
static void remove_pair_bonds_to(Particle &p, int other_pid)
Delete pair bonds to a specific partner.
static void remove_bond(Particle &p, BondView const &view)
Delete specific bond.
static ActionSet actions_for_breakage(CellStructure const &cell_structure, QueueEntry const &e, BreakageSpec const &spec)
Constructs the actions to take for a breakage queue entry.
@ REVERT_BIND_AT_POINT_OF_COLLISION
static auto gather_global_queue(Queue const &local_queue)
Gathers combined queue from all mpi ranks.
boost::variant< DeleteBond, DeleteAngleBond, DeleteAllBonds > Action
std::array< std::optional< int >, 2 > BondPartners
Stores one or two bond parnters for pair/angle bonds.
std::vector< QueueEntry > Queue
Record bonds broken during a time step.
std::unordered_set< Action > ActionSet
void gather_buffer(std::vector< T, Allocator > &buffer, boost::mpi::communicator const &comm, int root=0)
Gather buffer with different size on each node.
BondPartners bond_partners
Describes a cell structure / cell system.
Particle * get_local_particle(int id)
Get a local particle by id.
Struct holding all information for one particle.
auto const & bonds() const