24#ifdef ESPRESSO_SCAFACOS
47 std::shared_ptr<boost::mpi::environment> m_mpi_env_lock;
53 [
this]() {
return actor()->get_method(); }},
56 auto const m_tuned_methods =
57 std::set<std::string>{
"ewald",
"p2nfft",
"p3m"};
59 auto const method_name =
actor()->get_method();
60 auto const delegate =
actor()->get_near_field_delegation();
61 if (delegate and m_tuned_methods.contains(method_name)) {
62 auto const tuned_r_cut =
actor()->get_r_cut();
63 auto const field_name = method_name +
"_r_cut";
64 std::ostringstream serializer;
65 serializer << std::scientific << std::setprecision(17);
66 serializer << tuned_r_cut;
67 auto const tuned_r_cut_string = serializer.str();
68 auto const replacement =
69 "," + field_name +
"," + tuned_r_cut_string;
70 if (parameters_string.find(field_name) == field_name.npos) {
71 parameters_string += replacement;
73 auto const field_pattern =
74 std::regex(
"," + field_name +
",[0-9eE\\-\\+\\.]+");
75 parameters_string = std::regex_replace(
76 parameters_string, std::regex(field_pattern), replacement);
86 m_mpi_env_lock.reset();
91 auto const param_list = params.at(
"method_params");
98 actor()->set_prefactor(prefactor);
107 if (
name ==
"set_near_field_delegation") {
110 [&]() {
actor()->set_near_field_delegation(delegate); });
113 if (
name ==
"get_near_field_delegation") {
114 return actor()->get_near_field_delegation();
116 if (
name ==
"get_available_methods") {
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
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
VariantMap get_parameters() const
Get current parameters.
Context * context() const
Responsible context.
std::string_view name() const
std::unique_ptr< CommunicationEnvironment > communication_environment
This file contains the asynchronous MPI communication.
std::shared_ptr< CoulombScafacos > make_coulomb_scafacos(std::string const &method, std::string const ¶meters)
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.
make_recursive_variant< ObjectRef > Variant
Possible types for parameters.
T get_value(Variant const &v)
Extract value of specific type T from a Variant.
auto make_vector_of_variants(std::vector< T > const &v)
std::unordered_map< std::string, Variant > VariantMap
static void sanity_check_method(std::string const &method_name)
static constexpr const ReadOnly read_only