$extrastylesheet
00001 // The libMesh Finite Element Library. 00002 // Copyright (C) 2002-2014 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 #include "libmesh/auto_ptr.h" 00035 00036 // Trilinos includes 00037 #include "Epetra_Operator.h" 00038 #include "Epetra_FECrsMatrix.h" 00039 #include "Teuchos_ParameterList.hpp" 00040 00041 // C++ includes 00042 #include <cstddef> 00043 00044 namespace libMesh 00045 { 00046 00047 // forward declarations 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 (const libMesh::Parallel::Communicator &comm 00070 LIBMESH_CAN_DEFAULT_TO_COMMWORLD); 00071 00075 virtual ~TrilinosPreconditioner (); 00076 00081 virtual void apply(const NumericVector<T> & x, NumericVector<T> & y); 00082 00086 virtual void clear () {} 00087 00091 virtual void init (); 00092 00093 void set_params(Teuchos::ParameterList & list); 00094 00098 Epetra_FECrsMatrix * mat() { return _mat; } 00099 00102 void set_preconditioner_type (const PreconditionerType & preconditioner_type); 00103 00107 void compute(); 00108 00109 protected: 00110 00114 Epetra_Operator * _prec; 00115 00119 Epetra_FECrsMatrix * _mat; 00120 00124 Teuchos::ParameterList _param_list; 00125 00126 // Epetra_Operator interface 00127 virtual int SetUseTranspose(bool UseTranspose); 00128 virtual int Apply(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const; 00129 virtual int ApplyInverse(const Epetra_MultiVector &r, Epetra_MultiVector &z) const; 00130 virtual double NormInf() const; 00131 virtual const char *Label() const; 00132 virtual bool UseTranspose() const; 00133 virtual bool HasNormInf() const; 00134 virtual const Epetra_Comm &Comm() const; 00135 virtual const Epetra_Map &OperatorDomainMap() const; 00136 virtual const Epetra_Map &OperatorRangeMap() const; 00137 }; 00138 00139 00140 00141 00142 /*----------------------- inline functions ----------------------------------*/ 00143 template <typename T> 00144 inline 00145 TrilinosPreconditioner<T>::TrilinosPreconditioner (const libMesh::Parallel::Communicator &comm) : 00146 Preconditioner<T>(comm), 00147 _prec(NULL), 00148 _mat(NULL) 00149 { 00150 } 00151 00152 00153 00154 template <typename T> 00155 inline 00156 TrilinosPreconditioner<T>::~TrilinosPreconditioner () 00157 { 00158 this->clear (); 00159 } 00160 00161 } // namespace libMesh 00162 00163 #endif // #ifdef LIBMESH_HAVE_TRILINOS 00164 #endif // LIBMESH_TRILINOS_PRECONDITIONER_H