61 std::unordered_map<int, std::vector<std::pair<int, int>>>
partners;
65 auto &cell_structure = *
system.cell_structure;
68 for (
auto const &p : cell_structure.local_particles()) {
69 auto const pid1 = p.id();
70 for (
auto const bond : p.bonds()) {
71 if (
bond.partner_ids().size() == 1u) {
72 auto const pid2 =
bond.partner_ids()[0];
83 if (comm.rank() == 0) {
99 for (
int iteration = 1; iteration <
n_bonds_max; iteration++) {
100 for (
auto const pid1 : std::views::elements<0>(
partners)) {
121 boost::mpi::broadcast(comm,
partners, 0);
124 if (
auto p1 = cell_structure.get_local_particle(
pid1)) {
127 if (
auto p2 = cell_structure.get_local_particle(
pid2)) {
132 system.on_particle_change();
136Variant ParticleList::do_call_method(std::string
const &name,
138#ifdef ESPRESSO_EXCLUSIONS
139 if (
name ==
"auto_exclusions") {
145 if (
name ==
"get_highest_particle_id") {
148 if (
name ==
"clear") {
155 if (
name ==
"by_id") {
156 return std::dynamic_pointer_cast<ParticleHandle>(
157 context()->make_shared(
"Particles::ParticleHandle",
159 {
"__cell_structure", m_cell_structure.lock()},
160 {
"__bonded_ias", m_bonded_ias.lock()}}));
162 if (
name ==
"by_ids") {
164 "Particles::ParticleSlice",
166 {
"__cell_structure", m_cell_structure.lock()},
167 {
"__bonded_ias", m_bonded_ias.lock()}});
169 if (
name ==
"get_n_part") {
172 if (
name ==
"get_particle_ids") {
175 if (
name ==
"particle_exists") {
178 if (
name ==
"add_particle") {
181 local_params[
"__cell_structure"] = m_cell_structure.lock();
183 auto so = std::dynamic_pointer_cast<ParticleHandle>(
185#ifdef ESPRESSO_EXCLUSIONS
186 if (
params.contains(
"exclusions")) {
187 so->call_method(
"set_exclusions", {{
"p_ids",
params.at(
"exclusions")}});
virtual std::shared_ptr< ObjectHandle > make_shared(std::string const &name, const VariantMap ¶meters)=0
Get a new reference counted instance of a script interface by name.
static void auto_exclusions(boost::mpi::communicator const &comm, int const n_bonds_max)
Use the bond topology to automatically add exclusions between particles that are up to n_bonds_max bo...
void gather_buffer(std::vector< T, Allocator > &buffer, boost::mpi::communicator const &comm, int root=0)
Gather buffer with different size on each node.
void remove_all_particles()
Remove all particles.
int get_maximal_particle_id()
Get maximal particle id.
std::vector< int > get_particle_ids()
Get all particle ids.
bool particle_exists(int p_id)
Check if particle exists.
Particles creation and deletion.