21#ifndef PECLET_AMR_CSR_HPP
22#define PECLET_AMR_CSR_HPP
25#include "peclet/core/common/types.hpp"
26#include "peclet/core/common/view.hpp"
42 KOKKOS_INLINE_FUNCTION
void operator()(Index j,
double c) {
54template <
class CountFn>
55View<Index>
scanOffsets(Index n,
const CountFn& countFn, Index& nTotal) {
56 View<Index> start(Kokkos::view_alloc(
"peclet::amr::csr_off", Kokkos::WithoutInitializing),
57 static_cast<std::size_t
>(n) + 1);
58 Kokkos::parallel_scan(
59 "peclet::amr::csr_off_scan", n + 1,
60 KOKKOS_LAMBDA(
const Index i, Index& partial,
const bool final_pass) {
61 const Index c = (i < n) ? countFn(i) : Index(0);
66 Kokkos::deep_copy(nTotal, Kokkos::subview(start, n));
91 View<Index> start(Kokkos::view_alloc(
"peclet::amr::csr_start", Kokkos::WithoutInitializing),
92 static_cast<std::size_t
>(n) + 1);
93 Kokkos::parallel_scan(
94 "peclet::amr::csr_scan", n + 1,
95 KOKKOS_LAMBDA(
const Index i, Index& partial,
const bool final_pass) {
106 Kokkos::deep_copy(csr.
nFaces, Kokkos::subview(start, n));
108 csr.
nbr = View<Index>(Kokkos::view_alloc(
"peclet::amr::csr_nbr", Kokkos::WithoutInitializing),
109 static_cast<std::size_t
>(csr.
nFaces));
110 csr.
coef = View<double>(Kokkos::view_alloc(
"peclet::amr::csr_coef", Kokkos::WithoutInitializing),
111 static_cast<std::size_t
>(csr.
nFaces));
112 View<Index> nbr = csr.
nbr;
113 View<double> coef = csr.
coef;
114 Kokkos::parallel_for(
115 "peclet::amr::csr_fill", n, KOKKOS_LAMBDA(
const Index i) {
Csr buildFaceCsr(Index n, const Emit &emit)
Build a face-CSR on device from a per-cell emit functor.
View< Index > scanOffsets(Index n, const CountFn &countFn, Index &nTotal)
CSR row offsets (size n+1) from a per-cell count functor, via one exclusive prefix scan,...
Sink passed to the emit functor during the COUNT pass: just tallies faces.
void operator()(Index, double)
Sink passed to the emit functor during the FILL pass: writes each face into the cell's own slice [sta...
void operator()(Index j, double c)
An assembled face-CSR: row offsets (size n+1), neighbour index + coefficient per face (size nFaces).
View< Index > nbr
neighbour leaf per face, size nFaces
View< double > coef
coefficient per face, size nFaces
View< Index > start
CSR row offsets, size n+1; start(n) == nFaces.