include/pops/numerics/time/amr/advance/amr_advance.hpp Source FileΒΆ

adc_cpp: include/pops/numerics/time/amr/advance/amr_advance.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_advance.hpp
Go to the documentation of this file.
1#pragma once
2
4
23
24namespace pops {
25
26// --- Unified AMR engine (review, point 5) ---
27// The AMR hierarchy as a named OBJECT that the engine advances, rather than a family of
28// amr_step_* functions whose case (2/N levels, mono/multi-box) is encoded in the NAME.
29// Unified entry: advance_amr(m, LevelHierarchy&, dt), faithful facade of the N-level
30// multi-patch engine (verified at 2 AND 3 levels, maxdiff = 0, by test_advance_amr). The ROLES
31// from the review, their current backing (named types, or remaining code to promote):
32// OwnershipPolicy = DistributionMapping (who owns which patch) -> alias below
33// AmrLevel = AmrLevelMP (box + data + aux + dx of a level)
34// PatchRange = NAMED TYPE: coarse footprint [I0..I1]x[J0..J1] of a fine patch
35// (ratio 2), shared by average_down, coverage and registers
36// CoarseFineGhost = NAMED TYPE/HELPER: fill_cf_ghost_cell (space+time interp per ghost
37// cell), shared by the three mf_fill_fine_ghosts_*
38// CoarseFineInterface = NAMED TYPE: coverage (CoverageMask) + bordering reflux routing
39// (route_reflux), shared by subcycle_level_mp and amr_step_2level_multipatch
40// FluxRegister = NAMED TYPE: avg/ref buffers at global index + all_reduce_sum_inplace
41// SubcyclingSchedule = NAMED TYPE: Berger-Oliger cadence (ratio r, dt/r, frac s/r) per level
42// RegridPolicy = amr_regrid_finest (Berger-Rigoutsos), on the coupler side
44
46 std::vector<AmrLevelMP> levels; // level 0 = coarse, levels >0 = fine patches
47 Box2D base_dom; // footprint of the base level
48 Periodicity base_per{true, true}; // BC of the base domain
49 bool coarse_replicated = true; // level 0 replicated (true) or multi-box distributed (false)
50 bool recon_prim = false; // primitive reconstruction (cf. compute_face_fluxes)
51 bool imex = false; // stiff implicit source (backward_euler) instead of forward Euler
52 // NEWTON OPTIONS of the IMEX step (default {} = historical constants 2 iters / 1e-7 -> bit-identical).
53 // Honored only when imex==true; forwarded to backward_euler_source by mf_apply_source_treatment.
55 // TIME METHOD: kEuler (default, forward Euler per substep, bit-identical to the historical) or
56 // kSsprk3 (SSPRK3 order 3 + per-stage reflux). kSsprk3 requires imex == false (rejected otherwise, cf. engine).
58 // Zhang-Shu positivity floor (ADC-259): Density-role face-state + C/F-ghost-mean floor on the AMR
59 // transport. <= 0 (default) -> inactive, bit-identical to the historical path.
61};
62
63// Unified production entry: advances the hierarchy by one time step dt. "pieces" form (the coupler
64// owns its own stack and passes the vectors directly) and LevelHierarchy form. The gate FORWARDS
65// coarse_replicated to the engine; without it a de-replicated coarse level would switch back to
66// replicated (mf_find_box instead of parallel_copy). coarse_replicated=true (default) -> identical
67// to the historical behavior. recon_prim selects the primitive reconstruction (variables
68// (rho, u, p)) instead of conservative: same parameter as assemble_rhs, fixed when the block is added;
69// false (default) -> conservative, strictly bit-identical to the historical.
70template <class Limiter = NoSlope, class NumericalFlux = RusanovFlux, class Model>
71void advance_amr(const Model& m, std::vector<AmrLevelMP>& levels, const Box2D& base_dom, Real dt,
72 Periodicity base_per = Periodicity{true, true}, bool coarse_replicated = true,
73 bool recon_prim = false, bool imex = false, const NewtonOptions& nopts = {},
74 AmrTimeMethod tmethod = AmrTimeMethod::kEuler, Real pos_floor = Real(0)) {
75 detail::amr_step_multilevel_multipatch<Limiter, NumericalFlux>(m, levels, base_dom, dt, base_per,
76 coarse_replicated, recon_prim,
77 imex, nopts, tmethod, pos_floor);
78}
79
80template <class Limiter = NoSlope, class NumericalFlux = RusanovFlux, class Model>
81void advance_amr(const Model& m, LevelHierarchy& h, Real dt) {
82 advance_amr<Limiter, NumericalFlux>(m, h.levels, h.base_dom, dt, h.base_per, h.coarse_replicated,
84 h.pos_floor);
85}
86
87} // namespace pops
AMR multi-patch subcycling engine (several fine boxes per level): 2-level step (amr_step_2level_multi...
Owning MPI rank of each box, indexed by GLOBAL box index (parallel to a BoxArray).
Definition distribution_mapping.hpp:19
Definition amr_hierarchy.hpp:29
void advance_amr(const Model &m, std::vector< AmrLevelMP > &levels, const Box2D &base_dom, Real dt, Periodicity base_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_advance.hpp:71
double Real
Definition types.hpp:30
AmrTimeMethod
Definition amr_flux_helpers.hpp:46
2D integer index space, cell-centered.
Definition box2d.hpp:37
Definition amr_advance.hpp:45
AmrTimeMethod time_method
Definition amr_advance.hpp:57
std::vector< AmrLevelMP > levels
Definition amr_advance.hpp:46
NewtonOptions newton_options
Definition amr_advance.hpp:54
bool coarse_replicated
Definition amr_advance.hpp:49
bool recon_prim
Definition amr_advance.hpp:50
Periodicity base_per
Definition amr_advance.hpp:48
Box2D base_dom
Definition amr_advance.hpp:47
Real pos_floor
Definition amr_advance.hpp:60
bool imex
Definition amr_advance.hpp:51
Options of the local Newton of the implicit source (backward-Euler).
Definition implicit_stepper.hpp:114
Per-direction periodicity: halo wrapping in x and/or y during the exchange (false = open edge,...
Definition fill_boundary.hpp:37