Reference documentation for deal.II version Git f76dcf7 2016-06-24 16:51:56 -0700
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Types | List of all members
PreconditionBlock< MatrixType, inverse_type > Class Template Reference

#include <deal.II/lac/precondition_block.h>

Inheritance diagram for PreconditionBlock< MatrixType, inverse_type >:
[legend]

Classes

class  AdditionalData
 

Public Types

typedef types::global_dof_index size_type
 

Public Member Functions

 PreconditionBlock (bool store_diagonals=false)
 
 ~PreconditionBlock ()
 
void initialize (const MatrixType &A, const AdditionalData parameters)
 
void clear ()
 
bool empty () const
 
value_type el (size_type i, size_type j) const
 
void invert_diagblocks ()
 
template<typename number2 >
void forward_step (Vector< number2 > &dst, const Vector< number2 > &prev, const Vector< number2 > &src, const bool transpose_diagonal) const
 
template<typename number2 >
void backward_step (Vector< number2 > &dst, const Vector< number2 > &prev, const Vector< number2 > &src, const bool transpose_diagonal) const
 
size_type block_size () const
 
std::size_t memory_consumption () const
 
- Public Member Functions inherited from Subscriptor
 Subscriptor ()
 
 Subscriptor (const Subscriptor &)
 
 Subscriptor (Subscriptor &&)
 
virtual ~Subscriptor ()
 
Subscriptoroperator= (const Subscriptor &)
 
Subscriptoroperator= (Subscriptor &&)
 
void subscribe (const char *identifier=0) const
 
void unsubscribe (const char *identifier=0) const
 
unsigned int n_subscriptions () const
 
void list_subscribers () const
 
template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 

Static Public Member Functions

static::ExceptionBase & ExcWrongBlockSize (int arg1, int arg2)
 
static::ExceptionBase & ExcInverseMatricesAlreadyExist ()
 
- Static Public Member Functions inherited from Subscriptor
static::ExceptionBase & ExcInUse (int arg1, char *arg2, std::string &arg3)
 
static::ExceptionBase & ExcNoSubscriber (char *arg1, char *arg2)
 

Protected Member Functions

void initialize (const MatrixType &A, const std::vector< size_type > &permutation, const std::vector< size_type > &inverse_permutation, const AdditionalData parameters)
 
void set_permutation (const std::vector< size_type > &permutation, const std::vector< size_type > &inverse_permutation)
 
void invert_permuted_diagblocks (const std::vector< size_type > &permutation, const std::vector< size_type > &inverse_permutation)
 
- Protected Member Functions inherited from PreconditionBlockBase< inverse_type >
 PreconditionBlockBase (bool store_diagonals=false, Inversion method=gauss_jordan)
 
 ~PreconditionBlockBase ()
 
void clear ()
 
void reinit (unsigned int nblocks, size_type blocksize, bool compress, Inversion method=gauss_jordan)
 
void inverses_computed (bool are_they)
 
void set_same_diagonal ()
 
bool same_diagonal () const
 
bool store_diagonals () const
 
bool inverses_ready () const
 
bool empty () const
 
unsigned int size () const
 
inverse_type el (size_type i, size_type j) const
 
void inverse_vmult (size_type i, Vector< number2 > &dst, const Vector< number2 > &src) const
 
void inverse_Tvmult (size_type i, Vector< number2 > &dst, const Vector< number2 > &src) const
 
FullMatrix< inverse_type > & inverse (size_type i)
 
const FullMatrix< inverse_type > & inverse (size_type i) const
 
Householder< inverse_type > & inverse_householder (size_type i)
 
const Householder< inverse_type > & inverse_householder (size_type i) const
 
LAPACKFullMatrix< inverse_type > & inverse_svd (size_type i)
 
const LAPACKFullMatrix< inverse_type > & inverse_svd (size_type i) const
 
FullMatrix< inverse_type > & diagonal (size_type i)
 
const FullMatrix< inverse_type > & diagonal (size_type i) const
 
void log_statistics () const
 
std::size_t memory_consumption () const
 

Protected Attributes

size_type blocksize
 
SmartPointer< const MatrixType, PreconditionBlock< MatrixType, inverse_type > > A
 
double relaxation
 
std::vector< size_typepermutation
 
std::vector< size_typeinverse_permutation
 
- Protected Attributes inherited from PreconditionBlockBase< inverse_type >
Inversion inversion
 

Private Types

typedef MatrixType::value_type number
 
typedef inverse_type value_type
 

Additional Inherited Members

- Protected Types inherited from PreconditionBlockBase< inverse_type >
enum  Inversion
 
typedef types::global_dof_index size_type
 
- Static Protected Member Functions inherited from PreconditionBlockBase< inverse_type >
static::ExceptionBase & ExcDiagonalsNotStored ()
 
static::ExceptionBase & ExcInverseNotAvailable ()
 

Detailed Description

template<typename MatrixType, typename inverse_type = typename MatrixType::value_type>
class PreconditionBlock< MatrixType, inverse_type >

Base class for actual block preconditioners. This class assumes the MatrixType consisting of invertible blocks of blocksize on the diagonal and provides the inversion of the diagonal blocks of the matrix. It is not necessary for this class that the matrix be block diagonal; rather, it applies to matrices of arbitrary structure with the minimal property of having invertible blocks on the diagonal. Still the matrix must have access to single matrix entries. Therefore, BlockMatrixArray and similar classes are not a possible matrix class template arguments.

The block matrix structure used by this class is given, e.g., for the DG method for the transport equation. For a downstream numbering the matrices even have got a block lower left matrix structure, i.e. the matrices are empty above the diagonal blocks.

Note
This class is intended to be used for matrices whose structure is given by local contributions from disjoint cells, such as for DG methods. It is not intended for problems where the block structure results from different physical variables such as in the Stokes equations considered in step-22.

For all matrices that are empty above and below the diagonal blocks (i.e. for all block diagonal matrices) the BlockJacobi preconditioner is a direct solver. For all matrices that are empty only above the diagonal blocks (e.g. the matrices one gets by the DG method with downstream numbering) BlockSOR is a direct solver.

This first implementation of the PreconditionBlock assumes the matrix has blocks each of the same block size. Varying block sizes within the matrix must still be implemented if needed.

The first template parameter denotes the type of number representation in the sparse matrix, the second denotes the type of number representation in which the inverted diagonal block matrices are stored within this class by invert_diagblocks(). If you don't want to use the block inversion as an exact solver, but rather as a preconditioner, you may probably want to store the inverted blocks with less accuracy than the original matrix; for example, number==double, inverse_type=float might be a viable choice.

See also
Block (linear algebra)
Author
Ralf Hartmann, Guido Kanschat
Date
1999, 2000, 2010

Definition at line 81 of file precondition_block.h.

Member Typedef Documentation

template<typename MatrixType, typename inverse_type = typename MatrixType::value_type>
typedef MatrixType::value_type PreconditionBlock< MatrixType, inverse_type >::number
private

Define number type of matrix.

Definition at line 89 of file precondition_block.h.

template<typename MatrixType, typename inverse_type = typename MatrixType::value_type>
typedef inverse_type PreconditionBlock< MatrixType, inverse_type >::value_type
private

Value type for inverse matrices.

Definition at line 94 of file precondition_block.h.

template<typename MatrixType, typename inverse_type = typename MatrixType::value_type>
typedef types::global_dof_index PreconditionBlock< MatrixType, inverse_type >::size_type

Declare type for container size.

Definition at line 100 of file precondition_block.h.

Constructor & Destructor Documentation

template<typename MatrixType, typename inverse_type = typename MatrixType::value_type>
PreconditionBlock< MatrixType, inverse_type >::PreconditionBlock ( bool  store_diagonals = false)

Constructor.

template<typename MatrixType, typename inverse_type = typename MatrixType::value_type>
PreconditionBlock< MatrixType, inverse_type >::~PreconditionBlock ( )

Destructor.

Member Function Documentation

template<typename MatrixType, typename inverse_type = typename MatrixType::value_type>
void PreconditionBlock< MatrixType, inverse_type >::initialize ( const MatrixType &  A,
const AdditionalData  parameters 
)

Initialize matrix and block size. We store the matrix and the block size in the preconditioner object. In a second step, the inverses of the diagonal blocks may be computed.

Additionally, a relaxation parameter for derived classes may be provided.

template<typename MatrixType, typename inverse_type = typename MatrixType::value_type>
void PreconditionBlock< MatrixType, inverse_type >::initialize ( const MatrixType &  A,
const std::vector< size_type > &  permutation,
const std::vector< size_type > &  inverse_permutation,
const AdditionalData  parameters 
)
protected

Initialize matrix and block size for permuted preconditioning. Additionally to the parameters of the other initialize() function, we hand over two index vectors with the permutation and its inverse. For the meaning of these vectors see PreconditionBlockSOR.

In a second step, the inverses of the diagonal blocks may be computed. Make sure you use invert_permuted_diagblocks() to yield consistent data.

Additionally, a relaxation parameter for derived classes may be provided.

template<typename MatrixType, typename inverse_type = typename MatrixType::value_type>
void PreconditionBlock< MatrixType, inverse_type >::set_permutation ( const std::vector< size_type > &  permutation,
const std::vector< size_type > &  inverse_permutation 
)
protected

Set either the permutation of rows or the permutation of blocks, depending on the size of the vector.

If the size of the permutation vectors is equal to the dimension of the linear system, it is assumed that rows are permuted individually. In this case, set_permutation() must be called before initialize(), since the diagonal blocks are built from the permuted entries of the matrix.

If the size of the permutation vector is not equal to the dimension of the system, the diagonal blocks are computed from the unpermuted entries. Instead, the relaxation methods step() and Tstep() are executed applying the blocks in the order given by the permutation vector. They will throw an exception if length of this vector is not equal to the number of blocks.

Note
Permutation of blocks can only be applied to the relaxation operators step() and Tstep(), not to the preconditioning operators vmult() and Tvmult().
It is safe to call set_permutation() before initialize(), while the other order is only admissible for block permutation.
template<typename MatrixType, typename inverse_type = typename MatrixType::value_type>
void PreconditionBlock< MatrixType, inverse_type >::invert_permuted_diagblocks ( const std::vector< size_type > &  permutation,
const std::vector< size_type > &  inverse_permutation 
)
protected

Replacement of invert_diagblocks() for permuted preconditioning.

template<typename MatrixType, typename inverse_type = typename MatrixType::value_type>
void PreconditionBlock< MatrixType, inverse_type >::clear ( )

Deletes the inverse diagonal block matrices if existent, sets the blocksize to 0, hence leaves the class in the state that it had directly after calling the constructor.

template<typename MatrixType, typename inverse_type = typename MatrixType::value_type>
bool PreconditionBlock< MatrixType, inverse_type >::empty ( ) const

Checks whether the object is empty.

template<typename MatrixType, typename inverse_type = typename MatrixType::value_type>
value_type PreconditionBlock< MatrixType, inverse_type >::el ( size_type  i,
size_type  j 
) const

Read-only access to entries. This function is only possible if the inverse diagonal blocks are stored.

template<typename MatrixType, typename inverse_type = typename MatrixType::value_type>
void PreconditionBlock< MatrixType, inverse_type >::invert_diagblocks ( )

Stores the inverse of the diagonal blocks in inverse. This costs some additional memory - for DG methods about 1/3 (for double inverses) or 1/6 (for float inverses) of that used for the matrix - but it makes the preconditioning much faster.

It is not allowed to call this function twice (will produce an error) before a call of clear(...) because at the second time there already exist the inverse matrices.

After this function is called, the lock on the matrix given through the use_matrix function is released, i.e. you may overwrite of delete it. You may want to do this in case you use this matrix to precondition another matrix.

template<typename MatrixType, typename inverse_type = typename MatrixType::value_type>
template<typename number2 >
void PreconditionBlock< MatrixType, inverse_type >::forward_step ( Vector< number2 > &  dst,
const Vector< number2 > &  prev,
const Vector< number2 > &  src,
const bool  transpose_diagonal 
) const

Perform one block relaxation step in forward numbering.

Depending on the arguments dst and pref, this performs an SOR step (both reference the same vector) of a Jacobi step (both different vectors). For the Jacobi step, the calling function must copy dst to pref after this.

Note
If a permutation is set, it is automatically honored by this function.
template<typename MatrixType, typename inverse_type = typename MatrixType::value_type>
template<typename number2 >
void PreconditionBlock< MatrixType, inverse_type >::backward_step ( Vector< number2 > &  dst,
const Vector< number2 > &  prev,
const Vector< number2 > &  src,
const bool  transpose_diagonal 
) const

Perform one block relaxation step in backward numbering.

Depending on the arguments dst and pref, this performs an SOR step (both reference the same vector) of a Jacobi step (both different vectors). For the Jacobi step, the calling function must copy dst to pref after this.

Note
If a permutation is set, it is automatically honored by this function.
template<typename MatrixType, typename inverse_type = typename MatrixType::value_type>
size_type PreconditionBlock< MatrixType, inverse_type >::block_size ( ) const

Return the size of the blocks.

template<typename MatrixType, typename inverse_type = typename MatrixType::value_type>
std::size_t PreconditionBlock< MatrixType, inverse_type >::memory_consumption ( ) const

Determine an estimate for the memory consumption (in bytes) of this object.

Member Data Documentation

template<typename MatrixType, typename inverse_type = typename MatrixType::value_type>
size_type PreconditionBlock< MatrixType, inverse_type >::blocksize
protected

Size of the blocks. Each diagonal block is assumed to be of the same size.

Definition at line 327 of file precondition_block.h.

template<typename MatrixType, typename inverse_type = typename MatrixType::value_type>
SmartPointer<const MatrixType,PreconditionBlock<MatrixType,inverse_type> > PreconditionBlock< MatrixType, inverse_type >::A
protected

Pointer to the matrix. Make sure that the matrix exists as long as this class needs it, i.e. until calling invert_diagblocks, or (if the inverse matrices should not be stored) until the last call of the preconditoining vmult function of the derived classes.

Definition at line 335 of file precondition_block.h.

template<typename MatrixType, typename inverse_type = typename MatrixType::value_type>
double PreconditionBlock< MatrixType, inverse_type >::relaxation
protected

Relaxation parameter to be used by derived classes.

Definition at line 339 of file precondition_block.h.

template<typename MatrixType, typename inverse_type = typename MatrixType::value_type>
std::vector<size_type> PreconditionBlock< MatrixType, inverse_type >::permutation
protected

The permutation vector

Definition at line 344 of file precondition_block.h.

template<typename MatrixType, typename inverse_type = typename MatrixType::value_type>
std::vector<size_type> PreconditionBlock< MatrixType, inverse_type >::inverse_permutation
protected

The inverse permutation vector

Definition at line 349 of file precondition_block.h.


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