$extrastylesheet
laspack_linear_solver.h
Go to the documentation of this file.
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_LASPACK_LINEAR_SOLVER_H
00021 #define LIBMESH_LASPACK_LINEAR_SOLVER_H
00022 
00023 #include "libmesh/libmesh_common.h"
00024 
00025 #if defined(LIBMESH_HAVE_LASPACK)
00026 //#if defined(LIBMESH_HAVE_LASPACK) && !defined(LIBMESH_USE_COMPLEX_NUMBERS)
00027 
00028 // Laspack includes
00029 #include <itersolv.h>
00030 #include <rtc.h>
00031 #include <errhandl.h>
00032 
00033 // Local includes
00034 #include "libmesh/linear_solver.h"
00035 #include "libmesh/laspack_vector.h"
00036 #include "libmesh/laspack_matrix.h"
00037 
00038 // C++ includes
00039 
00040 namespace libMesh
00041 {
00042 
00043 
00044 
00052 template <typename T>
00053 class LaspackLinearSolver : public LinearSolver<T>
00054 {
00055 public:
00059   LaspackLinearSolver (const libMesh::Parallel::Communicator &comm
00060                        LIBMESH_CAN_DEFAULT_TO_COMMWORLD);
00061 
00065   ~LaspackLinearSolver ();
00066 
00070   void clear ();
00071 
00075   void init (const char* name = NULL);
00076 
00080   std::pair<unsigned int, Real>
00081   solve (SparseMatrix<T>  &matrix,
00082          NumericVector<T> &solution,
00083          NumericVector<T> &rhs,
00084          const double tol,
00085          const unsigned int m_its);
00086 
00090   std::pair<unsigned int, Real>
00091   adjoint_solve (SparseMatrix<T>  &matrix,
00092                  NumericVector<T> &solution,
00093                  NumericVector<T> &rhs,
00094                  const double tol,
00095                  const unsigned int m_its);
00096 
00100   std::pair<unsigned int, Real>
00101   solve (SparseMatrix<T>  &matrix,
00102          SparseMatrix<T>  &pc,
00103          NumericVector<T> &solution,
00104          NumericVector<T> &rhs,
00105          const double tol,
00106          const unsigned int m_its);
00107 
00111   std::pair<unsigned int, Real>
00112   solve (const ShellMatrix<T>& shell_matrix,
00113          NumericVector<T>& solution_in,
00114          NumericVector<T>& rhs_in,
00115          const double tol,
00116          const unsigned int m_its);
00117 
00123   virtual std::pair<unsigned int, Real>
00124   solve (const ShellMatrix<T>& shell_matrix,
00125          const SparseMatrix<T>& precond_matrix,
00126          NumericVector<T>& solution_in,
00127          NumericVector<T>& rhs_in,
00128          const double tol,
00129          const unsigned int m_its);
00130 
00135   virtual void print_converged_reason() const;
00136 
00140   virtual LinearConvergenceReason get_converged_reason() const;
00141 
00142 private:
00143 
00148   void set_laspack_preconditioner_type ();
00149 
00153   PrecondProcType _precond_type;
00154 };
00155 
00156 
00157 /*----------------------- functions ----------------------------------*/
00158 template <typename T>
00159 inline
00160 LaspackLinearSolver<T>::LaspackLinearSolver (const libMesh::Parallel::Communicator &comm) :
00161   LinearSolver<T>(comm),
00162   _precond_type (ILUPrecond)
00163 {
00164 }
00165 
00166 
00167 
00168 template <typename T>
00169 inline
00170 LaspackLinearSolver<T>::~LaspackLinearSolver ()
00171 {
00172   this->clear ();
00173 }
00174 
00175 
00176 
00177 template <typename T>
00178 inline
00179 std::pair<unsigned int, Real>
00180 LaspackLinearSolver<T>::solve (SparseMatrix<T>&,
00181                                SparseMatrix<T>&,
00182                                NumericVector<T>&,
00183                                NumericVector<T>&,
00184                                const double,
00185                                const unsigned int)
00186 {
00187   libmesh_error_msg("ERROR: LASPACK does not support a user-supplied preconditioner!");
00188 
00189   std::pair<unsigned int, Real> p;
00190   return p;
00191 }
00192 
00193 } // namespace libMesh
00194 
00195 #endif // #ifdef LIBMESH_HAVE_LASPACK
00196 #endif // LIBMESH_LASPACK_LINEAR_SOLVER_H