5#ifndef IPPL_LAPLACE_HELPERS_H
6#define IPPL_LAPLACE_HELPERS_H
12 constexpr static unsigned dim = E::dim;
18 template <
typename... Idx>
19 KOKKOS_INLINE_FUNCTION
auto operator()(
const Idx... args)
const {
20 using index_type = std::tuple_element_t<0, std::tuple<Idx...>>;
21 using T =
typename E::Mesh_t::value_type;
23 index_type coords[
dim] = {args...};
25 for (
unsigned d = 0; d <
dim; d++) {
26 index_type coords[
dim] = {args...};
33 res += (2.0 * center - left - right);
45 sizeof(E) + sizeof(typename E::Mesh_t::vector_type)
46 + 2 * sizeof(typename E::Layout_t::NDIndex_t)
48 constexpr static unsigned dim = E::dim;
53 unsigned nghosts,
const typename E::Layout_t::NDIndex_t& ldom,
54 const typename E::Layout_t::NDIndex_t& domain)
64 template <
typename... Idx>
65 KOKKOS_INLINE_FUNCTION
auto operator()(
const Idx... args)
const {
66 using index_type = std::tuple_element_t<0, std::tuple<Idx...>>;
67 using T =
typename E::Mesh_t::value_type;
70 for (
unsigned d = 0; d <
dim; d++) {
71 index_type coords[
dim] = {args...};
73 const int size =
domain_m.length()[d];
74 const bool not_left_boundary = (global_index != 0);
75 const bool right_boundary = (global_index == size - 1);
86 res +=
hvector_m[d] * (not_left_boundary * left + right_boundary * right);
103 template <
typename E>
106 sizeof(E) + sizeof(typename E::Mesh_t::vector_type)
107 + 2 * sizeof(typename E::Layout_t::NDIndex_t)
108 + sizeof(unsigned)> {
109 constexpr static unsigned dim = E::dim;
114 unsigned nghosts,
const typename E::Layout_t::NDIndex_t& ldom,
115 const typename E::Layout_t::NDIndex_t& domain)
125 template <
typename... Idx>
126 KOKKOS_INLINE_FUNCTION
auto operator()(
const Idx... args)
const {
127 using index_type = std::tuple_element_t<0, std::tuple<Idx...>>;
128 using T =
typename E::Mesh_t::value_type;
131 for (
unsigned d = 0; d <
dim; d++) {
132 index_type coords[
dim] = {args...};
134 const int size =
domain_m.length()[d];
135 const bool left_boundary = (global_index == 0);
136 const bool not_right_boundary = (global_index != size - 1);
147 res +=
hvector_m[d] * (left_boundary * left + not_right_boundary * right);
164 template <
typename E>
166 :
public Expression<meta_upper_and_lower_laplace<E>,
167 sizeof(E) + sizeof(typename E::Mesh_t::vector_type)> {
168 constexpr static unsigned dim = E::dim;
179 template <
typename... Idx>
180 KOKKOS_INLINE_FUNCTION
auto operator()(
const Idx... args)
const {
181 using index_type = std::tuple_element_t<0, std::tuple<Idx...>>;
182 using T =
typename E::Mesh_t::value_type;
184 for (
unsigned d = 0; d <
dim; d++) {
185 index_type coords[
dim] = {args...};
206 template <
typename Field>
221 template <
typename Field>
236 template <
typename Field>
242 typename mesh_type::vector_type hvector(0);
243 for (
unsigned d = 0; d <
Dim; d++) {
244 hvector[d] = 1.0 / Kokkos::pow(mesh.getMeshSpacing(d), 2);
248 const auto& ldom = layout.getLocalNDIndex();
249 const auto& domain = layout.getDomain();
257 template <
typename Field>
272 template <
typename Field>
278 typename mesh_type::vector_type hvector(0);
279 for (
unsigned d = 0; d <
Dim; d++) {
280 hvector[d] = 1.0 / Kokkos::pow(mesh.getMeshSpacing(d), 2);
284 const auto& ldom = layout.getLocalNDIndex();
285 const auto& domain = layout.getDomain();
293 template <
typename Field>
308 template <
typename Field>
314 typename mesh_type::vector_type hvector(0);
315 for (
unsigned d = 0; d <
Dim; d++) {
316 hvector[d] = 1.0 / Kokkos::pow(mesh.getMeshSpacing(d), 2);
328 template <
typename Field>
335 typename mesh_type::vector_type hvector(0);
336 for (
unsigned d = 0; d <
Dim; ++d) {
337 hvector[d] = Kokkos::pow(mesh.getMeshSpacing(d), 2);
338 sum += hvector[d] * Kokkos::pow(mesh.getMeshSpacing((d + 1) %
Dim), 2);
339 factor *= hvector[d];
342 return 0.5 * (factor / sum);
345 template <
typename Field>
351 for (
unsigned d = 0; d <
Dim; ++d) {
352 sum += 1 / (Kokkos::pow(mesh.getMeshSpacing(d), 2));
359 template <
typename Field>
365 Kokkos::parallel_for(
367 KOKKOS_LAMBDA(
int i,
int j,
int k) { view(i, j, k) *= c; });
typename ippl::detail::ViewType< ippl::Vector< double, Dim >, 1 >::view_type view_type
KOKKOS_INLINE_FUNCTION constexpr decltype(auto) apply(const View &view, const Coords &coords)
detail::meta_poisson< Field > poisson(Field &u)
detail::meta_upper_laplace< Field > upper_laplace(Field &u)
detail::meta_upper_and_lower_laplace< Field > upper_and_lower_laplace_no_comm(Field &u)
detail::meta_lower_laplace< Field > lower_laplace(Field &u)
double negative_inverse_diagonal_laplace(Field &u)
detail::meta_upper_laplace< Field > upper_laplace_no_comm(Field &u)
double diagonal_laplace(Field &u)
void mult(Field &u, const double c)
detail::meta_lower_laplace< Field > lower_laplace_no_comm(Field &u)
detail::meta_upper_and_lower_laplace< Field > upper_and_lower_laplace(Field &u)
Layout_t & getLayout() const
static constexpr unsigned dim
policy_type< execution_space, PolicyArgs... > getFieldRangePolicy(const int nghost=0) const
KOKKOS_INLINE_FUNCTION Mesh_t & get_mesh() const
typename BareField_t::view_type view_type
Mesh< double, Dim >::vector_type vector_type
static constexpr unsigned dim
KOKKOS_INLINE_FUNCTION auto operator()(const Idx... args) const
KOKKOS_FUNCTION meta_poisson(const E &u)
static constexpr unsigned dim
typename Mesh_t::vector_type vector_type
typename Layout_t::NDIndex_t domain_type
const domain_type domain_m
typename E::value_type value_type
const vector_type hvector_m
KOKKOS_INLINE_FUNCTION auto operator()(const Idx... args) const
typename E::Layout_t Layout_t
typename E::Mesh_t Mesh_t
KOKKOS_FUNCTION meta_lower_laplace(const E &u, const typename E::Mesh_t::vector_type &hvector, unsigned nghosts, const typename E::Layout_t::NDIndex_t &ldom, const typename E::Layout_t::NDIndex_t &domain)
typename E::Mesh_t Mesh_t
KOKKOS_INLINE_FUNCTION auto operator()(const Idx... args) const
typename E::Layout_t Layout_t
const vector_type hvector_m
typename E::value_type value_type
static constexpr unsigned dim
KOKKOS_FUNCTION meta_upper_laplace(const E &u, const typename E::Mesh_t::vector_type &hvector, unsigned nghosts, const typename E::Layout_t::NDIndex_t &ldom, const typename E::Layout_t::NDIndex_t &domain)
const domain_type domain_m
typename Layout_t::NDIndex_t domain_type
typename Mesh_t::vector_type vector_type
KOKKOS_INLINE_FUNCTION auto operator()(const Idx... args) const
KOKKOS_FUNCTION meta_upper_and_lower_laplace(const E &u, const typename E::Mesh_t::vector_type &hvector)
typename E::value_type value_type
typename E::Mesh_t::vector_type vector_type
const vector_type hvector_m
static constexpr unsigned dim