37#include <boost/mpi/collectives.hpp>
38#include <boost/mpi/communicator.hpp>
45#include <unordered_map>
60 std::unordered_map<int, std::vector<std::pair<int, int>>>
partners;
64 auto &cell_structure = *
system.cell_structure;
67 for (
auto const &p : cell_structure.local_particles()) {
68 auto const pid1 = p.id();
69 for (
auto const bond : p.bonds()) {
70 if (
bond.partner_ids().size() == 1u) {
71 auto const pid2 =
bond.partner_ids()[0];
82 if (comm.rank() == 0) {
98 for (
int iteration = 1; iteration <
n_bonds_max; iteration++) {
99 std::vector<int>
pids;
101 pids.emplace_back(kv.first);
125 boost::mpi::broadcast(comm,
partners, 0);
127 auto const pid1 = kv.first;
131 if (
auto p1 = cell_structure.get_local_particle(
pid1)) {
134 if (
auto p2 = cell_structure.get_local_particle(
pid2)) {
139 system.on_particle_change();
143Variant ParticleList::do_call_method(std::string
const &name,
146 if (
name ==
"auto_exclusions") {
152 if (
name ==
"get_highest_particle_id") {
155 if (
name ==
"clear") {
162 if (
name ==
"by_id") {
163 return std::dynamic_pointer_cast<ParticleHandle>(
164 context()->make_shared(
"Particles::ParticleHandle",
166 {
"__cell_structure", m_cell_structure.lock()},
167 {
"__bonded_ias", m_bonded_ias.lock()}}));
169 if (
name ==
"by_ids") {
171 "Particles::ParticleSlice",
173 {
"__cell_structure", m_cell_structure.lock()},
174 {
"__bonded_ias", m_bonded_ias.lock()}});
176 if (
name ==
"get_n_part") {
179 if (
name ==
"get_particle_ids") {
182 if (
name ==
"particle_exists") {
185 if (
name ==
"add_particle") {
188 local_params[
"__cell_structure"] = m_cell_structure.lock();
190 auto so = std::dynamic_pointer_cast<ParticleHandle>(
193 if (
params.count(
"exclusions")) {
194 so->call_method(
"set_exclusions", {{
"p_ids",
params.at(
"exclusions")}});
197 return so->get_parameter(
"id");
Vector implementation and trait types for boost qvm interoperability.
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.
boost::string_ref name() const
Context * context() const
Responsible context.
void add_exclusion(Particle &p, int p_id)
Insert an exclusion if not already set.
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...
T get_value(Variant const &v)
Extract value of specific type T from a Variant.
std::unordered_map< std::string, Variant > VariantMap
boost::make_recursive_variant< None, bool, int, std::size_t, double, std::string, ObjectRef, Utils::Vector3b, Utils::Vector3i, Utils::Vector2d, Utils::Vector3d, Utils::Vector4d, std::vector< int >, std::vector< double >, std::vector< boost::recursive_variant_ >, std::unordered_map< int, boost::recursive_variant_ >, std::unordered_map< std::string, boost::recursive_variant_ > >::type Variant
Possible types for parameters.
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.
int get_n_part()
Get number of particles.
bool particle_exists(int p_id)
Check if particle exists.
Particles creation and deletion.
static SteepestDescentParameters params
Currently active steepest descent instance.