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_PRECONDITIONER_H 00021 #define LIBMESH_PRECONDITIONER_H 00022 00023 00024 // Local includes 00025 #include "libmesh/libmesh_common.h" 00026 #include "libmesh/enum_solver_package.h" 00027 #include "libmesh/enum_solver_type.h" 00028 #include "libmesh/enum_preconditioner_type.h" 00029 #include "libmesh/reference_counted_object.h" 00030 #include "libmesh/libmesh.h" 00031 00032 // C++ includes 00033 #include <cstddef> 00034 00035 namespace libMesh 00036 { 00037 00038 // forward declarations 00039 template <typename T> class AutoPtr; 00040 template <typename T> class SparseMatrix; 00041 template <typename T> class NumericVector; 00042 template <typename T> class ShellMatrix; 00043 00044 00045 00046 00047 00060 template <typename T> 00061 class Preconditioner : public ReferenceCountedObject<Preconditioner<T> > 00062 { 00063 public: 00064 00068 Preconditioner (); 00069 00073 virtual ~Preconditioner (); 00074 00079 static Preconditioner<T> * build(const SolverPackage solver_package = 00080 libMesh::default_solver_package()); 00081 00086 bool initialized () const { return _is_initialized; } 00087 00092 virtual void apply(const NumericVector<T> & x, NumericVector<T> & y) = 0; 00093 00097 virtual void clear () {} 00098 00104 virtual void init () {} 00105 00111 virtual void setup () {} 00112 00116 void set_matrix(SparseMatrix<Number> & mat); 00117 00121 PreconditionerType type () const 00122 { return _preconditioner_type; } 00123 00127 void set_type (const PreconditionerType pct); 00128 00129 protected: 00130 00135 SparseMatrix<T> * _matrix; 00136 00140 PreconditionerType _preconditioner_type; 00141 00145 bool _is_initialized; 00146 }; 00147 00148 00149 00150 00151 /*----------------------- inline functions ----------------------------------*/ 00152 template <typename T> 00153 inline 00154 Preconditioner<T>::Preconditioner () : 00155 _matrix(NULL), 00156 _preconditioner_type (ILU_PRECOND), 00157 _is_initialized (false) 00158 { 00159 } 00160 00161 00162 00163 template <typename T> 00164 inline 00165 Preconditioner<T>::~Preconditioner () 00166 { 00167 this->clear (); 00168 } 00169 00170 template <typename T> 00171 void 00172 Preconditioner<T>::set_matrix(SparseMatrix<Number> & mat) 00173 { 00174 //If the matrix is changing then we (probably) need to reinitialize. 00175 _is_initialized = false; 00176 _matrix = &mat; 00177 } 00178 00179 template <typename T> 00180 void 00181 Preconditioner<T>::set_type (const PreconditionerType pct) 00182 { 00183 //If the preconditioner type changes we (probably) need to reinitialize. 00184 _is_initialized = false; 00185 _preconditioner_type = pct; 00186 } 00187 00188 } // namespace libMesh 00189 00190 00191 #endif // LIBMESH_PRECONDITIONER_H
Site Created By: libMesh Developers
Last modified: February 05 2013 19:54:48 UTC
Hosted By: