44template <
typename FloatType>
64template <
typename FloatType, Arch Architecture>
73 std::unique_ptr<p3m_data_struct_dipoles<FloatType>> dp3m_impl;
81 double prefactor,
int tune_timings,
bool tune_verbose)
83 dp3m_impl{std::move(dp3m_handle)}, tune_timings{tune_timings},
84 tune_verbose{tune_verbose} {
86 if (tune_timings <= 0) {
87 throw std::domain_error(
"Parameter 'timings' must be > 0");
90 throw std::domain_error(
"DipolarP3M requires a cubic mesh");
92 m_is_tuned = not
dp3m.params.tuning;
93 dp3m.params.tuning =
false;
98 if constexpr (Architecture ==
Arch::CPU) {
102 void tune()
override;
105 [[nodiscard]]
bool is_tuned() const noexcept
override {
return m_is_tuned; }
106 [[nodiscard]]
bool is_gpu() const noexcept
override {
110 return std::is_same_v<FloatType, double>;
123 if constexpr (Architecture ==
Arch::CPU) {
144template <
typename FloatType,
Arch Architecture,
145 template <
typename>
class FFTBackendImpl,
146 template <
typename>
class P3MFFTMeshImpl,
class... Args>
149 auto obj = std::make_shared<DipolarP3MImpl<FloatType, Architecture>>(
150 std::make_unique<p3m_data_struct_dipoles<FloatType>>(std::move(p3m)),
151 std::forward<Args>(args)...);
152 obj->dp3m.template make_mesh_instance<P3MFFTMeshImpl<FloatType>>();
153 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.
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
DipolarP3MImpl(std::unique_ptr< p3m_data_struct_dipoles< FloatType > > &&dp3m_handle, double prefactor, int tune_timings, bool tune_verbose)
void calc_influence_function_force() override
bool is_tuned() const noexcept override
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.