libMesh::AztecLinearSolver< T > Class Template Reference
#include <trilinos_aztec_linear_solver.h>

Public Member Functions | |
| AztecLinearSolver () | |
| ~AztecLinearSolver () | |
| void | clear () |
| void | init () |
| std::pair< unsigned int, Real > | solve (SparseMatrix< T > &matrix_in, NumericVector< T > &solution_in, NumericVector< T > &rhs_in, const double tol, const unsigned int m_its) |
| std::pair< unsigned int, Real > | solve (SparseMatrix< T > &matrix, SparseMatrix< T > &preconditioner, NumericVector< T > &solution, NumericVector< T > &rhs, const double tol, const unsigned int m_its) |
| std::pair< unsigned int, Real > | solve (const ShellMatrix< T > &shell_matrix, NumericVector< T > &solution_in, NumericVector< T > &rhs_in, const double tol, const unsigned int m_its) |
| virtual std::pair< unsigned int, Real > | solve (const ShellMatrix< T > &shell_matrix, const SparseMatrix< T > &precond_matrix, NumericVector< T > &solution_in, NumericVector< T > &rhs_in, const double tol, const unsigned int m_its) |
| void | get_residual_history (std::vector< double > &hist) |
| Real | get_initial_residual () |
| virtual void | print_converged_reason () |
| bool | initialized () const |
| SolverType | solver_type () const |
| void | set_solver_type (const SolverType st) |
| PreconditionerType | preconditioner_type () const |
| void | set_preconditioner_type (const PreconditionerType pct) |
| void | attach_preconditioner (Preconditioner< T > *preconditioner) |
| virtual void | reuse_preconditioner (bool) |
| bool | get_same_preconditioner () |
| virtual void | restrict_solve_to (const std::vector< unsigned int > *const dofs, const SubsetSolveMode subset_solve_mode=SUBSET_ZERO) |
| std::pair< unsigned int, Real > | solve (SparseMatrix< T > &matrix, SparseMatrix< T > *precond_matrix, NumericVector< T > &, NumericVector< T > &, const double, const unsigned int) |
| std::pair< unsigned int, Real > | solve (const ShellMatrix< T > &matrix, const SparseMatrix< T > *precond_matrix, NumericVector< T > &, NumericVector< T > &, const double, const unsigned int) |
| virtual std::pair< unsigned int, Real > | adjoint_solve (SparseMatrix< T > &, NumericVector< T > &, NumericVector< T > &, const double, const unsigned int) |
Static Public Member Functions | |
| static AutoPtr< LinearSolver< T > > | build (const SolverPackage solver_package=libMesh::default_solver_package()) |
| static std::string | get_info () |
| static void | print_info (std::ostream &out=libMesh::out) |
| static unsigned int | n_objects () |
| static void | enable_print_counter_info () |
| static void | disable_print_counter_info () |
Protected Types | |
| typedef std::map< std::string, std::pair< unsigned int, unsigned int > > | Counts |
Protected Member Functions | |
| void | increment_constructor_count (const std::string &name) |
| void | increment_destructor_count (const std::string &name) |
Protected Attributes | |
| SolverType | _solver_type |
| PreconditionerType | _preconditioner_type |
| bool | _is_initialized |
| Preconditioner< T > * | _preconditioner |
| bool | same_preconditioner |
Static Protected Attributes | |
| static Counts | _counts |
| static Threads::atomic < unsigned int > | _n_objects |
| static Threads::spin_mutex | _mutex |
| static bool | _enable_print_counter = true |
Private Member Functions | |
| void | set_solver_type () |
Private Attributes | |
| Epetra_LinearProblem * | _linear_problem |
| AztecOO * | _linear_solver |
Detailed Description
template<typename T>
class libMesh::AztecLinearSolver< T >
This class provides an interface to AztecOO iterative solvers that is compatible with the libMesh LinearSolver<>
Definition at line 51 of file trilinos_aztec_linear_solver.h.
Member Typedef Documentation
typedef std::map<std::string, std::pair<unsigned int, unsigned int> > libMesh::ReferenceCounter::Counts [protected, inherited] |
Data structure to log the information. The log is identified by the class name.
Definition at line 113 of file reference_counter.h.
Constructor & Destructor Documentation
| libMesh::AztecLinearSolver< T >::AztecLinearSolver | ( | ) | [inline] |
Constructor. Initializes Aztec data structures
Definition at line 168 of file trilinos_aztec_linear_solver.h.
References libMesh::LinearSolver< T >::_preconditioner_type, libMeshEnums::BLOCK_JACOBI_PRECOND, libMeshEnums::ILU_PRECOND, and libMesh::n_processors().
00169 { 00170 if (libMesh::n_processors() == 1) 00171 this->_preconditioner_type = ILU_PRECOND; 00172 else 00173 this->_preconditioner_type = BLOCK_JACOBI_PRECOND; 00174 }
| libMesh::AztecLinearSolver< T >::~AztecLinearSolver | ( | ) | [inline] |
Destructor.
Definition at line 180 of file trilinos_aztec_linear_solver.h.
References libMesh::AztecLinearSolver< T >::clear().
00181 { 00182 this->clear (); 00183 }
Member Function Documentation
| std::pair< unsigned int, Real > libMesh::LinearSolver< T >::adjoint_solve | ( | SparseMatrix< T > & | mat, | |
| NumericVector< T > & | sol, | |||
| NumericVector< T > & | rhs, | |||
| const double | tol, | |||
| const unsigned int | n_iter | |||
| ) | [inline, virtual, inherited] |
Function to solve the adjoint system. Note that this method will compute the preconditioner from the system matrix. This is not a pure virtual function and is defined linear_solver.C
Reimplemented in libMesh::LaspackLinearSolver< T >, and libMesh::PetscLinearSolver< T >.
Definition at line 137 of file linear_solver.C.
References libMesh::SparseMatrix< T >::close(), libMesh::SparseMatrix< T >::get_transpose(), and libMesh::LinearSolver< T >::solve().
Referenced by libMesh::ImplicitSystem::adjoint_solve().
00142 { 00143 // Log how long the linear solve takes. 00144 START_LOG("adjoint_solve()", "LinearSolver"); 00145 00146 // Take the discrete adjoint 00147 mat.close(); 00148 mat.get_transpose(mat); 00149 00150 // Call the solve function for the relevant linear algebra library and 00151 // solve the transpose matrix 00152 const std::pair<unsigned int, Real> totalrval = this->solve (mat, sol, rhs, tol, n_iter); 00153 00154 // Now transpose back and restore the original matrix 00155 // by taking the discrete adjoint 00156 mat.get_transpose(mat); 00157 00158 // Stop logging the nonlinear solve 00159 STOP_LOG("adjoint_solve()", "LinearSolver"); 00160 00161 return totalrval; 00162 00163 }
| void libMesh::LinearSolver< T >::attach_preconditioner | ( | Preconditioner< T > * | preconditioner | ) | [inline, inherited] |
Attaches a Preconditioner object to be used
Definition at line 105 of file linear_solver.C.
References libMesh::LinearSolver< T >::_is_initialized, libMesh::LinearSolver< T >::_preconditioner, libMesh::LinearSolver< T >::_preconditioner_type, libMesh::err, and libMeshEnums::SHELL_PRECOND.
00106 { 00107 if(this->_is_initialized) 00108 { 00109 libMesh::err<<"Preconditioner must be attached before the solver is initialized!"<<std::endl; 00110 libmesh_error(); 00111 } 00112 00113 _preconditioner_type = SHELL_PRECOND; 00114 _preconditioner = preconditioner; 00115 }
| AutoPtr< LinearSolver< T > > libMesh::LinearSolver< T >::build | ( | const SolverPackage | solver_package = libMesh::default_solver_package() |
) | [inline, static, inherited] |
Builds a LinearSolver using the linear solver package specified by solver_package
Definition at line 39 of file linear_solver.C.
References libMesh::err, libMesh::LASPACK_SOLVERS, libMeshEnums::PETSC_SOLVERS, and libMesh::TRILINOS_SOLVERS.
00040 { 00041 // Build the appropriate solver 00042 switch (solver_package) 00043 { 00044 00045 00046 #ifdef LIBMESH_HAVE_LASPACK 00047 case LASPACK_SOLVERS: 00048 { 00049 AutoPtr<LinearSolver<T> > ap(new LaspackLinearSolver<T>); 00050 return ap; 00051 } 00052 #endif 00053 00054 00055 #ifdef LIBMESH_HAVE_PETSC 00056 case PETSC_SOLVERS: 00057 { 00058 AutoPtr<LinearSolver<T> > ap(new PetscLinearSolver<T>); 00059 return ap; 00060 } 00061 #endif 00062 00063 00064 #ifdef LIBMESH_HAVE_TRILINOS 00065 case TRILINOS_SOLVERS: 00066 { 00067 AutoPtr<LinearSolver<T> > ap(new AztecLinearSolver<T>); 00068 return ap; 00069 } 00070 #endif 00071 00072 default: 00073 libMesh::err << "ERROR: Unrecognized solver package: " 00074 << solver_package 00075 << std::endl; 00076 libmesh_error(); 00077 } 00078 00079 AutoPtr<LinearSolver<T> > ap(NULL); 00080 return ap; 00081 }
| void libMesh::AztecLinearSolver< T >::clear | ( | ) | [inline, virtual] |
Release all memory and clear data structures.
Reimplemented from libMesh::LinearSolver< T >.
Definition at line 39 of file trilinos_aztec_linear_solver.C.
References libMesh::LinearSolver< T >::_is_initialized, libMesh::LinearSolver< T >::_preconditioner_type, libMesh::LinearSolver< T >::_solver_type, libMeshEnums::BLOCK_JACOBI_PRECOND, libMeshEnums::GMRES, libMeshEnums::ILU_PRECOND, libMesh::LinearSolver< T >::initialized(), and libMesh::n_processors().
Referenced by libMesh::AztecLinearSolver< T >::~AztecLinearSolver().
00040 { 00041 if (this->initialized()) 00042 { 00043 this->_is_initialized = false; 00044 00045 // Mimic PETSc default solver and preconditioner 00046 this->_solver_type = GMRES; 00047 00048 if (libMesh::n_processors() == 1) 00049 this->_preconditioner_type = ILU_PRECOND; 00050 else 00051 this->_preconditioner_type = BLOCK_JACOBI_PRECOND; 00052 } 00053 }
| void libMesh::ReferenceCounter::disable_print_counter_info | ( | ) | [static, inherited] |
Definition at line 106 of file reference_counter.C.
References libMesh::ReferenceCounter::_enable_print_counter.
00107 { 00108 _enable_print_counter = false; 00109 return; 00110 }
| void libMesh::ReferenceCounter::enable_print_counter_info | ( | ) | [static, inherited] |
Methods to enable/disable the reference counter output from print_info()
Definition at line 100 of file reference_counter.C.
References libMesh::ReferenceCounter::_enable_print_counter.
00101 { 00102 _enable_print_counter = true; 00103 return; 00104 }
| std::string libMesh::ReferenceCounter::get_info | ( | ) | [static, inherited] |
Gets a string containing the reference information.
Definition at line 47 of file reference_counter.C.
References libMesh::ReferenceCounter::_counts, and libMesh::Quality::name().
Referenced by libMesh::ReferenceCounter::print_info().
00048 { 00049 #if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG) 00050 00051 std::ostringstream oss; 00052 00053 oss << '\n' 00054 << " ---------------------------------------------------------------------------- \n" 00055 << "| Reference count information |\n" 00056 << " ---------------------------------------------------------------------------- \n"; 00057 00058 for (Counts::iterator it = _counts.begin(); 00059 it != _counts.end(); ++it) 00060 { 00061 const std::string name(it->first); 00062 const unsigned int creations = it->second.first; 00063 const unsigned int destructions = it->second.second; 00064 00065 oss << "| " << name << " reference count information:\n" 00066 << "| Creations: " << creations << '\n' 00067 << "| Destructions: " << destructions << '\n'; 00068 } 00069 00070 oss << " ---------------------------------------------------------------------------- \n"; 00071 00072 return oss.str(); 00073 00074 #else 00075 00076 return ""; 00077 00078 #endif 00079 }
| Real libMesh::AztecLinearSolver< T >::get_initial_residual | ( | ) | [inline] |
Returns just the initial residual for the solve just completed with this interface. Use this method instead of the one above if you just want the starting residual and not the entire history.
Definition at line 216 of file trilinos_aztec_linear_solver.C.
References libMesh::AztecLinearSolver< T >::_linear_solver.
00217 { 00218 return _linear_solver->TrueResidual(); 00219 }
| void libMesh::AztecLinearSolver< T >::get_residual_history | ( | std::vector< double > & | hist | ) | [inline] |
Fills the input vector with the sequence of residual norms from the latest iterative solve.
Definition at line 181 of file trilinos_aztec_linear_solver.C.
00182 { 00183 libmesh_not_implemented(); 00184 00185 // int ierr = 0; 00186 // int its = 0; 00187 00188 // // Fill the residual history vector with the residual norms 00189 // // Note that GetResidualHistory() does not copy any values, it 00190 // // simply sets the pointer p. Note that for some Krylov subspace 00191 // // methods, the number of residuals returned in the history 00192 // // vector may be different from what you are expecting. For 00193 // // example, TFQMR returns two residual values per iteration step. 00194 // PetscReal* p; 00195 // ierr = KSPGetResidualHistory(_ksp, &p, &its); 00196 // CHKERRABORT(libMesh::COMM_WORLD,ierr); 00197 00198 // // Check for early return 00199 // if (its == 0) return; 00200 00201 // // Create space to store the result 00202 // hist.resize(its); 00203 00204 // // Copy history into the vector provided by the user. 00205 // for (int i=0; i<its; ++i) 00206 // { 00207 // hist[i] = *p; 00208 // p++; 00209 // } 00210 }
| bool libMesh::LinearSolver< T >::get_same_preconditioner | ( | ) | [inline, inherited] |
Definition at line 285 of file linear_solver.h.
References libMesh::LinearSolver< T >::same_preconditioner.
00286 { 00287 return same_preconditioner; 00288 }
| void libMesh::ReferenceCounter::increment_constructor_count | ( | const std::string & | name | ) | [inline, protected, inherited] |
Increments the construction counter. Should be called in the constructor of any derived class that will be reference counted.
Definition at line 163 of file reference_counter.h.
References libMesh::ReferenceCounter::_counts, and libMesh::Threads::spin_mtx.
Referenced by libMesh::ReferenceCountedObject< RBParametrized >::ReferenceCountedObject().
00164 { 00165 Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx); 00166 std::pair<unsigned int, unsigned int>& p = _counts[name]; 00167 00168 p.first++; 00169 }
| void libMesh::ReferenceCounter::increment_destructor_count | ( | const std::string & | name | ) | [inline, protected, inherited] |
Increments the destruction counter. Should be called in the destructor of any derived class that will be reference counted.
Definition at line 176 of file reference_counter.h.
References libMesh::ReferenceCounter::_counts, and libMesh::Threads::spin_mtx.
Referenced by libMesh::ReferenceCountedObject< RBParametrized >::~ReferenceCountedObject().
00177 { 00178 Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx); 00179 std::pair<unsigned int, unsigned int>& p = _counts[name]; 00180 00181 p.second++; 00182 }
| void libMesh::AztecLinearSolver< T >::init | ( | ) | [inline, virtual] |
Initialize data structures if not done so already.
Implements libMesh::LinearSolver< T >.
Definition at line 58 of file trilinos_aztec_linear_solver.C.
References libMesh::LinearSolver< T >::_is_initialized, libMesh::AztecLinearSolver< T >::_linear_solver, libMesh::LinearSolver< T >::_preconditioner_type, libMeshEnums::BLOCK_JACOBI_PRECOND, libMeshEnums::ICC_PRECOND, libMeshEnums::ILU_PRECOND, libMesh::LinearSolver< T >::initialized(), libMeshEnums::LU_PRECOND, and libMesh::AztecLinearSolver< T >::set_solver_type().
Referenced by libMesh::AztecLinearSolver< T >::solve().
00059 { 00060 // Initialize the data structures if not done so already. 00061 if (!this->initialized()) 00062 { 00063 this->_is_initialized = true; 00064 00065 _linear_solver = new AztecOO(); 00066 00067 set_solver_type(); 00068 00069 switch(this->_preconditioner_type) 00070 { 00071 case ILU_PRECOND: 00072 _linear_solver->SetAztecOption(AZ_precond,AZ_dom_decomp); 00073 _linear_solver->SetAztecOption(AZ_subdomain_solve,AZ_ilu); 00074 break; 00075 00076 case BLOCK_JACOBI_PRECOND: 00077 _linear_solver->SetAztecOption(AZ_precond,AZ_Jacobi); 00078 break; 00079 00080 case ICC_PRECOND: 00081 _linear_solver->SetAztecOption(AZ_precond,AZ_dom_decomp); 00082 _linear_solver->SetAztecOption(AZ_subdomain_solve,AZ_icc); 00083 break; 00084 00085 case LU_PRECOND: 00086 _linear_solver->SetAztecOption(AZ_precond,AZ_dom_decomp); 00087 _linear_solver->SetAztecOption(AZ_subdomain_solve,AZ_lu); 00088 break; 00089 00090 default: 00091 _linear_solver->SetAztecOption(AZ_precond,AZ_dom_decomp); 00092 _linear_solver->SetAztecOption(AZ_subdomain_solve,AZ_ilu); 00093 } 00094 } 00095 }
| bool libMesh::LinearSolver< T >::initialized | ( | ) | const [inline, inherited] |
- Returns:
- true if the data structures are initialized, false otherwise.
Definition at line 81 of file linear_solver.h.
Referenced by libMesh::AztecLinearSolver< T >::clear(), libMesh::PetscLinearSolver< T >::clear(), libMesh::LaspackLinearSolver< T >::clear(), libMesh::AztecLinearSolver< T >::init(), libMesh::PetscLinearSolver< T >::init(), and libMesh::LaspackLinearSolver< T >::init().
00081 { return _is_initialized; }
| static unsigned int libMesh::ReferenceCounter::n_objects | ( | ) | [inline, static, inherited] |
Prints the number of outstanding (created, but not yet destroyed) objects.
Definition at line 79 of file reference_counter.h.
References libMesh::ReferenceCounter::_n_objects.
00080 { return _n_objects; }
| PreconditionerType libMesh::LinearSolver< T >::preconditioner_type | ( | ) | const [inline, inherited] |
Returns the type of preconditioner to use.
Definition at line 85 of file linear_solver.C.
References libMesh::LinearSolver< T >::_preconditioner, and libMesh::LinearSolver< T >::_preconditioner_type.
00086 { 00087 if(_preconditioner) 00088 return _preconditioner->type(); 00089 00090 return _preconditioner_type; 00091 }
| void libMesh::AztecLinearSolver< T >::print_converged_reason | ( | ) | [inline, virtual] |
Prints a useful message about why the latest linear solve con(di)verged.
Implements libMesh::LinearSolver< T >.
Definition at line 224 of file trilinos_aztec_linear_solver.C.
00225 { 00226 libmesh_not_implemented(); 00227 00228 // #if PETSC_VERSION_LESS_THAN(2,3,1) 00229 // libMesh::out << "This method is currently not supported " 00230 // << "(but may work!) for Petsc 2.3.0 and earlier." << std::endl; 00231 // #else 00232 // KSPConvergedReason reason; 00233 // KSPGetConvergedReason(_ksp, &reason); 00234 00235 // // KSP_CONVERGED_RTOL (residual 2-norm decreased by a factor of rtol, from 2-norm of right hand side) 00236 // // KSP_CONVERGED_ATOL (residual 2-norm less than abstol) 00237 // // KSP_CONVERGED_ITS (used by the preonly preconditioner that always uses ONE iteration) 00238 // // KSP_CONVERGED_STEP_LENGTH 00239 // // KSP_DIVERGED_ITS (required more than its to reach convergence) 00240 // // KSP_DIVERGED_DTOL (residual norm increased by a factor of divtol) 00241 // // KSP_DIVERGED_NAN (residual norm became Not-a-number likely do to 0/0) 00242 // // KSP_DIVERGED_BREAKDOWN (generic breakdown in method) 00243 00244 // switch (reason) 00245 // { 00246 // case KSP_CONVERGED_RTOL: 00247 // { 00248 // libMesh::out << "Linear solver converged, relative tolerance reached." << std::endl; 00249 // break; 00250 // } 00251 // case KSP_CONVERGED_ATOL: 00252 // { 00253 // libMesh::out << "Linear solver converged, absolute tolerance reached." << std::endl; 00254 // break; 00255 // } 00256 00257 // // Divergence 00258 // case KSP_DIVERGED_ITS: 00259 // { 00260 // libMesh::out << "Linear solver diverged, max no. of iterations reached." << std::endl; 00261 // break; 00262 // } 00263 // case KSP_DIVERGED_DTOL: 00264 // { 00265 // libMesh::out << "Linear solver diverged, residual norm increase by dtol (default 1.e5)." << std::endl; 00266 // break; 00267 // } 00268 // case KSP_DIVERGED_NAN: 00269 // { 00270 // libMesh::out << "Linear solver diverged, residual norm is NaN." << std::endl; 00271 // break; 00272 // } 00273 // case KSP_DIVERGED_BREAKDOWN: 00274 // { 00275 // libMesh::out << "Linear solver diverged, generic breakdown in the method." << std::endl; 00276 // break; 00277 // } 00278 // default: 00279 // { 00280 // libMesh::out << "Unknown/unsupported con(di)vergence reason: " << reason << std::endl; 00281 // } 00282 // } 00283 // #endif 00284 }
| void libMesh::ReferenceCounter::print_info | ( | std::ostream & | out = libMesh::out |
) | [static, inherited] |
Prints the reference information, by default to libMesh::out.
Definition at line 88 of file reference_counter.C.
References libMesh::ReferenceCounter::_enable_print_counter, and libMesh::ReferenceCounter::get_info().
00089 { 00090 if( _enable_print_counter ) out_stream << ReferenceCounter::get_info(); 00091 }
| void libMesh::LinearSolver< T >::restrict_solve_to | ( | const std::vector< unsigned int > *const | dofs, | |
| const SubsetSolveMode | subset_solve_mode = SUBSET_ZERO | |||
| ) | [inline, virtual, inherited] |
After calling this method, all successive solves will be restricted to the given set of dofs, which must contain local dofs on each processor only and not contain any duplicates. This mode can be disabled by calling this method with dofs being a NULL pointer.
Reimplemented in libMesh::PetscLinearSolver< T >.
Definition at line 126 of file linear_solver.C.
| void libMesh::LinearSolver< T >::reuse_preconditioner | ( | bool | reuse_flag | ) | [inline, virtual, inherited] |
Definition at line 119 of file linear_solver.C.
References libMesh::LinearSolver< T >::same_preconditioner.
Referenced by libMesh::ImplicitSystem::disable_cache().
00120 { 00121 same_preconditioner = reuse_flag; 00122 }
| void libMesh::LinearSolver< T >::set_preconditioner_type | ( | const PreconditionerType | pct | ) | [inline, inherited] |
Sets the type of preconditioner to use.
Definition at line 95 of file linear_solver.C.
References libMesh::LinearSolver< T >::_preconditioner, and libMesh::LinearSolver< T >::_preconditioner_type.
00096 { 00097 if(_preconditioner) 00098 _preconditioner->set_type(pct); 00099 else 00100 _preconditioner_type = pct; 00101 }
| void libMesh::LinearSolver< T >::set_solver_type | ( | const SolverType | st | ) | [inline, inherited] |
Sets the type of solver to use.
Definition at line 101 of file linear_solver.h.
00102 { _solver_type = st; }
| void libMesh::AztecLinearSolver< T >::set_solver_type | ( | ) | [inline, private] |
Tells AztecOO to use the user-specified solver stored in _solver_type
Definition at line 287 of file trilinos_aztec_linear_solver.C.
References libMesh::AztecLinearSolver< T >::_linear_solver, libMesh::LinearSolver< T >::_solver_type, libMeshEnums::BICGSTAB, libMeshEnums::CG, libMeshEnums::CGS, libMesh::err, libMeshEnums::GMRES, and libMeshEnums::TFQMR.
Referenced by libMesh::AztecLinearSolver< T >::init().
00288 { 00289 switch (this->_solver_type) 00290 { 00291 case CG: 00292 _linear_solver->SetAztecOption(AZ_solver, AZ_cg); return; 00293 00294 case CGS: 00295 _linear_solver->SetAztecOption(AZ_solver, AZ_cgs); return; 00296 00297 case TFQMR: 00298 _linear_solver->SetAztecOption(AZ_solver, AZ_tfqmr); return; 00299 00300 case BICGSTAB: 00301 _linear_solver->SetAztecOption(AZ_solver, AZ_bicgstab); return; 00302 00303 case GMRES: 00304 _linear_solver->SetAztecOption(AZ_solver, AZ_gmres); return; 00305 00306 default: 00307 libMesh::err << "ERROR: Unsupported AztecOO Solver: " 00308 << this->_solver_type << std::endl 00309 << "Continuing with AztecOO defaults" << std::endl; 00310 } 00311 }
| std::pair< unsigned int, Real > libMesh::LinearSolver< T >::solve | ( | const ShellMatrix< T > & | matrix, | |
| const SparseMatrix< T > * | precond_matrix, | |||
| NumericVector< T > & | sol, | |||
| NumericVector< T > & | rhs, | |||
| const double | tol, | |||
| const unsigned int | n_iter | |||
| ) | [inline, inherited] |
This function solves a system whose matrix is a shell matrix, but an optional sparse matrix may be used as preconditioning matrix.
Definition at line 310 of file linear_solver.h.
References libMesh::LinearSolver< T >::solve().
| std::pair< unsigned int, Real > libMesh::LinearSolver< T >::solve | ( | SparseMatrix< T > & | matrix, | |
| SparseMatrix< T > * | precond_matrix, | |||
| NumericVector< T > & | sol, | |||
| NumericVector< T > & | rhs, | |||
| const double | tol, | |||
| const unsigned int | n_iter | |||
| ) | [inline, inherited] |
This function calls the solver "_solver_type" preconditioned with the "_preconditioner_type" preconditioner. The preconditioning matrix is used if it is provided, or the system matrix is used if precond_matrix is null
Definition at line 293 of file linear_solver.h.
References libMesh::LinearSolver< T >::solve().
| std::pair< unsigned int, Real > libMesh::AztecLinearSolver< T >::solve | ( | const ShellMatrix< T > & | shell_matrix, | |
| const SparseMatrix< T > & | precond_matrix, | |||
| NumericVector< T > & | solution_in, | |||
| NumericVector< T > & | rhs_in, | |||
| const double | tol, | |||
| const unsigned int | m_its | |||
| ) | [inline, virtual] |
This function solves a system whose matrix is a shell matrix, but a sparse matrix is used as preconditioning matrix, this allowing other preconditioners than JACOBI.
Implements libMesh::LinearSolver< T >.
Definition at line 162 of file trilinos_aztec_linear_solver.C.
| std::pair< unsigned int, Real > libMesh::AztecLinearSolver< T >::solve | ( | const ShellMatrix< T > & | shell_matrix, | |
| NumericVector< T > & | solution_in, | |||
| NumericVector< T > & | rhs_in, | |||
| const double | tol, | |||
| const unsigned int | m_its | |||
| ) | [inline, virtual] |
This function solves a system whose matrix is a shell matrix.
Implements libMesh::LinearSolver< T >.
Definition at line 144 of file trilinos_aztec_linear_solver.C.
| std::pair< unsigned int, Real > libMesh::AztecLinearSolver< T >::solve | ( | SparseMatrix< T > & | matrix, | |
| SparseMatrix< T > & | preconditioner, | |||
| NumericVector< T > & | solution, | |||
| NumericVector< T > & | rhs, | |||
| const double | tol, | |||
| const unsigned int | m_its | |||
| ) | [inline, virtual] |
This method allows you to call a linear solver while specifying the matrix to use as the (left) preconditioning matrix. Note that the linear solver will not compute a preconditioner in this case, and will instead premultiply by the matrix you provide.
Implements libMesh::LinearSolver< T >.
Definition at line 102 of file trilinos_aztec_linear_solver.C.
References libMesh::AztecLinearSolver< T >::_linear_solver, libMesh::EpetraMatrix< T >::close(), libMesh::AztecLinearSolver< T >::init(), and libMesh::EpetraMatrix< T >::mat().
00108 { 00109 START_LOG("solve()", "AztecLinearSolver"); 00110 00111 // Make sure the data passed in are really of Epetra types 00112 EpetraMatrix<T>* matrix = libmesh_cast_ptr<EpetraMatrix<T>*>(&matrix_in); 00113 EpetraMatrix<T>* precond = libmesh_cast_ptr<EpetraMatrix<T>*>(&precond_in); 00114 EpetraVector<T>* solution = libmesh_cast_ptr<EpetraVector<T>*>(&solution_in); 00115 EpetraVector<T>* rhs = libmesh_cast_ptr<EpetraVector<T>*>(&rhs_in); 00116 00117 this->init(); 00118 00119 // Close the matrices and vectors in case this wasn't already done. 00120 matrix->close (); 00121 precond->close (); 00122 solution->close (); 00123 rhs->close (); 00124 00125 _linear_solver->SetAztecOption(AZ_max_iter,m_its); 00126 _linear_solver->SetAztecParam(AZ_tol,tol); 00127 00128 Epetra_FECrsMatrix * emat = matrix->mat(); 00129 Epetra_Vector * esol = solution->vec(); 00130 Epetra_Vector * erhs = rhs->vec(); 00131 00132 _linear_solver->Iterate(emat, esol, erhs, m_its, tol); 00133 00134 STOP_LOG("solve()", "AztecLinearSolver"); 00135 00136 // return the # of its. and the final residual norm. 00137 return std::make_pair(_linear_solver->NumIters(), _linear_solver->TrueResidual()); 00138 }
| std::pair<unsigned int, Real> libMesh::AztecLinearSolver< T >::solve | ( | SparseMatrix< T > & | matrix_in, | |
| NumericVector< T > & | solution_in, | |||
| NumericVector< T > & | rhs_in, | |||
| const double | tol, | |||
| const unsigned int | m_its | |||
| ) | [inline, virtual] |
Call the Aztec solver. It calls the method below, using the same matrix for the system and preconditioner matrices.
Implements libMesh::LinearSolver< T >.
Definition at line 79 of file trilinos_aztec_linear_solver.h.
00084 { 00085 return this->solve(matrix_in, matrix_in, solution_in, rhs_in, tol, m_its); 00086 }
| SolverType libMesh::LinearSolver< T >::solver_type | ( | ) | const [inline, inherited] |
Returns the type of solver to use.
Definition at line 96 of file linear_solver.h.
00096 { return _solver_type; }
Member Data Documentation
ReferenceCounter::Counts libMesh::ReferenceCounter::_counts [static, protected, inherited] |
Actually holds the data.
Definition at line 118 of file reference_counter.h.
Referenced by libMesh::ReferenceCounter::get_info(), libMesh::ReferenceCounter::increment_constructor_count(), and libMesh::ReferenceCounter::increment_destructor_count().
bool libMesh::ReferenceCounter::_enable_print_counter = true [static, protected, inherited] |
Flag to control whether reference count information is printed when print_info is called.
Definition at line 137 of file reference_counter.h.
Referenced by libMesh::ReferenceCounter::disable_print_counter_info(), libMesh::ReferenceCounter::enable_print_counter_info(), and libMesh::ReferenceCounter::print_info().
bool libMesh::LinearSolver< T >::_is_initialized [protected, inherited] |
Flag indicating if the data structures have been initialized.
Definition at line 242 of file linear_solver.h.
Referenced by libMesh::LinearSolver< T >::attach_preconditioner(), libMesh::AztecLinearSolver< T >::clear(), libMesh::PetscLinearSolver< T >::clear(), libMesh::LaspackLinearSolver< T >::clear(), libMesh::AztecLinearSolver< T >::init(), libMesh::PetscLinearSolver< T >::init(), libMesh::LaspackLinearSolver< T >::init(), and libMesh::LinearSolver< Number >::initialized().
Epetra_LinearProblem* libMesh::AztecLinearSolver< T >::_linear_problem [private] |
The Epetra linear problem object.
Definition at line 156 of file trilinos_aztec_linear_solver.h.
AztecOO* libMesh::AztecLinearSolver< T >::_linear_solver [private] |
The AztecOO solver object
Definition at line 161 of file trilinos_aztec_linear_solver.h.
Referenced by libMesh::AztecLinearSolver< T >::get_initial_residual(), libMesh::AztecLinearSolver< T >::init(), libMesh::AztecLinearSolver< T >::set_solver_type(), and libMesh::AztecLinearSolver< T >::solve().
Threads::spin_mutex libMesh::ReferenceCounter::_mutex [static, protected, inherited] |
Mutual exclusion object to enable thread-safe reference counting.
Definition at line 131 of file reference_counter.h.
Threads::atomic< unsigned int > libMesh::ReferenceCounter::_n_objects [static, protected, inherited] |
The number of objects. Print the reference count information when the number returns to 0.
Definition at line 126 of file reference_counter.h.
Referenced by libMesh::ReferenceCounter::n_objects(), libMesh::ReferenceCounter::ReferenceCounter(), and libMesh::ReferenceCounter::~ReferenceCounter().
Preconditioner<T>* libMesh::LinearSolver< T >::_preconditioner [protected, inherited] |
Holds the Preconditioner object to be used for the linear solves.
Definition at line 247 of file linear_solver.h.
Referenced by libMesh::PetscLinearSolver< T >::adjoint_solve(), libMesh::LinearSolver< T >::attach_preconditioner(), libMesh::PetscLinearSolver< T >::clear(), libMesh::PetscLinearSolver< T >::init(), libMesh::LinearSolver< T >::preconditioner_type(), libMesh::LinearSolver< T >::set_preconditioner_type(), and libMesh::PetscLinearSolver< T >::solve().
PreconditionerType libMesh::LinearSolver< T >::_preconditioner_type [protected, inherited] |
Enum statitng with type of preconditioner to use.
Definition at line 237 of file linear_solver.h.
Referenced by libMesh::LinearSolver< T >::attach_preconditioner(), libMesh::AztecLinearSolver< T >::AztecLinearSolver(), libMesh::AztecLinearSolver< T >::clear(), libMesh::PetscLinearSolver< T >::clear(), libMesh::LaspackLinearSolver< T >::clear(), libMesh::AztecLinearSolver< T >::init(), libMesh::PetscLinearSolver< T >::init(), libMesh::PetscLinearSolver< T >::PetscLinearSolver(), libMesh::LinearSolver< T >::preconditioner_type(), libMesh::LaspackLinearSolver< T >::set_laspack_preconditioner_type(), and libMesh::LinearSolver< T >::set_preconditioner_type().
SolverType libMesh::LinearSolver< T >::_solver_type [protected, inherited] |
Enum stating which type of iterative solver to use.
Definition at line 232 of file linear_solver.h.
Referenced by libMesh::LaspackLinearSolver< T >::adjoint_solve(), libMesh::AztecLinearSolver< T >::clear(), libMesh::PetscLinearSolver< T >::clear(), libMesh::LaspackLinearSolver< T >::clear(), libMesh::PetscLinearSolver< T >::set_petsc_solver_type(), libMesh::AztecLinearSolver< T >::set_solver_type(), libMesh::LinearSolver< Number >::set_solver_type(), libMesh::LaspackLinearSolver< T >::solve(), and libMesh::LinearSolver< Number >::solver_type().
bool libMesh::LinearSolver< T >::same_preconditioner [protected, inherited] |
Boolean flag to indicate whether we want to use an identical preconditioner to the previous solve. This can save substantial work in the cases where the system matrix is the same for successive solves.
Definition at line 255 of file linear_solver.h.
Referenced by libMesh::PetscLinearSolver< T >::adjoint_solve(), libMesh::LinearSolver< T >::get_same_preconditioner(), libMesh::LinearSolver< T >::reuse_preconditioner(), and libMesh::PetscLinearSolver< T >::solve().
The documentation for this class was generated from the following files:
Site Created By: libMesh Developers
Last modified: February 05 2013 19:55:41 UTC
Hosted By: