trilinos_aztec_linear_solver.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_AZTEC_LINEAR_SOLVER_H 00021 #define LIBMESH_TRILINOS_AZTEC_LINEAR_SOLVER_H 00022 00023 00024 00025 // Local includes 00026 #include "libmesh/libmesh_common.h" 00027 #include "libmesh/linear_solver.h" 00028 00032 #ifdef LIBMESH_HAVE_AZTECOO 00033 #include <Epetra_LinearProblem.h> 00034 #include <AztecOO.h> 00035 00036 // C++ includes 00037 #include <vector> 00038 00039 namespace libMesh 00040 { 00041 00050 template <typename T> 00051 class AztecLinearSolver : public LinearSolver<T> 00052 { 00053 public: 00057 AztecLinearSolver (); 00058 00062 ~AztecLinearSolver (); 00063 00067 void clear (); 00068 00072 void init (); 00073 00078 std::pair<unsigned int, Real> 00079 solve (SparseMatrix<T> &matrix_in, 00080 NumericVector<T> &solution_in, 00081 NumericVector<T> &rhs_in, 00082 const double tol, 00083 const unsigned int m_its) 00084 { 00085 return this->solve(matrix_in, matrix_in, solution_in, rhs_in, tol, m_its); 00086 } 00087 00094 std::pair<unsigned int, Real> 00095 solve (SparseMatrix<T> &matrix, 00096 SparseMatrix<T> &preconditioner, 00097 NumericVector<T> &solution, 00098 NumericVector<T> &rhs, 00099 const double tol, 00100 const unsigned int m_its); 00101 00105 std::pair<unsigned int, Real> 00106 solve (const ShellMatrix<T>& shell_matrix, 00107 NumericVector<T>& solution_in, 00108 NumericVector<T>& rhs_in, 00109 const double tol, 00110 const unsigned int m_its); 00111 00117 virtual std::pair<unsigned int, Real> 00118 solve (const ShellMatrix<T>& shell_matrix, 00119 const SparseMatrix<T>& precond_matrix, 00120 NumericVector<T>& solution_in, 00121 NumericVector<T>& rhs_in, 00122 const double tol, 00123 const unsigned int m_its); 00124 00129 void get_residual_history(std::vector<double>& hist); 00130 00137 Real get_initial_residual(); 00138 00143 virtual void print_converged_reason(); 00144 00145 private: 00146 00151 void set_solver_type (); 00152 00156 Epetra_LinearProblem * _linear_problem; 00157 00161 AztecOO * _linear_solver; 00162 }; 00163 00164 00165 /*----------------------- functions ----------------------------------*/ 00166 template <typename T> 00167 inline 00168 AztecLinearSolver<T>::AztecLinearSolver () 00169 { 00170 if (libMesh::n_processors() == 1) 00171 this->_preconditioner_type = ILU_PRECOND; 00172 else 00173 this->_preconditioner_type = BLOCK_JACOBI_PRECOND; 00174 } 00175 00176 00177 00178 template <typename T> 00179 inline 00180 AztecLinearSolver<T>::~AztecLinearSolver () 00181 { 00182 this->clear (); 00183 } 00184 00185 } // namespace libMesh 00186 00187 00188 00189 #endif // #ifdef LIBMESH_HAVE_AZTECOO 00190 #endif // LIBMESH_TRILINOS_AZTEC_LINEAR_SOLVER_H
Site Created By: libMesh Developers
Last modified: February 05 2013 19:54:49 UTC
Hosted By: