9#ifndef PECLET_FLOW_MAC_REDUCTIONS_HPP
10#define PECLET_FLOW_MAC_REDUCTIONS_HPP
13#include <Kokkos_Core.hpp>
14#include <Kokkos_MathematicalFunctions.hpp>
18using Exec = Kokkos::DefaultExecutionSpace;
19using Mem = Exec::memory_space;
20using DField = Kokkos::View<double*, Mem>;
21using DConst = Kokkos::View<const double*, Mem>;
40 const int ix =
static_cast<int>(c % inner.
x);
41 const int iy =
static_cast<int>((c / inner.
x) % inner.
y);
42 const int iz =
static_cast<int>(c / (
static_cast<long>(inner.
x) * inner.
y));
43 return static_cast<std::size_t
>(ix + ghost) +
static_cast<std::size_t
>(iy + ghost) * ext.
x +
44 static_cast<std::size_t
>(iz + ghost) *
static_cast<std::size_t
>(ext.
x) * ext.
y;
49 const long n =
static_cast<long>(inner.
x) * inner.
y * inner.
z;
53 Kokkos::parallel_reduce(
54 "peclet::flow::sum_max", Kokkos::RangePolicy<Exec>(0, n),
55 KOKKOS_LAMBDA(
long c,
SumMax& acc) {
56 const double v = f(
innerToExt(c, ext, ghost, inner));
58 const double a = Kokkos::fabs(v);
68 const long n =
static_cast<long>(inner.
x) * inner.
y * inner.
z;
72 Kokkos::parallel_reduce(
73 "peclet::flow::dot", Kokkos::RangePolicy<Exec>(0, n),
74 KOKKOS_LAMBDA(
long c,
double& acc) {
75 const std::size_t i =
innerToExt(c, ext, ghost, inner);
84 const std::size_t n = f.extent(0);
86 "peclet::flow::subtract", Kokkos::RangePolicy<Exec>(0, n),
87 KOKKOS_LAMBDA(std::size_t i) { f(i) -= m; });
double localDot(DConst a, DConst b, Ext3 ext, int ghost, Ext3 inner)
Local inner product <a,b> over the inner cells.
Kokkos::DefaultExecutionSpace Exec
Kokkos::View< double *, Mem > DField
SumMax localSumMax(DConst f, Ext3 ext, int ghost, Ext3 inner)
Local sum and max|.| over the inner cells.
void subtractAll(DField f, double m)
Subtract a constant from EVERY cell of the extended block (the mean-removal scatter).
Kokkos::View< const double *, Mem > DConst
std::size_t innerToExt(long c, Ext3 ext, int ghost, Ext3 inner)
{sum, max|.|} reduction value.
SumMax & operator+=(const SumMax &o)