16 #ifndef dealii_sundials_kinsol_h 17 #define dealii_sundials_kinsol_h 19 #include <deal.II/base/config.h> 20 #ifdef DEAL_II_WITH_SUNDIALS 22 # include <deal.II/base/conditional_ostream.h> 23 # include <deal.II/base/exceptions.h> 24 # include <deal.II/base/logstream.h> 25 # include <deal.II/base/mpi.h> 26 # include <deal.II/base/parameter_handler.h> 28 # include <deal.II/lac/vector.h> 29 # include <deal.II/lac/vector_memory.h> 31 # include <boost/signals2.hpp> 33 # include <kinsol/kinsol.h> 34 # include <kinsol/kinsol_impl.h> 35 # include <nvector/nvector_serial.h> 36 # include <sundials/sundials_math.h> 37 # include <sundials/sundials_types.h> 42 DEAL_II_NAMESPACE_OPEN
45 # define AssertKINSOL(code) Assert(code >= 0, ExcKINSOLError(code)) 197 template <
typename VectorType = Vector<
double>>
324 static std::string strategy_str(
"newton");
327 "Choose among newton|linesearch|fixed_point|picard",
329 "newton|linesearch|fixed_point|picard"));
330 prm.
add_action(
"Solution strategy", [&](
const std::string &value) {
331 if (value ==
"newton")
333 else if (value ==
"linesearch")
335 else if (value ==
"fixed_point")
337 else if (value ==
"picard")
352 prm.
add_parameter(
"Maximum allowable scaled length of the Newton step",
354 prm.
add_parameter(
"Relative error for different quotient computation",
359 prm.
add_parameter(
"Maximum number of beta-condition failures",
459 const MPI_Comm mpi_comm = MPI_COMM_WORLD);
472 solve(VectorType &initial_guess_and_solution);
492 std::function<int(const VectorType &src, VectorType &dst)>
residual;
507 std::function<int(const VectorType &src, VectorType &dst)>
551 std::function<int(const VectorType ¤t_u, const VectorType ¤t_f)>
591 std::function<int(
const VectorType &ycur,
592 const VectorType &fcur,
593 const VectorType &rhs,
619 <<
"One of the SUNDIALS KINSOL internal functions " 620 <<
" returned a negative error code: " << arg1
621 <<
". Please consult SUNDIALS manual.");
631 <<
"Please provide an implementation for the function \"" 681 DEAL_II_NAMESPACE_CLOSE
unsigned int maximum_non_linear_iterations
AdditionalData(const SolutionStrategy &strategy=linesearch, const unsigned int maximum_non_linear_iterations=200, const double function_tolerance=0.0, const double step_tolerance=0.0, const bool no_init_setup=false, const unsigned int maximum_setup_calls=0, const double maximum_newton_step=0.0, const double dq_relative_error=0.0, const unsigned int maximum_beta_failures=0, const unsigned int anderson_subspace_size=0)
std::function< int(const VectorType &src, VectorType &dst)> residual
unsigned int maximum_setup_calls
static ::ExceptionBase & ExcKINSOLError(int arg1)
double function_tolerance
std::function< int(const VectorType &src, VectorType &dst)> iteration_function
void set_functions_to_trigger_an_assert()
SolutionStrategy strategy
std::function< VectorType &()> get_function_scaling
unsigned int anderson_subspace_size
void add_parameter(const std::string &entry, ParameterType ¶meter, const std::string &documentation="", const Patterns::PatternBase &pattern= *Patterns::Tools::Convert< ParameterType >::to_pattern())
double maximum_newton_step
void add_parameters(ParameterHandler &prm)
void enter_subsection(const std::string &subsection)
#define DeclException1(Exception1, type1, outsequence)
#define Assert(cond, exc)
GrowingVectorMemory< VectorType > mem
std::function< VectorType &()> get_solution_scaling
static ::ExceptionBase & ExcFunctionNotProvided(std::string arg1)
unsigned int maximum_beta_failures
std::function< int(const VectorType &ycur, const VectorType &fcur, const VectorType &rhs, VectorType &dst)> solve_jacobian_system
std::function< void(VectorType &)> reinit_vector
KINSOL(const AdditionalData &data=AdditionalData(), const MPI_Comm mpi_comm=MPI_COMM_WORLD)
void add_action(const std::string &entry, const std::function< void(const std::string &value)> &action)
std::function< int(const VectorType ¤t_u, const VectorType ¤t_f)> setup_jacobian
unsigned int solve(VectorType &initial_guess_and_solution)
static ::ExceptionBase & ExcInternalError()