21#ifndef PECLET_CORE_AMR_DISTRIBUTED_ADAPT_HPP
22#define PECLET_CORE_AMR_DISTRIBUTED_ADAPT_HPP
24#ifdef PECLET_CORE_HAVE_MORTON
37template <
int Dim,
unsigned Bits>
39 const std::vector<double>&
u,
double eps = 0.01) {
43 const int F = 2 * Dim;
44 std::vector<double>
e(
static_cast<std::size_t
>(n), 0.0);
46 const double ui =
u[
static_cast<std::size_t
>(
i)];
48 for (
int axis = 0; axis < Dim; ++axis) {
49 const double up = g[
static_cast<std::size_t
>(
i) *
F + 2 * axis + 0];
50 const double um = g[
static_cast<std::size_t
>(
i) *
F + 2 * axis + 1];
53 const double d2 =
up - 2.0 *
ui +
um;
54 const double nrm = std::fabs(
up -
ui) + std::fabs(
ui -
um) +
55 eps * (std::fabs(
up) + 2.0 * std::fabs(
ui) + std::fabs(
um));
59 e[
static_cast<std::size_t
>(
i)] = (
den2 > 0.0) ? std::sqrt(
num2 /
den2) : 0.0;
67template <
int Dim,
unsigned Bits>
73 using Code =
typename BO::Code;
74 using M =
typename BO::M;
82 for (
unsigned oct = 0;
oct < (1u << Dim); ++
oct) {
83 Code cc = M::from_code(
parent).child(
pl,
oct).code();
Index coarsenIf(Pred &&pred)
Merge complete sibling groups (all 2^Dim children present, all at the same level) whose parent satisf...
Index refineIf(Pred &&pred)
Split every leaf for which pred(code, level) is true (and level > 0) into its 2^Dim children one leve...
std::vector< double > faceNeighborGather(const std::vector< double > &field, double sentinel=kNoNeighbor) const
For each local leaf and each of the 2*Dim faces, the neighbouring leaf's field value.
Index balance()
Bring the whole distributed octree to a 2:1-balanced state.
std::vector< int > flagByIndicator(const BlockOctree< Dim, Bits > &t, const std::vector< double > &ind, double refineThresh, double coarsenThresh, unsigned finestLevel=0)
std::vector< double > lohnerIndicatorDistributed(const DistributedOctree< Dim, Bits > &d, const std::vector< double > &u, double eps=0.01)
Löhner indicator per local leaf, using the owner-based face-neighbour halo so cross-block neighbours ...
std::vector< double > transferField(const BlockOctree< Dim, Bits > &oldT, const std::vector< double > &oldF, const BlockOctree< Dim, Bits > &newT, bool linear=true)
Conservative remap of a leaf field from oldT to newT (same domain).
std::vector< double > distributedAdapt(DistributedOctree< Dim, Bits > &d, const std::vector< double > &f, double refineThresh, double coarsenThresh, unsigned finestLevel=0, double eps=0.01, bool linear=true)
One distributed solution-adaptive step.
Kokkos::View< T *, MemSpace > View
1D device array.
std::int64_t Index
Signed index type for grids and particles (supersedes block_decomposer's long int IndxT).