74template <
typename VectorType = Vector<
double>>
244#ifdef DEAL_II_TRILINOS_WITH_NOX
249 const Teuchos::RCP<Teuchos::ParameterList> ¶meters =
250 Teuchos::rcp(
new Teuchos::ParameterList));
257#ifdef DEAL_II_WITH_SUNDIALS
267#ifdef DEAL_II_WITH_PETSC
279 solve(VectorType &initial_guess_and_solution);
302 std::function<void(
const VectorType &src, VectorType &dst)>
residual;
354 void(
const VectorType &rhs, VectorType &dst,
const double tolerance)>
372#ifdef DEAL_II_WITH_SUNDIALS
379#ifdef DEAL_II_TRILINOS_WITH_NOX
383 Teuchos::rcp(
new Teuchos::ParameterList);
389#ifdef DEAL_II_WITH_PETSC
405template <
typename VectorType>
410#ifdef DEAL_II_WITH_SUNDIALS
414 additional_data_kinsol.strategy =
416 else if (additional_data.
strategy ==
418 additional_data_kinsol.strategy =
420 else if (additional_data.
strategy ==
422 additional_data_kinsol.strategy =
427 additional_data_kinsol.maximum_non_linear_iterations =
429 additional_data_kinsol.function_tolerance =
431 additional_data_kinsol.step_tolerance = additional_data.
step_tolerance;
432 additional_data_kinsol.anderson_subspace_size =
437#ifdef DEAL_II_TRILINOS_WITH_NOX
438 parameters_nox->set(
"Nonlinear Solver",
"Line Search Based");
439 Teuchos::ParameterList &Line_Search = parameters_nox->sublist(
"Line Search");
440 Line_Search.set(
"Method",
"Full Step");
447#ifdef DEAL_II_WITH_PETSC
448 additional_data_petsc_snes.options_prefix =
"";
454 additional_data_petsc_snes.snes_type =
"anderson";
457 else if (additional_data.
strategy ==
460 additional_data_petsc_snes.snes_type =
"newtonls";
461 additional_data_petsc_snes.snes_linesearch_type =
"bt";
463 else if (additional_data.
strategy ==
466 additional_data_petsc_snes.snes_linesearch_type =
"newtonls";
467 additional_data_petsc_snes.snes_linesearch_type =
"basic";
469 else if (additional_data.
strategy ==
471 additional_data_petsc_snes.snes_type =
"nrichardson";
473 additional_data_petsc_snes.absolute_tolerance =
475 additional_data_petsc_snes.relative_tolerance =
477 additional_data_petsc_snes.step_tolerance = additional_data.
step_tolerance;
478 additional_data_petsc_snes.maximum_non_linear_iterations =
480 additional_data_petsc_snes.max_n_function_evaluations = -1;
487template <
typename VectorType>
489 : mpi_communicator(MPI_COMM_SELF)
494template <
typename VectorType>
497 : additional_data(additional_data)
498 , mpi_communicator(MPI_COMM_SELF)
505template <
typename VectorType>
509 : additional_data(additional_data)
510 , mpi_communicator(mpi_communicator)
517template <
typename VectorType>
522 additional_data.solver_type = type;
527template <
typename VectorType>
531 const unsigned int maximum_non_linear_iterations,
532 const double function_tolerance,
533 const double relative_tolerance,
534 const double step_tolerance,
535 const unsigned int anderson_subspace_size)
536 : solver_type(solver_type)
538 , maximum_non_linear_iterations(maximum_non_linear_iterations)
539 , function_tolerance(function_tolerance)
540 , relative_tolerance(relative_tolerance)
541 , step_tolerance(step_tolerance)
542 , anderson_subspace_size(anderson_subspace_size)
547#ifdef DEAL_II_TRILINOS_WITH_NOX
548template <
typename VectorType>
553 const Teuchos::RCP<Teuchos::ParameterList> ¶meters)
562#ifdef DEAL_II_WITH_SUNDIALS
563template <
typename VectorType>
574template <
typename VectorType>
580 ExcMessage(
"PETSc SNES requires you to use PETSc vectors."));
585#ifdef DEAL_II_WITH_PETSC
603 const double tolerance = 1e-6;
607 nonlinear_solver.
solve(initial_guess_and_solution);
613template <
typename VectorType>
616 VectorType &initial_guess_and_solution)
622#ifdef DEAL_II_WITH_PETSC
625#ifdef DEAL_II_TRILINOS_WITH_NOX
628#ifdef DEAL_II_WITH_SUNDIALS
639#ifdef DEAL_II_WITH_SUNDIALS
648 nonlinear_solver.
setup_jacobian = [&](
const VectorType ¤t_u,
649 const VectorType & ) {
655 nonlinear_solver.
solve(initial_guess_and_solution);
658 false,
ExcMessage(
"You do not have SUNDIALS configured with deal.II!"));
663#ifdef DEAL_II_TRILINOS_WITH_NOX
677 nonlinear_solver.
solve(initial_guess_and_solution);
680 false,
ExcMessage(
"You do not have Trilinos configured with deal.II"));
692 const std::string solvers =
""
693#ifdef DEAL_II_WITH_SUNDIALS
696#ifdef DEAL_II_TRILINOS_WITH_NOX
699#ifdef DEAL_II_WITH_PETSC
706 "Invalid nonlinear solver specified. "
707 "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_DEPRECATED
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)