include/pops/numerics/elliptic/linear/krylov_solver.hpp Source File¶
|
adc_cpp 0.3.0
Model-free C++23 core for coupled hyperbolic-elliptic systems on adaptive (AMR) meshes, with MPI and GPU (Kokkos) backends
|
krylov_solver.hpp
Go to the documentation of this file.
86 // current GLOBAL L2 residual ||rhs - L_int(phi)|| (collective). L2 counterpart of GeometricMG's norm_inf.
98 // r0 = rhs - L_int(phi) (true INHOMOGENEOUS residual, warm start respected). Here we KEEP the AFFINE
178 // INHOMOGENEOUS MATRIX-FREE matvec: out = L_int(in) = div(A grad in) - kappa in, ghosts of in filled
179 // with op_.bc() (the FULL BC). Reuses the coefficients of op_'s FULL operator (same pointers as
180 // current_residual). AFFINE in in when bcPhi carries a nonzero Dirichlet value: the boundary ghost
182 // apply_operator(0). We use it ONLY for the true residual r0 / residual() (where that constant term
183 // is exactly the Dirichlet data folded into the residual, which is what we want). The IN-LOOP matvecs
196 // apply_operator(0) the inhomogeneous boundary part (constant). BiCGStab applies the matvec to correction
197 // DIRECTIONS (phat = M^{-1} p, shat = M^{-1} s), NOT to the iterate; the operator must be linear there,
198 // otherwise the constant term c_bc injected at each matvec breaks the BiCGStab relations (residual that
199 // oscillates / diverges). We therefore subtract c_bc, just as we subtract d_bc in the preconditioner. Zero
200 // Dirichlet BC => has_op_offset_ stays false => apply_operator_lin == apply_operator, bit-identical.
207 // preconditioner M^{-1}: out = (N MG V-cycles on the symmetric part) applied to in, with HOMOGENEOUS
208 // BC (start out = 0, no warm start: M^{-1} is a LINEAR operator frozen for the BiCGStab iteration).
211 // The V-cycle of precond_ (precond_.vcycle()) runs at level 0 with its FULL BC bc_. Now if bcPhi
213 // ghost = 2 v - interior: starting from phi=0, the first pass injects a FIXED source term ~2 v,
214 // INDEPENDENT of in. The raw V-cycle is therefore AFFINE: precond_raw(in) = M^{-1} in + d_bc, with
215 // d_bc = precond_raw(0) (constant offset, function of the BC and coefficients alone, NOT of in).
216 // This offset injected into phat/shat would make phi += alpha phat + omega shat drift by a spurious
217 // term alpha d_bc + omega d_bc at each iteration and would break convergence. We therefore SUBTRACT the offset:
219 // which is EXACTLY the V-cycle with HOMOGENEOUS BC (the MG recursion is affine, its homogeneous part does
220 // not depend on v). Bit-identical to an internal vcycle_homogeneous(), without touching GeometricMG.
222 // Same reason and remedy as apply_operator_lin (linear matvec): the operator AND the preconditioner
224 // we linearize both by subtracting their respective offset (c_bc for the matvec, d_bc for the precond).
225 // Only the true residual r0 / residual() keeps the operator affine (the Dirichlet data is folded in there).
235 // RAW V-cycle of the preconditioner: out = (N MG V-cycles) applied to in, starting from phi=0. AFFINE in in
245 // Prepare the inhomogeneous BC offsets, ONCE per solve: c_bc = apply_operator(0) for the matvec and
246 // d_bc = precond_raw(0) for the preconditioner. A BC without a nonzero Dirichlet value leaves both
247 // offsets at 0 (has_*_offset_ = false): apply_operator_lin and apply_precond revert to the historical
249 // (matvec) and precond_.bc() (precond) separately. We use phat_ (1 ghost, required by fill_ghosts
BoxArray: the set of boxes tiling a level (disjoint, covering).
Definition geometric_mg.hpp:79
Field distributed over a level: decomposition (BoxArray) + distribution (DistributionMapping) + ncomp...
Definition multifab.hpp:33
void set_val(Real v)
Fills all cells (valid + ghosts) of every local fab with v.
Definition multifab.hpp:85
Definition krylov_solver.hpp:58
TensorKrylovSolver(GeometricMG &op, GeometricMG &precond, int n_precond_vcycles=1)
Definition krylov_solver.hpp:61
KrylovResult solve(Real rel_tol, int max_iters)
Definition krylov_solver.hpp:96
Parallel seam: minimal MPI abstraction (rank/size + collectives) with serial fallback.
DistributionMapping: maps each box (by global index) to its owning MPI rank.
GeometricMG: in-house geometric multigrid (V-cycle) for the elliptic operator, Gauss-Seidel smoother ...
Geometry: index-space (Box2D) <-> Cartesian physical-space mapping; PolarGeometry: SIBLING for a glob...
KrylovResult – the shared result type of every Krylov solve in include/pops/numerics/elliptic/linear.
MultiFab arithmetic (saxpy, lincomb, norm_inf, dot) over VALID cells.
MultiFab: a field DISTRIBUTED over a level (equivalent of AMReX's MultiFab).
Definition amr_hierarchy.hpp:29
void for_each_cell(const Box2D &b, F f)
Applies f to EACH cell (i, j) of box b (bounds inclusive), via Kokkos::parallel_for (Serial / OpenMP ...
Definition for_each.hpp:138
Real dot(const MultiFab &x, const MultiFab &y, int comp=0)
Dot product Sum_cells x.y over component comp, reduced over ALL ranks (all_reduce).
Definition mf_arith.hpp:163
void saxpy(MultiFab &y, Real a, const MultiFab &x)
y <- y + a x over ALL components of the valid cells. Identical layouts required.
Definition mf_arith.hpp:102
void apply_laplacian(const MultiFab &phi, const Geometry &geom, MultiFab &lap, const MultiFab *coef=nullptr, const MultiFab *eps=nullptr, const MultiFab *kappa=nullptr, const MultiFab *eps_y=nullptr, const MultiFab *a_xy=nullptr, const MultiFab *a_yx=nullptr)
Definition poisson_operator.hpp:191
void device_fence()
Device barrier: waits for in-flight kernels to finish before a HOST access to unified memory.
Definition kokkos_env.hpp:43
void lincomb(MultiFab &z, Real a, const MultiFab &x, Real b, const MultiFab &y)
z <- a x + b y over ALL components of the valid cells. Identical layouts; aliasing safe.
Definition mf_arith.hpp:133
void fill_ghosts(MultiFab &mf, const Box2D &domain, const BCRec &bc)
COMPLETE ghost filling: fill_boundary (interior + periodic, periodicity deduced from bc) THEN fill_ph...
Definition physical_bc.hpp:227
PHYSICAL boundary conditions at the domain edge (BCType, BCRec, fill_physical_bc, fill_ghosts).
Free functions of the elliptic operator: apply_laplacian (matvec), poisson_residual (residual),...
Cartesian geometry of a level: index domain + physical bounds [xlo, xhi] x [ylo, yhi].
Definition geometry.hpp:20
Outcome of a Krylov solve: iterations performed, final relative residual, convergence flag.
Definition krylov_result.hpp:16
Real rel_residual
||r_final|| / ||b|| (global L2 norm; base 1 when ||b|| == 0)
Definition krylov_result.hpp:18
bool converged
true if ||r|| <= rel_tol * ||b|| was reached
Definition krylov_result.hpp:19
Base scalar types and the POPS_HD macro (host+device portability).
Generated by