39 std::shared_ptr<::LeesEdwards::LeesEdwards> m_lees_edwards;
40 std::shared_ptr<Protocol> m_protocol;
41 std::unique_ptr<VariantMap> m_params;
52 system.lb.lebc_sanity_checks(invalid_dir, invalid_dir);
56 m_lees_edwards->unset_protocol();
57 system.on_lees_edwards_change();
62 auto const &lebc = get_lebc();
63 if (lebc.shear_direction == invalid_dir or
64 lebc.shear_plane_normal == invalid_dir) {
65 throw std::runtime_error(
66 "Parameters 'shear_plane_normal' and 'shear_direction' "
67 "must be initialized together with 'protocol' on first "
68 "activation via set_boundary_conditions()");
71 auto const protocol = get_value<std::shared_ptr<Protocol>>(value);
74 set_protocol(protocol);
76 set_protocol(m_protocol);
91 [
this]() {
return get_shear_name(get_lebc().shear_direction); }},
93 [
this]() {
return get_shear_name(get_lebc().shear_plane_normal); }}});
98 if (
name ==
"set_boundary_conditions") {
100 auto const variant =
params.at(
"protocol");
106 auto const protocol = get_value<std::shared_ptr<Protocol>>(variant);
107 auto const shear_direction = get_shear_axis(
params,
"shear_direction");
108 auto const shear_plane_normal =
109 get_shear_axis(
params,
"shear_plane_normal");
110 if (shear_plane_normal == shear_direction) {
111 throw std::invalid_argument(
"Parameters 'shear_direction' and "
112 "'shear_plane_normal' must differ");
115 system.lb.lebc_sanity_checks(shear_direction, shear_plane_normal);
120 system.box_geo->set_lees_edwards_bc(
122 set_protocol(protocol);
125 0., 0., old_shear_direction, old_shear_plane_normal});
126 set_protocol(m_protocol);
135 m_params = std::make_unique<VariantMap>(
params);
140 auto const value = get_value<std::string>(
params,
name);
150 throw std::invalid_argument(
"Parameter '" +
name +
"' is invalid");
153 Variant get_shear_name(
unsigned int axis) {
155 return {std::string(
"x")};
158 return {std::string(
"y")};
161 return {std::string(
"z")};
167 return get_system().box_geo->lees_edwards_bc();
172 auto const &
params = *m_params;
179 void set_protocol(std::shared_ptr<Protocol>
const &protocol) {
182 m_lees_edwards->set_protocol(protocol->protocol());
185 m_lees_edwards->unset_protocol();
187 system.on_lees_edwards_change();
188 m_protocol = protocol;
Bind parameters in the script interface.
void do_set_parameter(const std::string &name, const Variant &value) final
void add_parameters(std::vector< AutoParameter > &¶ms)
virtual void parallel_try_catch(std::function< void()> const &cb) const =0
Variant do_call_method(std::string const &name, VariantMap const ¶ms) override
void do_construct(VariantMap const ¶ms) override
void on_bind_system(::System::System &system) override
boost::string_ref name() const
Context * context() const
Responsible context.
auto const & get_system() const
std::shared_ptr< LeesEdwards::LeesEdwards > lees_edwards
std::unordered_map< std::string, Variant > VariantMap
Variant make_variant(const T &x)
Make a Variant from argument.
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.
bool is_none(Variant const &v)
constexpr const None none
None-"literal".
static SteepestDescentParameters params
Currently active steepest descent instance.
static auto constexpr invalid_dir
unsigned int shear_plane_normal
unsigned int shear_direction
static constexpr const ReadOnly read_only