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
98 template <
typename VectorType = Vector<
double>>
136 "Unable to assign the function since the target is not set in the "
137 "proxy. Most probably, you explicitly provided a stepper to create "
138 "the ARKode object and then tried to bind a callback to the latter. "
139 "For such use cases, assign the user callbacks directly to the "
140 "stepper. Assignment of callbacks to the ARKode object is permitted "
141 "only if one of the constructors without a stepper parameter was "
142 "used for instantiation of the ARKode object."));
189 "Use another constructor and ARKStepper::AdditionalData to initialize "
190 "with the ARKStepper relevant parameters instead.")
293 "Provide ARKStepper::AdditionalData::order instead.")
445 const
double intermediate_time,
446 const
bool reset_solver = false);
463 reset(const
double t, const
double h, const VectorType &y);
497 void(const
double t, const VectorType &y, VectorType &explicit_f)>
512 FunctionProxy<
void(const
double t, const VectorType &y, VectorType &res)>
529 FunctionProxy<
void(const
double t, const VectorType &v, VectorType &Mv)>
566 const VectorType &fy)>
581 void(const
double t, const VectorType &y, const VectorType &fy)>
635 const VectorType &fy,
656 const VectorType &fy,
708 std::function<
void(const
double t,
709 const VectorType &sol,
710 const
unsigned int step_number)>
773 << "Please provide an implementation
for the function \""
782 const
bool do_reset);
816# if DEAL_II_SUNDIALS_VERSION_GTE(6, 0, 0)
841# ifdef DEAL_II_WITH_PETSC
842# ifdef PETSC_USE_COMPLEX
843 static_assert(!std::is_same_v<VectorType, PETScWrappers::MPI::Vector>,
844 "Sundials does not support complex scalar types, "
845 "but PETSc is configured to use a complex scalar type!");
847 static_assert(!std::is_same_v<VectorType, PETScWrappers::MPI::BlockVector>,
848 "Sundials does not support complex scalar types, "
849 "but PETSc is configured to use a complex scalar type!");
856 template <
typename VectorType>
859 const double initial_time,
860 const double final_time,
861 const double initial_step_size,
862 const double output_period,
864 const double minimum_step_size,
865 const unsigned int maximum_order,
866 const unsigned int maximum_non_linear_iterations,
867 const bool implicit_function_is_linear,
868 const bool implicit_function_is_time_independent,
869 const bool mass_is_time_independent,
870 const int anderson_acceleration_subspace,
872 const double absolute_tolerance,
873 const double relative_tolerance)
874 : initial_time(initial_time)
875 , final_time(final_time)
876 , initial_step_size(initial_step_size)
877 , minimum_step_size(minimum_step_size)
878 , absolute_tolerance(absolute_tolerance)
879 , relative_tolerance(relative_tolerance)
880 , maximum_order(maximum_order)
881 , output_period(output_period)
882 , maximum_non_linear_iterations(maximum_non_linear_iterations)
883 , implicit_function_is_linear(implicit_function_is_linear)
884 , implicit_function_is_time_independent(
885 implicit_function_is_time_independent)
886 , mass_is_time_independent(mass_is_time_independent)
887 , anderson_acceleration_subspace(anderson_acceleration_subspace)
892 template <
typename VectorType>
895 const double initial_time,
896 const double final_time,
897 const double initial_step_size,
898 const double output_period,
900 const double minimum_step_size,
902 const double absolute_tolerance,
903 const double relative_tolerance)
904 : initial_time(initial_time)
905 , final_time(final_time)
906 , initial_step_size(initial_step_size)
907 , minimum_step_size(minimum_step_size)
908 , absolute_tolerance(absolute_tolerance)
909 , relative_tolerance(relative_tolerance)
911 , output_period(output_period)
912 , maximum_non_linear_iterations(10)
913 , implicit_function_is_linear(false)
914 , implicit_function_is_time_independent(false)
915 , mass_is_time_independent(false)
916 , anderson_acceleration_subspace(3)
921 template <
typename VectorType>
927 prm.
add_parameter(
"Time interval between each output", output_period);
933 maximum_non_linear_iterations);
935 implicit_function_is_linear);
937 implicit_function_is_time_independent);
938 prm.
add_parameter(
"Mass is time independent", mass_is_time_independent);
940 anderson_acceleration_subspace);
943 prm.
add_parameter(
"Absolute error tolerance", absolute_tolerance);
944 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
ARKodeStepper< VectorType > & stepper
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()
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)