core
Shared MPI block decomposition + asynchronous ghost-layer exchange (header-only C++20)
Loading...
Searching...
No Matches
peclet::core::amr::Multigrid< Dim, Bits > Class Template Reference

#include <multigrid.hpp>

Public Types

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

Public Member Functions

void build (const Octree &finest, double h0)
 Build + upload the hierarchy from a finest octree (uniform coarsening), openness- free.
 
template<class OpenFn >
void build (const Octree &finest, double h0, OpenFn &&openFn, bool periodic=true, bool immersedWall=false)
 Build with cut-cell openness openFn(faceCentreWorld, axis) → [0,1], coarsened to every level by area-averaging (AmrMultigrid::setOpenness — the same coarsenOpenAvg the host uses): each level's face weight is α·A/d with α the coarsened aperture, so the coarse operators stay consistent cut-cell operators.
 
void setKappaRestrict (bool on)
 Opt-in: use κ-weighted (fluid-fraction) restriction instead of the default plain volume-average.
 
void setRemoveMean (bool on)
 Opt-in (default off): project the correction to mean-zero over fluid cells at every V-cycle level — the singular (periodic pure-Neumann) nullspace removal, mirroring flow CutcellMG::vcycle.
 
void setHelmholtz (double c0, double cD)
 Turn every level's operator into the Helmholtz form H = c0·I + cD·L (default c0=0, cD=1 ⇒ the pure Laplacian L).
 
std::size_t numLevels () const
 
Index numLeaves (std::size_t L=0) const
 
Code octreeCode (std::size_t L, Index i) const
 
View< doublex (std::size_t L=0)
 
View< doubleb (std::size_t L=0)
 
const FvOpop (std::size_t L=0) const
 
View< IndexquadStart () const
 
View< IndexquadSlot () const
 
View< doublequadCoef () const
 
void vcycle (int pre=2, int post=2, int bottom=40, double omega=0.8, std::size_t L=0)
 One V-cycle on level L (default finest) of the standard (consistent conservative) operator, correction scheme.
 
double solveQuad (int outer=20, int cyclesPerOuter=1, int pre=2, int post=2, int bottom=40, double omega=0.8)
 Solve L_quad u = rhs (the 2nd-order graded operator) by deferred correction: each outer step solves L_std u = rhs − (L_quad−L_std)u with the quadratic correction lagged, via cyclesPerOuter standard V-cycles.
 
void reassembleOperators ()
 Re-assemble every level's operator ON THE DEVICE from the (host) hierarchy's current geometry — the dynamic-AMR rebuild hook (D5/D6).
 

Detailed Description

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

Definition at line 117 of file multigrid.hpp.

Member Typedef Documentation

◆ Octree

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

Definition at line 119 of file multigrid.hpp.

◆ M

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

Definition at line 120 of file multigrid.hpp.

◆ Code

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

Definition at line 121 of file multigrid.hpp.

◆ Poisson

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
using peclet::core::amr::Multigrid< Dim, Bits >::Poisson = AmrPoisson<Dim, Bits>

Definition at line 122 of file multigrid.hpp.

Member Function Documentation

◆ build() [1/2]

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
void peclet::core::amr::Multigrid< Dim, Bits >::build ( const Octree finest,
double  h0 
)
inline

Build + upload the hierarchy from a finest octree (uniform coarsening), openness- free.

h0 is the finest spacing (every level shares it; a coarse leaf's higher level encodes its width).

Definition at line 127 of file multigrid.hpp.

◆ build() [2/2]

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
template<class OpenFn >
void peclet::core::amr::Multigrid< Dim, Bits >::build ( const Octree finest,
double  h0,
OpenFn &&  openFn,
bool  periodic = true,
bool  immersedWall = false 
)
inline

Build with cut-cell openness openFn(faceCentreWorld, axis) → [0,1], coarsened to every level by area-averaging (AmrMultigrid::setOpenness — the same coarsenOpenAvg the host uses): each level's face weight is α·A/d with α the coarsened aperture, so the coarse operators stay consistent cut-cell operators.

Definition at line 138 of file multigrid.hpp.

◆ setKappaRestrict()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
void peclet::core::amr::Multigrid< Dim, Bits >::setKappaRestrict ( bool  on)
inline

Opt-in: use κ-weighted (fluid-fraction) restriction instead of the default plain volume-average.

Experimental — validate with the comparison test before relying on it.

Definition at line 150 of file multigrid.hpp.

◆ setRemoveMean()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
void peclet::core::amr::Multigrid< Dim, Bits >::setRemoveMean ( bool  on)
inline

Opt-in (default off): project the correction to mean-zero over fluid cells at every V-cycle level — the singular (periodic pure-Neumann) nullspace removal, mirroring flow CutcellMG::vcycle.

Needed when the V-cycle is the MG-PCG preconditioner for a singular operator (otherwise the cycle drifts / amplifies a near-nullspace mode and the projection blows up under large transient divergence). The bit-exact-vs-host MG test keeps this OFF.

Definition at line 157 of file multigrid.hpp.

◆ setHelmholtz()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
void peclet::core::amr::Multigrid< Dim, Bits >::setHelmholtz ( double  c0,
double  cD 
)
inline

Turn every level's operator into the Helmholtz form H = c0·I + cD·L (default c0=0, cD=1 ⇒ the pure Laplacian L).

With c0=idiag, cD=−μ the hierarchy represents the momentum operator idiag·I − μ∇² and (being non-singular for c0≠0) is an effective V-cycle preconditioner for the momentum BiCGStab. The reaction c0 is held constant on every level (standard for a Helmholtz MG preconditioner); cD scales the coarsened L.

Definition at line 164 of file multigrid.hpp.

◆ numLevels()

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

Definition at line 171 of file multigrid.hpp.

◆ numLeaves()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
Index peclet::core::amr::Multigrid< Dim, Bits >::numLeaves ( std::size_t  L = 0) const
inline

Definition at line 172 of file multigrid.hpp.

◆ octreeCode()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
Code peclet::core::amr::Multigrid< Dim, Bits >::octreeCode ( std::size_t  L,
Index  i 
) const
inline

Definition at line 173 of file multigrid.hpp.

◆ x()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
View< double > peclet::core::amr::Multigrid< Dim, Bits >::x ( std::size_t  L = 0)
inline

Definition at line 174 of file multigrid.hpp.

◆ b()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
View< double > peclet::core::amr::Multigrid< Dim, Bits >::b ( std::size_t  L = 0)
inline

Definition at line 175 of file multigrid.hpp.

◆ op()

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

Definition at line 176 of file multigrid.hpp.

◆ quadStart()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
View< Index > peclet::core::amr::Multigrid< Dim, Bits >::quadStart ( ) const
inline

Definition at line 177 of file multigrid.hpp.

◆ quadSlot()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
View< Index > peclet::core::amr::Multigrid< Dim, Bits >::quadSlot ( ) const
inline

Definition at line 178 of file multigrid.hpp.

◆ quadCoef()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
View< double > peclet::core::amr::Multigrid< Dim, Bits >::quadCoef ( ) const
inline

Definition at line 179 of file multigrid.hpp.

◆ vcycle()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
void peclet::core::amr::Multigrid< Dim, Bits >::vcycle ( int  pre = 2,
int  post = 2,
int  bottom = 40,
double  omega = 0.8,
std::size_t  L = 0 
)
inline

◆ solveQuad()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
double peclet::core::amr::Multigrid< Dim, Bits >::solveQuad ( int  outer = 20,
int  cyclesPerOuter = 1,
int  pre = 2,
int  post = 2,
int  bottom = 40,
double  omega = 0.8 
)
inline

Solve L_quad u = rhs (the 2nd-order graded operator) by deferred correction: each outer step solves L_std u = rhs − (L_quad−L_std)u with the quadratic correction lagged, via cyclesPerOuter standard V-cycles.

The finest b holds rhs on entry and is restored on return. Returns the final L_quad residual L2 norm.

Definition at line 216 of file multigrid.hpp.

References peclet::core::amr::quadDelta(), peclet::core::amr::residualFv(), and peclet::core::amr::Multigrid< Dim, Bits >::vcycle().

◆ reassembleOperators()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
void peclet::core::amr::Multigrid< Dim, Bits >::reassembleOperators ( )
inline

Re-assemble every level's operator ON THE DEVICE from the (host) hierarchy's current geometry — the dynamic-AMR rebuild hook (D5/D6).

After a moving boundary re-samples each level's openness on the host AmrPoisson (hmg_), this rebuilds all per-level FvOps on device with no host CSR walk and no round-trip, preserving each level's Helmholtz c0/cD. Topology (c2p/child maps) is unchanged.

Definition at line 347 of file multigrid.hpp.


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