44template <
typename FloatType>
62template <
typename FloatType, Arch Architecture>
71 std::unique_ptr<p3m_data_struct_coulomb<FloatType>> p3m_impl;
73 std::pair<std::optional<int>, std::optional<int>> tune_limits;
75 bool check_complex_residuals;
81 double prefactor,
int tune_timings,
bool tune_verbose,
82 decltype(tune_limits) tune_limits,
bool check_complex_residuals)
84 p3m_impl{std::move(p3m_handle)}, tune_timings{tune_timings},
85 tune_limits{std::move(tune_limits)}, tune_verbose{tune_verbose},
86 check_complex_residuals{check_complex_residuals} {
88 if (tune_timings <= 0) {
89 throw std::domain_error(
"Parameter 'timings' must be > 0");
91 m_is_tuned = not
p3m.params.tuning;
92 p3m.params.tuning =
false;
97 if constexpr (Architecture ==
Arch::CPU) {
101 if constexpr (Architecture ==
Arch::GPU) {
106 void tune()
override;
109 double square_sum_q)
override {
112 p3m.square_sum_q = square_sum_q;
118 [[nodiscard]]
bool is_tuned() const noexcept
override {
return m_is_tuned; }
119 [[nodiscard]]
bool is_gpu() const noexcept
override {
123 return std::is_same_v<FloatType, double>;
128 if constexpr (Architecture ==
Arch::GPU) {
135 if constexpr (Architecture ==
Arch::GPU) {
148 if constexpr (Architecture ==
Arch::CPU) {
152 if constexpr (Architecture ==
Arch::GPU) {
162 bool skip_cache)
override;
165 p3m.inter_weights.reset(
p3m.params.cao);
167 for (
int i = 0; i <
p3m.local_mesh.size; i++) {
168 p3m.mesh.rs_scalar[i] = FloatType(0);
188template <
typename FloatType,
Arch Architecture,
189 template <
typename>
class FFTBackendImpl,
190 template <
typename>
class P3MFFTMeshImpl,
class... Args>
193 auto obj = std::make_shared<CoulombP3MImpl<FloatType, Architecture>>(
194 std::make_unique<p3m_data_struct_coulomb<FloatType>>(std::move(p3m)),
195 std::forward<Args>(args)...);
196 obj->p3m.template make_mesh_instance<P3MFFTMeshImpl<FloatType>>();
197 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.
Arch
P3M kernel architecture.
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
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
CoulombP3MImpl(std::unique_ptr< p3m_data_struct_coulomb< FloatType > > &&p3m_handle, double prefactor, int tune_timings, bool tune_verbose, decltype(tune_limits) tune_limits, bool check_complex_residuals)
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.