ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
BreakageSpecs.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2022 The ESPResSo project
3 *
4 * This file is part of ESPResSo.
5 *
6 * ESPResSo is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * ESPResSo is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#pragma once
21
22#include "BreakageSpec.hpp"
23
25
29
30#include <memory>
31#include <stdexcept>
32#include <unordered_map>
33
34namespace ScriptInterface {
35namespace BondBreakage {
36
40
43
44public:
45 using key_type = typename Base::key_type;
47
48private:
49 std::shared_ptr<::BondBreakage::BondBreakage> m_bond_breakage;
50
51public:
52 ~BreakageSpecs() override { do_destruct(); }
53
54 void do_construct(VariantMap const &params) override {
55 m_bond_breakage = std::make_shared<::BondBreakage::BondBreakage>();
57 }
58 Variant do_call_method(std::string const &name,
59 VariantMap const &parameters) override {
60 if (name == "execute") {
61 context()->parallel_try_catch(
62 [this]() { m_bond_breakage->execute_bond_breakage(get_system()); });
63 return {};
64 }
65 return Base::do_call_method(name, parameters);
66 }
67
68private:
70 system.bond_breakage = m_bond_breakage;
71 }
72
74 if (context()->is_head_node()) {
75 throw std::runtime_error(
76 "Inserting breakage spec without a bond type is not permitted.");
77 }
78 return {};
79 }
81 mapped_type const &obj_ptr) override {
82 m_bond_breakage->breakage_specs.emplace(key, obj_ptr->breakage_spec());
83 }
84 void erase_in_core(key_type const &key) final {
85 m_bond_breakage->breakage_specs.erase(key);
86 }
87};
88} // namespace BondBreakage
89} // namespace ScriptInterface
Bind parameters in the script interface.
void erase_in_core(key_type const &key) final
void insert_in_core(key_type const &key, mapped_type const &obj_ptr) override
Variant do_call_method(std::string const &name, VariantMap const &parameters) override
key_type insert_in_core(mapped_type const &) override
void do_construct(VariantMap const &params) override
void on_bind_system(::System::System &system) override
Owning map of object handles.
Definition ObjectMap.hpp:52
std::shared_ptr< ManagedType > mapped_type
Definition ObjectMap.hpp:57
void restore_from_checkpoint(VariantMap const &params)
Variant do_call_method(std::string const &method, VariantMap const &parameters) override
Script interface wrapper for a component of the system class.
Main system class.
ObjectMap< BreakageSpec, AutoParameters< ObjectMap< BreakageSpec, System::Leaf >, System::Leaf > > BreakageSpecsBase_t
T get_value(Variant const &v)
Extract value of specific type T from a Variant.
std::unordered_map< std::string, Variant > VariantMap
Definition Variant.hpp:69
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.
Definition Variant.hpp:67
static SteepestDescentParameters params
Currently active steepest descent instance.