49 void operator()(std::vector<int>
const &, std::string
const &,
51 std::shared_ptr<CellSystem::CellSystem>,
52 std::shared_ptr<Interactions::BondedInteractions>)
const {
53 throw Exception(
"Values must be of type vector, got " +
54 detail::demangle::simplify_symbol(&
values));
60 std::shared_ptr<CellSystem::CellSystem> cell_structure,
61 std::shared_ptr<Interactions::BondedInteractions> bonded_ias)
const {
62 auto so = std::dynamic_pointer_cast<ParticleModifier>(context->
make_shared(
63 "Particles::ParticleModifier", {{
"id", -1},
64 {
"__cell_structure", cell_structure},
65 {
"__bonded_ias", bonded_ias}}));
66 for (std::size_t i = 0; i <
pids.size(); ++i) {
81 std::conditional_t<Variant::has_type<std::vector<T>>::value, T,
Variant>;
82 std::vector<value_type> result;
84 auto const n_ranks =
static_cast<std::size_t
>(context->
get_comm().size());
88 for (
auto const &pid :
pids) {
90 if (p
and not p->is_ghost()) {
105 "Missing or duplicate particle ids");
107 result.reserve(
pids.size());
108 for (
auto const &value :
parameters | std::views::values) {
109 result.emplace_back(std::move(value));
115 std::vector<int> m_id_selection;
117 std::weak_ptr<CellSystem::CellSystem> m_cell_structure;
118 std::weak_ptr<Interactions::BondedInteractions> m_bonded_ias;
119 std::weak_ptr<::System::System> m_system;
122 std::set<std::string_view>
const m_special_parameters{
123 "pos",
"type",
"bonds",
124#ifdef ESPRESSO_ELECTROSTATICS
127#ifdef ESPRESSO_EXCLUSIONS
133 auto cell_structure_ptr = m_cell_structure.lock();
134 assert(cell_structure_ptr !=
nullptr);
135 auto &cell_structure = cell_structure_ptr->get_cell_structure();
136 return &cell_structure;
139 auto get_system()
const {
140 auto ptr = m_system.lock();
141 assert(ptr !=
nullptr);
148 {
"chunk_size", AutoParameter::read_only,
149 [
this]() {
return m_chunk_size; }},
150 {
"id_selection", AutoParameter::read_only,
151 [
this]() {
return m_id_selection; }},
157 Variant do_call_method(std::string
const &name,
160 void attach(std::weak_ptr<::System::System> system) {
161 assert(m_system.expired());
Describes a cell structure / cell system.
Particle * get_local_particle(int id)
Get a local particle by id.
Bind parameters in the script interface.
Context of an object handle.
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.
virtual bool is_head_node() const =0
virtual boost::mpi::communicator const & get_comm() const =0
void attach(std::weak_ptr<::System::System > system)
auto get_particles_properties(std::vector< int > const &pids, std::function< T(Particle const &)> const &getter, Context *context, CellStructure const &cell_structure)
T get_value(Variant const &v)
Extract value of specific type T from a Variant.
std::unordered_map< std::string, Variant > VariantMap
void gather_buffer(std::vector< T, Allocator > &buffer, boost::mpi::communicator const &comm, int root=0)
Gather buffer with different size on each node.
static auto & get_cell_structure()
static SteepestDescentParameters params
Currently active steepest descent instance.
Struct holding all information for one particle.
void operator()(std::vector< int > const &, std::string const &, auto const &values, Context *, std::shared_ptr< CellSystem::CellSystem >, std::shared_ptr< Interactions::BondedInteractions >) const
void operator()(std::vector< int > const &pids, std::string const ¶m_name, std::vector< T > const &values, Context *context, std::shared_ptr< CellSystem::CellSystem > cell_structure, std::shared_ptr< Interactions::BondedInteractions > bonded_ias) const
Recursive variant implementation.