libMesh
|
This class provides a uniform interface for preconditioners. More...
#include <preconditioner.h>
Public Member Functions | |
Preconditioner (const libMesh::Parallel::Communicator &comm) | |
Constructor. More... | |
virtual | ~Preconditioner () |
Destructor. More... | |
bool | initialized () const |
virtual void | apply (const NumericVector< T > &x, NumericVector< T > &y)=0 |
Computes the preconditioned vector y based on input vector x . More... | |
virtual void | clear () |
Release all memory and clear data structures. More... | |
virtual void | init () |
Initialize data structures if not done so already. More... | |
virtual void | setup () |
This is called every time the "operator might have changed". More... | |
void | set_matrix (SparseMatrix< Number > &mat) |
Sets the matrix to be preconditioned. More... | |
PreconditionerType | type () const |
void | set_type (const PreconditionerType pct) |
Sets the type of preconditioner to use. More... | |
const Parallel::Communicator & | comm () const |
processor_id_type | n_processors () const |
processor_id_type | processor_id () const |
Static Public Member Functions | |
static std::unique_ptr< Preconditioner< T > > | build_preconditioner (const libMesh::Parallel::Communicator &comm, const SolverPackage solver_package=libMesh::default_solver_package()) |
Builds a Preconditioner using the linear solver package specified by solver_package , returning the result wrapped in a std::unique_ptr for safety. More... | |
static Preconditioner< T > * | build (const libMesh::Parallel::Communicator &comm, const SolverPackage solver_package=libMesh::default_solver_package()) |
Builds a Preconditioner using the linear solver package specified by solver_package . More... | |
static std::string | get_info () |
Gets a string containing the reference information. More... | |
static void | print_info (std::ostream &out=libMesh::out) |
Prints the reference information, by default to libMesh::out . More... | |
static unsigned int | n_objects () |
Prints the number of outstanding (created, but not yet destroyed) objects. More... | |
static void | enable_print_counter_info () |
Methods to enable/disable the reference counter output from print_info() More... | |
static void | disable_print_counter_info () |
Protected Types | |
typedef std::map< std::string, std::pair< unsigned int, unsigned int > > | Counts |
Data structure to log the information. More... | |
Protected Member Functions | |
void | increment_constructor_count (const std::string &name) |
Increments the construction counter. More... | |
void | increment_destructor_count (const std::string &name) |
Increments the destruction counter. More... | |
Protected Attributes | |
SparseMatrix< T > * | _matrix |
The matrix P... More... | |
PreconditionerType | _preconditioner_type |
Enum stating with type of preconditioner to use. More... | |
bool | _is_initialized |
Flag indicating if the data structures have been initialized. More... | |
const Parallel::Communicator & | _communicator |
Static Protected Attributes | |
static Counts | _counts |
Actually holds the data. More... | |
static Threads::atomic< unsigned int > | _n_objects |
The number of objects. More... | |
static Threads::spin_mutex | _mutex |
Mutual exclusion object to enable thread-safe reference counting. More... | |
static bool | _enable_print_counter |
Flag to control whether reference count information is printed when print_info is called. More... | |
This class provides a uniform interface for preconditioners.
This base class can be inherited from to wrap preconditioners from different packages like PETSc or Trilinos.
In the below comments P is the matrix to be preconditioned with Apply() performing the equivalent of the matrix vector product P^-1 x. This can also be thought of as (usually approximately) solving for Py=x.
Definition at line 66 of file preconditioner.h.
|
protectedinherited |
Data structure to log the information.
The log is identified by the class name.
Definition at line 117 of file reference_counter.h.
libMesh::Preconditioner< T >::Preconditioner | ( | const libMesh::Parallel::Communicator & | comm | ) |
Constructor.
Initializes Preconditioner data structures.
|
virtual |
Destructor.
Definition at line 174 of file preconditioner.h.
|
pure virtual |
Computes the preconditioned vector y
based on input vector x
.
This is usually done by solving to get the action of
.
Implemented in libMesh::TrilinosPreconditioner< T >, libMesh::PetscPreconditioner< T >, and libMesh::EigenPreconditioner< T >.
|
static |
Builds a Preconditioner
using the linear solver package specified by solver_package
.
|
static |
Builds a Preconditioner
using the linear solver package specified by solver_package
, returning the result wrapped in a std::unique_ptr for safety.
|
virtual |
Release all memory and clear data structures.
Reimplemented in libMesh::TrilinosPreconditioner< T >, libMesh::PetscPreconditioner< T >, and libMesh::EigenPreconditioner< T >.
Definition at line 118 of file preconditioner.h.
|
inherited |
Parallel::Communicator
object used by this mesh. Definition at line 89 of file parallel_object.h.
References libMesh::ParallelObject::_communicator.
Referenced by libMesh::EpetraVector< T >::EpetraVector(), libMesh::Parallel::sync_element_data_by_parent_id(), libMesh::Parallel::sync_node_data_by_element_id(), and libMesh::Parallel::sync_node_data_by_element_id_once().
|
staticinherited |
|
staticinherited |
Methods to enable/disable the reference counter output from print_info()
|
staticinherited |
Gets a string containing the reference information.
|
protectedinherited |
Increments the construction counter.
Should be called in the constructor of any derived class that will be reference counted.
Definition at line 181 of file reference_counter.h.
References libMesh::ReferenceCounter::_counts, libMesh::Quality::name(), and libMesh::Threads::spin_mtx.
Referenced by libMesh::ReferenceCountedObject< RBParametrized >::ReferenceCountedObject().
|
protectedinherited |
Increments the destruction counter.
Should be called in the destructor of any derived class that will be reference counted.
Definition at line 194 of file reference_counter.h.
References libMesh::ReferenceCounter::_counts, libMesh::Quality::name(), and libMesh::Threads::spin_mtx.
Referenced by libMesh::ReferenceCountedObject< RBParametrized >::~ReferenceCountedObject().
|
virtual |
Initialize data structures if not done so already.
Reimplemented in libMesh::TrilinosPreconditioner< T >, libMesh::PetscPreconditioner< T >, and libMesh::EigenPreconditioner< T >.
Definition at line 125 of file preconditioner.h.
bool libMesh::Preconditioner< T >::initialized | ( | ) | const |
true
if the data structures are initialized, false
otherwise. Definition at line 106 of file preconditioner.h.
|
staticinherited |
Prints the number of outstanding (created, but not yet destroyed) objects.
Definition at line 83 of file reference_counter.h.
References libMesh::ReferenceCounter::_n_objects.
|
inherited |
Definition at line 95 of file parallel_object.h.
References libMesh::ParallelObject::_communicator, and libMesh::Parallel::Communicator::size().
Referenced by libMesh::MeshBase::partition().
|
staticinherited |
Prints the reference information, by default to libMesh::out
.
|
inherited |
Definition at line 101 of file parallel_object.h.
References libMesh::ParallelObject::_communicator, and libMesh::Parallel::Communicator::rank().
Referenced by libMesh::DofMap::end_dof(), libMesh::DofMap::end_old_dof(), libMesh::DofMap::first_dof(), libMesh::DofMap::first_old_dof(), libMesh::DofMap::last_dof(), libMesh::MeshBase::n_active_local_elem(), libMesh::DofMap::n_local_dofs(), libMesh::MeshBase::n_local_elem(), libMesh::MeshBase::n_local_nodes(), and libMesh::MeshTools::weight().
void libMesh::Preconditioner< T >::set_matrix | ( | SparseMatrix< Number > & | mat | ) |
Sets the matrix to be preconditioned.
Definition at line 181 of file preconditioner.h.
void libMesh::Preconditioner< T >::set_type | ( | const PreconditionerType | pct | ) |
Sets the type of preconditioner to use.
Definition at line 190 of file preconditioner.h.
|
virtual |
This is called every time the "operator might have changed".
This is where you need to fill in your preconditioning matrix.
Definition at line 132 of file preconditioner.h.
PreconditionerType libMesh::Preconditioner< T >::type | ( | ) | const |
Definition at line 142 of file preconditioner.h.
|
protectedinherited |
Definition at line 107 of file parallel_object.h.
Referenced by libMesh::ParallelObject::comm(), libMesh::ParallelObject::n_processors(), libMesh::ParallelObject::operator=(), and libMesh::ParallelObject::processor_id().
|
staticprotectedinherited |
Actually holds the data.
Definition at line 122 of file reference_counter.h.
Referenced by libMesh::ReferenceCounter::increment_constructor_count(), and libMesh::ReferenceCounter::increment_destructor_count().
|
staticprotectedinherited |
Flag to control whether reference count information is printed when print_info is called.
Definition at line 141 of file reference_counter.h.
|
protected |
Flag indicating if the data structures have been initialized.
Definition at line 165 of file preconditioner.h.
Referenced by libMesh::Preconditioner< Number >::initialized().
|
protected |
The matrix P...
ie the matrix to be preconditioned. This is often the actual system matrix of a linear system.
Definition at line 155 of file preconditioner.h.
|
staticprotectedinherited |
Mutual exclusion object to enable thread-safe reference counting.
Definition at line 135 of file reference_counter.h.
|
staticprotectedinherited |
The number of objects.
Print the reference count information when the number returns to 0.
Definition at line 130 of file reference_counter.h.
Referenced by libMesh::ReferenceCounter::n_objects(), libMesh::ReferenceCounter::ReferenceCounter(), and libMesh::ReferenceCounter::~ReferenceCounter().
|
protected |
Enum stating with type of preconditioner to use.
Definition at line 160 of file preconditioner.h.
Referenced by libMesh::Preconditioner< Number >::type().