14#ifndef dealii_sundials_arkode_h
15#define dealii_sundials_arkode_h
20#ifdef DEAL_II_WITH_SUNDIALS
27# ifdef DEAL_II_WITH_PETSC
34# include <arkode/arkode.h>
35# include <nvector/nvector_serial.h>
36# ifdef DEAL_II_WITH_MPI
37# include <nvector/nvector_parallel.h>
46# include <boost/signals2.hpp>
48# include <sundials/sundials_linearsolver.h>
49# include <sundials/sundials_math.h>
58#ifdef DEAL_II_WITH_SUNDIALS
100 template <
typename VectorType = Vector<
double>>
138 "Unable to assign the function since the target is not set in the "
139 "proxy. Most probably, you explicitly provided a stepper to create "
140 "the ARKode object and then tried to bind a callback to the latter. "
141 "For such use cases, assign the user callbacks directly to the "
142 "stepper. Assignment of callbacks to the ARKode object is permitted "
143 "only if one of the constructors without a stepper parameter was "
144 "used for instantiation of the ARKode object."));
191 "Use another constructor and ARKStepper::AdditionalData to initialize "
192 "with the ARKStepper relevant parameters instead.")
295 "Provide ARKStepper::AdditionalData::order instead.")
447 const
double intermediate_time,
448 const
bool reset_solver = false);
465 reset(const
double t, const
double h, const VectorType &y);
481 resize(const
double t, const
double hscale, const VectorType &y);
515 void(const
double t, const VectorType &y, VectorType &explicit_f)>
530 FunctionProxy<
void(const
double t, const VectorType &y, VectorType &res)>
547 FunctionProxy<
void(const
double t, const VectorType &v, VectorType &Mv)>
584 const VectorType &fy)>
599 void(const
double t, const VectorType &y, const VectorType &fy)>
653 const VectorType &fy,
674 const VectorType &fy,
726 std::function<
void(const
double t,
727 const VectorType &sol,
728 const
unsigned int step_number)>
811 << "Please provide an implementation
for the function \""
820 const
bool do_reset);
867# if DEAL_II_SUNDIALS_VERSION_GTE(6, 0, 0)
893# ifdef DEAL_II_WITH_PETSC
894# ifdef PETSC_USE_COMPLEX
895 static_assert(!std::is_same_v<VectorType, PETScWrappers::MPI::Vector>,
896 "Sundials does not support complex scalar types, "
897 "but PETSc is configured to use a complex scalar type!");
899 static_assert(!std::is_same_v<VectorType, PETScWrappers::MPI::BlockVector>,
900 "Sundials does not support complex scalar types, "
901 "but PETSc is configured to use a complex scalar type!");
908 template <
typename VectorType>
911 const double initial_time,
912 const double final_time,
913 const double initial_step_size,
914 const double output_period,
916 const double minimum_step_size,
917 const unsigned int maximum_order,
918 const unsigned int maximum_non_linear_iterations,
919 const bool implicit_function_is_linear,
920 const bool implicit_function_is_time_independent,
921 const bool mass_is_time_independent,
922 const int anderson_acceleration_subspace,
924 const double absolute_tolerance,
925 const double relative_tolerance)
926 : initial_time(initial_time)
927 , final_time(final_time)
928 , initial_step_size(initial_step_size)
929 , minimum_step_size(minimum_step_size)
930 , absolute_tolerance(absolute_tolerance)
931 , relative_tolerance(relative_tolerance)
932 , maximum_order(maximum_order)
933 , output_period(output_period)
934 , maximum_non_linear_iterations(maximum_non_linear_iterations)
935 , implicit_function_is_linear(implicit_function_is_linear)
936 , implicit_function_is_time_independent(
937 implicit_function_is_time_independent)
938 , mass_is_time_independent(mass_is_time_independent)
939 , anderson_acceleration_subspace(anderson_acceleration_subspace)
944 template <
typename VectorType>
947 const double initial_time,
948 const double final_time,
949 const double initial_step_size,
950 const double output_period,
952 const double minimum_step_size,
954 const double absolute_tolerance,
955 const double relative_tolerance)
956 : initial_time(initial_time)
957 , final_time(final_time)
958 , initial_step_size(initial_step_size)
959 , minimum_step_size(minimum_step_size)
960 , absolute_tolerance(absolute_tolerance)
961 , relative_tolerance(relative_tolerance)
963 , output_period(output_period)
964 , maximum_non_linear_iterations(10)
965 , implicit_function_is_linear(false)
966 , implicit_function_is_time_independent(false)
967 , mass_is_time_independent(false)
968 , anderson_acceleration_subspace(3)
973 template <
typename VectorType>
979 prm.
add_parameter(
"Time interval between each output", output_period);
985 maximum_non_linear_iterations);
987 implicit_function_is_linear);
989 implicit_function_is_time_independent);
990 prm.
add_parameter(
"Mass is time independent", mass_is_time_independent);
992 anderson_acceleration_subspace);
995 prm.
add_parameter(
"Absolute error tolerance", absolute_tolerance);
996 prm.
add_parameter(
"Relative error tolerance", relative_tolerance);
* * for(const auto &cell :triangulation.active_cell_iterators())
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)
double absolute_tolerance
AdditionalData(const double initial_time, const double final_time, const double initial_step_size, const double output_period, const double minimum_step_size, 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_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
unsigned int maximum_non_linear_iterations
std::exception_ptr pending_exception
FunctionProxy< void(SundialsOperator< VectorType > &op, SundialsPreconditioner< VectorType > &prec, VectorType &x, const VectorType &b, double tol)> solve_linearized_system
std::unique_ptr< ARKStepper< VectorType > > ark_stepper_storage
void * get_arkode_memory() const
std::function< void(const double t, const VectorType &sol, const unsigned int step_number)> output_step
std::function< VectorType &()> get_local_tolerances
internal::SharedSUNContext arkode_ctx
ARKodeStepper< VectorType > & stepper
void resize(const double t, const double hscale, const VectorType &y)
FunctionProxy< void(const double t, const VectorType &v, VectorType &Mv)> mass_times_vector
MPI_Comm mpi_communicator
void reset(const double t, const double h, const VectorType &y)
void initialize_context()
std::function< double(const double t, VectorType &sol)> solver_should_resize
FunctionProxy< void(const VectorType &v, VectorType &Jv, const double t, const VectorType &y, const VectorType &fy)> jacobian_times_vector
FunctionProxy< void(const double t, const VectorType &y, VectorType &res)> implicit_function
FunctionProxy< void(SundialsOperator< VectorType > &op, SundialsPreconditioner< VectorType > &prec, VectorType &x, const VectorType &b, double tol)> solve_mass
std::function< bool(const double t, VectorType &sol)> solver_should_restart
unsigned int do_evolve_time(VectorType &solution, ::DiscreteTime &time, const bool do_reset)
FunctionProxy< void(const double t, const VectorType &y, const VectorType &fy, const VectorType &r, VectorType &z, const double gamma, const double tol, const int lr)> jacobian_preconditioner_solve
FunctionProxy< void(const double t)> mass_times_setup
void set_functions_to_trigger_an_assert()
FunctionProxy< void(const double t, const VectorType &y, VectorType &explicit_f)> explicit_function
FunctionProxy< void(const double t, const VectorType &y, const VectorType &fy)> jacobian_times_setup
FunctionProxy< void(const double t, const VectorType &r, VectorType &z, const double tol, const int lr)> mass_preconditioner_solve
FunctionProxy< void(const double t)> mass_preconditioner_setup
unsigned int solve_ode(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
FunctionProxy< void(const double t, const VectorType &y, const VectorType &fy, const int jok, int &jcur, const double gamma)> jacobian_preconditioner_setup
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_DEPRECATED_WITH_COMMENT(comment)
#define DEAL_II_NAMESPACE_CLOSE
static ::ExceptionBase & ExcFunctionNotProvided(std::string arg1)
#define DeclException1(Exception1, type1, outsequence)
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
FunctionProxy & operator=(std::function< Fn > f)
std::function< Fn > * target
FunctionProxy(std::function< Fn > *t=nullptr)
FunctionProxy & operator=(std::function< Fn > *t)