16 #ifndef dealii_sundials_ida_h
17 #define dealii_sundials_ida_h
22 #ifdef DEAL_II_WITH_SUNDIALS
27 # ifdef DEAL_II_WITH_PETSC
34 # ifdef DEAL_II_SUNDIALS_WITH_IDAS
35 # include <idas/idas.h>
40 # include <sundials/sundials_config.h>
41 # if DEAL_II_SUNDIALS_VERSION_LT(3, 0, 0)
42 # include <ida/ida_spbcgs.h>
43 # include <ida/ida_spgmr.h>
44 # include <ida/ida_sptfqmr.h>
48 # include <boost/signals2.hpp>
50 # include <nvector/nvector_serial.h>
51 # include <sundials/sundials_math.h>
52 # include <sundials/sundials_types.h>
60 # define AssertIDA(code) Assert(code >= 0, ExcIDAError(code))
238 template <
typename VectorType = Vector<
double>>
407 "Ignore algebraic terms for error computations",
409 "Indicate whether or not to suppress algebraic variables "
410 "in the local error test.");
414 static std::string ic_type_str =
"use_y_diff";
416 "Correction type at initial time",
418 "This is one of the following three options for the "
419 "initial condition calculation. \n"
420 " none: do not try to make initial conditions consistent. \n"
421 " use_y_diff: compute the algebraic components of y and differential\n"
422 " components of y_dot, given the differential components of y. \n"
423 " This option requires that the user specifies differential and \n"
424 " algebraic components in the function get_differential_components.\n"
425 " use_y_dot: compute all components of y, given y_dot.",
427 prm.
add_action(
"Correction type at initial time",
428 [&](
const std::string &value) {
429 if (value ==
"use_y_diff")
431 else if (value ==
"use_y_dot")
433 else if (value ==
"none")
439 static std::string reset_type_str =
"use_y_diff";
441 "Correction type after restart",
443 "This is one of the following three options for the "
444 "initial condition calculation. \n"
445 " none: do not try to make initial conditions consistent. \n"
446 " use_y_diff: compute the algebraic components of y and differential\n"
447 " components of y_dot, given the differential components of y. \n"
448 " This option requires that the user specifies differential and \n"
449 " algebraic components in the function get_differential_components.\n"
450 " use_y_dot: compute all components of y, given y_dot.",
452 prm.
add_action(
"Correction type after restart",
453 [&](
const std::string &value) {
454 if (value ==
"use_y_diff")
456 else if (value ==
"use_y_dot")
458 else if (value ==
"none")
466 "Factor to use when converting from the integrator tolerance to the linear solver tolerance",
603 const MPI_Comm & mpi_comm = MPI_COMM_WORLD);
615 solve_dae(VectorType &solution, VectorType &solution_dot);
639 reset(
const double t,
const double h, VectorType &y, VectorType &yp);
656 std::function<int(
const double t,
658 const VectorType &y_dot,
696 std::function<int(
const double t,
698 const VectorType &y_dot,
735 std::function<int(
const VectorType &rhs, VectorType &dst)>
780 int(
const VectorType &rhs, VectorType &dst,
const double tolerance)>
797 std::function<void(
const double t,
798 const VectorType & sol,
799 const VectorType & sol_dot,
800 const unsigned int step_number)>
819 std::function<
bool(
const double t, VectorType &sol, VectorType &sol_dot)>
851 <<
"One of the SUNDIALS IDA internal functions "
852 <<
" returned a negative error code: " << arg1
853 <<
". Please consult SUNDIALS manual.");
863 <<
"Please provide an implementation for the function \""
896 # ifdef DEAL_II_WITH_PETSC
897 # ifdef PETSC_USE_COMPLEX
898 static_assert(!std::is_same<VectorType, PETScWrappers::MPI::Vector>::value,
899 "Sundials does not support complex scalar types, "
900 "but PETSc is configured to use a complex scalar type!");
903 !std::is_same<VectorType, PETScWrappers::MPI::BlockVector>::value,
904 "Sundials does not support complex scalar types, "
905 "but PETSc is configured to use a complex scalar type!");
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 add_action(const std::string &entry, const std::function< void(const std::string &value)> &action)
void enter_subsection(const std::string &subsection)
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
unsigned int solve_dae(VectorType &solution, VectorType &solution_dot)
void set_functions_to_trigger_an_assert()
const AdditionalData data
void reset(const double t, const double h, VectorType &y, VectorType &yp)
std::function< IndexSet()> differential_components
DeclException1(ExcIDAError, int,<< "One of the SUNDIALS IDA internal functions "<< " returned a negative error code: "<< arg1<< ". Please consult SUNDIALS manual.")
IDA(const AdditionalData &data=AdditionalData(), const MPI_Comm &mpi_comm=MPI_COMM_WORLD)
std::function< int(const double t, const VectorType &y, const VectorType &y_dot, VectorType &res)> residual
std::function< VectorType &()> get_local_tolerances
std::function< void(const double t, const VectorType &sol, const VectorType &sol_dot, const unsigned int step_number)> output_step
std::function< bool(const double t, VectorType &sol, VectorType &sol_dot)> solver_should_restart
std::function< int(const double t, const VectorType &y, const VectorType &y_dot, const double alpha)> setup_jacobian
DeclException1(ExcFunctionNotProvided, std::string,<< "Please provide an implementation for the function \""<< arg1<< "\"")
GrowingVectorMemory< VectorType > mem
std::function< void(VectorType &)> reinit_vector
std::function< int(const VectorType &rhs, VectorType &dst, const double tolerance)> solve_with_jacobian
DEAL_II_DEPRECATED_EARLY std::function< int(const VectorType &rhs, VectorType &dst)> solve_jacobian_system
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_DEPRECATED_EARLY
#define DEAL_II_NAMESPACE_CLOSE
static ::ExceptionBase & ExcInternalError()
#define AssertThrow(cond, exc)
SymmetricTensor< 2, dim, Number > e(const Tensor< 2, dim, Number > &F)