26#if defined(ESPRESSO_DP3M)
78template <std::
size_t S, std::
size_t m>
85 auto const cao =
params.cao;
86 auto const &mesh =
params.mesh;
100 auto const nm2 =
nm.norm2();
108 [&](
unsigned dim,
int n) {
109 nm[dim] = shift[dim] + n * mesh[dim];
113 return numerator / (Utils::int_pow<S>(
static_cast<double>(d_op.
norm2())) *
132template <
typename FloatType, std::size_t
S, std::size_t m,
167 g[index] = FloatType(
171 [&](
unsigned dim,
int n) {
179template <std::
size_t m>
185 auto const cao =
params.cao;
186 auto const &mesh =
params.mesh;
196 [&](
unsigned dim,
int n) {
214template <
typename FloatType, std::
size_t m>
225 auto index = std::size_t(0
u);
235 energy +=
static_cast<double>(
g[index]) *
U2 *
d_op_off.norm2();
239 [&](
unsigned dim,
int n) {
Vector implementation and trait types for boost qvm interoperability.
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.
constexpr T norm2() const
cudaStream_t stream[1]
CUDA streams for parallel computing on CPU and GPU.
and std::invocable< Projector, unsigned, int > void for_each_3d(detail::IndexVectorConcept auto &&start, detail::IndexVectorConcept auto &&stop, detail::IndexVectorConcept auto &&counters, Kernel &&kernel, Projector &&projector=detail::noop_projector)
Repeat an operation on every element of a 3D grid.
double grid_influence_function_self_energy(P3MParameters const ¶ms, Utils::Vector3i const &n_start, Utils::Vector3i const &n_stop, std::vector< FloatType > const &g)
Calculate self-energy of the influence function.
double G_opt_dipolar(P3MParameters const ¶ms, Utils::Vector3i const &shift, Utils::Vector3i const &d_op)
Calculate the aliasing sums for the optimal influence function.
double G_opt_dipolar_self_energy(P3MParameters const ¶ms, Utils::Vector3i const &shift)
std::vector< FloatType > grid_influence_function_dipolar(P3MParameters const ¶ms, Utils::Vector3i const &n_start, Utils::Vector3i const &n_stop, Utils::Vector3d const &inv_box_l)
Map influence function over a grid.
T product(Vector< T, N > const &v)
DEVICE_QUALIFIER constexpr T sqr(T x)
Calculates the SQuaRe of x.
auto hadamard_division(Vector< T, N > const &a, Vector< U, N > const &b)
DEVICE_QUALIFIER auto sinc(T x)
Calculate the function .
Common functions for dipolar and charge P3M.
std::array< std::vector< int >, 3 > calc_p3m_mesh_shift(Utils::Vector3i const &mesh_size, bool zero_out_midpoint=false)
Calculate indices that shift P3MParameters::mesh by mesh/2.
static SteepestDescentParameters params
Currently active steepest descent instance.
Structure to hold P3M parameters and some dependent variables.