DiFfRG
Loading...
Searching...
No Matches
DiFfRG::KINSOL< VectorType_ > Class Template Reference

A newton solver, using local error estimates for each vector component. More...

#include <kinsol.hh>

Public Types

using VectorType = VectorType_
 

Public Member Functions

 KINSOL (double abstol_=1e-10, double reltol_=1e-6, double assemble_threshold_=0., unsigned int max_steps_=21, unsigned int n_stepsize_iterations_=21)
 
void reinit (const VectorType &u)
 Should it be necessary, one can force a recalculation of the jacobian hereby.
 
void operator() (VectorType &iterate)
 Perform a newton iteration on the input vector.
 
double threshold (const double thr)
 Set the jacobian recalculation threshold, i.e. below which reduction we force a jacobian update.
 
const VectorTypeget_residual () const
 
const VectorTypeget_initial () const
 
const VectorTypeget_iterate () const
 
double average_time_newton () const
 
unsigned int num_newton_calls () const
 
void set_ignore_nonconv (bool x)
 Make the newton algorithm return a success even if the evolution did not fulfill the convergence criterion. The iteration always fails if the solution contains NaNs or infinities.
 
double get_error ()
 Get the latest error.
 
unsigned int get_step ()
 Get the number of steps taken in the latest iteration.
 
unsigned int get_jacobians ()
 Get the number of jacobians created in the latest iteration.
 

Public Attributes

std::function< void(VectorType &, const VectorType &)> residual
 
std::function< void(VectorType &, const VectorType &)> lin_solve
 
std::function< void(const VectorType &)> update_jacobian
 

Private Member Functions

double get_EEst ()
 Calculate the current error estimate.
 
bool check ()
 Check if the iteration should go on.
 

Private Attributes

VectorType residual_vector
 
VectorType initial_vector
 
VectorType iterate_vector
 
double abstol
 
double reltol
 
double assemble_threshold
 
unsigned int max_steps
 
unsigned int n_stepsize_iterations
 
bool converged
 
bool ignore_nonconv
 
double resnorm
 
unsigned int step
 
unsigned int jacobians
 
std::vector< double > timings_newton
 
std::shared_ptr< SUNDIALS::KINSOL< VectorType > > kinsol
 

Detailed Description

template<typename VectorType_>
class DiFfRG::KINSOL< VectorType_ >

A newton solver, using local error estimates for each vector component.

Template Parameters
VectorType_Vector type used by the simulation (i.e. any dealii vector type)

Member Typedef Documentation

◆ VectorType

template<typename VectorType_ >
using DiFfRG::KINSOL< VectorType_ >::VectorType = VectorType_

Constructor & Destructor Documentation

◆ KINSOL()

template<typename VectorType_ >
DiFfRG::KINSOL< VectorType_ >::KINSOL ( double abstol_ = 1e-10,
double reltol_ = 1e-6,
double assemble_threshold_ = 0.,
unsigned int max_steps_ = 21,
unsigned int n_stepsize_iterations_ = 21 )

Member Function Documentation

◆ average_time_newton()

template<typename VectorType_ >
double DiFfRG::KINSOL< VectorType_ >::average_time_newton ( ) const

◆ check()

template<typename VectorType_ >
bool DiFfRG::KINSOL< VectorType_ >::check ( )
private

Check if the iteration should go on.

Returns
true
false

◆ get_EEst()

template<typename VectorType_ >
double DiFfRG::KINSOL< VectorType_ >::get_EEst ( )
private

Calculate the current error estimate.

Returns
double

◆ get_error()

template<typename VectorType_ >
double DiFfRG::KINSOL< VectorType_ >::get_error ( )

Get the latest error.

◆ get_initial()

template<typename VectorType_ >
const VectorType & DiFfRG::KINSOL< VectorType_ >::get_initial ( ) const

◆ get_iterate()

template<typename VectorType_ >
const VectorType & DiFfRG::KINSOL< VectorType_ >::get_iterate ( ) const

◆ get_jacobians()

template<typename VectorType_ >
unsigned int DiFfRG::KINSOL< VectorType_ >::get_jacobians ( )

Get the number of jacobians created in the latest iteration.

◆ get_residual()

template<typename VectorType_ >
const VectorType & DiFfRG::KINSOL< VectorType_ >::get_residual ( ) const

◆ get_step()

template<typename VectorType_ >
unsigned int DiFfRG::KINSOL< VectorType_ >::get_step ( )

Get the number of steps taken in the latest iteration.

◆ num_newton_calls()

template<typename VectorType_ >
unsigned int DiFfRG::KINSOL< VectorType_ >::num_newton_calls ( ) const

◆ operator()()

template<typename VectorType_ >
void DiFfRG::KINSOL< VectorType_ >::operator() ( VectorType & iterate)

Perform a newton iteration on the input vector.

Parameters
iteratethe input vector which contains the initial guess and later the solution.

◆ reinit()

template<typename VectorType_ >
void DiFfRG::KINSOL< VectorType_ >::reinit ( const VectorType & u)

Should it be necessary, one can force a recalculation of the jacobian hereby.

◆ set_ignore_nonconv()

template<typename VectorType_ >
void DiFfRG::KINSOL< VectorType_ >::set_ignore_nonconv ( bool x)

Make the newton algorithm return a success even if the evolution did not fulfill the convergence criterion. The iteration always fails if the solution contains NaNs or infinities.

Parameters
x

◆ threshold()

template<typename VectorType_ >
double DiFfRG::KINSOL< VectorType_ >::threshold ( const double thr)

Set the jacobian recalculation threshold, i.e. below which reduction we force a jacobian update.

Returns
double the old threshold

Member Data Documentation

◆ abstol

template<typename VectorType_ >
double DiFfRG::KINSOL< VectorType_ >::abstol
private

◆ assemble_threshold

template<typename VectorType_ >
double DiFfRG::KINSOL< VectorType_ >::assemble_threshold
private

◆ converged

template<typename VectorType_ >
bool DiFfRG::KINSOL< VectorType_ >::converged
private

◆ ignore_nonconv

template<typename VectorType_ >
bool DiFfRG::KINSOL< VectorType_ >::ignore_nonconv
private

◆ initial_vector

template<typename VectorType_ >
VectorType DiFfRG::KINSOL< VectorType_ >::initial_vector
private

◆ iterate_vector

template<typename VectorType_ >
VectorType DiFfRG::KINSOL< VectorType_ >::iterate_vector
private

◆ jacobians

template<typename VectorType_ >
unsigned int DiFfRG::KINSOL< VectorType_ >::jacobians
private

◆ kinsol

template<typename VectorType_ >
std::shared_ptr<SUNDIALS::KINSOL<VectorType> > DiFfRG::KINSOL< VectorType_ >::kinsol
private

◆ lin_solve

template<typename VectorType_ >
std::function<void(VectorType &, const VectorType &)> DiFfRG::KINSOL< VectorType_ >::lin_solve

◆ max_steps

template<typename VectorType_ >
unsigned int DiFfRG::KINSOL< VectorType_ >::max_steps
private

◆ n_stepsize_iterations

template<typename VectorType_ >
unsigned int DiFfRG::KINSOL< VectorType_ >::n_stepsize_iterations
private

◆ reltol

template<typename VectorType_ >
double DiFfRG::KINSOL< VectorType_ >::reltol
private

◆ residual

template<typename VectorType_ >
std::function<void(VectorType &, const VectorType &)> DiFfRG::KINSOL< VectorType_ >::residual

◆ residual_vector

template<typename VectorType_ >
VectorType DiFfRG::KINSOL< VectorType_ >::residual_vector
private

◆ resnorm

template<typename VectorType_ >
double DiFfRG::KINSOL< VectorType_ >::resnorm
private

◆ step

template<typename VectorType_ >
unsigned int DiFfRG::KINSOL< VectorType_ >::step
private

◆ timings_newton

template<typename VectorType_ >
std::vector<double> DiFfRG::KINSOL< VectorType_ >::timings_newton
private

◆ update_jacobian

template<typename VectorType_ >
std::function<void(const VectorType &)> DiFfRG::KINSOL< VectorType_ >::update_jacobian

The documentation for this class was generated from the following file: