Class SundialsImplicitIntegrator#

Nested Relationships#

Nested Types#

Inheritance Relationships#

Base Type#

Derived Types#

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

enum class NLSOLVER#

The nonlinear solver type to use (only applies to implicit methods)

Values:

enumerator FIXEDPOINT#
enumerator NEWTON#

Public Functions

SundialsImplicitIntegrator(const IntegratorType &integrator_type, size_t nstates, DerivativeFunction f, const SundialsImplicitIntegrator::IntegratorOptions *options = nullptr)#

Constructor.

Parameters:
  • nstates – The number of states to integrate.

  • 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.

Protected Functions

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.

std::unique_ptr<SundialsSolverBundle> _solvers#

Bundle of linear and nonlinear solvers, used for implicit integrators only.

struct IntegratorOptions : public Karana::Integrators::SundialsIntegrator::IntegratorOptions#

Struct with options for this integrator

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.

bool use_jacobian = false#

set to true to have the integrator use Jacobians (experimental)