42 using container_type =
43 std::unordered_map<
unsigned int,
44 std::shared_ptr<NonBondedInteractionHandle>>;
47 using key_type =
typename container_type::key_type;
51 container_type m_nonbonded_ia_params;
54 auto make_interaction(
int i,
int j) {
56 auto const types = std::vector<int>{{i, j}};
57 return std::dynamic_pointer_cast<NonBondedInteractionHandle>(
58 context()->make_shared_local(
"Interactions::NonBondedInteractionHandle",
63 auto const max_type = m_nonbonded_ias->get_max_seen_particle_type();
64 for (
int i = 0; i <= max_type; i++) {
65 for (
int j = 0; j <= i; j++) {
66 auto const key = m_nonbonded_ias->get_ia_param_key(i, j);
67 m_nonbonded_ias->set_ia_param(i, j,
68 std::make_shared<::IA_parameters>());
69 m_nonbonded_ia_params[key] = make_interaction(i, j);
77 auto const max_type = m_nonbonded_ias->get_max_seen_particle_type();
78 for (
int i = 0; i <= max_type; i++) {
79 for (
int j = 0; j <= i; j++) {
80 auto const key = m_nonbonded_ias->get_ia_param_key(i, j);
81 m_nonbonded_ia_params[key] = make_interaction(i, j);
86 std::pair<int, int> get_key(
Variant const &key)
const {
88 auto const types = get_value<std::vector<int>>(key);
89 if (types.size() != 2ul or types[0] < 0 or types[1] < 0) {
90 throw Exception(
"need two particle types");
92 return {std::max(types[0], types[1]), std::min(types[0], types[1])};
94 if (
context()->is_head_node()) {
95 throw std::invalid_argument(
96 "NonBondedInteractions[] expects two particle types as indices");
105 if (method ==
"get_n_types") {
106 return Variant{m_nonbonded_ias->get_max_seen_particle_type() + 1};
108 if (method ==
"reset") {
112 if (method ==
"insert") {
113 auto const [type_min, type_max] = get_key(
params.at(
"key"));
114 m_nonbonded_ias->make_particle_type_exist(type_max);
115 auto const key = m_nonbonded_ias->get_ia_param_key(type_min, type_max);
116 auto obj_ptr = get_value<std::shared_ptr<NonBondedInteractionHandle>>(
118 m_nonbonded_ias->set_ia_param(type_min, type_max, obj_ptr->get_ia());
119 m_nonbonded_ia_params[key] = obj_ptr;
123 if (method ==
"check_key") {
124 static_cast<void>(get_key(
params.at(
"key")));
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.