Reference documentation for deal.II version 8.4.1
Public Types | Public Member Functions | List of all members
PETScWrappers::MPI::BlockSparseMatrix Class Reference

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

Inheritance diagram for PETScWrappers::MPI::BlockSparseMatrix:
[legend]

Public Types

typedef BlockMatrixBase< SparseMatrixBaseClass
 
typedef BaseClass::BlockType BlockType
 
typedef BaseClass::value_type value_type
 
- Public Types inherited from BlockMatrixBase< SparseMatrix >
typedef SparseMatrix BlockType
 
typedef BlockType::value_type value_type
 

Public Member Functions

 BlockSparseMatrix ()
 
 ~BlockSparseMatrix ()
 
BlockSparseMatrixoperator= (const BlockSparseMatrix &)
 
BlockSparseMatrixoperator= (const double d)
 
void reinit (const size_type n_block_rows, const size_type n_block_columns)
 
void reinit (const std::vector< IndexSet > &rows, const std::vector< IndexSet > &cols, const BlockDynamicSparsityPattern &bdsp, const MPI_Comm &com)
 
void reinit (const std::vector< IndexSet > &sizes, const BlockDynamicSparsityPattern &bdsp, const MPI_Comm &com)
 
void vmult (BlockVector &dst, const BlockVector &src) const
 
void vmult (BlockVector &dst, const Vector &src) const
 
void vmult (Vector &dst, const BlockVector &src) const
 
void vmult (Vector &dst, const Vector &src) const
 
void Tvmult (BlockVector &dst, const BlockVector &src) const
 
void Tvmult (BlockVector &dst, const Vector &src) const
 
void Tvmult (Vector &dst, const BlockVector &src) const
 
void Tvmult (Vector &dst, const Vector &src) const
 
void collect_sizes ()
 
const MPI_Comm & get_mpi_communicator () const
 
- Public Member Functions inherited from BlockMatrixBase< SparseMatrix >
 BlockMatrixBase ()
 
 ~BlockMatrixBase ()
 
BlockMatrixBasecopy_from (const BlockMatrixType &source)
 
BlockTypeblock (const unsigned int row, const unsigned int column)
 
const BlockTypeblock (const unsigned int row, const unsigned int column) const
 
size_type m () const
 
size_type n () const
 
unsigned int n_block_rows () const
 
unsigned int n_block_cols () const
 
void set (const size_type i, const size_type j, const value_type value)
 
void set (const std::vector< size_type > &indices, const FullMatrix< number > &full_matrix, const bool elide_zero_values=false)
 
void set (const std::vector< size_type > &row_indices, const std::vector< size_type > &col_indices, const FullMatrix< number > &full_matrix, const bool elide_zero_values=false)
 
void set (const size_type row, const std::vector< size_type > &col_indices, const std::vector< number > &values, const bool elide_zero_values=false)
 
void set (const size_type row, const size_type n_cols, const size_type *col_indices, const number *values, const bool elide_zero_values=false)
 
void add (const size_type i, const size_type j, const value_type value)
 
void add (const std::vector< size_type > &indices, const FullMatrix< number > &full_matrix, const bool elide_zero_values=true)
 
void add (const std::vector< size_type > &row_indices, const std::vector< size_type > &col_indices, const FullMatrix< number > &full_matrix, const bool elide_zero_values=true)
 
void add (const size_type row, const std::vector< size_type > &col_indices, const std::vector< number > &values, const bool elide_zero_values=true)
 
void add (const size_type row, const size_type n_cols, const size_type *col_indices, const number *values, const bool elide_zero_values=true, const bool col_indices_are_sorted=false)
 
void add (const value_type factor, const BlockMatrixBase< SparseMatrix > &matrix)
 
value_type operator() (const size_type i, const size_type j) const
 
value_type el (const size_type i, const size_type j) const
 
value_type diag_element (const size_type i) const
 
void compress (::VectorOperation::values operation)
 
BlockMatrixBaseoperator*= (const value_type factor)
 
BlockMatrixBaseoperator/= (const value_type factor)
 
void vmult_add (BlockVectorType &dst, const BlockVectorType &src) const
 
void Tvmult_add (BlockVectorType &dst, const BlockVectorType &src) const
 
value_type matrix_norm_square (const BlockVectorType &v) const
 
value_type matrix_scalar_product (const BlockVectorType &u, const BlockVectorType &v) const
 
value_type residual (BlockVectorType &dst, const BlockVectorType &x, const BlockVectorType &b) const
 
void print (std::ostream &out, const bool alternative_output=false) const
 
iterator begin ()
 
iterator begin (const size_type r)
 
const_iterator begin () const
 
const_iterator begin (const size_type r) const
 
iterator end ()
 
iterator end (const size_type r)
 
const_iterator end () const
 
const_iterator end (const size_type r) const
 
const BlockIndicesget_row_indices () const
 
const BlockIndicesget_column_indices () const
 
std::size_t memory_consumption () const
 
 DeclException4 (ExcIncompatibleRowNumbers, int, int, int, int,<< "The blocks ["<< arg1<< ','<< arg2<< "] and ["<< arg3<< ','<< arg4<< "] have differing row numbers.")
 
 DeclException4 (ExcIncompatibleColNumbers, int, int, int, int,<< "The blocks ["<< arg1<< ','<< arg2<< "] and ["<< arg3<< ','<< arg4<< "] have differing column numbers.")
 
- Public Member Functions inherited from Subscriptor
 Subscriptor ()
 
 Subscriptor (const Subscriptor &)
 
virtual ~Subscriptor ()
 
Subscriptoroperator= (const Subscriptor &)
 
void subscribe (const char *identifier=0) const
 
void unsubscribe (const char *identifier=0) const
 
unsigned int n_subscriptions () const
 
void list_subscribers () const
 
 DeclException3 (ExcInUse, int, char *, std::string &,<< "Object of class "<< arg2<< " is still used by "<< arg1<< " other objects."<< "\n\n"<< "(Additional information: "<< arg3<< ")\n\n"<< "See the entry in the Frequently Asked Questions of "<< "deal.II (linked to from http://www.dealii.org/) for "<< "a lot more information on what this error means and "<< "how to fix programs in which it happens.")
 
 DeclException2 (ExcNoSubscriber, char *, char *,<< "No subscriber with identifier <"<< arg2<< "> subscribes to this object of class "<< arg1<< ". Consequently, it cannot be unsubscribed.")
 
template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 

Additional Inherited Members

- Protected Member Functions inherited from BlockMatrixBase< SparseMatrix >
void clear ()
 
void collect_sizes ()
 
void vmult_block_block (BlockVectorType &dst, const BlockVectorType &src) const
 
void vmult_block_nonblock (BlockVectorType &dst, const VectorType &src) const
 
void vmult_nonblock_block (VectorType &dst, const BlockVectorType &src) const
 
void vmult_nonblock_nonblock (VectorType &dst, const VectorType &src) const
 
void Tvmult_block_block (BlockVectorType &dst, const BlockVectorType &src) const
 
void Tvmult_block_nonblock (BlockVectorType &dst, const VectorType &src) const
 
void Tvmult_nonblock_block (VectorType &dst, const BlockVectorType &src) const
 
void Tvmult_nonblock_nonblock (VectorType &dst, const VectorType &src) const
 
void prepare_add_operation ()
 
void prepare_set_operation ()
 
- Protected Attributes inherited from BlockMatrixBase< SparseMatrix >
BlockIndices row_block_indices
 
Table< 2, SmartPointer< BlockType, BlockMatrixBase< SparseMatrix > > > sub_objects
 

Detailed Description

Blocked sparse matrix based on the PETScWrappers::SparseMatrix class. This class implements the functions that are specific to the PETSc SparseMatrix base objects for a blocked sparse matrix, and leaves the actual work relaying most of the calls to the individual blocks to the functions implemented in the base class. See there also for a description of when this class is useful.

In contrast to the deal.II-type SparseMatrix class, the PETSc matrices do not have external objects for the sparsity patterns. Thus, one does not determine the size of the individual blocks of a block matrix of this type by attaching a block sparsity pattern, but by calling reinit() to set the number of blocks and then by setting the size of each block separately. In order to fix the data structures of the block matrix, it is then necessary to let it know that we have changed the sizes of the underlying matrices. For this, one has to call the collect_sizes() function, for much the same reason as is documented with the BlockSparsityPattern class.

@ Block (linear algebra)

Author
Wolfgang Bangerth, 2004

Definition at line 68 of file petsc_parallel_block_sparse_matrix.h.

Member Typedef Documentation

Typedef the base class for simpler access to its own typedefs.

Definition at line 74 of file petsc_parallel_block_sparse_matrix.h.

Typedef the type of the underlying matrix.

Definition at line 79 of file petsc_parallel_block_sparse_matrix.h.

Import the typedefs from the base class.

Definition at line 84 of file petsc_parallel_block_sparse_matrix.h.

Constructor & Destructor Documentation

Constructor; initializes the matrix to be empty, without any structure, i.e. the matrix is not usable at all. This constructor is therefore only useful for matrices which are members of a class. All other matrices should be created at a point in the data flow where all necessary information is available.

You have to initialize the matrix before usage with reinit(BlockSparsityPattern). The number of blocks per row and column are then determined by that function.

Definition at line 27 of file petsc_parallel_block_sparse_matrix.cc.

Destructor.

Definition at line 31 of file petsc_parallel_block_sparse_matrix.cc.

Member Function Documentation

BlockSparseMatrix & BlockSparseMatrix< number >::operator= ( const BlockSparseMatrix m)

Pseudo copy operator only copying empty objects. The sizes of the block matrices need to be the same.

Definition at line 36 of file petsc_parallel_block_sparse_matrix.cc.

BlockSparseMatrix & BlockSparseMatrix< number >::operator= ( const double  d)
inline

This operator assigns a scalar to a matrix. Since this does usually not make much sense (should we set all matrix entries to this value? Only the nonzero entries of the sparsity pattern?), this operation is only allowed if the actual value to be assigned is zero. This operator only exists to allow for the obvious notation matrix=0, which sets all elements of the matrix to zero, but keep the sparsity pattern previously used.

Definition at line 258 of file petsc_parallel_block_sparse_matrix.h.

void BlockSparseMatrix< number >::reinit ( const size_type  n_block_rows,
const size_type  n_block_columns 
)

Resize the matrix, by setting the number of block rows and columns. This deletes all blocks and replaces them with uninitialized ones, i.e. ones for which also the sizes are not yet set. You have to do that by calling the reinit functions of the blocks themselves. Do not forget to call collect_sizes() after that on this object.

The reason that you have to set sizes of the blocks yourself is that the sizes may be varying, the maximum number of elements per row may be varying, etc. It is simpler not to reproduce the interface of the SparsityPattern class here but rather let the user call whatever function she desires.

Definition at line 46 of file petsc_parallel_block_sparse_matrix.cc.

void BlockSparseMatrix< number >::reinit ( const std::vector< IndexSet > &  rows,
const std::vector< IndexSet > &  cols,
const BlockDynamicSparsityPattern bdsp,
const MPI_Comm &  com 
)

Efficiently reinit the block matrix for a parallel computation. Only the BlockSparsityPattern of the Simple type can efficiently store large sparsity patterns in parallel, so this is the only supported argument. The IndexSets describe the locally owned range of DoFs for each block. Note that each IndexSet needs to be contiguous. For a symmetric structure hand in the same vector for the first two arguments.

Definition at line 72 of file petsc_parallel_block_sparse_matrix.cc.

void BlockSparseMatrix< number >::reinit ( const std::vector< IndexSet > &  sizes,
const BlockDynamicSparsityPattern bdsp,
const MPI_Comm &  com 
)

Same as above but for a symmetric structure only.

Definition at line 114 of file petsc_parallel_block_sparse_matrix.cc.

void BlockSparseMatrix< number >::vmult ( BlockVector dst,
const BlockVector src 
) const
inline

Matrix-vector multiplication: let \(dst = M*src\) with \(M\) being this matrix.

Definition at line 273 of file petsc_parallel_block_sparse_matrix.h.

void BlockSparseMatrix< number >::vmult ( BlockVector dst,
const Vector src 
) const
inline

Matrix-vector multiplication. Just like the previous function, but only applicable if the matrix has only one block column.

Definition at line 283 of file petsc_parallel_block_sparse_matrix.h.

void BlockSparseMatrix< number >::vmult ( Vector dst,
const BlockVector src 
) const
inline

Matrix-vector multiplication. Just like the previous function, but only applicable if the matrix has only one block row.

Definition at line 293 of file petsc_parallel_block_sparse_matrix.h.

void BlockSparseMatrix< number >::vmult ( Vector dst,
const Vector src 
) const
inline

Matrix-vector multiplication. Just like the previous function, but only applicable if the matrix has only one block.

Definition at line 303 of file petsc_parallel_block_sparse_matrix.h.

void BlockSparseMatrix< number >::Tvmult ( BlockVector dst,
const BlockVector src 
) const
inline

Matrix-vector multiplication: let \(dst = M^T*src\) with \(M\) being this matrix. This function does the same as vmult() but takes the transposed matrix.

Definition at line 312 of file petsc_parallel_block_sparse_matrix.h.

void BlockSparseMatrix< number >::Tvmult ( BlockVector dst,
const Vector src 
) const
inline

Matrix-vector multiplication. Just like the previous function, but only applicable if the matrix has only one block row.

Definition at line 322 of file petsc_parallel_block_sparse_matrix.h.

void BlockSparseMatrix< number >::Tvmult ( Vector dst,
const BlockVector src 
) const
inline

Matrix-vector multiplication. Just like the previous function, but only applicable if the matrix has only one block column.

Definition at line 332 of file petsc_parallel_block_sparse_matrix.h.

void BlockSparseMatrix< number >::Tvmult ( Vector dst,
const Vector src 
) const
inline

Matrix-vector multiplication. Just like the previous function, but only applicable if the matrix has only one block.

Definition at line 342 of file petsc_parallel_block_sparse_matrix.h.

void BlockSparseMatrix< number >::collect_sizes ( )

This function collects the sizes of the sub-objects and stores them in internal arrays, in order to be able to relay global indices into the matrix to indices into the subobjects. You must call this function each time after you have changed the size of the sub- objects.

Definition at line 124 of file petsc_parallel_block_sparse_matrix.cc.

const MPI_Comm & BlockSparseMatrix< number >::get_mpi_communicator ( ) const

Return a reference to the MPI communicator object in use with this matrix.

Definition at line 132 of file petsc_parallel_block_sparse_matrix.cc.


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