26#ifndef PECLET_AMR_MG_PREDICT_HPP
27#define PECLET_AMR_MG_PREDICT_HPP
35#include "peclet/core/decomp/block_decomposer.hpp"
36#include "peclet/core/decomp/stage_target.hpp"
66 for (
int a = 0;
a < Dim; ++
a)
67 if ((
G[
a] % 2) != 0 || (
G[
a] / 2) < 2)
69 for (std::size_t b = 0; b <
dec.numBlocks(); ++b)
70 for (
int a = 0;
a < Dim; ++
a)
71 if ((
dec.origins()[b][
a] % 2) != 0 || (
dec.sizes()[b][
a] % 2) != 0)
102 return "repartition";
126 std::vector<MgLevelPrediction<Dim>>
levels;
139 while (k <
levels.size() &&
160 for (
int d = 0; d < Dim; ++d)
161 mx = std::max(
mx,
G[d]);
171 for (
int d = 0; d < Dim; ++d)
172 if ((
G[d] % 2) != 0 || (
G[d] / 2) < 2)
180 for (
int d = 0; d < Dim; ++d)
181 c *=
static_cast<long long>(
G[d]);
191 p.levels.push_back(
lv);
215 Index bottomExtent = 4,
222 for (
unsigned j = 0;
j <= lmax; ++
j) {
224 for (
int d = 0; d < Dim; ++d)
225 e[d] =
G[d] << (lmax -
j);
232 namespace cd = core::decomp;
233 cd::BlockDecomposer<Dim>
dec(
static_cast<std::size_t
>(
numRanks),
G);
235 if (maxBlockCells < 0) {
236 maxBlockCells =
static_cast<Index>(cd::largestBlockCells(
dec));
237 for (
unsigned j = 0;
j < lmax; ++
j)
238 maxBlockCells <<= Dim;
245 for (
int d = 0; d < Dim; ++d)
251 if (
dec.numBlocks() <= 1 || detail::maxExtent<Dim>(
cur) <= bottomExtent)
256 const cd::StageTarget<Dim>
t = cd::chooseStageTarget(
258 policy.minExtent, maxBlockCells);
259 if (
t.kind == cd::StageKind::SiblingMerge ||
t.kind == cd::StageKind::Repartition) {
271 detail::pushLevel<Dim>(
p,
cur,
273 while (detail::gridCanHalve<Dim>(
cur, bottomExtent)) {
274 for (
int d = 0; d < Dim; ++d)
void pushLevel(MgLadderPrediction< Dim > &p, const IVec< Dim > &G, MgLevelKind kind)
long long cellsOf(const IVec< Dim > &G)
bool gridCanHalve(const IVec< Dim > &G, Index bottomExtent)
The grid half of the §6.2 rule: stop when the bottom smoother is already exact, and when the grid can...
Index maxExtent(const IVec< Dim > &G)
bool amrStageLiftable(const core::decomp::BlockDecomposer< Dim > &dec)
amr's lift rule (docs/amr_mg_depth.md §6.2) as core's stage predicate: the level grid halves into a c...
const char * toString(MgLevelKind k)
MgBottomKind
What solves the coarsest level.
@ Jacobi
damped Jacobi is exact there (max extent <= bottomExtent)
@ Amg
the agglomerated GraphAMG-PCG bottom
MgLevelKind
Where a predicted level comes from.
@ Octree
a coarsening of the octree itself (at or above the root brick)
@ Repartition
the continued ladder of a repartition stage (a fresh ORB on np_L ranks)
@ Sibling
the continued ladder of a sibling-merge stage (fewer ranks, agglomerated(d))
@ Lifted
below the root brick, in place: the ORB blocks nest, transfers stay local
@ Tail
below the in-place ladder: the gathered grid, solved redundantly on every rank
MgLadderPrediction< Dim > predictPressureLadder(IVec< Dim > G, unsigned lmax, int numRanks, Index bottomExtent=4, const PressureStagePolicy &policy={})
Predict the pressure-multigrid ladder for a global ROOT grid G (in root cells, i.e.
std::vector< std::array< double, Dim > > transferFieldGradients(const BlockOctree< Dim, Bits > &oldT, const std::vector< double > &oldF)
Per-old-leaf minmod prolongation gradients (per fine-coordinate unit) — transferField's stencil,...
The whole predicted ladder: what predictPressureLadder returns and what peclet.amr....
std::vector< MgLevelKind > stages
The stages met on the way down, outermost first (Tail, Sibling, Repartition).
bool tail
a replicated tail engages (at any depth)
MgBottomKind bottom
what solves the coarsest level under auto
std::vector< MgLevelPrediction< Dim > > levels
Finest first; each stage's levels appended after the ladder it continues.
bool hasStage() const
Whether any stage fires — compare against DistributedFlowMultigrid::hasStage().
std::size_t numInPlace() const
The levels ABOVE the first stage (kinds Octree and Lifted); compare against DistributedFlowMultigrid:...
IVec< Dim > tailFrom
the grid the (first) stage moves
std::string bottomName() const
"jacobi" / "amg", suffixed by every stage innermost first (§6.7's spelling: "+tail",...
One predicted level of the pressure ladder (docs/amr_mg_depth.md §6.7).
MgLevelKind kind
where the level comes from
long long cells
product of extent — the global cell count of a UNIFORM mesh
IVec< Dim > extent
global grid extent in THIS level's cell units
Which stage the distributed pressure ladder uses where its in-place lift blocks (docs/amr_mg_depth....
bool enabled
false: the replicated tail only (WO4)
Index maxBlockCells
Core's bound on a target block's cells.
int minExtent
Core's economic trigger / extent cap.