24#include "communication.hpp"
26#include "system/System.hpp"
31#include <boost/mpi.hpp>
32#include <boost/serialization/access.hpp>
38#include <unordered_set>
46using Action = std::variant<DeleteBond, DeleteAngleBond, DeleteAllBonds>;
52void BondBreakage::queue_breakage(
int particle_id,
55 m_queue.emplace_back(
QueueEntry{particle_id, bond_partners, bond_type});
73 return bond_partners[1];
80 {{*(
e.bond_partners[0]), *(
e.bond_partners[1])}},
85#ifdef ESPRESSO_VIRTUAL_SITES_RELATIVE
96 "breakage action has to be configured for the "
97 "bond on the virtual site. Encountered a particle "
98 "that is not virtual.";
108 p2->vs_relative().to_particle_id},
110 p1->vs_relative().to_particle_id},
119 if (
not vs->is_virtual()) {
121 "breakage action has to be configured for the "
122 "bond on the virtual site. Encountered a particle "
123 "that is not virtual.";
154 std::vector<std::pair<int, int>>
to_delete;
155 for (
auto b : p.
bonds()) {
156 if (b.partner_ids().size() == 1
and b.partner_ids()[0] ==
other_pid)
170 : cell_structure{cell_structure} {}
191 auto &cell_structure = *
system.cell_structure;
197 assert(breakage_specs.contains(
e.bond_type));
198 auto const &
spec = breakage_specs.at(
e.bond_type);
203 for (
auto const &a :
actions) {
204 std::visit(execute(cell_structure), a);
205 system.on_particle_change();
210 std::span<Particle *>
partners,
int bond_id,
215 retval = bond_breakage.check_and_handle_breakage(
216 p.
id(), {{partners[0]->id(), std::nullopt}}, bond_id, d);
220 retval = bond_breakage.check_and_handle_breakage(
221 p.id(), {{partners[0]->id(), partners[1]->id()}}, bond_id, d);
227 system.cell_structure->update_ghosts_and_resort_particle(
228 system.get_global_ghost_flags());
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.
ESPRESSO_ATTR_ALWAYS_INLINE Utils::Vector3< T > get_mi_vector(Utils::Vector3< T > const &a, Utils::Vector3< T > const &b) const
Get the minimum-image vector between two coordinates.
Describes a cell structure / cell system.
Particle * get_local_particle(int id)
Get a local particle by id.
cudaStream_t stream[1]
CUDA streams for parallel computing on CPU and GPU.
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.
std::variant< DeleteBond, DeleteAngleBond, DeleteAllBonds > Action
static bool bond_handler(BondBreakage &bond_breakage, Particle &p, std::span< Particle * > partners, int bond_id, BoxGeometry const &box_geo)
std::array< std::optional< int >, 2 > BondPartners
Stores one or two bond partners 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.
Struct holding all information for one particle.
auto const & bonds() const