deal2lkit: A ToolKit library for Deal.II
IDAInterface< VEC > Class Template Reference

Interface to SUNDIALS IDA library. More...

#include <ida_interface.h>

Inheritance diagram for IDAInterface< VEC >:
ParameterAcceptor Subscriptor

Public Member Functions

 IDAInterface (const std::string name="", const MPI_Comm mpi_comm=MPI_COMM_WORLD)
 Constructor for the IDAInterface class. More...
 
 IDAInterface (const std::string name="")
 Constructor for the IDAInterface class. More...
 
 ~IDAInterface ()
 House cleaning. More...
 
virtual void declare_parameters (ParameterHandler &prm)
 Declare parameters for this class to function properly. More...
 
unsigned int solve_dae (VEC &solution, VEC &solution_dot)
 Evolve. More...
 
void reset_dae (const double t, VEC &y, VEC &yp, double h, bool first_step)
 Clear internal memory, and start with clean objects. More...
 
void set_initial_time (const double &t)
 Set initial time equal to t disregarding what is written in the parameter file. More...
 
- Public Member Functions inherited from ParameterAcceptor
 ParameterAcceptor (const std::string section_name="")
 The constructor adds derived classes to the list of acceptors. More...
 
virtual ~ParameterAcceptor ()
 The destructor sets to zero the pointer relative to this index, so that it is safe to destroy the mother class. More...
 
virtual void parse_parameters (ParameterHandler &prm)
 Parse the parameter file. More...
 
virtual void parse_parameters_call_back ()
 Parse parameter call back. More...
 
std::string get_section_name () const
 Return the section name of this class. More...
 
std::vector< std::string > get_section_path () const
 Travers all registered classes, and figure out what subsections we need to enter. More...
 
template<class T >
void add_parameter (ParameterHandler &prm, T *parameter, const std::string &entry, const std::string &default_value, const Patterns::PatternBase &pattern=Patterns::Anything(), const std::string &documentation=std::string())
 Add a parameter the given parameter list. More...
 
template<class T >
void add_parameter (T &parameter, const std::string &entry, const std::string &documentation=std::string(), ParameterHandler &prm=ParameterAcceptor::prm)
 Add a parameter to the global parameter handler ParameterAcceptor::prm. More...
 
void enter_my_subsection (ParameterHandler &prm)
 Make sure we enter the right subsection of the global parameter file. More...
 
void leave_my_subsection (ParameterHandler &prm)
 This function undoes what the enter_my_subsection() function did. More...
 
template<>
std_cxx11::shared_ptr< Patterns::PatternBaseto_pattern (const double &)
 double More...
 
template<>
std::string to_string (const double &entry)
 
template<>
double to_type (const std::string &parameter)
 
template<>
std_cxx11::shared_ptr< Patterns::PatternBaseto_pattern (const int &)
 int More...
 
template<>
std::string to_string (const int &entry)
 
template<>
int to_type (const std::string &parameter)
 
template<>
std_cxx11::shared_ptr< Patterns::PatternBaseto_pattern (const unsigned int &)
 unsigned int More...
 
template<>
std::string to_string (const unsigned int &entry)
 
template<>
unsigned int to_type (const std::string &parameter)
 
template<>
std_cxx11::shared_ptr< Patterns::PatternBaseto_pattern (const bool &)
 bool More...
 
template<>
std::string to_string (const bool &entry)
 
template<>
bool to_type (const std::string &parameter)
 
- Public Member Functions inherited from Subscriptor
 Subscriptor ()
 
 Subscriptor (const Subscriptor &)
 
 Subscriptor (Subscriptor &&)
 
virtual ~Subscriptor ()
 
Subscriptoroperator= (const Subscriptor &)
 
Subscriptoroperator= (Subscriptor &&)
 
void subscribe (const char *identifier=0) const
 
void unsubscribe (const char *identifier=0) const
 
unsigned int n_subscriptions () const
 
void list_subscribers () const
 
void serialize (Archive &ar, const unsigned int version)
 

Public Attributes

std::function< shared_ptr< VEC >)> create_new_vector
 Return a shared_ptr<VEC>. More...
 
std::function< int(const double t, const VEC &y, const VEC &y_dot, VEC &res)> residual
 Compute residual. More...
 
std::function< int(const double t, const VEC &y, const VEC &y_dot, const double alpha)> setup_jacobian
 Compute Jacobian. More...
 
std::function< int(const VEC &rhs, VEC &dst)> solve_jacobian_system
 Solve linear system. More...
 
std::function< void(const double t, const VEC &sol, const VEC &sol_dot, const unsigned int step_number)> output_step
 Store solutions to file. More...
 
std::function< bool(const double t, VEC &sol, VEC &sol_dot)> solver_should_restart
 Evaluate wether the mesh should be refined or not. More...
 
std::function< VEC &()> differential_components
 Return a vector whose component are 1 if the corresponding dof is differential, 0 if algebraic. More...
 
std::function< VEC &()> get_local_tolerances
 Return a vector whose components are the weights used by IDA to compute the vector norm. More...
 

Private Member Functions

void set_functions_to_trigger_an_assert ()
 This function is executed at construction time to set the std::function above to trigger an assert if they are not implemented. More...
 

Private Attributes

double final_time
 Final time. More...
 
double initial_time
 Initial time for the ode. More...
 
double initial_step_size
 Initial step size. More...
 
double min_step_size
 Minimum step size. More...
 
double abs_tol
 Absolute error tolerance for adaptive time stepping. More...
 
double rel_tol
 Relative error tolerance for adaptive time stepping. More...
 
unsigned int max_order
 Maximum order of BDF. More...
 
double outputs_period
 Seconds between each output. More...
 
bool ignore_algebraic_terms_for_errors
 Ignore algebraic terms for errors. More...
 
std::string ic_type
 Type of initial conditions. More...
 
std::string reset_type
 Type of conditions to be used after a solver restart. More...
 
double ic_alpha
 Alpha to use in Newton method for IC calculation. More...
 
unsigned ic_max_iter
 Maximum number of iterations for Newton method in IC calculation. More...
 
unsigned int max_non_linear_iterations
 Maximum number of iterations for Newton method during time advancement. More...
 
bool is_initialized
 Initialization flag. More...
 
bool verbose
 Show the progress of time steps. More...
 
bool use_local_tolerances
 Use local tolerances when computing absolute tolerance. More...
 
void * ida_mem
 Ida memory object. More...
 
N_Vector yy
 Ida solution vector. More...
 
N_Vector yp
 Ida solution derivative vector. More...
 
N_Vector abs_tolls
 Ida absolute tolerances vector. More...
 
N_Vector diff_id
 Ida differential components vector. More...
 
MPI_Comm communicator
 
ConditionalOStream pcout
 Output stream. More...
 
unsigned int system_size
 
unsigned int local_system_size
 

Additional Inherited Members

- Static Public Member Functions inherited from ParameterAcceptor
static void initialize (const std::string filename="", const std::string outfilename="")
 Call declare_all_parameters(), read filename (if it is present as input parameter) and parse_all_parameters() on the static member prm. More...
 
static void clear ()
 Clear class list and global parameter file. More...
 
static void parse_all_parameters (ParameterHandler &prm=ParameterAcceptor::prm)
 Parse the given ParameterHandler. More...
 
static void log_info ()
 Print information about all stored classes. More...
 
static void declare_all_parameters (ParameterHandler &prm=ParameterAcceptor::prm)
 Initialize the ParameterHandler with all derived classes parameters.This function enters the subsection returned by get_section_name() for each derived class, and declares all parameters that were added using add_parameter(). More...
 
template<class T >
static std_cxx11::shared_ptr< Patterns::PatternBaseto_pattern (const T &)
 Given a class T, construct its default pattern to be used when declaring parameters. More...
 
template<class T >
static T to_type (const std::string &)
 Given a string, fill the value of the given parameter. More...
 
template<class T >
static std::string to_string (const T &)
 Given a parameter, return a string containing the given parameter. More...
 
- Static Public Member Functions inherited from Subscriptor
static::ExceptionBase & ExcInUse (int arg1, char *arg2, std::string &arg3)
 
static::ExceptionBase & ExcNoSubscriber (char *arg1, char *arg2)
 
- Static Public Attributes inherited from ParameterAcceptor
static ParameterHandler prm
 Static parameter. More...
 
- Protected Attributes inherited from ParameterAcceptor
const std::string section_name
 The subsection name for this class. More...
 

Detailed Description

template<typename VEC = Vector<double>>
class IDAInterface< VEC >

Interface to SUNDIALS IDA library.

deal2lkit features an interface for the SUite of Nonlinear and DIfferential/ALgebraic equation Solvers (SUNDIALS).

The class IDAInterface is a wrapper to the Implicit Differential-Algebraic solver which is a general purpose solver for systems of Differential-Algebraic Equations (DAEs).

The user has to provide the implmentation of the following std::functions:

  • create_new_vector;
  • residual;
  • setup_jacobian;
  • solve_jacobian_system;
  • output_step;
  • solver_should_restart;
  • differential_components.

Citing from the SUNDIALS documentation:

Consider a system of Differential-Algebraic Equations written in the general form

\[ \begin{cases} F(t,y,\dot y) = 0\, , \\ y(t_0) = y_0\, , \\ \dot y (t_0) = \dot y_0\, . \end{cases} \]

where $y,

y$ are vectors in $^n$, $t$ is often the time (but can

Definition at line 134 of file ida_interface.h.

Constructor & Destructor Documentation

§ IDAInterface() [1/2]

template<typename VEC = Vector<double>>
IDAInterface< VEC >::IDAInterface ( const std::string  name = "",
const MPI_Comm  mpi_comm = MPI_COMM_WORLD 
)

Constructor for the IDAInterface class.

§ IDAInterface() [2/2]

template<typename VEC >
IDAInterface< VEC >::IDAInterface ( const std::string  name = "")

Constructor for the IDAInterface class.

Definition at line 141 of file ida_interface.cc.

§ ~IDAInterface()

template<typename VEC >
IDAInterface< VEC >::~IDAInterface ( )

House cleaning.

Definition at line 151 of file ida_interface.cc.

Member Function Documentation

§ declare_parameters()

template<typename VEC >
void IDAInterface< VEC >::declare_parameters ( ParameterHandler prm)
virtual

Declare parameters for this class to function properly.

Reimplemented from ParameterAcceptor.

Definition at line 158 of file ida_interface.cc.

§ reset_dae()

template<typename VEC >
void IDAInterface< VEC >::reset_dae ( const double  t,
VEC &  y,
VEC &  yp,
double  h,
bool  first_step 
)

Clear internal memory, and start with clean objects.

This function is called when the simulation start and when the mesh is refined.

Definition at line 353 of file ida_interface.cc.

§ set_functions_to_trigger_an_assert()

template<typename VEC >
void IDAInterface< VEC >::set_functions_to_trigger_an_assert ( )
private

This function is executed at construction time to set the std::function above to trigger an assert if they are not implemented.

Definition at line 500 of file ida_interface.cc.

§ set_initial_time()

template<typename VEC >
void IDAInterface< VEC >::set_initial_time ( const double &  t)

Set initial time equal to t disregarding what is written in the parameter file.

Definition at line 494 of file ida_interface.cc.

§ solve_dae()

template<typename VEC >
unsigned int IDAInterface< VEC >::solve_dae ( VEC &  solution,
VEC &  solution_dot 
)

Evolve.

This function returns the final number of steps.

Definition at line 236 of file ida_interface.cc.

Member Data Documentation

§ abs_tol

template<typename VEC = Vector<double>>
double IDAInterface< VEC >::abs_tol
private

Absolute error tolerance for adaptive time stepping.

Definition at line 261 of file ida_interface.h.

§ abs_tolls

template<typename VEC = Vector<double>>
N_Vector IDAInterface< VEC >::abs_tolls
private

Ida absolute tolerances vector.

Definition at line 307 of file ida_interface.h.

§ communicator

template<typename VEC = Vector<double>>
MPI_Comm IDAInterface< VEC >::communicator
private

Definition at line 312 of file ida_interface.h.

§ create_new_vector

template<typename VEC = Vector<double>>
std::function<shared_ptr<VEC>)> IDAInterface< VEC >::create_new_vector

Return a shared_ptr<VEC>.

A shared_ptr is needed in order to keep the pointed vector alive, without the need to use a static variable.

Definition at line 177 of file ida_interface.h.

§ diff_id

template<typename VEC = Vector<double>>
N_Vector IDAInterface< VEC >::diff_id
private

Ida differential components vector.

Definition at line 309 of file ida_interface.h.

§ differential_components

template<typename VEC = Vector<double>>
std::function<VEC&()> IDAInterface< VEC >::differential_components

Return a vector whose component are 1 if the corresponding dof is differential, 0 if algebraic.

Definition at line 221 of file ida_interface.h.

§ final_time

template<typename VEC = Vector<double>>
double IDAInterface< VEC >::final_time
private

Final time.

Definition at line 249 of file ida_interface.h.

§ get_local_tolerances

template<typename VEC = Vector<double>>
std::function<VEC&()> IDAInterface< VEC >::get_local_tolerances

Return a vector whose components are the weights used by IDA to compute the vector norm.

The implementation of this function is optional.

Definition at line 228 of file ida_interface.h.

§ ic_alpha

template<typename VEC = Vector<double>>
double IDAInterface< VEC >::ic_alpha
private

Alpha to use in Newton method for IC calculation.

Definition at line 282 of file ida_interface.h.

§ ic_max_iter

template<typename VEC = Vector<double>>
unsigned IDAInterface< VEC >::ic_max_iter
private

Maximum number of iterations for Newton method in IC calculation.

Definition at line 285 of file ida_interface.h.

§ ic_type

template<typename VEC = Vector<double>>
std::string IDAInterface< VEC >::ic_type
private

Type of initial conditions.

Definition at line 276 of file ida_interface.h.

§ ida_mem

template<typename VEC = Vector<double>>
void* IDAInterface< VEC >::ida_mem
private

Ida memory object.

Definition at line 300 of file ida_interface.h.

§ ignore_algebraic_terms_for_errors

template<typename VEC = Vector<double>>
bool IDAInterface< VEC >::ignore_algebraic_terms_for_errors
private

Ignore algebraic terms for errors.

Definition at line 273 of file ida_interface.h.

§ initial_step_size

template<typename VEC = Vector<double>>
double IDAInterface< VEC >::initial_step_size
private

Initial step size.

Definition at line 255 of file ida_interface.h.

§ initial_time

template<typename VEC = Vector<double>>
double IDAInterface< VEC >::initial_time
private

Initial time for the ode.

Definition at line 252 of file ida_interface.h.

§ is_initialized

template<typename VEC = Vector<double>>
bool IDAInterface< VEC >::is_initialized
private

Initialization flag.

Definition at line 291 of file ida_interface.h.

§ local_system_size

template<typename VEC = Vector<double>>
unsigned int IDAInterface< VEC >::local_system_size
private

Definition at line 320 of file ida_interface.h.

§ max_non_linear_iterations

template<typename VEC = Vector<double>>
unsigned int IDAInterface< VEC >::max_non_linear_iterations
private

Maximum number of iterations for Newton method during time advancement.

Definition at line 288 of file ida_interface.h.

§ max_order

template<typename VEC = Vector<double>>
unsigned int IDAInterface< VEC >::max_order
private

Maximum order of BDF.

Definition at line 267 of file ida_interface.h.

§ min_step_size

template<typename VEC = Vector<double>>
double IDAInterface< VEC >::min_step_size
private

Minimum step size.

Definition at line 258 of file ida_interface.h.

§ output_step

template<typename VEC = Vector<double>>
std::function<void (const double t, const VEC &sol, const VEC &sol_dot, const unsigned int step_number)> IDAInterface< VEC >::output_step

Store solutions to file.

Definition at line 206 of file ida_interface.h.

§ outputs_period

template<typename VEC = Vector<double>>
double IDAInterface< VEC >::outputs_period
private

Seconds between each output.

Definition at line 270 of file ida_interface.h.

§ pcout

template<typename VEC = Vector<double>>
ConditionalOStream IDAInterface< VEC >::pcout
private

Output stream.

Definition at line 316 of file ida_interface.h.

§ rel_tol

template<typename VEC = Vector<double>>
double IDAInterface< VEC >::rel_tol
private

Relative error tolerance for adaptive time stepping.

Definition at line 264 of file ida_interface.h.

§ reset_type

template<typename VEC = Vector<double>>
std::string IDAInterface< VEC >::reset_type
private

Type of conditions to be used after a solver restart.

Definition at line 279 of file ida_interface.h.

§ residual

template<typename VEC = Vector<double>>
std::function<int(const double t, const VEC &y, const VEC &y_dot, VEC &res)> IDAInterface< VEC >::residual

Compute residual.

Definition at line 185 of file ida_interface.h.

§ setup_jacobian

template<typename VEC = Vector<double>>
std::function<int(const double t, const VEC &y, const VEC &y_dot, const double alpha)> IDAInterface< VEC >::setup_jacobian

Compute Jacobian.

Definition at line 193 of file ida_interface.h.

§ solve_jacobian_system

template<typename VEC = Vector<double>>
std::function<int(const VEC &rhs, VEC &dst)> IDAInterface< VEC >::solve_jacobian_system

Solve linear system.

Definition at line 198 of file ida_interface.h.

§ solver_should_restart

template<typename VEC = Vector<double>>
std::function<bool (const double t, VEC &sol, VEC &sol_dot)> IDAInterface< VEC >::solver_should_restart

Evaluate wether the mesh should be refined or not.

If so, it refines and interpolate the solutions from the old to the new mesh.

Definition at line 215 of file ida_interface.h.

§ system_size

template<typename VEC = Vector<double>>
unsigned int IDAInterface< VEC >::system_size
private

Definition at line 318 of file ida_interface.h.

§ use_local_tolerances

template<typename VEC = Vector<double>>
bool IDAInterface< VEC >::use_local_tolerances
private

Use local tolerances when computing absolute tolerance.

Definition at line 297 of file ida_interface.h.

§ verbose

template<typename VEC = Vector<double>>
bool IDAInterface< VEC >::verbose
private

Show the progress of time steps.

Definition at line 294 of file ida_interface.h.

§ yp

template<typename VEC = Vector<double>>
N_Vector IDAInterface< VEC >::yp
private

Ida solution derivative vector.

Definition at line 305 of file ida_interface.h.

§ yy

template<typename VEC = Vector<double>>
N_Vector IDAInterface< VEC >::yy
private

Ida solution vector.

Definition at line 303 of file ida_interface.h.


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