include/pops/numerics/elliptic/polar/polar_tensor_operator.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
|
polar_tensor_operator.hpp
Go to the documentation of this file.
141 // DIAGONAL radial term: (1/r_i) [ r_{i+1/2} a_rr_p (phi_{i+1}-phi_i)/dr - r_{i-1/2} a_rr_m (phi_i-phi_{i-1})/dr ] / dr.
144 if (hrt) { // CROSS radial term a_rt (1/r_face) d_theta phi at face i+-1/2 (d_theta averaged over 4 corners).
147 // (d_theta phi)_face averaged over the 4 corners of the face: 1/(r_face) because grad_theta = (1/r) d_theta phi.
152 // (1/r_i)(1/dr) [ r_{i+1/2} F_cross_p - r_{i-1/2} F_cross_m ], F_cross = a_rt (1/r_face) d_theta phi.
168 // DIAGONAL azimuthal term: a_tt^{j+-1/2} (phi_{j+1}-2 phi+phi_{j-1}) / (r_i^2 dtheta^2), flux form.
188POPS_HD inline Real polar_diag(const ConstArray4& arr, const ConstArray4& att, int i, int j, Real ri,
263 // isotropic case provides fields CONSTANT at 1 (PolarTensorKrylovSolver does this via its internal
358 // tridiagonal per theta line via a SEQUENTIAL Thomas sweep in r. This sweep must stay LOCAL to a
359 // box (it cannot cross a box/rank boundary). We therefore REQUIRE that each box of the BoxArray
360 // cover the FULL RADIAL RANGE [domain.lo[0], domain.hi[0]] (splitting in theta only). The Jacobi
373 // a_rr_store_/a_tt_store_ or external fields. A DEFAULT copy/move would leave these pointers aiming
374 // at the SOURCE object's stores (dangling/UB). The solver is ALWAYS used as a LOCAL scope variable
419 // BiCGStab body. The per-fab operations (lincomb/saxpy/copy/apply_precond/apply_polar_tensor) are
420 // no-ops on an empty rank; the COLLECTIVES (dot/l2_norm/project_mean -> all_reduce_sum) are called
421 // by ALL ranks in the SAME order (an empty rank contributes 0). The stopping criteria rely only on
422 // these GLOBAL scalars (identical everywhere) -> no desynchronization, no separate "run_empty_rank"
424 // Isend/Irecv, not a collective): an empty rank posts nothing and nobody sends to it -> no deadlock.
428 // SINGULAR OPERATOR (pure radial Neumann + periodic theta, no reaction): the constant is in the
429 // kernel of L_int. BiCGStab then diverges (the residual keeps an undamped constant component). We
430 // FIX THE GAUGE by projection onto the zero-mean subspace: we remove the mean of r0 (the RHS must
765 // COLLECTIVE all-reduce (over all ranks, including empty ones): GLOBAL mean identical everywhere.
806 // RadialLine preconditioner: radial tridiagonal of the diagonal block per theta line. PER LOCAL BOX
807 // (line_b_/sub_/sup_[li]), each stored [jl*nr + i] where jl = theta index LOCAL to the box, i = global
BoxArray: the set of boxes tiling a level (disjoint, covering).
ConstArray4 const_array() const
READ handle (POD device-copyable) over this Fab. Valid as long as the Fab lives.
Definition fab2d.hpp:96
Array4 array()
WRITE handle (POD device-copyable) over this Fab. Valid as long as the Fab lives.
Definition fab2d.hpp:91
Field distributed over a level: decomposition (BoxArray) + distribution (DistributionMapping) + ncomp...
Definition multifab.hpp:33
Fab2D & fab(int li)
Local fab at index li (0 <= li < local_size()), for writing.
Definition multifab.hpp:67
void sync_host()
Makes the HOST residence valid (before a host access: operator(), loop, set_val).
Definition multifab.hpp:79
const Box2D & box(int li) const
VALID box of local fab li.
Definition multifab.hpp:71
void set_val(Real v)
Fills all cells (valid + ghosts) of every local fab with v.
Definition multifab.hpp:85
int local_size() const
Number of fabs OWNED by this rank (bound on local indices).
Definition multifab.hpp:65
MATRIX-FREE BiCGStab Krylov solver for the FULL-tensor POLAR elliptic operator L_int(phi) = div(A gra...
Definition polar_tensor_operator.hpp:332
PolarTensorKrylovSolver & operator=(PolarTensorKrylovSolver &&)=delete
PolarTensorKrylovSolver(const PolarTensorKrylovSolver &)=delete
void set_coefficients(MultiFab *a_rr, MultiFab *a_tt, MultiFab *a_rt=nullptr, MultiFab *a_tr=nullptr)
Sets the tensor A coefficients.
Definition polar_tensor_operator.hpp:391
PolarTensorKrylovSolver & operator=(const PolarTensorKrylovSolver &)=delete
Real residual()
Current GLOBAL L2 residual ||rhs - L_int(phi)|| (collective). Prepares once if needed.
Definition polar_tensor_operator.hpp:402
const PolarGeometry & geom() const
Definition polar_tensor_operator.hpp:385
PolarTensorKrylovSolver(PolarTensorKrylovSolver &&)=delete
PolarKrylovResult solve(Real rel_tol, int max_iters)
MATRIX-FREE BiCGStab preconditioned by precond_ (RadialLine by default, Jacobi as fallback); fixes th...
Definition polar_tensor_operator.hpp:414
PolarTensorKrylovSolver(const PolarGeometry &geom, const BoxArray &ba, const BCRec &bc, PolarPrecond precond=PolarPrecond::RadialLine)
Definition polar_tensor_operator.hpp:337
Parallel seam: minimal MPI abstraction (rank/size + collectives) with serial fallback.
Contract of the iterative POLAR elliptic operators: same shape as PolarEllipticSolver (cf.
Definition polar_tensor_operator.hpp:291
DistributionMapping: maps each box (by global index) to its owning MPI rank.
Fab2D: single-grid data on a Box2D (in-house equivalent of AMReX's FArrayBox); Array4 / ConstArray4: ...
for_each_cell and reductions: the parallelism SEAM over the cells of a Box2D; sync_host / sync_device...
Geometry: index-space (Box2D) <-> Cartesian physical-space mapping; PolarGeometry: SIBLING for a glob...
MultiFab arithmetic (saxpy, lincomb, norm_inf, dot) over VALID cells.
MultiFab: a field DISTRIBUTED over a level (equivalent of AMReX's MultiFab).
POPS_HD Real polar_diag(const ConstArray4 &arr, const ConstArray4 &att, int i, int j, Real ri, Real rfm, Real rfp, Real idr, Real idth)
Diagonal (coefficient of phi_{i,j}) of the diagonal POLAR stencil (radial + azimuthal),...
Definition polar_tensor_operator.hpp:188
POPS_HD Real polar_radial_div(const ConstArray4 &p, const ConstArray4 &arr, bool hrt, const ConstArray4 &art, int i, int j, Real ri, Real rfm, Real rfp, Real idr, Real idth)
RADIAL FACE contribution to the diagonal + cross stencil, at (i, j).
Definition polar_tensor_operator.hpp:135
POPS_HD Real polar_azimuthal_div(const ConstArray4 &p, const ConstArray4 &att, bool htr, const ConstArray4 &atr, int i, int j, Real ri, Real idr, Real idth)
AZIMUTHAL FACE contribution to the diagonal + cross stencil, at (i, j).
Definition polar_tensor_operator.hpp:162
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 device_fence()
Device barrier: waits for in-flight kernels to finish before a HOST access to unified memory.
Definition kokkos_env.hpp:43
Real sum(const MultiFab &mf, int comp=0)
Sum of the VALID cells of component comp, reduced over ALL ranks (all_reduce).
Definition multifab.hpp:121
void apply_polar_tensor(const MultiFab &phi, const PolarGeometry &geom, MultiFab &lap, const MultiFab *a_rr, const MultiFab *a_tt, const MultiFab *a_rt, const MultiFab *a_tr)
Applies L_int(phi) = div(A grad phi) in polar over the whole MultiFab.
Definition polar_tensor_operator.hpp:259
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
PolarPrecond
Choice of the SIMPLE BiCGStab PRECONDITIONER (NO MG V-cycle – stagnation on polar 1/r^2,...
Definition polar_tensor_operator.hpp:319
@ Jacobi
@ RadialLine
BCType
Boundary condition type for a face: Periodic (handled by fill_boundary), Foextrap (zero gradient,...
Definition physical_bc.hpp:25
@ Foextrap
@ Dirichlet
@ Periodic
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).
WRITE POD handle (raw pointer + strides) over a Fab2D buffer, indexed by (i, j, c) IN GLOBAL INDICES ...
Definition fab2d.hpp:29
Boundary conditions for the FOUR faces of the domain (type + associated Dirichlet value).
Definition physical_bc.hpp:29
POPS_HD int nx() const
Width (direction 0). POPS_HD (called from Geometry::dx() in a device kernel).
Definition box2d.hpp:50
POPS_HD int ny() const
Height (direction 1). POPS_HD (called from Geometry::dy() in a device kernel).
Definition box2d.hpp:52
READ-only handle (const counterpart of Array4): same layout and same contract (POD device-copyable,...
Definition fab2d.hpp:44
Definition geometry.hpp:59
POPS_HD Real r_face(int i) const
Radius at radial FACE i (face between cells i-1 and i; i = 0 -> r_min, i = nr -> r_max).
Definition geometry.hpp:75
POPS_HD Real r_cell(int i) const
Radius at the CENTER of radial cell i (i = 0 -> r_min + dr/2).
Definition geometry.hpp:73
Box2D domain
nx() = nr (radial cells), ny() = ntheta (azimuthal cells)
Definition geometry.hpp:60
Result of a polar BiCGStab solve: iterations, relative residual, convergence.
Definition polar_tensor_operator.hpp:304
L_int(phi) = div(A grad phi) in polar (apply).
Definition polar_tensor_operator.hpp:204
POPS_HD void operator()(int i, int j) const
Definition polar_tensor_operator.hpp:211
POPS_HD void operator()(int i, int j) const
Definition polar_tensor_operator.hpp:237
Computes idiag = 1 / diag of the diagonal polar stencil (for Jacobi). diag = polar_diag (< 0).
Definition polar_tensor_operator.hpp:241
POPS_HD void operator()(int i, int j) const
Definition polar_tensor_operator.hpp:245
out = (f - L0 phi) / |diag| – one Jacobi iteration (point-by-point relaxation) on the DIAGONAL polar ...
Definition polar_tensor_operator.hpp:225
POPS_HD void operator()(int i, int j) const
Definition polar_tensor_operator.hpp:229
ConstArray4 idiag
Definition polar_tensor_operator.hpp:228
Base scalar types and the POPS_HD macro (host+device portability).
Generated by