HermesCommon 1.0
precond.h
Go to the documentation of this file.
00001 // This file is part of HermesCommon
00002 //
00003 // Copyright (c) 2009 hp-FEM group at the University of Nevada, Reno (UNR).
00004 // Email: hpfem-group@unr.edu, home page: http://hpfem.org/.
00005 //
00006 // Hermes2D is free software; you can redistribute it and/or modify
00007 // it under the terms of the GNU General Public License as published
00008 // by the Free Software Foundation; either version 2 of the License,
00009 // or (at your option) any later version.
00010 //
00011 // Hermes2D is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // GNU General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU General Public License
00017 // along with Hermes2D; if not, write to the Free Software
00018 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00022 #ifndef __HERMES_COMMON_PRECOND_H_
00023 #define __HERMES_COMMON_PRECOND_H_
00024 
00025 #include "common.h"  // Also includes preprocessor definitions for the various
00026 // solver libraries via config.h.
00027 
00028 #include "matrix.h"
00029 
00030 #ifdef HAVE_EPETRA
00031 #include <Epetra_Operator.h>
00032 #endif
00033 
00034 using namespace Hermes::Algebra;
00035 
00036 namespace Hermes
00037 {
00039   namespace Preconditioners
00040   {
00044     template <typename Scalar>
00045     class Precond
00046 #ifdef HAVE_EPETRA
00047       : public Epetra_Operator
00048 #endif
00049     {
00050     public:
00051       virtual void create(Matrix<Scalar> *mat) = 0;
00052       virtual void destroy() = 0;
00053       virtual void compute() = 0;
00054 
00055 #ifdef HAVE_EPETRA
00056       virtual Epetra_Operator *get_obj() = 0;
00057 
00058       // Epetra_Operator interface
00059       virtual int SetUseTranspose(bool UseTranspose) { return 0; }
00060       virtual int Apply(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const { return 0; }
00061       virtual int ApplyInverse(const Epetra_MultiVector &r, Epetra_MultiVector &z) const { return 0; }
00062       virtual double NormInf() const { return 0.0; }
00063       virtual const char *Label() const { return NULL; }
00064       virtual bool UseTranspose() const { return false; }
00065       virtual bool HasNormInf() const { return false; }
00066       virtual const Epetra_Comm &Comm() const = 0;
00067       virtual const Epetra_Map &OperatorDomainMap() const = 0;
00068       virtual const Epetra_Map &OperatorRangeMap() const = 0;
00069 #endif
00070     };
00071   }
00072 }
00073 #endif