peclet-amr 0.2.0
Block-local-Morton AMR octree + collocated cut-cell Navier–Stokes solver (header-only C++20, Kokkos + MPI)
Loading...
Searching...
No Matches
peclet::amr::AmrMultigrid< Dim, Bits > Class Template Reference

Geometric multigrid for AmrPoisson over a uniformly-coarsened octree hierarchy. More...

#include <poisson.hpp>

Public Types

using Octree = BlockOctree< Dim, Bits >
 
using M = typename Octree::M
 
using Code = typename Octree::Code
 

Public Member Functions

void build (const Octree &finest, Real h0, bool liftRoot=true, Index bottomExtent=4)
 Build the hierarchy from a finest octree by uniform coarsening until a single leaf remains (or no full sibling group can be merged), then — with liftRoot — CONTINUE BELOW THE ROOT BRICK by lifting the root (docs/amr_mg_depth.md §6.1–§6.2): each further level is the level above with its brick halved and lmax incremented, so every former root cell acquires siblings and coarsenIf merges one octet more.
 
void build (const Octree &finest, const Vec< Dim > &h0, bool liftRoot=true, Index bottomExtent=4)
 Phase 3: every level shares the same PER-AXIS finest spacing — a coarse leaf carries a higher level, and cellWidth = h0[d]*2^level already encodes its width on each axis, so the root aspect ratio is inherited by the whole hierarchy (docs/amr_anisotropic.md AM1).
 
std::size_t numLevels () const
 
const AmrPoisson< Dim, Bits > & op (std::size_t L=0) const
 
void setPeriodic (bool p)
 Apply a boundary condition to every level (periodic default, or non-periodic homogeneous Dirichlet).
 
void setImmersedWall (bool w)
 Enable the immersed no-slip (Dirichlet) wall on every level — the velocity operator.
 
void vcycle (std::size_t L, std::vector< double > &u, const std::vector< double > &rhs, int pre=2, int post=2)
 One V-cycle on level L solving L u = rhs (correction scheme).
 
double solveQuad (std::vector< double > &u, const std::vector< double > &rhs, int outer=30, int cyclesPerOuter=1)
 Solve the quadratic C/F operator L_quad u = rhs by deferred correction: the standard-operator V-cycle solves L_std u = rhs - (L_quad - L_std) u, with the cheap-to-evaluate quadratic correction lagged.
 
template<class OpenFn >
void setOpenness (OpenFn &&openFn)
 Set cut-cell face openness on the finest level from a geometry callable openFn(faceCentreWorld, axis) -> [0,1], then coarsen it to every coarser level by area-averaging the fine sub-faces (flow's coarsenOpenAvg).
 
void setOpennessRaw (std::vector< double > alpha)
 Same, but the finest level's openness is handed over ALREADY EVALUATED (alpha is the AmrPoisson::opennessRaw() layout: numLeaves()·2·Dim doubles, face-major per leaf) instead of being sampled from a geometry callable.
 

Static Public Member Functions

static bool canLiftLevel (const Octree &t, Index bottomExtent)
 The single-rank lift rule of docs/amr_mg_depth.md §6.2, evaluated on one level: may the hierarchy continue BELOW this level by lifting its root? G is the level's root brick.
 

Detailed Description

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
class peclet::amr::AmrMultigrid< Dim, Bits >

Geometric multigrid for AmrPoisson over a uniformly-coarsened octree hierarchy.

Definition at line 634 of file poisson.hpp.

Member Typedef Documentation

◆ Octree

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
using peclet::amr::AmrMultigrid< Dim, Bits >::Octree = BlockOctree<Dim, Bits>

Definition at line 636 of file poisson.hpp.

◆ M

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
using peclet::amr::AmrMultigrid< Dim, Bits >::M = typename Octree::M

Definition at line 637 of file poisson.hpp.

◆ Code

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
using peclet::amr::AmrMultigrid< Dim, Bits >::Code = typename Octree::Code

Definition at line 638 of file poisson.hpp.

Member Function Documentation

◆ canLiftLevel()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
static bool peclet::amr::AmrMultigrid< Dim, Bits >::canLiftLevel ( const Octree &  t,
Index  bottomExtent 
)
inlinestatic

The single-rank lift rule of docs/amr_mg_depth.md §6.2, evaluated on one level: may the hierarchy continue BELOW this level by lifting its root? G is the level's root brick.

Stops when the level is already small enough for the bottom smoother to be exact (max extent <= bottomExtent), when the grid cannot halve into a cube level (odd extent, or fewer than two cells left on an axis), or when the block itself cannot lift (odd brick or odd global origin — trivially satisfied single-rank, origin 0).

Definition at line 646 of file poisson.hpp.

References peclet::amr::transferFieldGradients().

Referenced by peclet::amr::AmrMultigrid< Dim, Bits >::build().

◆ build() [1/2]

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
void peclet::amr::AmrMultigrid< Dim, Bits >::build ( const Octree &  finest,
Real  h0,
bool  liftRoot = true,
Index  bottomExtent = 4 
)
inline

Build the hierarchy from a finest octree by uniform coarsening until a single leaf remains (or no full sibling group can be merged), then — with liftRoot — CONTINUE BELOW THE ROOT BRICK by lifting the root (docs/amr_mg_depth.md §6.1–§6.2): each further level is the level above with its brick halved and lmax incremented, so every former root cell acquires siblings and coarsenIf merges one octet more.

The leaf codes are untouched by a lift, so a lifted level is bit-for-bit the level a deeper tree on the same mesh would have produced. bottomExtent is where the ladder stops because the bottom smoother is exact there (§6.6).

Definition at line 667 of file poisson.hpp.

References peclet::amr::AmrMultigrid< Dim, Bits >::build(), and peclet::amr::transferFieldGradients().

Referenced by peclet::amr::AmrMultigrid< Dim, Bits >::build(), and peclet::amr::pybind::Poisson::Poisson().

◆ build() [2/2]

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
void peclet::amr::AmrMultigrid< Dim, Bits >::build ( const Octree &  finest,
const Vec< Dim > &  h0,
bool  liftRoot = true,
Index  bottomExtent = 4 
)
inline

Phase 3: every level shares the same PER-AXIS finest spacing — a coarse leaf carries a higher level, and cellWidth = h0[d]*2^level already encodes its width on each axis, so the root aspect ratio is inherited by the whole hierarchy (docs/amr_anisotropic.md AM1).

Definition at line 673 of file poisson.hpp.

References peclet::amr::AmrMultigrid< Dim, Bits >::canLiftLevel(), and peclet::amr::transferFieldGradients().

◆ numLevels()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
std::size_t peclet::amr::AmrMultigrid< Dim, Bits >::numLevels ( ) const
inline

Definition at line 720 of file poisson.hpp.

Referenced by peclet::amr::pybind::Poisson::num_levels().

◆ op()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
const AmrPoisson< Dim, Bits > & peclet::amr::AmrMultigrid< Dim, Bits >::op ( std::size_t  L = 0) const
inline

◆ setPeriodic()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
void peclet::amr::AmrMultigrid< Dim, Bits >::setPeriodic ( bool  p)
inline

Apply a boundary condition to every level (periodic default, or non-periodic homogeneous Dirichlet).

Call after build().

Definition at line 725 of file poisson.hpp.

References peclet::amr::transferFieldGradients().

Referenced by peclet::amr::pybind::Poisson::Poisson().

◆ setImmersedWall()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
void peclet::amr::AmrMultigrid< Dim, Bits >::setImmersedWall ( bool  w)
inline

Enable the immersed no-slip (Dirichlet) wall on every level — the velocity operator.

Call after setOpenness() (the wall is derived per level from that level's coarsened aperture, so it is consistent down the hierarchy). Call after build().

Definition at line 733 of file poisson.hpp.

References peclet::amr::transferFieldGradients().

◆ vcycle()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
void peclet::amr::AmrMultigrid< Dim, Bits >::vcycle ( std::size_t  L,
std::vector< double > &  u,
const std::vector< double > &  rhs,
int  pre = 2,
int  post = 2 
)
inline

◆ solveQuad()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
double peclet::amr::AmrMultigrid< Dim, Bits >::solveQuad ( std::vector< double > &  u,
const std::vector< double > &  rhs,
int  outer = 30,
int  cyclesPerOuter = 1 
)
inline

Solve the quadratic C/F operator L_quad u = rhs by deferred correction: the standard-operator V-cycle solves L_std u = rhs - (L_quad - L_std) u, with the cheap-to-evaluate quadratic correction lagged.

Returns the final L_quad residual norm. cyclesPerOuter V-cycles per correction update.

Definition at line 784 of file poisson.hpp.

References peclet::amr::transferFieldGradients(), and peclet::amr::AmrMultigrid< Dim, Bits >::vcycle().

◆ setOpenness()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
template<class OpenFn >
void peclet::amr::AmrMultigrid< Dim, Bits >::setOpenness ( OpenFn &&  openFn)
inline

Set cut-cell face openness on the finest level from a geometry callable openFn(faceCentreWorld, axis) -> [0,1], then coarsen it to every coarser level by area-averaging the fine sub-faces (flow's coarsenOpenAvg).

The per-level operators are thereby rediscretized with consistent openness, and the openness-weighted quadratic C/F flux applies on every level. Call after build().

Definition at line 809 of file poisson.hpp.

References peclet::amr::transferFieldGradients().

◆ setOpennessRaw()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
void peclet::amr::AmrMultigrid< Dim, Bits >::setOpennessRaw ( std::vector< double >  alpha)
inline

Same, but the finest level's openness is handed over ALREADY EVALUATED (alpha is the AmrPoisson::opennessRaw() layout: numLeaves()·2·Dim doubles, face-major per leaf) instead of being sampled from a geometry callable.

The ladder below it is the identical area-averaging. This is what the redundant tail needs (docs/amr_mg_depth.md §6.5): the tail's level 0 is a gathered copy of a distributed level whose α rows were computed by the distributed openness ladder — re-sampling the geometry there would be both wasteful and, at a coarsened cut face, not the same number.

Definition at line 824 of file poisson.hpp.

References peclet::amr::transferFieldGradients().


The documentation for this class was generated from the following file: