45template <
typename FloatType>
65template <
typename FloatType, Arch Architecture>
74 std::unique_ptr<p3m_data_struct_dipoles<FloatType>> dp3m_impl;
76 std::pair<std::optional<int>, std::optional<int>> tune_limits;
83 double prefactor,
int tune_timings,
bool tune_verbose,
84 decltype(tune_limits) tune_limits)
86 dp3m_impl{std::move(dp3m_handle)}, tune_timings{tune_timings},
87 tune_limits{std::move(tune_limits)}, tune_verbose{tune_verbose} {
89 if (tune_timings <= 0) {
90 throw std::domain_error(
"Parameter 'timings' must be > 0");
93 throw std::domain_error(
"DipolarP3M requires a cubic mesh");
95 m_is_tuned = not
dp3m.params.tuning;
96 dp3m.params.tuning =
false;
101 if constexpr (Architecture ==
Arch::CPU) {
105 void tune()
override;
108 [[nodiscard]]
bool is_tuned() const noexcept
override {
return m_is_tuned; }
109 [[nodiscard]]
bool is_gpu() const noexcept
override {
113 return std::is_same_v<FloatType, double>;
126 if constexpr (Architecture ==
Arch::CPU) {
147template <
typename FloatType,
Arch Architecture,
148 template <
typename>
class FFTBackendImpl,
149 template <
typename>
class P3MFFTMeshImpl,
class... Args>
152 auto obj = std::make_shared<DipolarP3MImpl<FloatType, Architecture>>(
153 std::make_unique<p3m_data_struct_dipoles<FloatType>>(std::move(p3m)),
154 std::forward<Args>(args)...);
155 obj->dp3m.template make_mesh_instance<P3MFFTMeshImpl<FloatType>>();
156 obj->dp3m.template make_fft_instance<FFTBackendImpl<FloatType>>();
Vector implementation and trait types for boost qvm interoperability.
void set_prefactor(double new_prefactor)
double prefactor
Magnetostatics prefactor.
static DEVICE_QUALIFIER constexpr Vector< T, N > broadcast(typename Base::value_type const &value)
Create a vector that has all entries set to the same value.
Cache for interpolation weights.
This file contains the defaults for ESPResSo.
P3M algorithm for long-range magnetic dipole-dipole interaction.
std::shared_ptr< DipolarP3M > new_dp3m_handle(P3MParameters &&p3m, Args &&...args)
Common functions for dipolar and charge P3M.
Arch
P3M kernel architecture.
static SteepestDescentParameters params
Currently active steepest descent instance.
void calc_energy_correction() override
double long_range_kernel(bool force_flag, bool energy_flag, ParticleRange const &particles)
Compute the k-space part of forces and energies.
double long_range_energy(ParticleRange const &particles) override
p3m_data_struct_dipoles< FloatType > & dp3m
Dipolar P3M parameters.
double calc_surface_term(bool force_flag, bool energy_flag, ParticleRange const &particles) override
void dipole_assign(ParticleRange const &particles) override
bool is_double_precision() const noexcept override
void calc_influence_function_energy() override
bool is_gpu() const noexcept override
void add_long_range_forces(ParticleRange const &particles) override
void count_magnetic_particles() override
~DipolarP3MImpl() override=default
void calc_influence_function_force() override
bool is_tuned() const noexcept override
DipolarP3MImpl(std::unique_ptr< p3m_data_struct_dipoles< FloatType > > &&dp3m_handle, double prefactor, int tune_timings, bool tune_verbose, decltype(tune_limits) tune_limits)
void on_activation() override
void scaleby_box_l() override
double calc_average_self_energy_k_space() const override
void sanity_checks() const
Structure to hold P3M parameters and some dependent variables.
double energy_correction
cached k-space self-energy correction
int sum_dip_part
number of dipolar particles (only on head node).
double pos_shift
position shift for calculation of first assignment mesh point.
p3m_interpolation_cache inter_weights
double sum_mu2
Sum of square of magnetic dipoles (only on head node).
std::vector< FloatType > ks_scalar
k-space scalar mesh for k-space calculations.
Base class for the electrostatics and magnetostatics P3M algorithms.