14#ifndef PECLET_AMR_BLOCK_OCTREE_VIEW_HPP
15#define PECLET_AMR_BLOCK_OCTREE_VIEW_HPP
21#include "peclet/core/common/view.hpp"
26template <
int Dim,
unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
53 KOKKOS_INLINE_FUNCTION Index
faceNeighbor(Index i,
int axis,
int dir)
const {
54 M probe = M::from_code(
codes(i));
57 if (!probe.try_add(
static_cast<unsigned>(axis), step))
60 if (!probe.try_sub(
static_cast<unsigned>(axis), 1))
63 return locate(probe.code());
Per-block adaptive octree over block-local Morton codes.
morton::Morton< Dim, Bits > M
const std::vector< std::uint8_t > & levels() const
const std::vector< Code > & codes() const
typename M::coord_type Coord
typename M::code_type Code
Index amrLocate(const typename M::code_type *codes, const std::uint8_t *levels, Index n, typename M::code_type p)
Locate the leaf containing Morton code p in sorted leaf arrays.
Device mirror of a BlockOctree's leaf arrays + device-callable queries.
Index faceNeighbor(Index i, int axis, int dir) const
Leaf across leaf i's face on axis in direction dir (±1), or -1 if it lies outside the block.
BlockOctree< Dim, Bits > Host
View< std::uint8_t > levels
Index locate(Code p) const
Leaf containing Morton code p, or -1. Callable in a device kernel.
typename Host::Coord Coord
void upload(const Host &t)
(Re)upload the host octree's current leaf set to the device.