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/logstream.h> 23 #include <deal.II/base/exceptions.h> 24 #include <deal.II/base/parameter_handler.h> 25 #include <deal.II/base/conditional_ostream.h> 26 #include <deal.II/base/mpi.h> 27 #include <deal.II/lac/vector.h> 28 #include <deal.II/lac/vector_memory.h> 30 #include <kinsol/kinsol.h> 31 #include <kinsol/kinsol_impl.h> 32 #include <nvector/nvector_serial.h> 33 #include <sundials/sundials_math.h> 34 #include <sundials/sundials_types.h> 36 #include <boost/signals2.hpp> 40 DEAL_II_NAMESPACE_OPEN
43 #define AssertKINSOL(code) Assert(code >= 0, ExcKINSOLError(code)) 195 template<
typename VectorType=Vector<
double> >
318 static std::string strategy_str(
"newton");
320 "Choose among newton|linesearch|fixed_point|picard",
322 prm.
add_action(
"Solution strategy", [&](
const std::string &value)
324 if (value ==
"newton")
326 else if (value ==
"linesearch")
328 else if (value ==
"fixed_point")
330 else if (value ==
"picard")
348 prm.
add_parameter(
"Maximum allowable scaled length of the Newton step",
350 prm.
add_parameter(
"Relative error for different quotient computation",
355 prm.
add_parameter(
"Maximum number of beta-condition failures",
455 const MPI_Comm mpi_comm = MPI_COMM_WORLD);
467 unsigned int solve(VectorType &initial_guess_and_solution);
487 std::function<int(
const VectorType &src,
503 std::function<int(
const VectorType &src,
547 std::function<int(
const VectorType ¤t_u,
586 std::function<int(
const VectorType &ycur,
587 const VectorType &fcur,
588 const VectorType &rhs,
612 <<
" returned a negative error code: " 613 << arg1 <<
". Please consult SUNDIALS manual.");
622 <<
"Please provide an implementation for the function \"" << arg1 <<
"\"");
670 DEAL_II_NAMESPACE_CLOSE
unsigned int maximum_non_linear_iterations
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
unsigned int anderson_subspace_size
double maximum_newton_step
void add_parameters(ParameterHandler &prm)
void enter_subsection(const std::string &subsection)
std::function< int(const VectorType &ycur, const VectorType &fcur, const VectorType &rhs, VectorType &dst)> solve_jacobian_system
#define DeclException1(Exception1, type1, outsequence)
#define Assert(cond, exc)
GrowingVectorMemory< VectorType > mem
static ::ExceptionBase & ExcFunctionNotProvided(std::string arg1)
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< VectorType &()> get_function_scaling
unsigned int maximum_beta_failures
std::function< void(VectorType &)> reinit_vector
std::function< VectorType &()> get_solution_scaling
KINSOL(const AdditionalData &data=AdditionalData(), const MPI_Comm mpi_comm=MPI_COMM_WORLD)
void add_parameter(const std::string &entry, ParameterType ¶meter, const std::string &documentation=std::string(), const Patterns::PatternBase &pattern= *Patterns::Tools::Convert< ParameterType >::to_pattern())
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()