include/pops/numerics/time/integrators/implicit_stepper.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
|
implicit_stepper.hpp
Go to the documentation of this file.
77// Implicit mask CARRIED BY THE BLOCK / time policy (and NOT by the model): device-clean POD carrier
80// components with flag[c] == true are advanced implicitly, the others explicitly (forward Euler). This is what
81// lets you REUSE the SAME model with different implicit treatments depending on the block. Inactive (default:
82// active == false) -> falls back to model_is_implicit -> behavior bit-identical to the historical one.
89// Is component c implicit, with the block mask TAKING PRIORITY over the model default? The inactive mask
232// differences (step h = fd_eps*|W| + fd_eps, source perturbed column by column around S0 = S(W)).
233// Body EXTRACTED word-for-word from the two paths (2a defaults, 2b instrumented) -> bit-identical;
234// POPS_HD because called from newton_source_solve (device-callable). S0 = m.source(W, a) already computed
316 // criterion ||F||_inf <= abs_tol + rel_tol*||F0||_inf at the start of an iteration, the detection of
317 // non-finite residual / degenerate pivot, and the exit statistic. One ADDITIONAL source evaluation
407// Device kernel of the implicit step on the source (local Newton in place). NAMED FUNCTOR (and not an
408// extended lambda): ROBUST device emission when the Model-template kernel is instantiated from an EXTERNAL TU
409// (IMEX path of an add_compiled_model block, via the advance std::function of block_builder). Body
429// the scratch st (comp 0 = ||F||_inf, 1 = iterations, 2 = failure 0/1, 3 = ENCODED OFFENDING CELL).
430// Encoding comp 3: -1 if the cell did not fail; otherwise (j*2^20 + i)*16 + (offending_comp + 1) --
431// exact integer in double up to ~2^44 (i, j < 2^20), so that a MAX reduction yields ONE offending
479// @p mask: implicit mask CARRIED BY THE BLOCK (override of the model default); inactive (default) ->
482// MPI all_reduce) and AGGREGATES into *report (max residual, max iterations, number of failures; reset() is
483// the caller's responsibility at the start of the advance). report == nullptr AND tolerances inactive -> historical
489 // FAST path (historical): neither a report requested nor an active fail_policy -> no scratch, no
490 // reduction, historical kernel bit-identical. A fail_policy != kFailNone REQUIRES the detection,
528 if (nfail_g > 0 && enc_g >= 0) { // decode the offending cell with maximal index (cf. StatKernel)
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
Definition implicit_stepper.hpp:72
Definition implicit_stepper.hpp:45
Definition implicit_stepper.hpp:52
for_each_cell and reductions: the parallelism SEAM over the cells of a Box2D; sync_host / sync_device...
MultiFab: a field DISTRIBUTED over a level (equivalent of AMReX's MultiFab).
POPS_HD void assemble_newton_jacobian(const Model &m, const typename Model::State &W, const Aux &a, Real dt, const NewtonOptions &opts, const int impl[N], int m_impl, const typename Model::State &S0, Real J[N][N])
Definition implicit_stepper.hpp:237
POPS_HD bool solve_dense(Real J[N][N], Real b[N], Real x[N], int n)
Definition implicit_stepper.hpp:190
POPS_HD Model::State newton_source_solve(const Model &m, const typename Model::State &Un, const Aux &a, Real dt, const NewtonOptions &opts, const ImplicitMask< Model::n_vars > &mask={}, NewtonCellStat *stat=nullptr)
Definition implicit_stepper.hpp:276
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
void backward_euler_source(const Model &model, const MultiFab &aux, MultiFab &U, Real dt, const NewtonOptions &opts, const ImplicitMask< Model::n_vars > &mask={}, NewtonReport *report=nullptr)
Definition implicit_stepper.hpp:486
void validate_newton_options(const NewtonOptions &newton, const char *where)
Range-validate a NewtonOptions POD; shared by System::add_block and AmrSystem::add_block,...
Definition implicit_stepper.hpp:132
POPS_HD bool newton_finite(Real x)
Finite? (device-safe, without <cmath>: NaN fails x == x; +-inf fails the bounds).
Definition implicit_stepper.hpp:178
Real reduce_sum_cell(const Box2D &b, F f)
SUM reduction with a REDUCING FUNCTOR: f receives (i, j, Real& acc) and accumulates,...
Definition for_each.hpp:274
Real reduce_max_cell(const Box2D &b, F f)
MAX reduction with a REDUCING FUNCTOR: f receives (i, j, Real& acc) and updates acc,...
Definition for_each.hpp:240
POPS_HD bool is_implicit_component(const ImplicitMask< N > &mask, int c)
Definition implicit_stepper.hpp:92
Cartesian spatial operator: assembles R(U, aux) = -div F + S over the cells of a level.
Pointwise types of the physics layer: StateVec<N> (conserved state) and Aux (auxiliary fields from th...
WRITE POD handle (raw pointer + strides) over a Fab2D buffer, indexed by (i, j, c) IN GLOBAL INDICES ...
Definition fab2d.hpp:29
POINTWISE auxiliary fields shared with the physics: single coupling channel.
Definition state.hpp:123
READ-only handle (const counterpart of Array4): same layout and same contract (POD device-copyable,...
Definition fab2d.hpp:44
Definition implicit_stepper.hpp:84
Definition implicit_stepper.hpp:578
void operator()(Coupler &coupler, Block &block, Real dt, int, int) const
Definition implicit_stepper.hpp:582
OUTPUT statistic of the Newton of ONE cell (device POD, written into the diagnostics scratch): res = ...
Definition implicit_stepper.hpp:152
Options of the local Newton of the implicit source (backward-Euler).
Definition implicit_stepper.hpp:114
AGGREGATED report (whole block, all substeps of one advance) of the implicit-source Newton.
Definition implicit_stepper.hpp:165
double failed_comp
one offending cell (-1 if none)
Definition implicit_stepper.hpp:172
Real max_iters_used
max over cells/substeps of iterations consumed
Definition implicit_stepper.hpp:169
Real max_residual
max over cells/substeps of ||F||_inf at exit
Definition implicit_stepper.hpp:168
bool converged
no failed cell over the advance
Definition implicit_stepper.hpp:167
double n_failed
number of (cells x substeps) failed (non-finite / pivot / non-convergence)
Definition implicit_stepper.hpp:170
bool enabled
a report was computed (at least one instrumented substep)
Definition implicit_stepper.hpp:166
Definition implicit_stepper.hpp:412
POPS_HD void operator()(int i, int j) const
Definition implicit_stepper.hpp:419
ImplicitMask< Model::n_vars > mask
Definition implicit_stepper.hpp:418
Definition implicit_stepper.hpp:436
ImplicitMask< Model::n_vars > mask
Definition implicit_stepper.hpp:442
POPS_HD void operator()(int i, int j) const
Definition implicit_stepper.hpp:443
NewtonOptions opts
Definition implicit_stepper.hpp:441
REDUCTION kernels of the diagnostics scratch (max / sum of one component).
Definition implicit_stepper.hpp:461
POPS_HD void operator()(int i, int j, Real &acc) const
Definition implicit_stepper.hpp:464
Definition implicit_stepper.hpp:470
POPS_HD void operator()(int i, int j, Real &acc) const
Definition implicit_stepper.hpp:473
Base scalar types and the POPS_HD macro (host+device portability).
Generated by