16#ifndef dealii_sundials_arkode_h
17#define dealii_sundials_arkode_h
23#ifdef DEAL_II_WITH_SUNDIALS
29# ifdef DEAL_II_WITH_PETSC
36# include <arkode/arkode.h>
37# if DEAL_II_SUNDIALS_VERSION_LT(4, 0, 0)
38# include <arkode/arkode_impl.h>
40# include <nvector/nvector_serial.h>
41# ifdef DEAL_II_WITH_MPI
42# include <nvector/nvector_parallel.h>
49# include <boost/signals2.hpp>
51# include <sundials/sundials_linearsolver.h>
52# include <sundials/sundials_math.h>
53# include <sundials/sundials_types.h>
62# define AssertARKode(code) Assert(code >= 0, ExcARKodeError(code))
332 template <
typename VectorType = Vector<
double>>
530 const MPI_Comm & mpi_comm = MPI_COMM_WORLD);
575 const double intermediate_time,
576 const bool reset_solver =
false);
593 reset(
const double t,
const double h,
const VectorType &y);
642 int(
const double t,
const VectorType &y, VectorType &explicit_f)>
661 std::function<
int(
const double t,
const VectorType &y, VectorType &res)>
664# if DEAL_II_SUNDIALS_VERSION_LT(4, 0, 0)
749 std::function<
int(
const int convfail,
752 const VectorType &ypred,
753 const VectorType &fpred,
754 bool & j_is_current)>
801 std::function<
int(
const double t,
803 const VectorType &ycur,
804 const VectorType &fcur,
805 const VectorType &rhs,
863 std::function<
int(
const VectorType &rhs, VectorType &dst)>
884 std::function<
int(
double t,
const VectorType &v, VectorType &Mv)>
949 std::function<
int(
const VectorType &v,
953 const VectorType &fy)>
990 std::function<
int(realtype t,
const VectorType &y,
const VectorType &fy)>
1063 std::function<
int(
double t,
1064 const VectorType &y,
1065 const VectorType &fy,
1066 const VectorType &r,
1115 std::function<
int(
double t,
1116 const VectorType &y,
1117 const VectorType &fy,
1151 int(
double t,
const VectorType &r, VectorType &z,
double tol,
int lr)>
1195 std::function<void(
const double t,
1196 const VectorType & sol,
1197 const unsigned int step_number)>
1260 <<
"Please provide an implementation for the function \""
1269 const bool do_reset);
1271# if DEAL_II_SUNDIALS_VERSION_GTE(4, 0, 0)
1323# if DEAL_II_SUNDIALS_VERSION_GTE(4, 0, 0)
1325 std::unique_ptr<internal::LinearSolverWrapper<VectorType>>
mass_solver;
1328# ifdef DEAL_II_WITH_PETSC
1329# ifdef PETSC_USE_COMPLEX
1330 static_assert(!std::is_same<VectorType, PETScWrappers::MPI::Vector>::value,
1331 "Sundials does not support complex scalar types, "
1332 "but PETSc is configured to use a complex scalar type!");
1335 !std::is_same<VectorType, PETScWrappers::MPI::BlockVector>::value,
1336 "Sundials does not support complex scalar types, "
1337 "but PETSc is configured to use a complex scalar type!");
1348 <<
"One of the SUNDIALS ARKode internal functions "
1349 <<
" returned a negative error code: " << arg1
1350 <<
". 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)
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(const double t, const double gamma, const VectorType &ycur, const VectorType &fcur, const VectorType &rhs, VectorType &dst)> solve_jacobian_system
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
std::function< int(const int convfail, const double t, const double gamma, const VectorType &ypred, const VectorType &fpred, bool &j_is_current)> setup_jacobian
ARKode(const AdditionalData &data=AdditionalData(), const MPI_Comm &mpi_comm=MPI_COMM_WORLD)
int do_evolve_time(VectorType &solution, ::DiscreteTime &time, const bool do_reset)
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 VectorType &rhs, VectorType &dst)> solve_mass_system
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
std::function< int(const double t)> setup_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
SymmetricTensor< 2, dim, Number > e(const Tensor< 2, dim, Number > &F)
std::function< int(SundialsOperator< VectorType > &op, SundialsPreconditioner< VectorType > &prec, VectorType &x, const VectorType &b, double tol)> LinearSolveFunction
DeclException1(ExcARKodeError, int,<< "One of the SUNDIALS ARKode internal functions "<< " returned a negative error code: "<< arg1<< ". Please consult SUNDIALS manual.")
long double gamma(const unsigned int n)