Reference documentation for deal.II version 9.4.0
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
trilinos_solver.h
Go to the documentation of this file.
1// ---------------------------------------------------------------------
2//
3// Copyright (C) 2008 - 2020 by the deal.II authors
4//
5// This file is part of the deal.II library.
6//
7// The deal.II library is free software; you can use it, redistribute
8// it, and/or modify it under the terms of the GNU Lesser General
9// Public License as published by the Free Software Foundation; either
10// version 2.1 of the License, or (at your option) any later version.
11// The full text of the license can be found in the file LICENSE.md at
12// the top level directory of deal.II.
13//
14// ---------------------------------------------------------------------
15
16#ifndef dealii_trilinos_solver_h
17# define dealii_trilinos_solver_h
18
19
20# include <deal.II/base/config.h>
21
22# ifdef DEAL_II_WITH_TRILINOS
23
27# include <deal.II/lac/vector.h>
28
29# include <Amesos.h>
30# include <AztecOO.h>
31# include <Epetra_LinearProblem.h>
32# include <Epetra_Operator.h>
33
34# include <memory>
35
36
38
39namespace TrilinosWrappers
40{
41 // forward declarations
42# ifndef DOXYGEN
43 class SparseMatrix;
44 class PreconditionBase;
45# endif
46
47
67 {
68 public:
77 {
97 tfqmr
99
105 {
114 explicit AdditionalData(const bool output_solver_details = false,
115 const unsigned int gmres_restart_parameter = 30);
116
122
126 const unsigned int gmres_restart_parameter;
127 };
128
133 const AdditionalData &data = AdditionalData());
134
140 SolverControl & cn,
141 const AdditionalData &data = AdditionalData());
142
146 virtual ~SolverBase() = default;
147
153 void
154 solve(const SparseMatrix & A,
155 MPI::Vector & x,
156 const MPI::Vector & b,
157 const PreconditionBase &preconditioner);
158
166 void
167 solve(const Epetra_Operator & A,
168 MPI::Vector & x,
169 const MPI::Vector & b,
170 const PreconditionBase &preconditioner);
171
181 void
182 solve(const Epetra_Operator &A,
183 MPI::Vector & x,
184 const MPI::Vector & b,
185 const Epetra_Operator &preconditioner);
186
196 void
197 solve(const Epetra_Operator & A,
198 Epetra_MultiVector & x,
199 const Epetra_MultiVector &b,
200 const PreconditionBase & preconditioner);
201
212 void
213 solve(const Epetra_Operator & A,
214 Epetra_MultiVector & x,
215 const Epetra_MultiVector &b,
216 const Epetra_Operator & preconditioner);
217
218
219
230 void
231 solve(const SparseMatrix & A,
233 const ::Vector<double> &b,
234 const PreconditionBase & preconditioner);
235
247 void
250 const ::Vector<double> &b,
251 const PreconditionBase & preconditioner);
252
259 void
262 const ::LinearAlgebra::distributed::Vector<double> &b,
263 const PreconditionBase &preconditioner);
264
272 void
275 const ::LinearAlgebra::distributed::Vector<double> &b,
276 const PreconditionBase &preconditioner);
277
278
283 control() const;
284
289 int,
290 << "An error with error number " << arg1
291 << " occurred while calling a Trilinos function");
292
293 protected:
301
302 private:
307 template <typename Preconditioner>
308 void
309 do_solve(const Preconditioner &preconditioner);
310
314 template <typename Preconditioner>
315 void
316 set_preconditioner(AztecOO &solver, const Preconditioner &preconditioner);
317
323 std::unique_ptr<Epetra_LinearProblem> linear_problem;
324
329 std::unique_ptr<AztecOO_StatusTest> status_test;
330
335 AztecOO solver;
336
341 };
342
343
344 // provide a declaration for two explicit specializations
345 template <>
346 void
347 SolverBase::set_preconditioner(AztecOO & solver,
348 const PreconditionBase &preconditioner);
349
350 template <>
351 void
352 SolverBase::set_preconditioner(AztecOO & solver,
353 const Epetra_Operator &preconditioner);
354
355
356
362 class SolverCG : public SolverBase
363 {
364 public:
370 {
374 explicit AdditionalData(const bool output_solver_details = false);
375 };
376
385
386 protected:
391 };
392
393
394
400 class SolverCGS : public SolverBase
401 {
402 public:
407 {
411 explicit AdditionalData(const bool output_solver_details = false);
412 };
413
422
423 protected:
428 };
429
430
431
436 class SolverGMRES : public SolverBase
437 {
438 public:
443 {
448 explicit AdditionalData(const bool output_solver_details = false,
449 const unsigned int restart_parameter = 30);
450 };
451
460 const AdditionalData &data = AdditionalData());
461
462 protected:
467 };
468
469
470
478 {
479 public:
484 {
488 explicit AdditionalData(const bool output_solver_details = false);
489 };
490
499 const AdditionalData &data = AdditionalData());
500
501 protected:
506 };
507
508
509
516 class SolverTFQMR : public SolverBase
517 {
518 public:
523 {
527 explicit AdditionalData(const bool output_solver_details = false);
528 };
529
538 const AdditionalData &data = AdditionalData());
539
540 protected:
545 };
546
547
548
562 {
563 public:
569 {
573 explicit AdditionalData(const bool output_solver_details = false,
574 const std::string &solver_type = "Amesos_Klu");
575
581
600 std::string solver_type;
601 };
602
607 const AdditionalData &data = AdditionalData());
608
612 virtual ~SolverDirect() = default;
613
620 void
621 initialize(const SparseMatrix &A);
622
628 void
629 solve(MPI::Vector &x, const MPI::Vector &b);
630
636 void
638 const ::LinearAlgebra::distributed::Vector<double> &b);
639
646 void
647 solve(const SparseMatrix &A, MPI::Vector &x, const MPI::Vector &b);
648
656 void
657 solve(const SparseMatrix & A,
659 const ::Vector<double> &b);
660
667 void
670 const ::LinearAlgebra::distributed::Vector<double> &b);
671
676 control() const;
677
682 int,
683 << "An error with error number " << arg1
684 << " occurred while calling a Trilinos function");
685
686 private:
691 void
692 do_solve();
693
701
707 std::unique_ptr<Epetra_LinearProblem> linear_problem;
708
713 std::unique_ptr<Amesos_BaseSolver> solver;
714
719 };
720
721} // namespace TrilinosWrappers
722
724
725# endif // DEAL_II_WITH_TRILINOS
726
727/*---------------------------- trilinos_solver.h ---------------------------*/
728
729#endif
730/*---------------------------- trilinos_solver.h ---------------------------*/
virtual ~SolverBase()=default
SolverControl & control() const
void solve(const SparseMatrix &A, MPI::Vector &x, const MPI::Vector &b, const PreconditionBase &preconditioner)
const AdditionalData additional_data
std::unique_ptr< AztecOO_StatusTest > status_test
void set_preconditioner(AztecOO &solver, const Preconditioner &preconditioner)
void do_solve(const Preconditioner &preconditioner)
void solve(Epetra_Operator &A, ::LinearAlgebra::distributed::Vector< double > &x, const ::LinearAlgebra::distributed::Vector< double > &b, const PreconditionBase &preconditioner)
std::unique_ptr< Epetra_LinearProblem > linear_problem
SolverBase(SolverControl &cn, const AdditionalData &data=AdditionalData())
enum TrilinosWrappers::SolverBase::SolverName solver_name
void solve(const SparseMatrix &A, ::LinearAlgebra::distributed::Vector< double > &x, const ::LinearAlgebra::distributed::Vector< double > &b, const PreconditionBase &preconditioner)
const AdditionalData additional_data
SolverBicgstab(SolverControl &cn, const AdditionalData &data=AdditionalData())
const AdditionalData additional_data
SolverCGS(SolverControl &cn, const AdditionalData &data=AdditionalData())
const AdditionalData additional_data
SolverCG(SolverControl &cn, const AdditionalData &data=AdditionalData())
void solve(const SparseMatrix &A, ::LinearAlgebra::distributed::Vector< double > &x, const ::LinearAlgebra::distributed::Vector< double > &b)
const AdditionalData additional_data
virtual ~SolverDirect()=default
SolverDirect(SolverControl &cn, const AdditionalData &data=AdditionalData())
void initialize(const SparseMatrix &A)
std::unique_ptr< Amesos_BaseSolver > solver
void solve(MPI::Vector &x, const MPI::Vector &b)
std::unique_ptr< Epetra_LinearProblem > linear_problem
SolverControl & control() const
const AdditionalData additional_data
SolverGMRES(SolverControl &cn, const AdditionalData &data=AdditionalData())
SolverTFQMR(SolverControl &cn, const AdditionalData &data=AdditionalData())
const AdditionalData additional_data
Definition: vector.h:109
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:442
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:443
static ::ExceptionBase & ExcTrilinosError(int arg1)
static ::ExceptionBase & ExcTrilinosError(int arg1)
#define DeclException1(Exception1, type1, outsequence)
Definition: exceptions.h:509
static const char A
SymmetricTensor< 2, dim, Number > b(const Tensor< 2, dim, Number > &F)
AdditionalData(const bool output_solver_details=false, const unsigned int gmres_restart_parameter=30)
AdditionalData(const bool output_solver_details=false)
AdditionalData(const bool output_solver_details=false)
AdditionalData(const bool output_solver_details=false)
AdditionalData(const bool output_solver_details=false, const std::string &solver_type="Amesos_Klu")
AdditionalData(const bool output_solver_details=false, const unsigned int restart_parameter=30)
AdditionalData(const bool output_solver_details=false)