Class SundialsImplicitIntegrator#
Defined in File Integrator.h
Nested Relationships#
Nested Types#
Inheritance Relationships#
Base Type#
public Karana::Integrators::SundialsIntegrator(Class SundialsIntegrator)
Derived Types#
public Karana::Integrators::ArkImplicitIntegrator(Class ArkImplicitIntegrator)public Karana::Integrators::CVodeIntegrator(Class CVodeIntegrator)
Class Documentation#
-
class SundialsImplicitIntegrator : public Karana::Integrators::SundialsIntegrator#
Abstract base class for implicit Sundials integrators (CVode/ARKStep).
This class manages linear and nonlinear solvers specifically, and adds options and vars relating to implicit integration.
Subclassed by Karana::Integrators::ArkImplicitIntegrator, Karana::Integrators::CVodeIntegrator
Public Types
Public Functions
-
SundialsImplicitIntegrator(const IntegratorType &integrator_type, size_t num_states, size_t num_q_states, DerivativeFunction f, const SundialsImplicitIntegrator::IntegratorOptions *options = nullptr)#
Constructor.
- Parameters:
num_states – The number of states to integrate.
num_q_states – Number of leading Q states; zero means no partition is specified.
f – The derivative function to calculate the derivative of the states.
integrator_type – The type of sundials integrator to use.
options – The integrator options.
-
~SundialsImplicitIntegrator()#
-
void setAndersonDamping(double damping)#
Set the Anderson damping factor to use for nonlinear solves; must be in (0, 1] and smaller means stronger damping.
- Parameters:
damping – Damping factor; pass a value of 1 for no damping.
-
void setAndersonLength(unsigned int length)#
Set the subspace size to use for Anderson acceleration.
- Parameters:
length – Damping factor; pass a value of 0 for no damping.
-
void setMaxNLIters(unsigned int iters)#
Set the maximum nonlinear iterations.
- Parameters:
iters – Max iters to take before trying a smaller timestep.
-
virtual void setLinearSetupFrequency(long frequency) = 0#
Set the number of integration steps between linear-solver setups.
- Parameters:
frequency – Setup frequency; zero selects the SUNDIALS default.
-
virtual void setJacobianEvalFrequency(long frequency) = 0#
Set the number of integration steps between Jacobian evaluations.
- Parameters:
frequency – Evaluation frequency; zero selects the SUNDIALS default.
Protected Types
-
enum class JacobianType#
Jacobian construction policy selected by an implicit-integrator preset.
Values:
-
enumerator CVODE_DEFAULT#
Use the integrator’s default dense finite-difference Jacobian handling.
-
enumerator QUASI_NEWTON#
Use the kdFlex motion-ranked quasi-Newton Jacobian callback.
-
enumerator JACOBIAN_FREE#
Use matrix-free difference-quotient Jacobian-vector products.
-
enumerator CVODE_DEFAULT#
Protected Functions
-
virtual void _resetStats() override#
Clear common and implicit cached statistics for a hard reset.
-
virtual void _rolloverCachedStats() override#
Roll over common and implicit counters before a soft reset.
-
void _setupSolvers()#
Set up common solvers (nonlinear and linear).
-
virtual Karana::Core::ks_ptr<Karana::Core::BaseVars> _getVars() const override#
Create the vars for this object.
- Returns:
The vars for this object.
-
virtual void _bindSolvers() = 0#
Bind internal nonlinear (and possibly linear) solvers to the implementation solver.
Protected Attributes
-
NLSOLVER _nlsolver = NLSOLVER::FIXEDPOINT#
The Nonlinear solver type to use.
-
JacobianType _jacobian_type = JacobianType::CVODE_DEFAULT#
Jacobian policy used when the implicit solver bundle is initialized.
-
std::unique_ptr<SundialsSolverBundle> _solvers#
Bundle of linear and nonlinear solvers, used for implicit integrators only.
-
CachedCounter<long int> _num_nonlin_iters#
Nonlinear iterations retained across soft resets for CVODE.
Note
ARKODE owns a lifetime counter that intentionally bypasses this cache.
-
CachedCounter<long int> _num_step_solve_fails#
Failed step solves retained across soft resets.
-
StaleCachedCounter<long int> _num_jac_evals#
Jacobian evaluations retained across soft resets with pre-7.6 stale-value handling.
-
CachedCounter<long int> _num_lin_solver_setups#
Linear-solver setups retained across soft resets.
-
StaleCachedCounter<long int> _num_lin_rhs_evals#
Linear RHS evaluations retained across soft resets with pre-7.6 stale-value handling.
-
CachedCounter<long int> _num_nonlin_conv_fails#
Nonlinear convergence failures retained across soft resets for CVODE.
Note
ARKODE owns a lifetime counter that intentionally bypasses this cache.
-
StaleCachedCounter<long int> _num_lin_conv_fails#
Linear convergence failures retained across soft resets with pre-7.6 stale handling.
-
StaleCachedCounter<long int> _num_lin_iters#
Linear iterations retained across soft resets with pre-7.6 stale-value handling.
-
struct IntegratorOptions : public Karana::Integrators::SundialsIntegrator::IntegratorOptions#
Struct with options for this integrator
Subclassed by Karana::Integrators::ArkImplicitIntegrator::IntegratorOptions, Karana::Integrators::CVodeIntegrator::IntegratorOptions
Public Members
-
double anderson_damping = 1#
Anderson damping in (0, 1] used for implicit integrators with fixed-point solves.
This is used to potentially speed up internal iterations by reusing past iterates (within the same time step). A value of 1 indicates no damping, and smaller values imply a “stronger” damping.
-
int anderson_length = 0#
Number of past iterates to consider with Anderson acceleration.
-
unsigned int max_nl_iters = 3#
Maximum number of nonlinear iterations before we try a smaller step size.
-
long linear_setup_frequency = 0#
Number of integration steps between implicit linear-solver setups.
This option applies to CVODE Newton and ARKODE implicit solvers. A value of zero selects the backend’s SUNDIALS default.
-
long jacobian_eval_frequency = 0#
Number of integration steps between implicit Jacobian evaluations.
This option applies to CVODE Newton and ARKODE implicit solvers. A value of zero selects the backend’s SUNDIALS default.
-
bool use_jacobian = false#
Experimental: the application must keep the stored Jacobian current with updateJacobian(); kdFlex does not compute or refresh it automatically.
-
double anderson_damping = 1#
-
SundialsImplicitIntegrator(const IntegratorType &integrator_type, size_t num_states, size_t num_q_states, DerivativeFunction f, const SundialsImplicitIntegrator::IntegratorOptions *options = nullptr)#