30#include <boost/mpi/collectives/all_reduce.hpp>
45class ParticleModifier;
48 std::stringstream
msg;
49 msg <<
"attribute '" << name <<
"' of 'ParticleHandle' " <<
reason;
56 throw std::domain_error(
"Invalid particle id: " + std::to_string(
p_id));
59 if (ptr !=
nullptr and ptr->is_ghost()) {
62 auto const n_found = boost::mpi::all_reduce(
63 comm,
static_cast<int>(ptr !=
nullptr), std::plus<>());
65 throw std::runtime_error(
"Particle with id " + std::to_string(
p_id) +
73 throw std::domain_error(
"Invalid particle id: " + std::to_string(
p_id));
76 if (std::isnan(pos[0])
or std::isnan(pos[1])
or std::isnan(pos[2])
or
77 std::isinf(pos[0])
or std::isinf(pos[1])
or std::isinf(pos[2])) {
78 throw std::domain_error(
"Particle position must be finite");
83#ifdef ESPRESSO_EXCLUSIONS
120 throw std::runtime_error(
"Particles cannot exclude themselves (id " +
121 std::to_string(
pid1) +
")");
131 mutable std::weak_ptr<CellSystem::CellSystem> m_cell_structure;
132 mutable std::weak_ptr<Interactions::BondedInteractions> m_bonded_ias;
133 mutable std::weak_ptr<::System::System> m_system;
134 auto get_cell_structure()
const {
135 auto ptr = m_cell_structure.lock();
139 auto get_bonded_ias()
const {
140 auto ptr = m_bonded_ias.lock();
144 auto get_system()
const {
145 auto ptr = m_system.lock();
150 template <
typename T>
151 T get_particle_property(T
const &(
Particle::*
getter)()
const)
const;
152 template <
typename T,
class F> T get_particle_property(
F const &
fun)
const;
154 template <
typename T>
158 template <
class F>
void set_particle_property(
F const &
fun)
const;
172 assert(m_system.expired());
183 throw std::logic_error(
184 "ParticleModifier is not meant to create new particles");
196 if (
name ==
"remove_particle") {
197 throw std::logic_error(
"ParticleModifier has no method '" +
name +
"'");
Describes a cell structure / cell system.
Particle * get_local_particle(int id)
Get a local particle by id.
Bind parameters in the script interface.
std::string_view name() const
Variant do_call_method(std::string const &name, VariantMap const ¶ms) override
void attach(std::weak_ptr<::System::System > system)
void do_construct(VariantMap const ¶ms) override
Thin wrapper to read and write particle attributes in batches.
Variant do_call_method(std::string const &name, VariantMap const ¶ms) override
void do_construct(VariantMap const ¶ms) override
cudaStream_t stream[1]
CUDA streams for parallel computing on CPU and GPU.
void delete_exclusion(Particle &p, int p_id)
Remove exclusion from particle if possible.
void add_exclusion(Particle &p, int p_id)
Insert an exclusion if not already set.
auto get_real_particle(boost::mpi::communicator const &comm, int p_id, ::CellStructure &cell_structure)
void particle_exclusion_sanity_checks(int pid1, int pid2, ::CellStructure &cell_structure, auto const &comm)
void local_remove_exclusion(int pid1, int pid2, ::CellStructure &cell_structure)
Locally remove an exclusion to a particle.
void particle_checks(int p_id, Utils::Vector3d const &pos)
auto error_msg(std::string const &name, std::string const &reason)
void local_add_exclusion(int pid1, int pid2, ::CellStructure &cell_structure)
Locally add an exclusion to a particle.
std::unordered_map< std::string, Variant > VariantMap
make_recursive_variant< ObjectRef > Variant
Possible types for parameters.
static SteepestDescentParameters params
Currently active steepest descent instance.
Struct holding all information for one particle.
Recursive variant implementation.