14#ifndef dealii_sundials_ida_h
15#define dealii_sundials_ida_h
19#ifdef DEAL_II_WITH_SUNDIALS
25# ifdef DEAL_II_WITH_PETSC
32# ifdef DEAL_II_SUNDIALS_WITH_IDAS
33# include <idas/idas.h>
41# include <boost/signals2.hpp>
43# include <nvector/nvector_serial.h>
44# include <sundials/sundials_config.h>
45# include <sundials/sundials_math.h>
53#ifdef DEAL_II_WITH_SUNDIALS
479 template <
typename VectorType = Vector<
double>>
649 "Ignore algebraic terms for error computations",
651 "Indicate whether or not to suppress algebraic variables "
652 "in the local error test.");
656 static std::string ic_type_str =
"use_y_diff";
658 "Correction type at initial time",
660 "This is one of the following three options for the "
661 "initial condition calculation. \n"
662 " none: do not try to make initial conditions consistent. \n"
663 " use_y_diff: compute the algebraic components of y and differential\n"
664 " components of y_dot, given the differential components of y. \n"
665 " This option requires that the user specifies differential and \n"
666 " algebraic components in the function differential_components().\n"
667 " use_y_dot: compute all components of y, given y_dot.",
669 prm.
add_action(
"Correction type at initial time",
670 [&](
const std::string &value) {
671 if (value ==
"use_y_diff")
673 else if (value ==
"use_y_dot")
675 else if (value ==
"none")
681 static std::string reset_type_str =
"use_y_diff";
683 "Correction type after restart",
685 "This is one of the following three options for the "
686 "initial condition calculation. \n"
687 " none: do not try to make initial conditions consistent. \n"
688 " use_y_diff: compute the algebraic components of y and differential\n"
689 " components of y_dot, given the differential components of y. \n"
690 " This option requires that the user specifies differential and \n"
691 " algebraic components in the function differential_components().\n"
692 " use_y_dot: compute all components of y, given y_dot.",
694 prm.
add_action(
"Correction type after restart",
695 [&](
const std::string &value) {
696 if (value ==
"use_y_diff")
698 else if (value ==
"use_y_dot")
700 else if (value ==
"none")
708 "Factor to use when converting from the integrator tolerance to the linear solver tolerance",
866 solve_dae(VectorType &solution, VectorType &solution_dot);
890 reset(
const double t,
const double h, VectorType &y, VectorType &yp);
907 std::function<void(
const double t,
909 const VectorType &y_dot,
943 std::function<void(
const double t,
945 const VectorType &y_dot,
991 void(
const VectorType &rhs, VectorType &dst,
const double tolerance)>
1008 std::function<void(
const double t,
1009 const VectorType &sol,
1010 const VectorType &sol_dot,
1011 const unsigned int step_number)>
1037 std::function<
bool(
const double t, VectorType &sol, VectorType &sol_dot)>
1071 <<
"Please provide an implementation for the function \""
1092# if DEAL_II_SUNDIALS_VERSION_GTE(6, 0, 0)
1117# ifdef DEAL_II_WITH_PETSC
1118# ifdef PETSC_USE_COMPLEX
1119 static_assert(!std::is_same_v<VectorType, PETScWrappers::MPI::Vector>,
1120 "Sundials does not support complex scalar types, "
1121 "but PETSc is configured to use a complex scalar type!");
1123 static_assert(!std::is_same_v<VectorType, PETScWrappers::MPI::BlockVector>,
1124 "Sundials does not support complex scalar types, "
1125 "but PETSc is configured to use a complex scalar type!");
1135 <<
"One of SUNDIALS IDA's internal functions "
1136 <<
"returned an error code: " << arg1
1137 <<
". Please consult SUNDIALS manual.");
void add_parameter(const std::string &entry, ParameterType ¶meter, const std::string &documentation="", const Patterns::PatternBase &pattern= *Patterns::Tools::Convert< ParameterType >::to_pattern(), const bool has_to_be_set=false)
void enter_subsection(const std::string &subsection, const bool create_path_if_needed=true)
void add_action(const std::string &entry, const std::function< void(const std::string &value)> &action, const bool execute_action=true)
double relative_tolerance
InitialConditionCorrection ic_type
bool ignore_algebraic_terms_for_errors
void add_parameters(ParameterHandler &prm)
AdditionalData(const double initial_time=0.0, const double final_time=1.0, const double initial_step_size=1e-2, const double output_period=1e-1, const double minimum_step_size=1e-6, const unsigned int maximum_order=5, const unsigned int maximum_non_linear_iterations=10, const double ls_norm_factor=0, const double absolute_tolerance=1e-6, const double relative_tolerance=1e-5, const bool ignore_algebraic_terms_for_errors=true, const InitialConditionCorrection &ic_type=use_y_diff, const InitialConditionCorrection &reset_type=use_y_diff, const unsigned int maximum_non_linear_iterations_ic=5)
unsigned maximum_non_linear_iterations_ic
InitialConditionCorrection reset_type
unsigned int maximum_order
InitialConditionCorrection
unsigned int maximum_non_linear_iterations
double absolute_tolerance
std::function< void(const VectorType &rhs, VectorType &dst, const double tolerance)> solve_with_jacobian
unsigned int solve_dae(VectorType &solution, VectorType &solution_dot)
MPI_Comm mpi_communicator
std::function< void(const double t, const VectorType &y, const VectorType &y_dot, const double alpha)> setup_jacobian
void set_functions_to_trigger_an_assert()
const AdditionalData data
void reset(const double t, const double h, VectorType &y, VectorType &yp)
std::function< void(const double t, const VectorType &y, const VectorType &y_dot, VectorType &res)> residual
std::function< void(const double t, const VectorType &sol, const VectorType &sol_dot, const unsigned int step_number)> output_step
std::function< IndexSet()> differential_components
std::function< VectorType &()> get_local_tolerances
std::function< bool(const double t, VectorType &sol, VectorType &sol_dot)> solver_should_restart
GrowingVectorMemory< VectorType > mem
std::function< void(VectorType &)> reinit_vector
std::exception_ptr pending_exception
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
static ::ExceptionBase & ExcFunctionNotProvided(std::string arg1)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcIDAError(int arg1)
#define DeclException1(Exception1, type1, outsequence)
#define AssertThrow(cond, exc)