trilinos_preconditioner.h
Go to the documentation of this file.00001 // The libMesh Finite Element Library. 00002 // Copyright (C) 2002-2012 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner 00003 00004 // This library is free software; you can redistribute it and/or 00005 // modify it under the terms of the GNU Lesser General Public 00006 // License as published by the Free Software Foundation; either 00007 // version 2.1 of the License, or (at your option) any later version. 00008 00009 // This library is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 // Lesser General Public License for more details. 00013 00014 // You should have received a copy of the GNU Lesser General Public 00015 // License along with this library; if not, write to the Free Software 00016 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 00018 00019 00020 #ifndef LIBMESH_TRILINOS_PRECONDITIONER_H 00021 #define LIBMESH_TRILINOS_PRECONDITIONER_H 00022 00023 #include "libmesh/libmesh_config.h" 00024 00025 #ifdef LIBMESH_HAVE_TRILINOS 00026 00027 // Local includes 00028 #include "libmesh/preconditioner.h" 00029 #include "libmesh/libmesh_common.h" 00030 #include "libmesh/enum_solver_package.h" 00031 #include "libmesh/enum_preconditioner_type.h" 00032 #include "libmesh/reference_counted_object.h" 00033 #include "libmesh/libmesh.h" 00034 00035 // Trilinos includes 00036 #include "Epetra_Operator.h" 00037 #include "Epetra_FECrsMatrix.h" 00038 #include "Teuchos_ParameterList.hpp" 00039 00040 // C++ includes 00041 #include <cstddef> 00042 00043 namespace libMesh 00044 { 00045 00046 // forward declarations 00047 template <typename T> class AutoPtr; 00048 template <typename T> class SparseMatrix; 00049 template <typename T> class NumericVector; 00050 template <typename T> class ShellMatrix; 00051 00059 template <typename T> 00060 class TrilinosPreconditioner : 00061 public Preconditioner<T>, 00062 public Epetra_Operator 00063 { 00064 public: 00065 00069 TrilinosPreconditioner (); 00070 00074 virtual ~TrilinosPreconditioner (); 00075 00080 virtual void apply(const NumericVector<T> & x, NumericVector<T> & y); 00081 00085 virtual void clear () {} 00086 00090 virtual void init (); 00091 00092 void set_params(Teuchos::ParameterList & list); 00093 00097 Epetra_FECrsMatrix * mat() { return _mat; } 00098 00101 void set_preconditioner_type (const PreconditionerType & preconditioner_type); 00102 00106 void compute(); 00107 00108 protected: 00109 00113 Epetra_Operator * _prec; 00114 00118 Epetra_FECrsMatrix * _mat; 00119 00123 Teuchos::ParameterList _param_list; 00124 00125 // Epetra_Operator interface 00126 virtual int SetUseTranspose(bool UseTranspose); 00127 virtual int Apply(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const; 00128 virtual int ApplyInverse(const Epetra_MultiVector &r, Epetra_MultiVector &z) const; 00129 virtual double NormInf() const; 00130 virtual const char *Label() const; 00131 virtual bool UseTranspose() const; 00132 virtual bool HasNormInf() const; 00133 virtual const Epetra_Comm &Comm() const; 00134 virtual const Epetra_Map &OperatorDomainMap() const; 00135 virtual const Epetra_Map &OperatorRangeMap() const; 00136 }; 00137 00138 00139 00140 00141 /*----------------------- inline functions ----------------------------------*/ 00142 template <typename T> 00143 inline 00144 TrilinosPreconditioner<T>::TrilinosPreconditioner () : 00145 Preconditioner<T>(), 00146 _prec(NULL), 00147 _mat(NULL) 00148 { 00149 } 00150 00151 00152 00153 template <typename T> 00154 inline 00155 TrilinosPreconditioner<T>::~TrilinosPreconditioner () 00156 { 00157 this->clear (); 00158 } 00159 00160 } // namespace libMesh 00161 00162 #endif // #ifdef LIBMESH_HAVE_TRILINOS 00163 #endif // LIBMESH_TRILINOS_PRECONDITIONER_H
Site Created By: libMesh Developers
Last modified: February 05 2013 19:54:49 UTC
Hosted By: