75template <
typename VectorType = Vector<
double>>
242#ifdef DEAL_II_WITH_TRILINOS
247 const Teuchos::RCP<Teuchos::ParameterList> ¶meters =
248 Teuchos::rcp(
new Teuchos::ParameterList));
255#ifdef DEAL_II_WITH_SUNDIALS
265#ifdef DEAL_II_WITH_PETSC
277 solve(VectorType &initial_guess_and_solution);
300 std::function<void(
const VectorType &src, VectorType &dst)>
residual;
352 void(
const VectorType &rhs, VectorType &dst,
const double tolerance)>
370#ifdef DEAL_II_WITH_SUNDIALS
377#ifdef DEAL_II_WITH_TRILINOS
381 Teuchos::rcp(
new Teuchos::ParameterList);
387#ifdef DEAL_II_WITH_PETSC
403template <
typename VectorType>
408#ifdef DEAL_II_WITH_SUNDIALS
412 additional_data_kinsol.strategy =
414 else if (additional_data.
strategy ==
416 additional_data_kinsol.strategy =
418 else if (additional_data.
strategy ==
420 additional_data_kinsol.strategy =
425 additional_data_kinsol.maximum_non_linear_iterations =
427 additional_data_kinsol.function_tolerance =
429 additional_data_kinsol.step_tolerance = additional_data.
step_tolerance;
430 additional_data_kinsol.anderson_subspace_size =
435#ifdef DEAL_II_WITH_TRILINOS
436 parameters_nox->set(
"Nonlinear Solver",
"Line Search Based");
437 Teuchos::ParameterList &Line_Search = parameters_nox->sublist(
"Line Search");
438 Line_Search.set(
"Method",
"Full Step");
445#ifdef DEAL_II_WITH_PETSC
446 additional_data_petsc_snes.options_prefix =
"";
452 additional_data_petsc_snes.snes_type =
"anderson";
455 else if (additional_data.
strategy ==
458 additional_data_petsc_snes.snes_type =
"newtonls";
459 additional_data_petsc_snes.snes_linesearch_type =
"bt";
461 else if (additional_data.
strategy ==
464 additional_data_petsc_snes.snes_linesearch_type =
"newtonls";
465 additional_data_petsc_snes.snes_linesearch_type =
"basic";
467 else if (additional_data.
strategy ==
469 additional_data_petsc_snes.snes_type =
"nrichardson";
471 additional_data_petsc_snes.absolute_tolerance =
473 additional_data_petsc_snes.relative_tolerance =
475 additional_data_petsc_snes.step_tolerance = additional_data.
step_tolerance;
476 additional_data_petsc_snes.maximum_non_linear_iterations =
478 additional_data_petsc_snes.max_n_function_evaluations = -1;
485template <
typename VectorType>
490template <
typename VectorType>
493 : additional_data(additional_data)
500template <
typename VectorType>
504 : additional_data(additional_data)
505 , mpi_communicator(mpi_communicator)
512template <
typename VectorType>
517 additional_data.solver_type = type;
522template <
typename VectorType>
526 const unsigned int maximum_non_linear_iterations,
527 const double function_tolerance,
528 const double relative_tolerance,
529 const double step_tolerance,
530 const unsigned int anderson_subspace_size)
531 : solver_type(solver_type)
533 , maximum_non_linear_iterations(maximum_non_linear_iterations)
534 , function_tolerance(function_tolerance)
535 , relative_tolerance(relative_tolerance)
536 , step_tolerance(step_tolerance)
537 , anderson_subspace_size(anderson_subspace_size)
542#ifdef DEAL_II_WITH_TRILINOS
543template <
typename VectorType>
548 const Teuchos::RCP<Teuchos::ParameterList> ¶meters)
557#ifdef DEAL_II_WITH_SUNDIALS
558template <
typename VectorType>
569template <
typename VectorType>
575 ExcMessage(
"PETSc SNES requires you to use PETSc vectors."));
580#ifdef DEAL_II_WITH_PETSC
598 const double tolerance = 1e-6;
602 nonlinear_solver.
solve(initial_guess_and_solution);
608template <
typename VectorType>
611 VectorType &initial_guess_and_solution)
617#ifdef DEAL_II_WITH_PETSC
620#ifdef DEAL_II_WITH_TRILINOS
623#ifdef DEAL_II_WITH_SUNDIALS
634#ifdef DEAL_II_WITH_SUNDIALS
643 nonlinear_solver.
setup_jacobian = [&](
const VectorType ¤t_u,
644 const VectorType & ) {
650 nonlinear_solver.
solve(initial_guess_and_solution);
653 false,
ExcMessage(
"You do not have SUNDIALS configured with deal.II!"));
658#ifdef DEAL_II_WITH_TRILINOS
672 nonlinear_solver.
solve(initial_guess_and_solution);
675 false,
ExcMessage(
"You do not have Trilinos configured with deal.II"));
687 const std::string solvers =
688#ifdef DEAL_II_WITH_SUNDIALS
691#ifdef DEAL_II_WITH_TRILINOS
694#ifdef DEAL_II_WITH_PETSC
701 "Invalid nonlinear solver specified. "
702 "The solvers available in your installation are:\n" +
unsigned int anderson_subspace_size
SolutionStrategy strategy
AdditionalData(const SolverType &solver_type=automatic, const SolutionStrategy &strategy=linesearch, const unsigned int maximum_non_linear_iterations=200, const double function_tolerance=1e-8, const double relative_tolerance=1e-5, const double step_tolerance=0.0, const unsigned int anderson_subspace_size=0)
double function_tolerance
unsigned int maximum_non_linear_iterations
const double relative_tolerance
TrilinosWrappers::NOXSolver< VectorType >::AdditionalData additional_data_nox
void set_data(const AdditionalData &additional_data)
void solve_with_petsc(VectorType &initial_guess_and_solution)
void set_data(const typename PETScWrappers::NonlinearSolverData &additional_data)
SUNDIALS::KINSOL< VectorType >::AdditionalData additional_data_kinsol
std::function< void(const VectorType &src, VectorType &dst)> residual
std::function< void(VectorType &)> reinit_vector
AdditionalData additional_data
Teuchos::RCP< Teuchos::ParameterList > parameters_nox
PETScWrappers::NonlinearSolverData additional_data_petsc_snes
MPI_Comm mpi_communicator
void solve(VectorType &initial_guess_and_solution)
void select(const typename AdditionalData::SolverType &type)
NonlinearSolverSelector()
std::function< void(const VectorType ¤t_u)> setup_jacobian
std::function< void(const VectorType &rhs, VectorType &dst, const double tolerance)> solve_with_jacobian
std::function< void(const VectorType &src, VectorType &dst)> solve_with_jacobian
std::function< void(const VectorType &x, VectorType &res)> residual
unsigned int solve(VectorType &x)
std::function< void(const VectorType &x)> setup_jacobian
std::function< void(const VectorType ¤t_u, const VectorType ¤t_f)> setup_jacobian
unsigned int solve(VectorType &initial_guess_and_solution)
std::function< void(const VectorType &src, VectorType &dst)> residual
std::function< void(const VectorType &rhs, VectorType &dst, const double tolerance)> solve_with_jacobian
std::function< void(VectorType &)> reinit_vector
std::function< void(const VectorType &y, VectorType &x, const double tolerance)> solve_with_jacobian
std::function< void(const VectorType &u, VectorType &F)> residual
unsigned int solve(VectorType &solution)
std::function< void(const VectorType ¤t_u)> setup_jacobian
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)