31#include "communication.hpp"
40#ifdef ESPRESSO_SHARED_MEMORY_PARALLELISM
41#include <Kokkos_Core.hpp>
54#ifdef ESPRESSO_ADDITIONAL_CHECKS
55#define ESPRESSO_DP3M_HEFFTE_CROSS_CHECKS
58template <
typename FloatType,
class FFTConfig>
class P3MFFT;
65template <
typename FloatType,
class FFTConfig>
90 std::unique_ptr<FFTBackend<FloatType>>
fft;
97 for (
auto i = 0
u; i < 3u; ++i) {
115#ifdef ESPRESSO_DP3M_HEFFTE_CROSS_CHECKS
134 std::shared_ptr<P3MFFT<FloatType, FFTConfig>>
fft;
140#ifdef ESPRESSO_SHARED_MEMORY_PARALLELISM
146#ifdef ESPRESSO_DP3M_HEFFTE_CROSS_CHECKS
152 "DipolarP3MState::rs_fields_kokkos", 0, 0, 0);
157template <
typename FloatType, Arch Architecture,
class FFTConfig>
170#ifdef ESPRESSO_SHARED_MEMORY_PARALLELISM
172 std::shared_ptr<KokkosHandle> m_kokkos_handle;
175 std::unique_ptr<DipolarP3MStateClass> dp3m_impl;
189 throw std::domain_error(
"Parameter 'timings' must be > 0");
192 throw std::domain_error(
"DipolarP3M requires a cubic mesh");
197#ifdef ESPRESSO_SHARED_MEMORY_PARALLELISM
207 void tune()
override;
215 return std::is_same_v<FloatType, double>;
236 void prepare_fft_mesh() {
238#ifdef ESPRESSO_SHARED_MEMORY_PARALLELISM
248#ifdef ESPRESSO_DP3M_HEFFTE_CROSS_CHECKS
249 for (
auto dir : {0
u, 1u, 2u}) {
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) noexcept
Create a vector that has all entries set to the same value.
Cache for interpolation weights.
void reset(int cao)
Reset the cache.
cudaStream_t stream[1]
CUDA streams for parallel computing on CPU and GPU.
std::shared_ptr< KokkosHandle > kokkos_handle
P3M algorithm for long-range magnetic dipole-dipole interaction.
Common functions for dipolar and charge P3M.
static SteepestDescentParameters params
Currently active steepest descent instance.
bool is_double_precision() const noexcept override
void npt_add_virial_contribution(double energy) const override
DipolarP3MHeffte(std::unique_ptr< DipolarP3MStateClass > &&dp3m_state, TuningParameters tuning_params, double prefactor)
double long_range_energy(ParticleRange const &particles) override
double long_range_kernel(bool force_flag, bool energy_flag, ParticleRange const &particles)
Compute the k-space part of forces and energies.
~DipolarP3MHeffte() override=default
double calc_surface_term(bool force_flag, bool energy_flag, ParticleRange const &particles) override
void calc_influence_function_energy() override
void scaleby_box_l() override
void calc_influence_function_force() override
void count_magnetic_particles() override
void add_long_range_forces(ParticleRange const &particles) override
DipolarP3MStateClass & dp3m
Dipolar P3M parameters.
void on_activation() override
double calc_average_self_energy_k_space() const override
void dipole_assign(ParticleRange const &particles) override
void calc_energy_correction() override
bool is_gpu() const noexcept override
bool is_tuned() const noexcept override
Base class for the magnetostatics P3M algorithm.
std::vector< FloatType > g_force
Force optimised influence function (k-space)
std::vector< ComplexType > ks_B_field_storage
magnetic fields in k-space without halo
double sum_mu2
Sum of square of magnetic dipoles.
p3m_interpolation_cache inter_weights
std::complex< FloatType > ComplexType
std::array< std::vector< FloatType >, 3 > rs_B_fields
magnetic fields in real-space with halo
std::size_t sum_dip_part
number of dipolar particles.
std::unique_ptr< FFTBackend< FloatType > > fft
FFT algorithm.
P3MFFTMesh< FloatType > mesh
std::array< std::vector< FloatType >, 3u > rs_dipole_density
dipole density in real-space with halo
p3m_send_mesh< FloatType > halo_comm
std::vector< FloatType > g_energy
Energy optimised influence function (k-space)
std::unique_ptr< FFTBuffers< FloatType > > fft_buffers
FFT buffers.
std::array< std::vector< FloatType >, 3u > rs_B_fields_no_halo
magnetic fields in real-space without halo
double pos_shift
position shift for calculation of first assignment mesh point.
void make_fft_instance(Args... args)
double energy_correction
cached k-space self-energy correction
std::vector< ComplexType > ks_scalar
k-space scalar mesh for k-space calculations.
std::shared_ptr< P3MFFT< FloatType, FFTConfig > > fft
void resize_heffte_buffers()
struct DipolarP3MState::@1 heffte
Kokkos::View< FloatType ***, Kokkos::LayoutRight, Kokkos::HostSpace > rs_fields_kokkos
std::array< std::vector< ComplexType >, 3u > ks_dipole_density
dipole density in k-space without halo
void make_mesh_instance(Args... args)
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?
Utils::Vector3i mesh
number of mesh points per coordinate direction (>0), in real space.
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.