36#include <unordered_map>
41namespace Interactions {
55 std::shared_ptr<::BondedInteractionsMap> m_handle;
56 std::unique_ptr<VariantMap> m_params;
62 m_handle = std::make_shared<::BondedInteractionsMap>();
63 m_params = std::make_unique<VariantMap>(
params);
68 system.bonded_ias = m_handle;
69 m_handle->bind_system(m_system.lock());
70 m_handle->on_ia_change();
71 if (m_params
and not m_params->empty()) {
79 context()->parallel_try_catch(
80 [&]() {
key = m_handle->insert(
obj_ptr->bonded_ia()); });
86 context()->parallel_try_catch(
87 [&]() { m_handle->insert(
key,
obj_ptr->bonded_ia()); });
95 if (name ==
"get_size") {
96 return {
static_cast<int>(m_handle->size())};
99 if (name ==
"get_bond_ids") {
100 auto const view = std::views::elements<0>(*m_handle);
105 if (name ==
"has_bond") {
107 return {
elements().contains(bond_id)};
110 if (name ==
"get_bond") {
113 assert(
elements().contains(bond_id) == m_handle->contains(bond_id));
114 if (
not context()->is_head_node())
118 throw std::out_of_range(
"The bond with id " + std::to_string(bond_id) +
119 " is not yet defined.");
124 if (name ==
"get_zero_based_type") {
126 return m_handle->get_zero_based_type(bond_id);
The ScriptInterface counterparts of the bonded interactions parameters structs from the core are defi...
Data structures for bonded interactions.
Bind parameters in the script interface.
std::shared_ptr< ManagedType > mapped_type
~BondedInteractions() override
void insert_in_core(key_type const &key, mapped_type const &obj_ptr) override
Variant do_call_method(std::string const &name, VariantMap const ¶ms) override
void erase_in_core(key_type const &key) final
void do_construct(VariantMap const ¶ms) override
void on_bind_system(::System::System &system) override
key_type insert_in_core(mapped_type const &obj_ptr) override
Owning map of object handles.
std::shared_ptr< ManagedType > mapped_type
key_type get_key(Variant const &key) const
auto const & elements() const
Map elements.
void restore_from_checkpoint(VariantMap const ¶ms)
Variant do_call_method(std::string const &method, VariantMap const ¶meters) override
Script interface wrapper for a component of the system class.
cudaStream_t stream[1]
CUDA streams for parallel computing on CPU and GPU.
ObjectMap< BondedInteraction, AutoParameters< ObjectMap< BondedInteraction, System::Leaf >, System::Leaf > > BondedInteractionsBase_t
std::unordered_map< std::string, Variant > VariantMap
static SteepestDescentParameters params
Currently active steepest descent instance.
Recursive variant implementation.