39#error "The FFTW3 library shouldn't be visible in this translation unit"
45template <Arch Architecture>
46class DipolarP3M :
public Actor<DipolarP3M<Architecture>, ::DipolarP3M> {
63 [
this]() {
return not
actor()->is_double_precision(); }},
65 [
this]() {
return actor()->dp3m_params.alpha_L; }},
67 [
this]() {
return actor()->dp3m_params.r_cut_iL; }},
69 [
this]() {
return actor()->dp3m_params.mesh; }},
71 [
this]() {
return actor()->dp3m_params.mesh_off; }},
73 [
this]() {
return actor()->dp3m_params.cao; }},
75 [
this]() {
return actor()->dp3m_params.accuracy; }},
77 [
this]() {
return actor()->dp3m_params.epsilon; }},
79 [
this]() {
return actor()->dp3m_params.a; }},
81 [
this]() {
return actor()->dp3m_params.alpha; }},
83 [
this]() {
return actor()->dp3m_params.r_cut; }},
85 [
this]() {
return actor()->is_tuned(); }},
87 [
this]() {
return m_tuning.verbose; }},
89 [
this]() {
return m_tuning.timings; }},
92#if defined(__clang__) and defined(__cray__) or defined(__INTEL_LLVM_COMPILER)
93 auto const &range_min = m_tuning.limits.first;
94 auto const &range_max = m_tuning.limits.second;
96 auto const &[range_min, range_max] = m_tuning.limits;
98 std::vector<Variant> retval = {
112 m_tuning.limits = {std::nullopt, std::nullopt};
113 if (params.contains(
"tune_limits")) {
114 auto const &variant = params.at(
"tune_limits");
115 std::size_t range_length = 0u;
116 if (
is_type<std::vector<int>>(variant)) {
118 range_length = range.size();
119 if (range_length == 2u) {
120 m_tuning.limits = {range[0u], range[1u]};
124 range_length = range.size();
125 if (range_length == 2u) {
135 if (range_length != 2u) {
136 throw std::invalid_argument(
"Parameter 'tune_limits' needs 2 values");
138 if (m_tuning.limits.first and *m_tuning.limits.first <= 0) {
139 throw std::domain_error(
"Parameter 'tune_limits' must be > 0");
141 if (m_tuning.limits.second and *m_tuning.limits.second <= 0) {
142 throw std::domain_error(
"Parameter 'tune_limits' must be > 0");
146 auto const single_precision =
get_value<bool>(params,
"single_precision");
147 static_assert(Architecture ==
Arch::CPU,
"GPU not implemented");
159 single_precision, Architecture);
void add_parameters(std::vector< AutoParameter > &¶ms)
virtual void parallel_try_catch(std::function< void()> const &cb) const =0
std::shared_ptr< CoreActorClass > actor()
std::shared_ptr< CoreActorClass > m_actor
void do_construct(VariantMap const ¶ms) override
std::shared_ptr< CoreActorClass > actor()
Actor< DipolarP3M< Architecture >, ::DipolarP3M > Base
std::shared_ptr< CoreActorClass > m_actor
Type to indicate no value in Variant.
Context * context() const
Responsible context.
P3M algorithm for long-range magnetic dipole-dipole interaction.
std::shared_ptr< DipolarP3M > new_dipolar_p3m_heffte(P3MParameters &&p3m_params, TuningParameters const &tuning_params, double prefactor, bool single_precision, Arch arch)
constexpr bool is_none(Variant const &v)
constexpr bool is_type(Variant const &v)
Check is a Variant holds a specific type.
make_recursive_variant< ObjectRef > Variant
Possible types for parameters.
T get_value(Variant const &v)
Extract value of specific type T from a Variant.
T get_value_or(VariantMap const &vals, std::string const &name, T const &default_)
Get a value from a VariantMap by name, or return a default value if it does not exist.
std::unordered_map< std::string, Variant > VariantMap
Structure to hold P3M parameters and some dependent variables.
static constexpr const ReadOnly read_only