Reference documentation for deal.II version 8.1.0
trilinos_solver.h
1 // ---------------------------------------------------------------------
2 // @f$Id: trilinos_solver.h 30040 2013-07-18 17:06:48Z maier @f$
3 //
4 // Copyright (C) 2008 - 2013 by the deal.II authors
5 //
6 // This file is part of the deal.II library.
7 //
8 // The deal.II library is free software; you can use it, redistribute
9 // it, and/or modify it under the terms of the GNU Lesser General
10 // Public License as published by the Free Software Foundation; either
11 // version 2.1 of the License, or (at your option) any later version.
12 // The full text of the license can be found in the file LICENSE at
13 // the top level of the deal.II distribution.
14 //
15 // ---------------------------------------------------------------------
16 
17 #ifndef __deal2__trilinos_solver_h
18 #define __deal2__trilinos_solver_h
19 
20 
21 #include <deal.II/base/config.h>
22 
23 #ifdef DEAL_II_WITH_TRILINOS
24 
25 # include <deal.II/base/std_cxx1x/shared_ptr.h>
26 # include <deal.II/lac/exceptions.h>
27 # include <deal.II/lac/solver_control.h>
28 # include <deal.II/lac/vector.h>
29 
30 # include <Epetra_LinearProblem.h>
31 # include <AztecOO.h>
32 # include <Epetra_Operator.h>
33 # include <Amesos.h>
34 
36 
37 namespace TrilinosWrappers
38 {
39  // forward declarations
40  class SparseMatrix;
41  class VectorBase;
42  class PreconditionBase;
43 
44 
65  class SolverBase
66  {
67  public:
68 
83  enum SolverName {cg, cgs, gmres, bicgstab, tfqmr} solver_name;
84 
92  {
106  AdditionalData (const bool output_solver_details = false,
107  const unsigned int gmres_restart_parameter = 30);
108 
115 
120  const unsigned int gmres_restart_parameter;
121  };
122 
129 
138  SolverBase (const enum SolverName solver_name,
139  SolverControl &cn);
140 
144  virtual ~SolverBase ();
145 
157  void
158  solve (const SparseMatrix &A,
159  VectorBase &x,
160  const VectorBase &b,
161  const PreconditionBase &preconditioner);
162 
177  void
178  solve (Epetra_Operator &A,
179  VectorBase &x,
180  const VectorBase &b,
181  const PreconditionBase &preconditioner);
182 
201  void
202  solve (const SparseMatrix &A,
203  ::Vector<double> &x,
204  const ::Vector<double> &b,
205  const PreconditionBase &preconditioner);
206 
227  void
228  solve (Epetra_Operator &A,
229  ::Vector<double> &x,
230  const ::Vector<double> &b,
231  const PreconditionBase &preconditioner);
232 
237  SolverControl &control() const;
238 
242  DeclException1 (ExcTrilinosError,
243  int,
244  << "An error with error number " << arg1
245  << " occurred while calling a Trilinos function");
246 
247  protected:
248 
262 
263  private:
264 
269  void execute_solve(const PreconditionBase &preconditioner);
270 
279  std_cxx1x::shared_ptr<Epetra_LinearProblem> linear_problem;
280 
286  AztecOO solver;
287 
293 
294  };
295 
296 
297 
305  class SolverCG : public SolverBase
306  {
307  public:
315  {
320  AdditionalData (const bool output_solver_details = false);
321 
328  };
329 
340  SolverCG (SolverControl &cn,
341  const AdditionalData &data = AdditionalData());
342 
343  protected:
349  };
350 
351 
352 
360  class SolverCGS : public SolverBase
361  {
362  public:
369  {
374  AdditionalData (const bool output_solver_details = false);
375 
382  };
383 
395  const AdditionalData &data = AdditionalData());
396 
397  protected:
403  };
404 
405 
406 
413  class SolverGMRES : public SolverBase
414  {
415  public:
422  {
429  AdditionalData (const bool output_solver_details = false,
430  const unsigned int restart_parameter = 30);
431 
438 
443  unsigned int restart_parameter;
444  };
445 
457  const AdditionalData &data = AdditionalData());
458 
459  protected:
465  };
466 
467 
468 
476  class SolverBicgstab : public SolverBase
477  {
478  public:
485  {
490  AdditionalData (const bool output_solver_details = false);
491 
498  };
499 
511  const AdditionalData &data = AdditionalData());
512 
513  protected:
519  };
520 
521 
522 
530  class SolverTFQMR : public SolverBase
531  {
532  public:
539  {
544  AdditionalData (const bool output_solver_details = false);
545 
552  };
553 
565  const AdditionalData &data = AdditionalData());
566 
567  protected:
573  };
574 
575 
576 
585  {
586  public:
587 
595  {
600  AdditionalData (const bool output_solver_details = false);
601 
608  };
609 
616  const AdditionalData &data = AdditionalData());
617 
621  virtual ~SolverDirect ();
622 
631  void
632  solve (const SparseMatrix &A,
633  VectorBase &x,
634  const VectorBase &b);
635 
654  void
655  solve (const SparseMatrix &A,
656  ::Vector<double> &x,
657  const ::Vector<double> &b);
658 
663  SolverControl &control() const;
664 
668  DeclException1 (ExcTrilinosError,
669  int,
670  << "An error with error number " << arg1
671  << " occurred while calling a Trilinos function");
672 
673  private:
674 
688 
697  std_cxx1x::shared_ptr<Epetra_LinearProblem> linear_problem;
698 
704  std_cxx1x::shared_ptr<Amesos_BaseSolver> solver;
705 
711 
712  };
713 
714 }
715 
716 DEAL_II_NAMESPACE_CLOSE
717 
718 #endif // DEAL_II_WITH_TRILINOS
719 
720 /*---------------------------- trilinos_solver.h ---------------------------*/
721 
722 #endif
723 /*---------------------------- trilinos_solver.h ---------------------------*/
SolverControl & control() const
const AdditionalData additional_data
const AdditionalData additional_data
const AdditionalData additional_data
const AdditionalData additional_data
void solve(const SparseMatrix &A, VectorBase &x, const VectorBase &b, const PreconditionBase &preconditioner)
SolverBase(SolverControl &cn)
std_cxx1x::shared_ptr< Epetra_LinearProblem > linear_problem
std_cxx1x::shared_ptr< Epetra_LinearProblem > linear_problem
const AdditionalData additional_data
void execute_solve(const PreconditionBase &preconditioner)
const AdditionalData additional_data
AdditionalData(const bool output_solver_details=false, const unsigned int gmres_restart_parameter=30)
const AdditionalData additional_data
DeclException1(ExcTrilinosError, int,<< "An error with error number "<< arg1<< " occurred while calling a Trilinos function")
std_cxx1x::shared_ptr< Amesos_BaseSolver > solver