Skip to content

Commit b33e646

Browse files
committed
script_interface: fix for ParticleSlice template resolution error
1 parent 70d3ea8 commit b33e646

File tree

1 file changed

+31
-8
lines changed

1 file changed

+31
-8
lines changed

src/script_interface/particle_data/ParticleSlice.hpp

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,24 @@ namespace ScriptInterface {
4646
namespace Particles {
4747

4848
struct SetParticleParametersVisitor {
49+
private:
50+
template <typename T>
51+
void set_from_vector_like(
52+
std::vector<int> const &pids, std::string const &param_name,
53+
T const &values, Context *context,
54+
std::shared_ptr<CellSystem::CellSystem> cell_structure,
55+
std::shared_ptr<Interactions::BondedInteractions> bonded_ias) const {
56+
auto so = std::dynamic_pointer_cast<ParticleModifier>(context->make_shared(
57+
"Particles::ParticleModifier", {{"id", -1},
58+
{"__cell_structure", cell_structure},
59+
{"__bonded_ias", bonded_ias}}));
60+
for (std::size_t i = 0; i < pids.size(); ++i) {
61+
so->set_pid(pids[i]);
62+
so->do_set_parameter(param_name, values[i]);
63+
}
64+
}
65+
66+
public:
4967
void operator()(std::vector<int> const &, std::string const &,
5068
auto const &values, Context *,
5169
std::shared_ptr<CellSystem::CellSystem>,
@@ -59,14 +77,19 @@ struct SetParticleParametersVisitor {
5977
std::vector<T> const &values, Context *context,
6078
std::shared_ptr<CellSystem::CellSystem> cell_structure,
6179
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) {
67-
so->set_pid(pids[i]);
68-
so->do_set_parameter(param_name, values[i]);
69-
}
80+
set_from_vector_like(pids, param_name, values, context, cell_structure,
81+
bonded_ias);
82+
}
83+
template <typename T>
84+
void
85+
operator()(std::vector<int> const &pids, std::string const &param_name,
86+
Utils::Vector<T, 3> const &values, Context *context,
87+
std::shared_ptr<CellSystem::CellSystem> cell_structure,
88+
std::shared_ptr<Interactions::BondedInteractions> bonded_ias) const
89+
requires(std::is_same_v<T, int> or std::is_same_v<T, double>)
90+
{
91+
set_from_vector_like(pids, param_name, values, context, cell_structure,
92+
bonded_ias);
7093
}
7194
};
7295

0 commit comments

Comments
 (0)