libMesh
Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
libMesh::TrilinosPreconditioner< T > Class Template Reference

This class provides an interface to the suite of preconditioners available from Trilinos. More...

#include <trilinos_preconditioner.h>

Inheritance diagram for libMesh::TrilinosPreconditioner< T >:
[legend]

Public Member Functions

 TrilinosPreconditioner (const libMesh::Parallel::Communicator &comm)
 Constructor. More...
 
virtual ~TrilinosPreconditioner ()
 Destructor. More...
 
virtual void apply (const NumericVector< T > &x, NumericVector< T > &y) override
 Computes the preconditioned vector y based on input vector x. More...
 
virtual void clear () override
 Release all memory and clear data structures. More...
 
virtual void init () override
 Initialize data structures if not done so already. More...
 
void set_params (Teuchos::ParameterList &list)
 Stores a copy of the ParameterList list internally. More...
 
Epetra_FECrsMatrix * mat ()
 
void set_preconditioner_type (const PreconditionerType &preconditioner_type)
 Sets the Trilinos preconditioner to use based on the libMesh PreconditionerType. More...
 
void compute ()
 Compute the preconditioner. More...
 
bool initialized () const
 
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::Communicatorcomm () 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

virtual int SetUseTranspose (bool UseTranspose) override
 
virtual int Apply (const Epetra_MultiVector &X, Epetra_MultiVector &Y) const override
 
virtual int ApplyInverse (const Epetra_MultiVector &r, Epetra_MultiVector &z) const override
 
virtual double NormInf () const override
 
virtual const char * Label () const override
 
virtual bool UseTranspose () const override
 
virtual bool HasNormInf () const override
 
virtual const Epetra_Comm & Comm () const override
 
virtual const Epetra_Map & OperatorDomainMap () const override
 
virtual const Epetra_Map & OperatorRangeMap () const override
 
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

Epetra_Operator * _prec
 Trilinos preconditioner. More...
 
Epetra_FECrsMatrix * _mat
 Trilinos matrix that's been pulled out of the _matrix object. More...
 
Teuchos::ParameterList _param_list
 Parameter list to be used for building the preconditioner. More...
 
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...
 

Detailed Description

template<typename T>
class libMesh::TrilinosPreconditioner< T >

This class provides an interface to the suite of preconditioners available from Trilinos.

All overridden virtual functions are documented in preconditioner.h.

Author
David Andrs
Date
2011

Definition at line 71 of file trilinos_preconditioner.h.

Member Typedef Documentation

◆ Counts

typedef std::map<std::string, std::pair<unsigned int, unsigned int> > libMesh::ReferenceCounter::Counts
protectedinherited

Data structure to log the information.

The log is identified by the class name.

Definition at line 117 of file reference_counter.h.

Constructor & Destructor Documentation

◆ TrilinosPreconditioner()

Constructor.

Initializes PetscPreconditioner data structures

Definition at line 151 of file trilinos_preconditioner.h.

151  :
152  Preconditioner<T>(comm),
153  _prec(nullptr),
154  _mat(nullptr)
155 {
156 }
const Parallel::Communicator & comm() const
Epetra_FECrsMatrix * _mat
Trilinos matrix that&#39;s been pulled out of the _matrix object.
Epetra_Operator * _prec
Trilinos preconditioner.

◆ ~TrilinosPreconditioner()

template<typename T >
libMesh::TrilinosPreconditioner< T >::~TrilinosPreconditioner ( )
virtual

Destructor.

Definition at line 162 of file trilinos_preconditioner.h.

163 {
164  this->clear ();
165 }
virtual void clear() override
Release all memory and clear data structures.

Member Function Documentation

◆ apply()

template<typename T >
virtual void libMesh::TrilinosPreconditioner< T >::apply ( const NumericVector< T > &  x,
NumericVector< T > &  y 
)
overridevirtual

Computes the preconditioned vector y based on input vector x.

This is usually done by solving $ Py=x $ to get the action of $ P^-1 x $.

Implements libMesh::Preconditioner< T >.

◆ Apply()

template<typename T >
virtual int libMesh::TrilinosPreconditioner< T >::Apply ( const Epetra_MultiVector &  X,
Epetra_MultiVector &  Y 
) const
overrideprotectedvirtual

◆ ApplyInverse()

template<typename T >
virtual int libMesh::TrilinosPreconditioner< T >::ApplyInverse ( const Epetra_MultiVector &  r,
Epetra_MultiVector &  z 
) const
overrideprotectedvirtual

◆ build()

template<typename T>
static Preconditioner<T>* libMesh::Preconditioner< T >::build ( const libMesh::Parallel::Communicator comm,
const SolverPackage  solver_package = libMesh::default_solver_package() 
)
staticinherited

Builds a Preconditioner using the linear solver package specified by solver_package.

Deprecated:
Use build_preconditioner() instead.

◆ build_preconditioner()

template<typename T>
static std::unique_ptr<Preconditioner<T> > libMesh::Preconditioner< T >::build_preconditioner ( const libMesh::Parallel::Communicator comm,
const SolverPackage  solver_package = libMesh::default_solver_package() 
)
staticinherited

Builds a Preconditioner using the linear solver package specified by solver_package, returning the result wrapped in a std::unique_ptr for safety.

◆ clear()

template<typename T >
virtual void libMesh::TrilinosPreconditioner< T >::clear ( )
overridevirtual

Release all memory and clear data structures.

Reimplemented from libMesh::Preconditioner< T >.

Definition at line 89 of file trilinos_preconditioner.h.

89 {}

◆ comm()

const Parallel::Communicator& libMesh::ParallelObject::comm ( ) const
inherited

◆ Comm()

template<typename T >
virtual const Epetra_Comm& libMesh::TrilinosPreconditioner< T >::Comm ( ) const
overrideprotectedvirtual

◆ compute()

template<typename T >
void libMesh::TrilinosPreconditioner< T >::compute ( )

Compute the preconditioner.

In Trilinos, we need to call this explicitly.

◆ disable_print_counter_info()

static void libMesh::ReferenceCounter::disable_print_counter_info ( )
staticinherited

◆ enable_print_counter_info()

static void libMesh::ReferenceCounter::enable_print_counter_info ( )
staticinherited

Methods to enable/disable the reference counter output from print_info()

◆ get_info()

static std::string libMesh::ReferenceCounter::get_info ( )
staticinherited

Gets a string containing the reference information.

◆ HasNormInf()

template<typename T >
virtual bool libMesh::TrilinosPreconditioner< T >::HasNormInf ( ) const
overrideprotectedvirtual

◆ increment_constructor_count()

void libMesh::ReferenceCounter::increment_constructor_count ( const std::string &  name)
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().

182 {
183  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
184  std::pair<unsigned int, unsigned int> & p = _counts[name];
185 
186  p.first++;
187 }
std::string name(const ElemQuality q)
static Counts _counts
Actually holds the data.
spin_mutex spin_mtx
A convenient spin mutex object which can be used for obtaining locks.

◆ increment_destructor_count()

void libMesh::ReferenceCounter::increment_destructor_count ( const std::string &  name)
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().

195 {
196  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
197  std::pair<unsigned int, unsigned int> & p = _counts[name];
198 
199  p.second++;
200 }
std::string name(const ElemQuality q)
static Counts _counts
Actually holds the data.
spin_mutex spin_mtx
A convenient spin mutex object which can be used for obtaining locks.

◆ init()

template<typename T >
virtual void libMesh::TrilinosPreconditioner< T >::init ( )
overridevirtual

Initialize data structures if not done so already.

Note
This MUST be called before the preconditioning object is used.

Reimplemented from libMesh::Preconditioner< T >.

◆ initialized()

template<typename T>
bool libMesh::Preconditioner< T >::initialized ( ) const
inherited
Returns
true if the data structures are initialized, false otherwise.

Definition at line 106 of file preconditioner.h.

106 { return _is_initialized; }
bool _is_initialized
Flag indicating if the data structures have been initialized.

◆ Label()

template<typename T >
virtual const char* libMesh::TrilinosPreconditioner< T >::Label ( ) const
overrideprotectedvirtual

◆ mat()

template<typename T >
Epetra_FECrsMatrix* libMesh::TrilinosPreconditioner< T >::mat ( )
Returns
The actual Trilinos preconditioner object.

Definition at line 101 of file trilinos_preconditioner.h.

References libMesh::TrilinosPreconditioner< T >::_mat.

101 { return _mat; }
Epetra_FECrsMatrix * _mat
Trilinos matrix that&#39;s been pulled out of the _matrix object.

◆ n_objects()

static unsigned int libMesh::ReferenceCounter::n_objects ( )
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.

84  { return _n_objects; }
static Threads::atomic< unsigned int > _n_objects
The number of objects.

◆ n_processors()

processor_id_type libMesh::ParallelObject::n_processors ( ) const
inherited
Returns
The number of processors in the group.

Definition at line 93 of file parallel_object.h.

References libMesh::ParallelObject::_communicator, and libMesh::Parallel::Communicator::size().

Referenced by libMesh::MeshBase::partition().

94  { return cast_int<processor_id_type>(_communicator.size()); }
processor_id_type size() const
Definition: communicator.h:175
const Parallel::Communicator & _communicator

◆ NormInf()

template<typename T >
virtual double libMesh::TrilinosPreconditioner< T >::NormInf ( ) const
overrideprotectedvirtual

◆ OperatorDomainMap()

template<typename T >
virtual const Epetra_Map& libMesh::TrilinosPreconditioner< T >::OperatorDomainMap ( ) const
overrideprotectedvirtual

◆ OperatorRangeMap()

template<typename T >
virtual const Epetra_Map& libMesh::TrilinosPreconditioner< T >::OperatorRangeMap ( ) const
overrideprotectedvirtual

◆ print_info()

static void libMesh::ReferenceCounter::print_info ( std::ostream &  out = libMesh::out)
staticinherited

Prints the reference information, by default to libMesh::out.

◆ processor_id()

processor_id_type libMesh::ParallelObject::processor_id ( ) const
inherited

◆ set_matrix()

template<typename T >
void libMesh::Preconditioner< T >::set_matrix ( SparseMatrix< Number > &  mat)
inherited

Sets the matrix to be preconditioned.

Definition at line 181 of file preconditioner.h.

182 {
183  //If the matrix is changing then we (probably) need to reinitialize.
184  _is_initialized = false;
185  _matrix = &mat;
186 }
bool _is_initialized
Flag indicating if the data structures have been initialized.
SparseMatrix< T > * _matrix
The matrix P...

◆ set_params()

template<typename T >
void libMesh::TrilinosPreconditioner< T >::set_params ( Teuchos::ParameterList &  list)

Stores a copy of the ParameterList list internally.

◆ set_preconditioner_type()

template<typename T >
void libMesh::TrilinosPreconditioner< T >::set_preconditioner_type ( const PreconditionerType preconditioner_type)

Sets the Trilinos preconditioner to use based on the libMesh PreconditionerType.

Note
Not all libMesh PreconditionerTypes are supported.

◆ set_type()

template<typename T >
void libMesh::Preconditioner< T >::set_type ( const PreconditionerType  pct)
inherited

Sets the type of preconditioner to use.

Definition at line 190 of file preconditioner.h.

191 {
192  //If the preconditioner type changes we (probably) need to reinitialize.
193  _is_initialized = false;
194  _preconditioner_type = pct;
195 }
PreconditionerType _preconditioner_type
Enum stating with type of preconditioner to use.
bool _is_initialized
Flag indicating if the data structures have been initialized.

◆ setup()

template<typename T>
virtual void libMesh::Preconditioner< T >::setup ( )
virtualinherited

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.

132 {}

◆ SetUseTranspose()

template<typename T >
virtual int libMesh::TrilinosPreconditioner< T >::SetUseTranspose ( bool  UseTranspose)
overrideprotectedvirtual

◆ type()

template<typename T>
PreconditionerType libMesh::Preconditioner< T >::type ( ) const
inherited
Returns
The type of preconditioner to use.

Definition at line 142 of file preconditioner.h.

142 { return _preconditioner_type; }
PreconditionerType _preconditioner_type
Enum stating with type of preconditioner to use.

◆ UseTranspose()

template<typename T >
virtual bool libMesh::TrilinosPreconditioner< T >::UseTranspose ( ) const
overrideprotectedvirtual

Member Data Documentation

◆ _communicator

const Parallel::Communicator& libMesh::ParallelObject::_communicator
protectedinherited

◆ _counts

Counts libMesh::ReferenceCounter::_counts
staticprotectedinherited

◆ _enable_print_counter

bool libMesh::ReferenceCounter::_enable_print_counter
staticprotectedinherited

Flag to control whether reference count information is printed when print_info is called.

Definition at line 141 of file reference_counter.h.

◆ _is_initialized

template<typename T>
bool libMesh::Preconditioner< T >::_is_initialized
protectedinherited

Flag indicating if the data structures have been initialized.

Definition at line 165 of file preconditioner.h.

Referenced by libMesh::Preconditioner< Number >::initialized().

◆ _mat

template<typename T >
Epetra_FECrsMatrix* libMesh::TrilinosPreconditioner< T >::_mat
protected

Trilinos matrix that's been pulled out of the _matrix object.

Definition at line 125 of file trilinos_preconditioner.h.

Referenced by libMesh::TrilinosPreconditioner< T >::mat().

◆ _matrix

template<typename T>
SparseMatrix<T>* libMesh::Preconditioner< T >::_matrix
protectedinherited

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.

◆ _mutex

Threads::spin_mutex libMesh::ReferenceCounter::_mutex
staticprotectedinherited

Mutual exclusion object to enable thread-safe reference counting.

Definition at line 135 of file reference_counter.h.

◆ _n_objects

Threads::atomic<unsigned int> libMesh::ReferenceCounter::_n_objects
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().

◆ _param_list

template<typename T >
Teuchos::ParameterList libMesh::TrilinosPreconditioner< T >::_param_list
protected

Parameter list to be used for building the preconditioner.

Definition at line 130 of file trilinos_preconditioner.h.

◆ _prec

template<typename T >
Epetra_Operator* libMesh::TrilinosPreconditioner< T >::_prec
protected

Trilinos preconditioner.

Definition at line 120 of file trilinos_preconditioner.h.

◆ _preconditioner_type

template<typename T>
PreconditionerType libMesh::Preconditioner< T >::_preconditioner_type
protectedinherited

Enum stating with type of preconditioner to use.

Definition at line 160 of file preconditioner.h.

Referenced by libMesh::Preconditioner< Number >::type().


The documentation for this class was generated from the following file: