Interface to SUNDIALS
IDA library.
More...
#include <ida_interface.h>
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 ¶meter, 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::PatternBase > | to_pattern (const double &) |
double More... | |
template<> | |
std::string | to_string (const double &entry) |
template<> | |
double | to_type (const std::string ¶meter) |
template<> | |
std_cxx11::shared_ptr< Patterns::PatternBase > | to_pattern (const int &) |
int More... | |
template<> | |
std::string | to_string (const int &entry) |
template<> | |
int | to_type (const std::string ¶meter) |
template<> | |
std_cxx11::shared_ptr< Patterns::PatternBase > | to_pattern (const unsigned int &) |
unsigned int More... | |
template<> | |
std::string | to_string (const unsigned int &entry) |
template<> | |
unsigned int | to_type (const std::string ¶meter) |
template<> | |
std_cxx11::shared_ptr< Patterns::PatternBase > | to_pattern (const bool &) |
bool More... | |
template<> | |
std::string | to_string (const bool &entry) |
template<> | |
bool | to_type (const std::string ¶meter) |
Public Member Functions inherited from Subscriptor | |
Subscriptor () | |
Subscriptor (const Subscriptor &) | |
Subscriptor (Subscriptor &&) | |
virtual | ~Subscriptor () |
Subscriptor & | operator= (const Subscriptor &) |
Subscriptor & | operator= (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::PatternBase > | to_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... | |
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:
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,
Definition at line 134 of file ida_interface.h.
IDAInterface< VEC >::IDAInterface | ( | const std::string | name = "" , |
const MPI_Comm | mpi_comm = MPI_COMM_WORLD |
||
) |
Constructor for the IDAInterface class.
IDAInterface< VEC >::IDAInterface | ( | const std::string | name = "" | ) |
Constructor for the IDAInterface class.
Definition at line 141 of file ida_interface.cc.
IDAInterface< VEC >::~IDAInterface | ( | ) |
House cleaning.
Definition at line 151 of file ida_interface.cc.
|
virtual |
Declare parameters for this class to function properly.
Reimplemented from ParameterAcceptor.
Definition at line 158 of file ida_interface.cc.
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.
|
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.
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.
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.
|
private |
Absolute error tolerance for adaptive time stepping.
Definition at line 261 of file ida_interface.h.
|
private |
Ida absolute tolerances vector.
Definition at line 307 of file ida_interface.h.
|
private |
Definition at line 312 of file ida_interface.h.
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.
|
private |
Ida differential components vector.
Definition at line 309 of file ida_interface.h.
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.
|
private |
Final time.
Definition at line 249 of file ida_interface.h.
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.
|
private |
Alpha to use in Newton method for IC calculation.
Definition at line 282 of file ida_interface.h.
|
private |
Maximum number of iterations for Newton method in IC calculation.
Definition at line 285 of file ida_interface.h.
|
private |
Type of initial conditions.
Definition at line 276 of file ida_interface.h.
|
private |
Ida memory object.
Definition at line 300 of file ida_interface.h.
|
private |
Ignore algebraic terms for errors.
Definition at line 273 of file ida_interface.h.
|
private |
Initial step size.
Definition at line 255 of file ida_interface.h.
|
private |
Initial time for the ode.
Definition at line 252 of file ida_interface.h.
|
private |
Initialization flag.
Definition at line 291 of file ida_interface.h.
|
private |
Definition at line 320 of file ida_interface.h.
|
private |
Maximum number of iterations for Newton method during time advancement.
Definition at line 288 of file ida_interface.h.
|
private |
Maximum order of BDF.
Definition at line 267 of file ida_interface.h.
|
private |
Minimum step size.
Definition at line 258 of file ida_interface.h.
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.
|
private |
Seconds between each output.
Definition at line 270 of file ida_interface.h.
|
private |
Output stream.
Definition at line 316 of file ida_interface.h.
|
private |
Relative error tolerance for adaptive time stepping.
Definition at line 264 of file ida_interface.h.
|
private |
Type of conditions to be used after a solver restart.
Definition at line 279 of file ida_interface.h.
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.
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.
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.
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.
|
private |
Definition at line 318 of file ida_interface.h.
|
private |
Use local tolerances when computing absolute tolerance.
Definition at line 297 of file ida_interface.h.
|
private |
Show the progress of time steps.
Definition at line 294 of file ida_interface.h.
|
private |
Ida solution derivative vector.
Definition at line 305 of file ida_interface.h.
|
private |
Ida solution vector.
Definition at line 303 of file ida_interface.h.