This class provides a uniform interface for linear solvers. This base class is overloaded to provide linear solvers from different packages like PETSC or LASPACK.
Author:
Benjamin Kirk, 2003
Definition at line 53 of file linear_solver.h.
Member Typedef Documentation
typedef std::map<std::string, std::pair<unsigned int, unsigned int> > ReferenceCounter::Counts [protected, inherited]Data structure to log the information. The log is identified by the class name.
Definition at line 105 of file reference_counter.h.
Constructor & Destructor Documentation
template<typename T > LinearSolver< T >::LinearSolver () [inline]Constructor. Initializes Solver data structures
template<typename T > LinearSolver< T >::~LinearSolver () [inline, virtual]Destructor.
Definition at line 228 of file linear_solver.h.
{
this->clear ();
}
Member Function Documentation
template<typename T> void LinearSolver< T >::attach_preconditioner (Preconditioner< T > *preconditioner)Attaches a Preconditioner object to be used
Definition at line 103 of file linear_solver.C.
References libMesh::libMeshPrivateData::_is_initialized, and libMeshEnums::SHELL_PRECOND.
{
if(this->_is_initialized)
{
std::cerr<<'Preconditioner must be attached before the solver is initialized!'<<std::endl;
libmesh_error();
}
_preconditioner_type = SHELL_PRECOND;
_preconditioner = preconditioner;
}
template<typename T > AutoPtr< LinearSolver< T > > LinearSolver< T >::build (const SolverPackagesolver_package = libMesh::default_solver_package()) [static]Builds a LinearSolver using the linear solver package specified by solver_package
Definition at line 37 of file linear_solver.C.
References LASPACK_SOLVERS, libMeshEnums::PETSC_SOLVERS, and TRILINOS_SOLVERS.
template<typename T> virtual void LinearSolver< T >::clear () [inline, virtual]Release all memory and clear data structures.
Reimplemented in LaspackLinearSolver< T >, PetscLinearSolver< T >, and AztecLinearSolver< T >.
Definition at line 83 of file linear_solver.h.
{}
std::string ReferenceCounter::get_info () [static, inherited]Gets a string containing the reference information.
Definition at line 45 of file reference_counter.C.
References ReferenceCounter::_counts, and Quality::name().
Referenced by ReferenceCounter::print_info().
{
#if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG)
std::ostringstream out;
out << '
<< ' ----------------------------------------------------------------------------
<< '| Reference count information |
<< ' ---------------------------------------------------------------------------- ;
for (Counts::iterator it = _counts.begin();
it != _counts.end(); ++it)
{
const std::string name(it->first);
const unsigned int creations = it->second.first;
const unsigned int destructions = it->second.second;
out << '| ' << name << ' reference count information:
<< '| Creations: ' << creations << '
<< '| Destructions: ' << destructions << ';
}
out << ' ---------------------------------------------------------------------------- ;
return out.str();
#else
return '';
#endif
}
void 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 149 of file reference_counter.h.
References ReferenceCounter::_counts, Quality::name(), and Threads::spin_mtx.
Referenced by ReferenceCountedObject< Value >::ReferenceCountedObject().
void 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 167 of file reference_counter.h.
References ReferenceCounter::_counts, Quality::name(), and Threads::spin_mtx.
Referenced by ReferenceCountedObject< Value >::~ReferenceCountedObject().
template<typename T> virtual void LinearSolver< T >::init () [pure virtual]Initialize data structures if not done so already.
Implemented in LaspackLinearSolver< T >, PetscLinearSolver< T >, and AztecLinearSolver< T >.
template<typename T> bool LinearSolver< T >::initialized () const [inline]Returns:
true if the data structures are initialized, false otherwise.
Definition at line 78 of file linear_solver.h.
{ return _is_initialized; }
static unsigned int ReferenceCounter::n_objects () [inline, static, inherited]Prints the number of outstanding (created, but not yet destroyed) objects.
Definition at line 76 of file reference_counter.h.
References ReferenceCounter::_n_objects.
Referenced by System::read_serialized_blocked_dof_objects(), and System::write_serialized_blocked_dof_objects().
{ return _n_objects; }
template<typename T > PreconditionerType LinearSolver< T >::preconditioner_type () constReturns the type of preconditioner to use.
template<typename T> virtual void LinearSolver< T >::print_converged_reason () [pure virtual]Prints a useful message about why the latest linear solve con(di)verged.
Implemented in LaspackLinearSolver< T >, PetscLinearSolver< T >, and AztecLinearSolver< T >.
void ReferenceCounter::print_info () [static, inherited]Prints the reference information to std::cout.
Definition at line 83 of file reference_counter.C.
template<typename T> void LinearSolver< T >::set_solver_type (const SolverTypest) [inline]Sets the type of solver to use.
Definition at line 98 of file linear_solver.h.
{ _solver_type = st; }
template<typename T> virtual std::pair<unsigned int, Real> LinearSolver< T >::solve (SparseMatrix< T > &, SparseMatrix< T > &, NumericVector< T > &, NumericVector< T > &, const double, const unsignedint) [pure virtual]This function calls the solver '_solver_type' preconditioned with the '_preconditioner_type' preconditioner. Note that this method will compute the preconditioner from the system matrix.
Implemented in LaspackLinearSolver< T >, PetscLinearSolver< T >, and AztecLinearSolver< T >.
template<typename T> virtual std::pair<unsigned int, Real> LinearSolver< T >::solve (SparseMatrix< T > &, NumericVector< T > &, NumericVector< T > &, const double, const unsignedint) [pure virtual]This function calls the solver '_solver_type' preconditioned with the '_preconditioner_type' preconditioner. Note that this method will compute the preconditioner from the system matrix.
Implemented in LaspackLinearSolver< T >, PetscLinearSolver< T >, and AztecLinearSolver< T >.
template<typename T> virtual std::pair<unsigned int, Real> LinearSolver< T >::solve (const ShellMatrix< T > &shell_matrix, NumericVector< T > &, NumericVector< T > &, const double, const unsignedint) [pure virtual]This function solves a system whose matrix is a shell matrix.
Implemented in LaspackLinearSolver< T >, PetscLinearSolver< T >, and AztecLinearSolver< T >.
template<typename T> virtual std::pair<unsigned int, Real> LinearSolver< T >::solve (const ShellMatrix< T > &shell_matrix, const SparseMatrix< T > &precond_matrix, NumericVector< T > &, NumericVector< T > &, const double, const unsignedint) [pure 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.
Implemented in LaspackLinearSolver< T >, PetscLinearSolver< T >, and AztecLinearSolver< T >.
template<typename T> SolverType LinearSolver< T >::solver_type () const [inline]Returns the type of solver to use.
Definition at line 93 of file linear_solver.h.
{ return _solver_type; }
Member Data Documentation
ReferenceCounter::CountsReferenceCounter::_counts [static, protected, inherited]Actually holds the data.
Definition at line 110 of file reference_counter.h.
Referenced by ReferenceCounter::get_info(), ReferenceCounter::increment_constructor_count(), and ReferenceCounter::increment_destructor_count().
template<typename T> bool LinearSolver< T >::_is_initialized [protected]Flag indicating if the data structures have been initialized.
Definition at line 200 of file linear_solver.h.
Referenced by LinearSolver< Number >::initialized().
Definition at line 123 of file reference_counter.h.
Threads::atomic< unsigned int > ReferenceCounter::_n_objects [static, protected, inherited]The number of objects. Print the reference count information when the number returns to 0.
Definition at line 118 of file reference_counter.h.
Referenced by ReferenceCounter::n_objects(), ReferenceCounter::ReferenceCounter(), and ReferenceCounter::~ReferenceCounter().
template<typename T> Preconditioner<T>* LinearSolver< T >::_preconditioner [protected]Holds the Preconditioner object to be used for the linear solves.
Definition at line 205 of file linear_solver.h.
template<typename T> PreconditionerType LinearSolver< T >::_preconditioner_type [protected]Enum statitng with type of preconditioner to use.
Definition at line 195 of file linear_solver.h.
template<typename T> SolverType LinearSolver< T >::_solver_type [protected]Enum stating which type of iterative solver to use.
Definition at line 190 of file linear_solver.h.
Referenced by LinearSolver< Number >::set_solver_type(), and LinearSolver< Number >::solver_type().
template<typename T> bool LinearSolver< T >::same_preconditionerBoolean 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 182 of file linear_solver.h.
Author
Generated automatically by Doxygen for libMesh from the source code.