#include <laspack_linear_solver.h>
LaspackLinearSolver ()
~LaspackLinearSolver ()
void clear ()
void init ()
std::pair< unsigned int, Real > solve (SparseMatrix< T > &matrix, NumericVector< T > &solution, NumericVector< T > &rhs, const double tol, const unsigned int m_its)
std::pair< unsigned int, Real > solve (SparseMatrix< T > &matrix, SparseMatrix< T > &pc, 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)
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)
static AutoPtr< LinearSolver< T > > build (const SolverPackage solver_package=libMesh::default_solver_package())
static std::string get_info ()
static void print_info ()
static unsigned int n_objects ()
typedef std::map< std::string, std::pair< unsigned int, unsigned int > > Counts
void increment_constructor_count (const std::string &name)
void increment_destructor_count (const std::string &name)
SolverType _solver_type
PreconditionerType _preconditioner_type
bool _is_initialized
Preconditioner< T > * _preconditioner
static Counts _counts
static Threads::atomic< unsigned int > _n_objects
static Threads::spin_mutex _mutex
void set_laspack_preconditioner_type ()
Author:
Definition at line 53 of file laspack_linear_solver.h.
Definition at line 105 of file reference_counter.h.
Definition at line 144 of file laspack_linear_solver.h.
:
_precond_type (ILUPrecond)
{
}
Definition at line 153 of file laspack_linear_solver.h.
{
this->clear ();
}
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;
}
Definition at line 37 of file linear_solver.C.
References LASPACK_SOLVERS, libMeshEnums::PETSC_SOLVERS, and TRILINOS_SOLVERS.
Referenced by LegacyXdrIO::read_mesh().
{
// Build the appropriate solver
switch (solver_package)
{
#ifdef LIBMESH_HAVE_LASPACK
case LASPACK_SOLVERS:
{
AutoPtr<LinearSolver<T> > ap(new LaspackLinearSolver<T>);
return ap;
}
#endif
#ifdef LIBMESH_HAVE_PETSC
case PETSC_SOLVERS:
{
AutoPtr<LinearSolver<T> > ap(new PetscLinearSolver<T>);
return ap;
}
#endif
#ifdef LIBMESH_HAVE_TRILINOS
case TRILINOS_SOLVERS:
{
AutoPtr<LinearSolver<T> > ap(new AztecLinearSolver<T>);
return ap;
}
#endif
default:
std::cerr << 'ERROR: Unrecognized solver package: '
<< solver_package
<< std::endl;
libmesh_error();
}
AutoPtr<LinearSolver<T> > ap(NULL);
return ap;
}
Reimplemented from LinearSolver< T >.
Definition at line 78 of file laspack_linear_solver.C.
References libMesh::libMeshPrivateData::_is_initialized, libMeshEnums::GMRES, libMeshEnums::ILU_PRECOND, and libMesh::initialized().
Referenced by LaspackVector< T >::init(), LaspackMatrix< T >::~LaspackMatrix(), and LaspackVector< T >::~LaspackVector().
{
if (this->initialized())
{
this->_is_initialized = false;
this->_solver_type = GMRES;
this->_preconditioner_type = ILU_PRECOND;
}
}
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
}
Definition at line 149 of file reference_counter.h.
References ReferenceCounter::_counts, Quality::name(), and Threads::spin_mtx.
Referenced by ReferenceCountedObject< Value >::ReferenceCountedObject().
{
Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
std::pair<unsigned int, unsigned int>& p = _counts[name];
p.first++;
}
Definition at line 167 of file reference_counter.h.
References ReferenceCounter::_counts, Quality::name(), and Threads::spin_mtx.
Referenced by ReferenceCountedObject< Value >::~ReferenceCountedObject().
{
Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
std::pair<unsigned int, unsigned int>& p = _counts[name];
p.second++;
}
Implements LinearSolver< T >.
Definition at line 92 of file laspack_linear_solver.C.
References libMesh::libMeshPrivateData::_is_initialized, and libMesh::initialized().
{
// Initialize the data structures if not done so already.
if (!this->initialized())
{
this->_is_initialized = true;
}
// SetRTCAuxProc (print_iter_accuracy);
}
Definition at line 78 of file linear_solver.h.
{ return _is_initialized; }
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; }
Definition at line 83 of file linear_solver.C.
{
if(_preconditioner)
return _preconditioner->type();
return _preconditioner_type;
}
Implements LinearSolver< T >.
Definition at line 340 of file laspack_linear_solver.C.
{
std::cout << 'print_converged_reason() is currently only supported'
<< 'with Petsc 2.3.1 and later.' << std::endl;
}
Definition at line 83 of file reference_counter.C.
References ReferenceCounter::get_info().
{
#if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG)
std::cout << ReferenceCounter::get_info();
#endif
}
Definition at line 311 of file laspack_linear_solver.C.
References libMeshEnums::IDENTITY_PRECOND, libMeshEnums::ILU_PRECOND, libMeshEnums::JACOBI_PRECOND, and libMeshEnums::SSOR_PRECOND.
{
switch (this->_preconditioner_type)
{
case IDENTITY_PRECOND:
_precond_type = NULL; return;
case ILU_PRECOND:
_precond_type = ILUPrecond; return;
case JACOBI_PRECOND:
_precond_type = JacobiPrecond; return;
case SSOR_PRECOND:
_precond_type = SSORPrecond; return;
default:
std::cerr << 'ERROR: Unsupported LASPACK Preconditioner: '
<< this->_preconditioner_type << std::endl
<< 'Continuing with ILU' << std::endl;
this->_preconditioner_type = ILU_PRECOND;
this->set_laspack_preconditioner_type();
}
}
Definition at line 93 of file linear_solver.C.
{
if(_preconditioner)
_preconditioner->set_type(pct);
else
_preconditioner_type = pct;
}
Definition at line 98 of file linear_solver.h.
{ _solver_type = st; }
Implements LinearSolver< T >.
Definition at line 297 of file laspack_linear_solver.C.
{
libmesh_not_implemented();
return std::make_pair(0,0.0);
}
Implements LinearSolver< T >.
Definition at line 283 of file laspack_linear_solver.C.
{
libmesh_not_implemented();
return std::make_pair(0,0.0);
}
Implements LinearSolver< T >.
Definition at line 163 of file laspack_linear_solver.h.
{
std::cerr << 'ERROR: LASPACK does not support a user-supplied preconditioner!'
<< std::endl;
libmesh_error();
std::pair<unsigned int, Real> p;
return p;
}
Implements LinearSolver< T >.
Definition at line 107 of file laspack_linear_solver.C.
References LaspackMatrix< T >::_QMat, libMeshEnums::BICG, libMeshEnums::BICGSTAB, libMeshEnums::CG, libMeshEnums::CGN, libMeshEnums::CGS, LaspackMatrix< T >::close(), libMeshEnums::GMRES, libMesh::init(), libMeshEnums::JACOBI, libMeshEnums::QMR, libMeshEnums::SSOR, and LaspackVector< T >::zero().
{
START_LOG('solve()', 'LaspackLinearSolver');
this->init ();
// Make sure the data passed in are really in Laspack types
LaspackMatrix<T>* matrix = libmesh_cast_ptr<LaspackMatrix<T>*>(&matrix_in);
LaspackVector<T>* solution = libmesh_cast_ptr<LaspackVector<T>*>(&solution_in);
LaspackVector<T>* rhs = libmesh_cast_ptr<LaspackVector<T>*>(&rhs_in);
// Zero-out the solution to prevent the solver from exiting in 0
// iterations (?)
//TODO:[BSK] Why does Laspack do this? Comment out this and try ex13...
solution->zero();
// Close the matrix and vectors in case this wasn't already done.
matrix->close ();
solution->close ();
rhs->close ();
// Set the preconditioner type
this->set_laspack_preconditioner_type ();
// Set the solver tolerance
SetRTCAccuracy (tol);
// Solve the linear system
switch (this->_solver_type)
{
// Conjugate-Gradient
case CG:
{
CGIter (&matrix->_QMat,
&solution->_vec,
&rhs->_vec,
m_its,
_precond_type,
1.);
break;
}
// Conjugate-Gradient Normalized
case CGN:
{
CGNIter (&matrix->_QMat,
&solution->_vec,
&rhs->_vec,
m_its,
_precond_type,
1.);
break;
}
// Conjugate-Gradient Squared
case CGS:
{
CGSIter (&matrix->_QMat,
&solution->_vec,
&rhs->_vec,
m_its,
_precond_type,
1.);
break;
}
// Bi-Conjugate Gradient
case BICG:
{
BiCGIter (&matrix->_QMat,
&solution->_vec,
&rhs->_vec,
m_its,
_precond_type,
1.);
break;
}
// Bi-Conjugate Gradient Stabilized
case BICGSTAB:
{
BiCGSTABIter (&matrix->_QMat,
&solution->_vec,
&rhs->_vec,
m_its,
_precond_type,
1.);
break;
}
// Quasi-Minimum Residual
case QMR:
{
QMRIter (&matrix->_QMat,
&solution->_vec,
&rhs->_vec,
m_its,
_precond_type,
1.);
break;
}
// Symmetric over-relaxation
case SSOR:
{
SSORIter (&matrix->_QMat,
&solution->_vec,
&rhs->_vec,
m_its,
_precond_type,
1.);
break;
}
// Jacobi Relaxation
case JACOBI:
{
JacobiIter (&matrix->_QMat,
&solution->_vec,
&rhs->_vec,
m_its,
_precond_type,
1.);
break;
}
// Generalized Minimum Residual
case GMRES:
{
SetGMRESRestart (30);
GMRESIter (&matrix->_QMat,
&solution->_vec,
&rhs->_vec,
m_its,
_precond_type,
1.);
break;
}
// Unknown solver, use GMRES
default:
{
std::cerr << 'ERROR: Unsupported LASPACK Solver: '
<< this->_solver_type << std::endl
<< 'Continuing with GMRES' << std::endl;
this->_solver_type = GMRES;
return this->solve (*matrix,
*solution,
*rhs,
tol,
m_its);
}
}
// Check for an error
if (LASResult() != LASOK)
{
std::cerr << 'ERROR: LASPACK Error: ' << std::endl;
WriteLASErrDescr(stdout);
libmesh_error();
}
STOP_LOG('solve()', 'LaspackLinearSolver');
// Get the convergence step # and residual
return std::make_pair(GetLastNoIter(), GetLastAccuracy());
}
Definition at line 93 of file linear_solver.h.
{ return _solver_type; }
Definition at line 110 of file reference_counter.h.
Referenced by ReferenceCounter::get_info(), ReferenceCounter::increment_constructor_count(), and ReferenceCounter::increment_destructor_count().
Definition at line 200 of file linear_solver.h.
Referenced by LinearSolver< Number >::initialized().
Definition at line 123 of file reference_counter.h.
Definition at line 118 of file reference_counter.h.
Referenced by ReferenceCounter::n_objects(), ReferenceCounter::ReferenceCounter(), and ReferenceCounter::~ReferenceCounter().
Definition at line 137 of file laspack_linear_solver.h.
Definition at line 205 of file linear_solver.h.
Definition at line 195 of file linear_solver.h.
Definition at line 190 of file linear_solver.h.
Referenced by LinearSolver< Number >::set_solver_type(), and LinearSolver< Number >::solver_type().
Definition at line 182 of file linear_solver.h.
Generated automatically by Doxygen for libMesh from the source code.