48 std::shared_ptr<boost::mpi::environment> m_mpi_env_lock;
54 [
this]() {
return actor()->get_method(); }},
57 auto const m_tuned_methods =
58 std::set<std::string>{
"ewald",
"p2nfft",
"p3m"};
59 auto parameters_string =
actor()->get_parameters();
60 auto const method_name =
actor()->get_method();
61 auto const delegate =
actor()->get_near_field_delegation();
62 if (delegate and m_tuned_methods.count(method_name)) {
63 auto const tuned_r_cut =
actor()->get_r_cut();
64 auto const field_name = method_name +
"_r_cut";
65 std::ostringstream serializer;
66 serializer << std::scientific << std::setprecision(17);
67 serializer << tuned_r_cut;
68 auto const tuned_r_cut_string = serializer.str();
69 auto const replacement =
70 "," + field_name +
"," + tuned_r_cut_string;
71 if (parameters_string.find(field_name) == field_name.npos) {
72 parameters_string += replacement;
74 auto const field_pattern =
75 std::regex(
"," + field_name +
",[0-9eE\\-\\+\\.]+");
76 parameters_string = std::regex_replace(
77 parameters_string, std::regex(field_pattern), replacement);
87 m_mpi_env_lock.reset();
91 auto const method_name = get_value<std::string>(
params,
"method_name");
92 auto const param_list =
params.at(
"method_params");
93 auto const prefactor = get_value<double>(
params,
"prefactor");
99 actor()->set_prefactor(prefactor);
108 if (
name ==
"set_near_field_delegation") {
109 auto const delegate = get_value<bool>(
params,
"delegate");
111 [&]() {
actor()->set_near_field_delegation(delegate); });
114 if (
name ==
"get_near_field_delegation") {
115 return actor()->get_near_field_delegation();
117 if (
name ==
"get_available_methods") {
Communication::MpiCallbacks manages MPI communication using a visitor pattern.
ScafacosContextBase provides the public interface of the ScaFaCoS bridge.
void add_parameters(std::vector< AutoParameter > &¶ms)
virtual void parallel_try_catch(std::function< void()> const &cb) const =0
Common interface for electrostatic actors.
std::shared_ptr< CoreActorClass > m_actor
std::shared_ptr< CoreActorClass > actor()
Variant do_call_method(std::string const &name, VariantMap const ¶ms) override
void set_charge_neutrality_tolerance(VariantMap const ¶ms)
~CoulombScafacos() override
void do_construct(VariantMap const ¶ms) override
Variant do_call_method(std::string const &name, VariantMap const ¶ms) override
boost::string_ref name() const
Context * context() const
Responsible context.
This file contains the defaults for ESPResSo.
This file contains the asynchronous MPI communication.
std::shared_ptr< CoulombScafacos > make_coulomb_scafacos(std::string const &method, std::string const ¶meters)
std::shared_ptr< MpiCallbacks > mpiCallbacksHandle()
std::unordered_map< std::string, Variant > deserialize_parameters(std::string const ¶meters)
Convert flattened parameters to a map.
std::string serialize_parameters(Variant const &pack)
Flatten a parameter map.
std::vector< std::string > available_methods()
Fetch list of methods compiled in ScaFaCoS.
std::unordered_map< std::string, Variant > VariantMap
auto make_vector_of_variants(std::vector< T > const &v)
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.
static SteepestDescentParameters params
Currently active steepest descent instance.
static void sanity_check_method(std::string const &method_name)
static constexpr const ReadOnly read_only