26#ifndef PECLET_VORO_TOPOLOGY_STORE_HPP
27#define PECLET_VORO_TOPOLOGY_STORE_HPP
29#include <Kokkos_Core.hpp>
32#include "peclet/core/common/view.hpp"
38template <
int MAXP,
int MAXT>
42 Kokkos::View<int*, MemSpace>
np;
43 Kokkos::View<int*, MemSpace>
nt;
44 Kokkos::View<int*, MemSpace>
pnbr;
45 Kokkos::View<unsigned*, MemSpace>
tri;
46 Kokkos::View<unsigned char*, MemSpace>
54 using Kokkos::view_alloc;
55 using Kokkos::WithoutInitializing;
57 np = Kokkos::View<int*, MemSpace>(
"topo.np", n);
58 nt = Kokkos::View<int*, MemSpace>(
"topo.nt", n);
59 pnbr = Kokkos::View<int*, MemSpace>(view_alloc(std::string(
"topo.pnbr"), WithoutInitializing),
61 tri = Kokkos::View<unsigned*, MemSpace>(
62 view_alloc(std::string(
"topo.tri"), WithoutInitializing), (
size_t)n * MAXT);
68 poke4 = Kokkos::View<unsigned char*, MemSpace>(
69 Kokkos::view_alloc(std::string(
"topo.poke4"), Kokkos::WithoutInitializing),
70 (
size_t)
N * MAXT * 4);
75 KOKKOS_INLINE_FUNCTION
void save(
int i,
const Cell& c)
const {
78 for (
int k = 0; k < c.np; ++k)
79 pnbr((
size_t)i * MAXP + k) = c.pnbr[k];
80 for (
int t = 0; t < c.nt; ++t)
81 tri((
size_t)i * MAXT + t) = (unsigned)c.t0[t] | ((
unsigned)c.t1[t] << 8) |
82 ((
unsigned)c.t2[t] << 16) | ((c.alive[t] ? 1u : 0u) << 24);
92 template <
class Cell,
class Real>
93 KOKKOS_INLINE_FUNCTION
void load(
int i, Cell& c, Real L0, Real L1, Real L2)
const {
94 c.initBoxPlanes(L0, L1, L2);
95 const int npi =
np(i), nti =
nt(i);
99 for (
int k = 6; k < npi; ++k)
100 c.pnbr[k] =
pnbr((
size_t)i * MAXP + k);
101 for (
int t = 0; t < nti; ++t) {
102 const unsigned w =
tri((
size_t)i * MAXT + t);
103 c.t0[t] = (
unsigned char)(w & 0xffu);
104 c.t1[t] = (
unsigned char)((w >> 8) & 0xffu);
105 c.t2[t] = (
unsigned char)((w >> 16) & 0xffu);
106 c.alive[t] = ((w >> 24) & 1u) != 0u;
Definition convex_cell.hpp:40
Definition topology_store.hpp:39
void alloc(int n)
Definition topology_store.hpp:53
int N
Definition topology_store.hpp:41
Kokkos::View< int *, MemSpace > np
Definition topology_store.hpp:42
Kokkos::View< unsigned char *, MemSpace > poke4
Definition topology_store.hpp:47
peclet::core::MemSpace MemSpace
Definition topology_store.hpp:40
KOKKOS_INLINE_FUNCTION void load(int i, Cell &c, Real L0, Real L1, Real L2) const
Definition topology_store.hpp:93
Kokkos::View< unsigned *, MemSpace > tri
Definition topology_store.hpp:45
KOKKOS_INLINE_FUNCTION void save(int i, const Cell &c) const
Persist cell c at slot i (call after the cell is finalised — clipped + complete).
Definition topology_store.hpp:75
Kokkos::View< int *, MemSpace > nt
Definition topology_store.hpp:43
Kokkos::View< int *, MemSpace > pnbr
Definition topology_store.hpp:44
void allocPoke4()
Definition topology_store.hpp:67