43template <
typename FloatType>
61template <
typename FloatType, Arch Architecture>
70 std::unique_ptr<p3m_data_struct_coulomb<FloatType>> p3m_impl;
73 bool check_complex_residuals;
79 double prefactor,
int tune_timings,
bool tune_verbose,
80 bool check_complex_residuals)
82 p3m_impl{std::move(p3m_handle)}, tune_timings{tune_timings},
83 tune_verbose{tune_verbose},
84 check_complex_residuals{check_complex_residuals} {
86 if (tune_timings <= 0) {
87 throw std::domain_error(
"Parameter 'timings' must be > 0");
89 m_is_tuned = not
p3m.params.tuning;
90 p3m.params.tuning =
false;
95 if constexpr (Architecture ==
Arch::CPU) {
99 if constexpr (Architecture ==
Arch::GPU) {
104 void tune()
override;
107 double square_sum_q)
override {
110 p3m.square_sum_q = square_sum_q;
116 [[nodiscard]]
bool is_tuned() const noexcept
override {
return m_is_tuned; }
117 [[nodiscard]]
bool is_gpu() const noexcept
override {
121 return std::is_same_v<FloatType, double>;
126 if constexpr (Architecture ==
Arch::GPU) {
133 if constexpr (Architecture ==
Arch::GPU) {
146 if constexpr (Architecture ==
Arch::CPU) {
150 if constexpr (Architecture ==
Arch::GPU) {
160 bool skip_cache)
override;
163 p3m.inter_weights.reset(
p3m.params.cao);
165 for (
int i = 0; i <
p3m.local_mesh.size; i++) {
166 p3m.mesh.rs_scalar[i] = FloatType(0);
186template <
typename FloatType,
Arch Architecture,
187 template <
typename>
class FFTBackendImpl,
188 template <
typename>
class P3MFFTMeshImpl,
class... Args>
191 auto obj = std::make_shared<CoulombP3MImpl<FloatType, Architecture>>(
192 std::make_unique<p3m_data_struct_coulomb<FloatType>>(std::move(p3m)),
193 std::forward<Args>(args)...);
194 obj->p3m.template make_mesh_instance<P3MFFTMeshImpl<FloatType>>();
195 obj->p3m.template make_fft_instance<FFTBackendImpl<FloatType>>();
Vector implementation and trait types for boost qvm interoperability.
void set_prefactor(double new_prefactor)
double prefactor
Electrostatics prefactor.
Cache for interpolation weights.
This file contains the defaults for ESPResSo.
Common functions for dipolar and charge P3M.
auto constexpr P3M_EPSILON_METALLIC
This value indicates metallic boundary conditions.
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.
void charge_assign(ParticleRange const &particles) override
double long_range_energy(ParticleRange const &particles) override
bool is_gpu() const noexcept override
bool is_tuned() const noexcept override
void assign_charge(double q, Utils::Vector3d const &real_pos, bool skip_cache) override
void calc_influence_function_energy() override
Calculate the influence function optimized for the energy and the self energy correction.
void add_long_range_forces(ParticleRange const &particles) override
void count_charged_particles_elc(int n, double sum_q2, double square_sum_q) override
CoulombP3MImpl(std::unique_ptr< p3m_data_struct_coulomb< FloatType > > &&p3m_handle, double prefactor, int tune_timings, bool tune_verbose, bool check_complex_residuals)
void scaleby_box_l() override
void calc_influence_function_force() override
Calculate the optimal influence function of .
Utils::Vector9d long_range_pressure(ParticleRange const &particles) override
bool is_double_precision() const noexcept override
~CoulombP3MImpl() override=default
void on_activation() override
void count_charged_particles() override
double long_range_kernel(bool force_flag, bool energy_flag, ParticleRange const &particles)
Compute the k-space part of forces and energies.
std::shared_ptr< P3MGpuParams > m_gpu_data
void prepare_fft_mesh(bool reset_weights) override
void add_long_range_forces_gpu(ParticleRange const &particles)
p3m_data_struct_coulomb< FloatType > & p3m
Coulomb P3M parameters.
void adapt_epsilon_elc() override
void sanity_checks() const
Structure to hold P3M parameters and some dependent variables.
double sum_q2
Sum of square of charges (only on head node).
double square_sum_q
square of sum of charges (only on head node).
int sum_qpart
number of charged particles (only on head node).
p3m_interpolation_cache inter_weights
Base class for the electrostatics and magnetostatics P3M algorithms.