42#error "The FFTW3 library shouldn't be visible in this translation unit"
48template <Arch Architecture>
53 bool m_check_complex_residuals;
54 bool m_single_precision;
55 std::pair<std::optional<int>, std::optional<int>> m_tune_limits;
71 [
this]() {
return not
actor()->is_double_precision(); }},
73 [
this]() {
return actor()->p3m_params.alpha_L; }},
75 [
this]() {
return actor()->p3m_params.r_cut_iL; }},
77 [
this]() {
return actor()->p3m_params.mesh; }},
79 [
this]() {
return actor()->p3m_params.mesh_off; }},
81 [
this]() {
return actor()->p3m_params.cao; }},
83 [
this]() {
return actor()->p3m_params.accuracy; }},
85 [
this]() {
return actor()->p3m_params.epsilon; }},
87 [
this]() {
return actor()->p3m_params.a; }},
89 [
this]() {
return actor()->p3m_params.alpha; }},
91 [
this]() {
return actor()->p3m_params.r_cut; }},
93 [
this]() {
return actor()->is_tuned(); }},
95 [
this]() {
return m_tune_verbose; }},
97 [
this]() {
return m_tune_timings; }},
100 auto const &[range_min, range_max] = m_tune_limits;
101 std::vector<Variant> retval = {
109 [
this]() {
return m_check_complex_residuals; }},
114 m_tune = get_value<bool>(
params,
"tune");
115 m_tune_timings = get_value<int>(
params,
"timings");
116 m_tune_verbose = get_value<bool>(
params,
"verbose");
117 m_tune_limits = {std::nullopt, std::nullopt};
118 if (
params.contains(
"tune_limits")) {
119 auto const &variant =
params.at(
"tune_limits");
120 std::size_t range_length = 0u;
121 if (
is_type<std::vector<int>>(variant)) {
122 auto const range = get_value<std::vector<int>>(variant);
123 range_length = range.size();
124 if (range_length == 2u) {
125 m_tune_limits = {range[0u], range[1u]};
128 auto const range = get_value<std::vector<Variant>>(variant);
129 range_length = range.size();
130 if (range_length == 2u) {
132 m_tune_limits.first = get_value<int>(range[0u]);
135 m_tune_limits.second = get_value<int>(range[1u]);
140 if (range_length != 2u) {
141 throw std::invalid_argument(
"Parameter 'tune_limits' needs 2 values");
143 if (m_tune_limits.first and *m_tune_limits.first <= 0) {
144 throw std::domain_error(
"Parameter 'tune_limits' must be > 0");
146 if (m_tune_limits.second and *m_tune_limits.second <= 0) {
147 throw std::domain_error(
"Parameter 'tune_limits' must be > 0");
151 m_check_complex_residuals =
152 get_value<bool>(
params,
"check_complex_residuals");
153 auto const single_precision = get_value<bool>(
params,
"single_precision");
155 if (Architecture ==
Arch::GPU and not single_precision) {
156 throw std::invalid_argument(
157 "P3M GPU only implemented in single-precision mode");
160 get_value<double>(
params,
"epsilon"),
161 get_value<double>(
params,
"r_cut"),
162 get_value<Utils::Vector3i>(
params,
"mesh"),
163 get_value<Utils::Vector3d>(
params,
"mesh_off"),
164 get_value<int>(
params,
"cao"),
165 get_value<double>(
params,
"alpha"),
166 get_value<double>(
params,
"accuracy")};
167 make_handle(single_precision, std::move(p3m),
168 get_value<double>(
params,
"prefactor"), m_tune_timings,
169 m_tune_verbose, m_tune_limits, m_check_complex_residuals);
175 template <
typename FloatType,
class... Args>
176 void make_handle_impl(Args &&...args) {
180 template <
class... Args>
181 void make_handle(
bool single_precision, Args &&...args) {
182 if (single_precision) {
183 make_handle_impl<float, Args...>(std::forward<Args>(args)...);
185 make_handle_impl<double, Args...>(std::forward<Args>(args)...);
Historic FFT backend based on FFTW3.
Buffers for FFTBackendLegacy.
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()
void set_charge_neutrality_tolerance(VariantMap const ¶ms)
void do_construct(VariantMap const ¶ms) override
Type to indicate no value in Variant.
Context * context() const
Responsible context.
This file contains the defaults for ESPResSo.
bool is_type(Variant const &v)
Check is a Variant holds a specific type.
std::unordered_map< std::string, Variant > VariantMap
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)
P3M algorithm for long-range Coulomb interaction.
std::shared_ptr< CoulombP3M > new_p3m_handle(P3MParameters &&p3m, Args &&...args)
static SteepestDescentParameters params
Currently active steepest descent instance.
Structure to hold P3M parameters and some dependent variables.
static constexpr const ReadOnly read_only