17#ifndef dealii_sundials_arkode_h
18#define dealii_sundials_arkode_h
24#ifdef DEAL_II_WITH_SUNDIALS
30# ifdef DEAL_II_WITH_PETSC
37# include <arkode/arkode.h>
38# include <nvector/nvector_serial.h>
39# ifdef DEAL_II_WITH_MPI
40# include <nvector/nvector_parallel.h>
47# include <boost/signals2.hpp>
49# include <sundials/sundials_linearsolver.h>
50# include <sundials/sundials_math.h>
51# include <sundials/sundials_types.h>
60# define AssertARKode(code) Assert(code >= 0, ExcARKodeError(code))
324 template <
typename VectorType = Vector<
double>>
533 const double intermediate_time,
534 const bool reset_solver =
false);
551 reset(
const double t,
const double h,
const VectorType &y);
600 int(
const double t,
const VectorType &y, VectorType &explicit_f)>
619 std::function<
int(
const double t,
const VectorType &y, VectorType &res)>
639 std::function<
int(
double t,
const VectorType &v, VectorType &Mv)>
704 std::function<
int(
const VectorType &v,
708 const VectorType &fy)>
745 std::function<
int(realtype t,
const VectorType &y,
const VectorType &fy)>
817 std::function<
int(
double t,
819 const VectorType &fy,
869 std::function<
int(
double t,
871 const VectorType &fy,
905 int(
double t,
const VectorType &r, VectorType &z,
double tol,
int lr)>
948 std::function<void(
const double t,
949 const VectorType & sol,
950 const unsigned int step_number)>
1013 <<
"Please provide an implementation for the function \""
1022 const bool do_reset);
1060# if DEAL_II_SUNDIALS_VERSION_GTE(6, 0, 0)
1079 std::unique_ptr<internal::LinearSolverWrapper<VectorType>>
mass_solver;
1081# ifdef DEAL_II_WITH_PETSC
1082# ifdef PETSC_USE_COMPLEX
1083 static_assert(!std::is_same<VectorType, PETScWrappers::MPI::Vector>::value,
1084 "Sundials does not support complex scalar types, "
1085 "but PETSc is configured to use a complex scalar type!");
1088 !std::is_same<VectorType, PETScWrappers::MPI::BlockVector>::value,
1089 "Sundials does not support complex scalar types, "
1090 "but PETSc is configured to use a complex scalar type!");
1101 <<
"One of the SUNDIALS ARKode internal functions "
1102 <<
" returned a negative error code: " << arg1
1103 <<
". Please consult SUNDIALS manual.");
1106 template <
typename VectorType>
1109 const double initial_time,
1110 const double final_time,
1111 const double initial_step_size,
1112 const double output_period,
1114 const double minimum_step_size,
1115 const unsigned int maximum_order,
1116 const unsigned int maximum_non_linear_iterations,
1117 const bool implicit_function_is_linear,
1118 const bool implicit_function_is_time_independent,
1119 const bool mass_is_time_independent,
1120 const int anderson_acceleration_subspace,
1122 const double absolute_tolerance,
1123 const double relative_tolerance)
1124 : initial_time(initial_time)
1125 , final_time(final_time)
1126 , initial_step_size(initial_step_size)
1127 , minimum_step_size(minimum_step_size)
1128 , absolute_tolerance(absolute_tolerance)
1129 , relative_tolerance(relative_tolerance)
1130 , maximum_order(maximum_order)
1131 , output_period(output_period)
1132 , maximum_non_linear_iterations(maximum_non_linear_iterations)
1133 , implicit_function_is_linear(implicit_function_is_linear)
1134 , implicit_function_is_time_independent(
1135 implicit_function_is_time_independent)
1136 , mass_is_time_independent(mass_is_time_independent)
1137 , anderson_acceleration_subspace(anderson_acceleration_subspace)
1142 template <
typename VectorType>
1148 prm.
add_parameter(
"Time interval between each output", output_period);
1154 maximum_non_linear_iterations);
1156 implicit_function_is_linear);
1158 implicit_function_is_time_independent);
1159 prm.
add_parameter(
"Mass is time independent", mass_is_time_independent);
1161 anderson_acceleration_subspace);
1164 prm.
add_parameter(
"Absolute error tolerance", absolute_tolerance);
1165 prm.
add_parameter(
"Relative error tolerance", relative_tolerance);
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)
double absolute_tolerance
unsigned int maximum_order
bool implicit_function_is_linear
bool mass_is_time_independent
bool implicit_function_is_time_independent
double relative_tolerance
void add_parameters(ParameterHandler &prm)
int anderson_acceleration_subspace
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 bool implicit_function_is_linear=false, const bool implicit_function_is_time_independent=false, const bool mass_is_time_independent=false, const int anderson_acceleration_subspace=3, const double absolute_tolerance=1e-6, const double relative_tolerance=1e-5)
unsigned int maximum_non_linear_iterations
void setup_mass_solver(const VectorType &solution)
std::function< int(const double t, const VectorType &y, VectorType &res)> implicit_function
std::function< int(double t, const VectorType &r, VectorType &z, double tol, int lr)> mass_preconditioner_solve
std::function< int(const VectorType &v, VectorType &Jv, double t, const VectorType &y, const VectorType &fy)> jacobian_times_vector
std::function< int(double t)> mass_preconditioner_setup
void * get_arkode_memory() const
std::function< VectorType &()> get_local_tolerances
std::function< int(realtype t, const VectorType &y, const VectorType &fy)> jacobian_times_setup
LinearSolveFunction< VectorType > solve_linearized_system
int do_evolve_time(VectorType &solution, ::DiscreteTime &time, const bool do_reset)
MPI_Comm mpi_communicator
std::function< int(const double t)> mass_times_setup
DeclException1(ExcFunctionNotProvided, std::string,<< "Please provide an implementation for the function \""<< arg1<< "\"")
void reset(const double t, const double h, const VectorType &y)
std::unique_ptr< internal::LinearSolverWrapper< VectorType > > mass_solver
std::function< int(double t, const VectorType &y, const VectorType &fy, int jok, int &jcur, double gamma)> jacobian_preconditioner_setup
std::function< int(const double t, const VectorType &y, VectorType &explicit_f)> explicit_function
std::function< bool(const double t, VectorType &sol)> solver_should_restart
std::function< int(double t, const VectorType &v, VectorType &Mv)> mass_times_vector
std::function< void(const double t, const VectorType &sol, const unsigned int step_number)> output_step
void set_functions_to_trigger_an_assert()
std::function< int(double t, const VectorType &y, const VectorType &fy, const VectorType &r, VectorType &z, double gamma, double tol, int lr)> jacobian_preconditioner_solve
std::unique_ptr< internal::LinearSolverWrapper< VectorType > > linear_solver
LinearSolveFunction< VectorType > solve_mass
unsigned int solve_ode(VectorType &solution)
void setup_system_solver(const VectorType &solution)
unsigned int solve_ode_incrementally(VectorType &solution, const double intermediate_time, const bool reset_solver=false)
std::function< void(void *arkode_mem)> custom_setup
DEAL_II_DEPRECATED std::function< void(VectorType &)> reinit_vector
#define DEAL_II_DEPRECATED
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
#define DeclException1(Exception1, type1, outsequence)
std::function< int(SundialsOperator< VectorType > &op, SundialsPreconditioner< VectorType > &prec, VectorType &x, const VectorType &b, double tol)> LinearSolveFunction