include/pops/numerics/time/amr/levels/amr_subcycling.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
|
amr_subcycling.hpp
Go to the documentation of this file.
2#include <pops/mesh/storage/mf_arith.hpp> // saxpy, lincomb (SSPRK3 stages, named device-clean functors)
56void amr_step_2level_multipatch(const Model& m, MultiFab& Uc, const Box2D& dom, Real dxc, Real dyc,
115 // multi-box fine fluxes: one face-box per GLOBAL fine box, same dmap as Uf. Built on the global
206// coverage-aware AND routes the correction to the PARENT box containing the adjacent coarse cell.
207// Reduces BIT-FOR-BIT to the single-box path when each level has only one box (validation guard).
210// (test_mpi_amr_multipatch3, 3 levels with a distributed multi-box intermediate level whose fine
227// parent->child aux injection (inject_aux_mb) still assumes the parent is local via mf_find_box;
255// - DISTRIBUTED (intermediate): the parent may be on another rank; its valid regions are brought
298// The parent box of a coarse cell may be on another rank, and the parent may be either REPLICATED
299// (level 0, each rank has a copy) or DISTRIBUTED (intermediate, a single owner). Both are covered
300// by a GLOBAL-indexed coarse buffer: each rank deposits the 2x2 average of ITS local fine patches
365// time-interpolated coarse-fine ghosts from the parent at position frac (mf_fill_fine_ghosts_mb)
366// THEN fine-fine halos (fill_boundary). Factored out of the head of subcycle_level_mp, REUSED by
387// flux: true SSPRK method-of-lines, cf. mf_eval_rhs -- IMEX is NOT supported, rejected upstream).
388// (2) Fills (fx, fy) with the EFFECTIVE FLUX of the step Feff = 1/6 F(U0) + 1/6 F(U1) + 2/3 F(U2)
389// which is EXACTLY the transport flux seen by the final state (U_new = U0 - dt div Feff + dt Seff).
390// This is the flux the conservative reflux must record (coarse side g.c* and fine side g.f*), hence
393// ghosts are refreshed by ssprk3_refill_level_ghosts at the SAME frac: the coarse-fine boundary is
403 // Density-role component for the C/F ghost floor (ADC-259), resolved ONCE on the host. pos_floor<=0
404 // -> 0 without model introspection (positivity_comp short-circuit) -> bit-identical historical path.
420 compute_face_fluxes<Limiter, NumericalFlux>(m, lv.U, *lv.aux, Fxs, Fys, lv.dx, lv.dy, recon_prim,
432 compute_face_fluxes<Limiter, NumericalFlux>(m, lv.U, *lv.aux, Fxs, Fys, lv.dx, lv.dy, recon_prim,
440 device_fence(); // (fx, fy) = Feff and lv.U = U_new consistent for host reads (parentRegs/reflux)
451 // not been verified), rejected EXPLICITLY rather than run silently. The facade cannot produce it
460 // Density-role component for the C/F ghost floor (ADC-259), resolved ONCE on the host. pos_floor<=0
461 // -> 0 without model introspection (positivity_comp short-circuit) -> bit-identical historical path.
493 // SSPRK3: we FIRST advance lv.U from t to t+dt (3 stages) AND replace (fx, fy) -- which contain
496 // reflux) reads (fx, fy) and the advanced state EXACTLY as in Euler: recording Feff (instead of
499 // correctly replaces the effective coarse flux with the effective fine flux). The starting state
501 // Euler (ssprk3 == false) this block is skipped and the advance stays the original one, in place
556 // coarse level), it becomes DISTRIBUTED like the fine levels, and mf_find_box(lv.U, I, J) would
632 // state t for the temporal interpolation of the children. SSPRK3: lv.U is ALREADY advanced (the
680void amr_step_multilevel_multipatch(const Model& m, std::vector<AmrLevelMP>& L, const Box2D& dom,
Basic MultiFab building blocks of an AMR step: AmrTimeMethod enum, device-clean functors and advance ...
Named types of the multi-patch coarse-fine interface: PatchRange (coarse footprint of a fine patch),...
Box2D bounding_box() const
Smallest box enclosing all boxes (empty box if the tiling is empty).
Definition box_array.hpp:57
const Box2D & grown_box() const
Grown box (valid + ng ghosts) = actual memory footprint.
Definition fab2d.hpp:76
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
const DistributionMapping & dmap() const
GLOBAL distribution (owner rank per box).
Definition multifab.hpp:58
const BoxArray & box_array() const
GLOBAL decomposition of the level (all boxes, all ranks).
Definition multifab.hpp:56
const Box2D & box(int li) const
VALID box of local fab li.
Definition multifab.hpp:71
int local_size() const
Number of fabs OWNED by this rank (bound on local indices).
Definition multifab.hpp:65
MultiFab arithmetic (saxpy, lincomb, norm_inf, dot) over VALID cells.
void ssprk3_advance_level(const Model &m, AmrLevelMP &lv, Real dt, MultiFab &fx, MultiFab &fy, bool recon_prim, int lev, const Box2D &base_dom, Periodicity base_per, const MultiFab *pOld, const MultiFab *pNew, Real frac, bool coarse_replicated, Real pos_floor=Real(0))
Definition amr_subcycling.hpp:398
void ssprk3_refill_level_ghosts(MultiFab &U, int lev, const Box2D &base_dom, Periodicity base_per, const MultiFab *pOld, const MultiFab *pNew, Real frac, bool coarse_replicated, Real pos_floor=Real(0), int pos_comp=0)
Definition amr_subcycling.hpp:370
void subcycle_level_mp(const Model &m, std::vector< AmrLevelMP > &L, int lev, Real dt, const Box2D &base_dom, Periodicity base_per, const MultiFab *pOld, const MultiFab *pNew, Real frac, std::vector< RegMP > *parentRegs, bool coarse_replicated=true, bool recon_prim=false, bool imex=false, const NewtonOptions &nopts={}, AmrTimeMethod tmethod=AmrTimeMethod::kEuler, Real pos_floor=Real(0))
Definition amr_subcycling.hpp:444
void amr_step_multilevel_multipatch(const Model &m, std::vector< AmrLevelMP > &L, const Box2D &dom, Real dt, Periodicity per=Periodicity{true, true}, bool coarse_replicated=true, bool recon_prim=false, bool imex=false, const NewtonOptions &nopts={}, AmrTimeMethod tmethod=AmrTimeMethod::kEuler, Real pos_floor=Real(0))
Definition amr_subcycling.hpp:680
Definition amr_hierarchy.hpp:29
void mf_apply_source(const Model &m, MultiFab &U, const MultiFab &aux, Real dt)
Definition amr_flux_helpers.hpp:128
void mf_average_down_mb(const MultiFab &Uf, MultiFab &Uc)
Definition amr_subcycling.hpp:305
BoxArray coarsen(const BoxArray &ba, int r)
Coarsens each box of the BoxArray by a ratio r (coarsen box by box, order preserved).
Definition refinement.hpp:39
void mf_fill_fine_ghosts_mb(MultiFab &Uf, const MultiFab &Po, const MultiFab &Pn, Real frac, bool replicated_parent=true, Real pos_floor=Real(0), int pos_comp=0)
Definition amr_subcycling.hpp:259
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
BoxArray coarsen_grown(const BoxArray &ba, int ngrow, int r)
Definition amr_subcycling.hpp:241
void fill_cf_ghost_cell(Array4 f, const ConstArray4 &co, const ConstArray4 &cn, int i, int j, int nc, Real frac, Real pos_floor=Real(0), int pos_comp=0)
Definition amr_flux_helpers.hpp:194
Box2D xface_box(const Box2D &v)
xface_box / yface_box: face boxes normal to x (resp.
Definition face_flux.hpp:147
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 fill_periodic_local(MultiFab &mf, const Box2D &dom)
Definition amr_patch_range.hpp:102
void fill_boundary(MultiFab &mf, const Box2D &domain, Periodicity per={})
BLOCKING halo exchange: begin then end immediately (no overlap).
Definition fill_boundary.hpp:333
void mf_apply_source_treatment(const Model &m, MultiFab &U, const MultiFab &aux, Real dt, bool imex, const NewtonOptions &nopts={})
Definition amr_flux_helpers.hpp:158
@ kSsprk3
@ kEuler
constexpr int kAmrRefRatio
The native AMR refinement ratio between two consecutive levels.
Definition refinement_ratio.hpp:30
void mf_advance_faces(MultiFab &U, const MultiFab &Fx, const MultiFab &Fy, Real dx, Real dy, Real dt)
Definition amr_flux_helpers.hpp:96
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 parallel_copy(MultiFab &dst, const MultiFab &src)
Copies the valid regions that OVERLAP from src to dst (same indices, no shift).
Definition refinement.hpp:50
void mf_fill_fine_ghosts_multi(MultiFab &Uf, const MultiFab &Uc_old, const MultiFab &Uc_new, Real frac)
Definition amr_patch_range.hpp:54
POPS_HD int coarsen_index(int a, int r)
Index of the coarse cell containing the fine cell a (FLOOR division by r, handles a < 0).
Definition refinement.hpp:34
void amr_step_2level_multipatch(const Model &m, MultiFab &Uc, const Box2D &dom, Real dxc, Real dyc, MultiFab &Uf, const MultiFab &auxc, const MultiFab &auxf, Real dt)
Definition amr_subcycling.hpp:56
void mf_eval_rhs(const Model &m, const MultiFab &U, const MultiFab &aux, const MultiFab &Fx, const MultiFab &Fy, Real dx, Real dy, MultiFab &R)
Definition amr_flux_helpers.hpp:73
AMR inter-level transfer operators (integer ratio r) + parallel_copy.
Single source of truth for the native AMR refinement ratio.
Definition amr_subcycling.hpp:349
WRITE POD handle (raw pointer + strides) over a Fab2D buffer, indexed by (i, j, c) IN GLOBAL INDICES ...
Definition fab2d.hpp:29
static Box2D from_extents(int nx, int ny)
Box [0, nx-1] x [0, ny-1] covering nx*ny cells from the index origin.
Definition box2d.hpp:42
POPS_HD int nx() const
Width (direction 0). POPS_HD (called from Geometry::dx() in a device kernel).
Definition box2d.hpp:50
bool contains(int i, int j) const
true if cell (i, j) is inside the box (lo/hi bounds inclusive).
Definition box2d.hpp:61
POPS_HD int ny() const
Height (direction 1). POPS_HD (called from Geometry::dy() in a device kernel).
Definition box2d.hpp:52
Box2D intersect(const Box2D &o) const
Intersection of the two boxes (possibly empty: hi < lo if they do not overlap).
Definition box2d.hpp:95
Definition amr_patch_range.hpp:196
void route_reflux(const Reg &g, Real dx, Real dy, Real dt, FluxRegister &ref, int nc) const
Definition amr_patch_range.hpp:212
bool covered(int I, int J) const
Definition amr_patch_range.hpp:205
READ-only handle (const counterpart of Array4): same layout and same contract (POD device-copyable,...
Definition fab2d.hpp:44
Definition amr_patch_range.hpp:152
Definition amr_patch_range.hpp:124
Options of the local Newton of the implicit source (backward-Euler).
Definition implicit_stepper.hpp:114
Definition amr_patch_range.hpp:42
Per-direction periodicity: halo wrapping in x and/or y during the exchange (false = open edge,...
Definition fill_boundary.hpp:37
Definition amr_subcycling.hpp:357
Definition amr_patch_range.hpp:180
Generated by