14#ifndef dealii_sundials_ida_h
15#define dealii_sundials_ida_h
19#ifdef DEAL_II_WITH_SUNDIALS
25# ifdef DEAL_II_WITH_PETSC
32# ifdef DEAL_II_SUNDIALS_WITH_IDAS
33# include <idas/idas.h>
41# include <boost/signals2.hpp>
43# include <nvector/nvector_serial.h>
44# include <sundials/sundials_config.h>
45# include <sundials/sundials_math.h>
55#ifdef DEAL_II_WITH_SUNDIALS
490 template <
typename VectorType = Vector<
double>>
621 std::pow(std::numeric_limits<double>::epsilon(), 2.0 / 3.0),
730 "Smallest allowed integration step.");
734 "Largest allowed integration step; zero is unlimited.");
737 "Maximum internal steps between output times.");
739 "Maximum error test failures",
741 "Stops a solve after repeated local error test rejections.");
743 "Maximum nonlinear convergence failures",
745 "Stops a solve after repeated nonlinear solver failures.");
753 "Convergence coefficient",
755 "Controls when Newton corrections count as converged.");
762 "Ignore algebraic terms for error computations",
764 "Indicate whether or not to suppress algebraic variables "
765 "in the local error test.");
770 "Correction type at initial time",
772 "This is one of the following three options for the "
773 "initial condition calculation. \n"
774 " none: do not try to make initial conditions consistent. \n"
775 " use_y_diff: compute the algebraic components of y and differential\n"
776 " components of y_dot, given the differential components of y. \n"
777 " This option requires that the user specifies differential and \n"
778 " algebraic components in the function differential_components().\n"
779 " use_y_dot: compute all components of y, given y_dot.");
781 "Correction type after restart",
783 "This is one of the following three options for the "
784 "initial condition calculation. \n"
785 " none: do not try to make initial conditions consistent. \n"
786 " use_y_diff: compute the algebraic components of y and differential\n"
787 " components of y_dot, given the differential components of y. \n"
788 " This option requires that the user specifies differential and \n"
789 " algebraic components in the function differential_components().\n"
790 " use_y_dot: compute all components of y, given y_dot.");
794 "Factor to use when converting from the integrator tolerance to the linear solver tolerance",
797 "Maximum number of steps",
799 "Bounds work while making the initial values consistent.");
801 "Maximum number of Jacobians",
803 "Bounds Jacobian refresh attempts during IC correction.");
806 "Limits trial reductions in the IC line search.");
809 "Enable backtracking when adjusting initial values.");
813 "Treats a sufficiently small Newton correction as convergence.");
815 "Nonlinear convergence coefficient",
817 "Sets the Newton convergence test used by IDACalcIC.");
822 "Linear tolerance factor",
824 "Relates linear solve accuracy to the nonlinear tolerance.");
826 "Difference quotient increment factor",
828 "Scales finite-difference perturbations in Jacobian products.");
830 "Linear solution scaling",
832 "Compensates for changes in Cj between linear solves.");
834 "Cj setup difference factor",
836 "Rebuilds linear setup when Cj changes by this fraction.");
841 "Minimum step growth factor",
843 "Prevents overly aggressive reductions in step size.");
846 "Caps step growth after a successful step.");
849 "Applies when IDA takes a lower-order step.");
850 prm.
add_parameter(
"Minimum growth factor after error failure",
852 "Limits step reduction after a failed error test.");
854 "Growth factor after convergence failure",
856 "Sets the next-step reduction after nonlinear failure.");
858 "Minimum fixed step growth factor",
860 "Lower step-size ratio bound for retaining the current step size.");
862 "Maximum fixed step growth factor",
864 "Upper step-size ratio bound for retaining the current step size.");
868 "Maximum constraint failures",
870 "Rejects a step after this many constraint violations.");
946 std::pow(std::numeric_limits<double>::epsilon(), 2.0 / 3.0);
1161 solve_dae(VectorType &solution, VectorType &solution_dot);
1185 reset(
const double t,
const double h, VectorType &y, VectorType &yp);
1204 std::function<void(
const double t,
1205 const VectorType &y,
1206 const VectorType &y_dot,
1240 std::function<void(
const double t,
1241 const VectorType &y,
1242 const VectorType &y_dot,
1243 const double alpha)>
1288 void(
const VectorType &rhs, VectorType &dst,
const double tolerance)>
1305 std::function<void(
const double t,
1306 const VectorType &sol,
1307 const VectorType &sol_dot,
1308 const unsigned int step_number)>
1334 std::function<
bool(
const double t, VectorType &sol, VectorType &sol_dot)>
1403 <<
"Please provide an implementation for the function \""
1424# if DEAL_II_SUNDIALS_VERSION_GTE(6, 0, 0)
1449# ifdef DEAL_II_WITH_PETSC
1450# ifdef PETSC_USE_COMPLEX
1451 static_assert(!std::is_same_v<VectorType, PETScWrappers::MPI::Vector>,
1452 "Sundials does not support complex scalar types, "
1453 "but PETSc is configured to use a complex scalar type!");
1455 static_assert(!std::is_same_v<VectorType, PETScWrappers::MPI::BlockVector>,
1456 "Sundials does not support complex scalar types, "
1457 "but PETSc is configured to use a complex scalar type!");
1467 <<
"One of SUNDIALS IDA's internal functions "
1468 <<
"returned an error code: " << arg1
1469 <<
". 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, const bool create_path_if_needed=true)
double relative_tolerance
double nonlinear_convergence_coefficient_ic
unsigned int maximum_number_of_steps_ic
unsigned int maximum_number_of_backtracks_ic
InitialConditionCorrection ic_type
bool ignore_algebraic_terms_for_errors
void add_parameters(ParameterHandler &prm)
unsigned int maximum_convergence_failures
double nonlinear_convergence_coefficient
double linear_tolerance_factor
unsigned int maximum_error_test_failures
unsigned int maximum_constraint_failures
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-15, 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, const double maximum_step_size=0.0, const long int maximum_number_of_steps=500, const unsigned int maximum_error_test_failures=10, const unsigned int maximum_convergence_failures=10, const double nonlinear_convergence_coefficient=0.33, const unsigned int maximum_number_of_steps_ic=5, const unsigned int maximum_number_of_jacobians_ic=4, const unsigned int maximum_number_of_backtracks_ic=100, const bool line_search_enabled_ic=true, const double step_tolerance_ic=std::pow(std::numeric_limits< double >::epsilon(), 2.0/3.0), const double nonlinear_convergence_coefficient_ic=0.0033, const double linear_tolerance_factor=0.05, const double increment_factor=1.0, const bool linear_solution_scaling=true, const double delta_cj_lsetup=0.25, const double eta_min=0.5, const double eta_max=2.0, const double eta_low=0.9, const double eta_min_err_fail=0.25, const double eta_conv_fail=0.25, const double eta_min_fixed=1.0, const double eta_max_fixed=2.0, const unsigned int maximum_constraint_failures=10)
long int maximum_number_of_steps
unsigned maximum_non_linear_iterations_ic
InitialConditionCorrection reset_type
bool linear_solution_scaling
bool line_search_enabled_ic
unsigned int maximum_order
unsigned int maximum_number_of_jacobians_ic
InitialConditionCorrection
unsigned int maximum_non_linear_iterations
double absolute_tolerance
std::function< void(const VectorType &rhs, VectorType &dst, const double tolerance)> solve_with_jacobian
unsigned int solve_dae(VectorType &solution, VectorType &solution_dot)
MPI_Comm mpi_communicator
std::function< void(const double t, const VectorType &y, const VectorType &y_dot, const double alpha)> setup_jacobian
void set_functions_to_trigger_an_assert()
const AdditionalData data
void reset(const double t, const double h, VectorType &y, VectorType &yp)
std::function< void(const double t, const VectorType &y, const VectorType &y_dot, VectorType &res)> residual
std::function< void(const double t, const VectorType &sol, const VectorType &sol_dot, const unsigned int step_number)> output_step
std::function< IndexSet()> differential_components
std::function< void(void *ida_mem)> custom_setup
void * get_ida_memory() const
std::function< VectorType &()> get_local_tolerances
std::function< bool(const double t, VectorType &sol, VectorType &sol_dot)> solver_should_restart
GrowingVectorMemory< VectorType > mem
std::function< void(VectorType &)> reinit_vector
std::function< VectorType &()> get_constraint_vector
std::exception_ptr pending_exception
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
static ::ExceptionBase & ExcFunctionNotProvided(std::string arg1)
static ::ExceptionBase & ExcIDAError(int arg1)
#define DeclException1(Exception1, type1, outsequence)
::VectorizedArray< Number, width > pow(const ::VectorizedArray< Number, width > &, const Number p)