HermesCommon  3.0
aztecoo_solver.h
Go to the documentation of this file.
1 // This file is part of HermesCommon
2 //
3 // Copyright (c) 2009 hp-FEM group at the University of Nevada, Reno (UNR).
4 // Email: hpfem-group@unr.edu, home page: http://www.hpfem.org/.
5 //
6 // Hermes2D is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published
8 // by the Free Software Foundation; either version 2 of the License,
9 // or (at your option) any later version.
10 //
11 // Hermes2D is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with Hermes2D; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 #ifndef __HERMES_COMMON_AZTECOO_SOLVER_H_
23 #define __HERMES_COMMON_AZTECOO_SOLVER_H_
24 #include "../../config.h"
25 #ifdef HAVE_AZTECOO
26 #include "epetra.h"
28 #include "precond_ifpack.h"
29 #include "precond_ml.h"
30 #include <AztecOO.h>
31 #include <EpetraExt_Permutation.h>
32 
33 namespace Hermes
34 {
35  namespace Solvers
36  {
39  template <typename Scalar>
40  class HERMES_API AztecOOSolver : public IterSolver < Scalar >
41  {
42  public:
44  void free();
45  virtual ~AztecOOSolver();
46 
49  void set_solver(const char *solver);
52  void set_tolerance(double tol);
55  void set_max_iters(int iters);
56 
59  virtual void set_precond(const char *name);
60 
63  virtual void set_precond(Precond<Scalar> *pc);
64 
65  virtual void set_reuse_scheme(MatrixStructureReuseScheme reuse_scheme);
66 
67  virtual void use_node_wise_ordering(unsigned int num_pdes);
68  virtual void use_equations_wise_ordering();
69 
70  virtual void solve();
71  virtual void solve(Scalar* initial_guess);
72 
73  virtual int get_matrix_size();
74 
75  virtual int get_num_iters();
76  virtual double get_residual_norm();
77 
79  void set_option(int option, int value);
80 
82  void set_param(int param, double value);
83 
84  protected:
86  AztecOO aztec;
89 
90  int *row_perm;
91  int *col_perm;
92  EpetraExt::Permutation<Epetra_CrsMatrix> *P;
93  EpetraExt::Permutation<Epetra_CrsMatrix> *Q;
94  EpetraMatrix<Scalar> *final_matrix;
95 
96  void create_permutation_vectors();
97  void free_permutation_data();
98 
100 
101  template<typename T> friend LinearMatrixSolver<T>* create_linear_solver(Matrix<T>* matrix, Vector<T>* rhs, bool use_direct_solver);
102  };
103  }
104 }
105 #endif
106 #endif
General (abstract) matrix representation in Hermes.
Definition: matrix.h:36
General namespace for the Hermes library.
Linear matrix solver functionality.
Encapsulation of AztecOO linear solver.
General (abstract) vector representation in Hermes.
Abstract class to define interface for preconditioners.
Definition: precond.h:57
AztecOO aztec
Instance of the Aztec solver.
IFPACK (Trilinos package) preconditioners interface.
Abstract class for Epetra preconditioners.
Definition: precond.h:66
HERMES_API LinearMatrixSolver< Scalar > * create_linear_solver(Matrix< Scalar > *matrix, Vector< Scalar > *rhs, bool use_direct_solver=false)
Function returning a solver according to the users's choice.
Abstract class for defining solver interface.
Abstract class for defining interface for iterative solvers. Internal, though utilizable for defining...
EpetraMatrix and EpetraVector storage classes for Amesos, AztecOO, ... .
ML (Trilinos package) preconditioners interface.