include/pops/numerics/time/integrators/implicit_stepper.hpp File ReferenceΒΆ

adc_cpp: include/pops/numerics/time/integrators/implicit_stepper.hpp File Reference
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 File Reference

Implicit / IMEX block step as a named CONTRACT. More...

#include <pops/core/state/state.hpp>
#include <pops/core/foundation/types.hpp>
#include <pops/mesh/execution/for_each.hpp>
#include <pops/mesh/storage/multifab.hpp>
#include <pops/numerics/spatial_operator.hpp>
#include <algorithm>
#include <concepts>
#include <cstdio>
#include <stdexcept>
#include <string>
+ Include dependency graph for implicit_stepper.hpp:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  pops::ImplicitMask< N >
 
struct  pops::NewtonOptions
 Options of the local Newton of the implicit source (backward-Euler). More...
 
struct  pops::NewtonCellStat
 OUTPUT statistic of the Newton of ONE cell (device POD, written into the diagnostics scratch): res = ||F||_inf at exit; iters = iterations consumed; failed = 1 if the cell failed (non-finite residual, degenerate/non-finite pivot, or active tolerance not reached within budget), 0 otherwise; comp = index of the conserved COMPONENT carrying the max residual at exit (-1 if nothing implicit). More...
 
struct  pops::NewtonReport
 AGGREGATED report (whole block, all substeps of one advance) of the implicit-source Newton. More...
 
struct  pops::detail::BackwardEulerSourceKernel< Model >
 
struct  pops::detail::BackwardEulerSourceStatKernel< Model >
 
struct  pops::detail::NewtonStatMaxKernel
 REDUCTION kernels of the diagnostics scratch (max / sum of one component). More...
 
struct  pops::detail::NewtonStatSumKernel
 
struct  pops::ImplicitSourceStepper
 

Namespaces

namespace  pops
 
namespace  pops::detail
 

Concepts

concept  pops::ImplicitBlockStepper
 
concept  pops::PartiallyImplicitModel
 
concept  pops::HasSourceJacobian
 

Functions

template<class Model >
POPS_HD bool pops::model_is_implicit (int c)
 
template<class Model , int N>
POPS_HD bool pops::is_implicit_component (const ImplicitMask< N > &mask, int c)
 
void pops::validate_newton_options (const NewtonOptions &newton, const char *where)
 Range-validate a NewtonOptions POD; shared by System::add_block and AmrSystem::add_block, which carried this defensive check verbatim.
 
POPS_HD bool pops::newton_finite (Real x)
 Finite? (device-safe, without <cmath>: NaN fails x == x; +-inf fails the bounds).
 
template<int N>
POPS_HD bool pops::detail::solve_dense (Real J[N][N], Real b[N], Real x[N], int n)
 
template<class Model , int N>
POPS_HD void pops::detail::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])
 
template<class Model >
POPS_HD Model::State pops::detail::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)
 
template<class Model >
POPS_HD Model::State pops::detail::newton_source_solve (const Model &m, const typename Model::State &Un, const Aux &a, Real dt, int iters, const ImplicitMask< Model::n_vars > &mask={})
 COMPATIBILITY: old signature with a bare iteration budget (iters).
 
template<class Model >
void pops::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)
 
template<class Model >
void pops::backward_euler_source (const Model &model, const MultiFab &aux, MultiFab &U, Real dt, int iters=2, const ImplicitMask< Model::n_vars > &mask={})
 COMPATIBILITY: old signature with a bare iteration budget (iters = 2 historical).
 

Detailed Description

Implicit / IMEX block step as a named CONTRACT.

Concept ImplicitBlockStepper, ready-to-use default backward_euler_source (local Newton on the model stiff source) and the ImplicitSourceStepper object that wires it into SystemCoupler::step. Includes the partial-IMEX mask (ImplicitMask), the analytic Jacobian trait (HasSourceJacobian) and the Newton options (NewtonOptions / NewtonReport).

Layer: include/pops/numerics/time. Role: provide "an IMEX by default without the user writing Newton". backward_euler_source solves IN PLACE W = U + dt S(W, aux) by local Newton (finite-difference Jacobian, or analytic if the model declares source_jacobian); exact in one iteration if S is linear, quadratic convergence otherwise, unconditionally stable for a stiff relaxation (where Picard would diverge as soon as dt*stiffness > 1).

Invariants:

  • the source is LOCAL (cell by cell): no flux coupling, no reflux;
  • PARTIAL IMEX: a model can declare variable by variable which ones are stiff (PartiallyImplicitModel::is_implicit), or an ImplicitMask carried by the BLOCK overrides the model default. Inactive mask (default) -> all implicit -> bit-identical to before;
  • default NewtonOptions {} = 2 FIXED iterations, no stop test, fd_eps=1e-7, damping=1, fail_policy=kFailNone -> reproduces EXACTLY the historical behavior;
  • device kernels = NAMED functors (BackwardEulerSourceKernel, NewtonStat*Kernel); fail_policy != kFailNone and Newton report aggregation act HOST side, after the reductions (no snprintf/throw in kernel).