HermesCommon  3.0
precond.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_PRECOND_H_
23 #define __HERMES_COMMON_PRECOND_H_
24 
25 #include "common.h" // Also includes preprocessor definitions for the various
26 // solver libraries via config.h.
27 
28 #include "algebra/matrix.h"
29 
30 #ifdef HAVE_EPETRA
31 #include <Epetra_Operator.h>
32 #endif
33 
34 using namespace Hermes::Algebra;
35 
36 namespace Hermes
37 {
39  namespace Preconditioners
40  {
43  {
44  Jacobi = 0,
45  MultiColoredSGS = 1,
46  ILU = 2,
47  MultiColoredILU = 3,
48  IC = 4,
49  AIChebyshev = 5,
50  MultiElimination = 6,
51  SaddlePoint = 7
52  };
53 
56  template <typename Scalar>
57  class Precond
58  {
59  public:
60  virtual ~Precond() {};
61  };
62 
65  template <typename Scalar>
66  class EpetraPrecond : public Precond < Scalar >
67 #ifdef HAVE_EPETRA
68  , public Epetra_Operator
69 #endif
70  {
71  public:
72  virtual void create(Matrix<Scalar> *mat) = 0;
73  virtual void destroy() = 0;
74  virtual void compute() = 0;
75  virtual void recompute() = 0;
76 
77 #ifdef HAVE_EPETRA
78  virtual Epetra_Operator *get_obj() = 0;
79 
80  // Epetra_Operator interface
81  virtual int SetUseTranspose(bool UseTranspose) { return 0; }
82  virtual int Apply(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const { return 0; }
83  virtual int ApplyInverse(const Epetra_MultiVector &r, Epetra_MultiVector &z) const { return 0; }
84  virtual double NormInf() const { return 0.0; }
85  virtual const char *Label() const { return nullptr; }
86  virtual bool UseTranspose() const { return false; }
87  virtual bool HasNormInf() const { return false; }
88  virtual const Epetra_Comm &Comm() const = 0;
89  virtual const Epetra_Map &OperatorDomainMap() const = 0;
90  virtual const Epetra_Map &OperatorRangeMap() const = 0;
91 #endif
92  };
93  }
94 }
95 #endif
General (abstract) matrix representation in Hermes.
Definition: matrix.h:36
General namespace for the Hermes library.
Abstract class to define interface for preconditioners.
Definition: precond.h:57
Namespace containing classes for vector / matrix operations.
PreconditionerType
The preconditioner type.
Definition: precond.h:42
Abstract class for Epetra preconditioners.
Definition: precond.h:66
Basic matrix classes and operations.
File containing common definitions, and basic global enums etc. for HermesCommon. ...