HermesCommon  2.0
precond_ifpack.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://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_PRECOND_IFPACK_H_
23 #define __HERMES_COMMON_PRECOND_IFPACK_H_
24 #include "../config.h"
25 #ifdef HAVE_IFPACK
26 
27 #include "precond.h"
28 #include "epetra.h"
29 #include <Ifpack_Preconditioner.h>
30 
31 namespace Hermes
32 {
33  namespace Preconditioners
34  {
35  using namespace Hermes::Solvers;
39  template <typename Scalar>
40  class HERMES_API IfpackPrecond: public Precond<Scalar>
41  {
42  public:
47  IfpackPrecond(const char *cls, const char *type = "Jacobi");
52  IfpackPrecond(const char *cls, const char *type, int overlap);
54  IfpackPrecond(Ifpack_Preconditioner *ipc);
55  virtual ~IfpackPrecond();
56 
57  void set_param(const char *name, const char *value);
58  void set_param(const char *name, int value);
59  void set_param(const char *name, double value);
60  protected:
61 
62  virtual Epetra_Operator *get_obj() { return prec; }
63 
64  virtual void create(Matrix<Scalar> *mat);
65  virtual void destroy() { }
66  virtual void compute();
67 
68  // Epetra_Operator interface
69  virtual int ApplyInverse(const Epetra_MultiVector &r, Epetra_MultiVector &z) const;
70  virtual const Epetra_Comm &Comm() const;
71  virtual const Epetra_Map &OperatorDomainMap() const;
72  virtual const Epetra_Map &OperatorRangeMap() const;
73 
74  void create_point_relax(EpetraMatrix<Scalar> *a, const char *name);
75  void create_block_relax(EpetraMatrix<Scalar> *a, const char *name);
76  void create_add_schwartz(EpetraMatrix<Scalar> *a, const char *name, int overlap);
77  int initialize();
78  void apply_params();
79  Ifpack_Preconditioner *prec;
80  Teuchos::ParameterList ilist;
81  EpetraMatrix<Scalar> *mat;
82  unsigned owner:1;
83  const char *cls; // class of the preconditioner
84  const char *type;
85  int overlap;
86 
87  friend class AztecOOSolver<Scalar>;
88  };
89  }
90 }
91 #endif
92 #endif