30#include "communication.hpp"
39#ifdef ESPRESSO_SHARED_MEMORY_PARALLELISM
40#include <Kokkos_Core.hpp>
53template <
typename FloatType,
class FFTConfig>
class P3MFFT;
60template <
typename FloatType,
class FFTConfig>
86 std::shared_ptr<P3MFFT<FloatType, FFTConfig>>
fft;
87#ifdef ESPRESSO_SHARED_MEMORY_PARALLELISM
94 "CoulombP3MState::rs_charge_density_kokkos", 0, 0);
103template <
typename FloatType, Arch Architecture,
class FFTConfig>
112#ifdef ESPRESSO_SHARED_MEMORY_PARALLELISM
114 std::shared_ptr<KokkosHandle> m_kokkos_handle;
116 std::unique_ptr<CoulombP3MStateClass> p3m_state_ptr;
121 auto constexpr memory_order = CoulombP3MStateClass::memory_order;
132#ifdef ESPRESSO_SHARED_MEMORY_PARALLELISM
135 p3m_state_ptr{
std::move(p3m_state)}, tuning{
std::move(tuning_params)} {
138 throw std::domain_error(
"Parameter 'timings' must be > 0");
143#ifdef ESPRESSO_SHARED_MEMORY_PARALLELISM
149 if constexpr (Architecture ==
Arch::CPU) {
158 void tune()
override;
161 double square_sum_q)
override {
170 [[nodiscard]]
bool is_tuned() const noexcept
override {
return m_is_tuned; }
171 [[nodiscard]]
bool is_gpu() const noexcept
override {
175 return std::is_same_v<FloatType, double>;
198 if constexpr (Architecture ==
Arch::CPU) {
212 bool skip_cache)
override;
218#ifdef ESPRESSO_SHARED_MEMORY_PARALLELISM
219 using execution_space = Kokkos::DefaultExecutionSpace;
220 auto const num_threads = execution_space().concurrency();
242 void kernel_ks_charge_density();
243 void kernel_rs_electric_field();
Vector implementation and trait types for boost qvm interoperability.
void set_prefactor(double new_prefactor)
double prefactor
Electrostatics prefactor.
Cache for interpolation weights.
void reset(int cao)
Reset the cache.
std::shared_ptr< KokkosHandle > kokkos_handle
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.
double long_range_energy() override
void adapt_epsilon_elc() override
void count_charged_particles_elc(std::size_t n, double sum_q2, double square_sum_q) override
std::shared_ptr< P3MGpuParams > m_gpu_data
void assign_charge(double q, Utils::Vector3d const &real_pos, bool skip_cache) override
double long_range_kernel(bool force_flag, bool energy_flag)
Compute the k-space part of forces and energies.
void add_long_range_forces_gpu()
bool is_gpu() const noexcept override
void charge_assign() override
void on_activation() override
~CoulombP3MHeffte() override=default
void count_charged_particles() override
void calc_influence_function_energy() override
Calculate the influence function optimized for the energy and the self energy correction.
CoulombP3MHeffte(std::unique_ptr< CoulombP3MStateClass > &&p3m_state, TuningParameters tuning_params, double prefactor)
CoulombP3MStateClass & p3m
Coulomb P3M parameters.
bool is_tuned() const noexcept override
Utils::Vector9d long_range_pressure() override
void add_long_range_forces() override
bool is_double_precision() const noexcept override
void calc_influence_function_force() override
Calculate the optimal influence function of .
void prepare_fft_mesh(bool reset_weights) override
void scaleby_box_l() override
Base class for the electrostatics P3M algorithm.
std::size_t sum_qpart
number of charged particles.
std::array< std::vector< FloatType >, 3 > rs_E_fields_no_halo
electric fields in real-space without halo
std::complex< value_type > ComplexType
std::array< std::vector< FloatType >, 3 > rs_E_fields
electric fields in real-space with halo
double square_sum_q
square of sum of charges.
Kokkos::View< FloatType **, Kokkos::LayoutRight, Kokkos::HostSpace > rs_charge_density_kokkos
std::vector< FloatType > rs_charge_density
charge density in real-space with halo
std::shared_ptr< P3MFFT< FloatType, FFTConfig > > fft
p3m_send_mesh< FloatType > halo_comm
double sum_q2
Sum of square of charges.
std::vector< ComplexType > ks_charge_density
charge density in k-space without halo
std::array< std::vector< ComplexType >, 3 > ks_E_fields
electric fields in k-space without halo
p3m_interpolation_cache inter_weights
void sanity_checks() const
std::size_t size
number of local mesh points including halo layers.
int cao
charge assignment order ([0,7]).
bool tuning
tuning or production?
double epsilon
epsilon of the "surrounding dielectric".
State of the p3m methods, the part which applies to both, electrostatic and dipolar p3m.
P3MParameters params
P3M base parameters.
P3MLocalMesh local_mesh
Local mesh geometry information for this MPI rank.