Reference documentation for deal.II version 9.0.0
|
#include <deal.II/lac/block_matrix_array.h>
Classes | |
class | Entry |
Public Types | |
typedef types::global_dof_index | size_type |
Public Member Functions | |
BlockMatrixArray () | |
BlockMatrixArray (const unsigned int n_block_rows, const unsigned int n_block_cols) | |
void | initialize (const unsigned int n_block_rows, const unsigned int n_block_cols) |
void | reinit (const unsigned int n_block_rows, const unsigned int n_block_cols) |
template<typename MatrixType > | |
void | enter (const MatrixType &matrix, const unsigned int row, const unsigned int col, const number prefix=1., const bool transpose=false) |
void | clear () |
unsigned int | n_block_rows () const |
unsigned int | n_block_cols () const |
void | vmult (BlockVectorType &dst, const BlockVectorType &src) const |
void | vmult_add (BlockVectorType &dst, const BlockVectorType &src) const |
void | Tvmult (BlockVectorType &dst, const BlockVectorType &src) const |
void | Tvmult_add (BlockVectorType &dst, const BlockVectorType &src) const |
number | matrix_scalar_product (const BlockVectorType &u, const BlockVectorType &v) const |
number | matrix_norm_square (const BlockVectorType &u) const |
template<class StreamType > | |
void | print_latex (StreamType &out) const |
Public Member Functions inherited from Subscriptor | |
Subscriptor () | |
Subscriptor (const Subscriptor &) | |
Subscriptor (Subscriptor &&) noexcept | |
virtual | ~Subscriptor () |
Subscriptor & | operator= (const Subscriptor &) |
Subscriptor & | operator= (Subscriptor &&) noexcept |
void | subscribe (const char *identifier=nullptr) const |
void | unsubscribe (const char *identifier=nullptr) const |
unsigned int | n_subscriptions () const |
void | list_subscribers () const |
template<class Archive > | |
void | serialize (Archive &ar, const unsigned int version) |
Protected Attributes | |
std::vector< Entry > | entries |
Private Attributes | |
unsigned int | block_rows |
unsigned int | block_cols |
Additional Inherited Members | |
Static Public Member Functions inherited from Subscriptor | |
static ::ExceptionBase & | ExcInUse (int arg1, std::string arg2, std::string arg3) |
static ::ExceptionBase & | ExcNoSubscriber (std::string arg1, std::string arg2) |
Block matrix composed of different single matrices; these matrices may even be of different types.
Given a set of arbitrary matrices Ai, this class implements a block matrix with block entries of the form Mjk = sjkAi. Each Ai may be used several times with different prefix. The matrices are not copied into the BlockMatrixArray object, but rather a PointerMatrix referencing each of them will be stored along with factors and transposition flags.
Non-zero entries are registered by the function enter(), zero entries are not stored at all. Using enter() with the same location (i,j)
several times will add the corresponding matrices in matrix-vector multiplications. These matrices will not be actually added, but the multiplications with them will be summed up.
The template argument MatrixType
is a class providing the matrix- vector multiplication functions vmult(), Tvmult(), vmult_add() and Tvmult_add() used in this class, but with arguments of type Vector<number> instead of BlockVector<number>. Every matrix which can be used by PointerMatrix is allowed, in particular SparseMatrix is a possible entry type.
We document the relevant parts of examples/doxygen/block_matrix_array.cc
.
Obviously, we have to include the header file containing the definition of BlockMatrixArray:
First, we set up some matrices to be entered into the blocks.
Now, we are ready to build a 2x2 BlockMatrixArray.
A
multiplied by 2 in the upper left block B1
in the upper right block. B2
to the upper right block and continue in a similar fashion. In the end, the block matrix structure is printed into an LaTeX table. Now, we set up vectors to be multiplied with this matrix and do a multiplication.
Finally, we solve a linear system with BlockMatrixArray, using no preconditioning and the conjugate gradient method.
The remaining code of this sample program concerns preconditioning and is described in the documentation of BlockTrianglePrecondition.
Definition at line 116 of file block_matrix_array.h.
typedef types::global_dof_index BlockMatrixArray< number, BlockVectorType >::size_type |
Declare the type for container size.
Definition at line 122 of file block_matrix_array.h.
BlockMatrixArray< number, BlockVectorType >::BlockMatrixArray | ( | ) |
Default constructor creating a useless object. initialize() must be called before using it.
Definition at line 52 of file block_matrix_array.cc.
BlockMatrixArray< number, BlockVectorType >::BlockMatrixArray | ( | const unsigned int | n_block_rows, |
const unsigned int | n_block_cols | ||
) |
Constructor fixing the dimensions.
Definition at line 61 of file block_matrix_array.cc.
void BlockMatrixArray< number, BlockVectorType >::initialize | ( | const unsigned int | n_block_rows, |
const unsigned int | n_block_cols | ||
) |
Initialize object completely. This is the function to call for an object created by the default constructor.
Definition at line 71 of file block_matrix_array.cc.
void BlockMatrixArray< number, BlockVectorType >::reinit | ( | const unsigned int | n_block_rows, |
const unsigned int | n_block_cols | ||
) |
Adjust the matrix to a new size and delete all blocks.
Definition at line 83 of file block_matrix_array.cc.
void BlockMatrixArray< number, BlockVectorType >::enter | ( | const MatrixType & | matrix, |
const unsigned int | row, | ||
const unsigned int | col, | ||
const number | prefix = 1. , |
||
const bool | transpose = false |
||
) |
Add a block matrix entry. The matrix
is entered into a list of blocks for multiplication, together with its coordinates row
and col
as well as optional multiplication factor prefix
and transpose flag transpose
.
void BlockMatrixArray< number, BlockVectorType >::clear | ( | ) |
Delete all entries, i.e. reset the matrix to an empty state.
Definition at line 95 of file block_matrix_array.cc.
unsigned int BlockMatrixArray< number, BlockVectorType >::n_block_rows | ( | ) | const |
Number of block-entries per column.
Definition at line 238 of file block_matrix_array.cc.
unsigned int BlockMatrixArray< number, BlockVectorType >::n_block_cols | ( | ) | const |
Number of block-entries per row.
Definition at line 247 of file block_matrix_array.cc.
void BlockMatrixArray< number, BlockVectorType >::vmult | ( | BlockVectorType & | dst, |
const BlockVectorType & | src | ||
) | const |
Matrix-vector multiplication.
Definition at line 134 of file block_matrix_array.cc.
void BlockMatrixArray< number, BlockVectorType >::vmult_add | ( | BlockVectorType & | dst, |
const BlockVectorType & | src | ||
) | const |
Matrix-vector multiplication adding to dst
.
Definition at line 103 of file block_matrix_array.cc.
void BlockMatrixArray< number, BlockVectorType >::Tvmult | ( | BlockVectorType & | dst, |
const BlockVectorType & | src | ||
) | const |
Transposed matrix-vector multiplication.
Definition at line 176 of file block_matrix_array.cc.
void BlockMatrixArray< number, BlockVectorType >::Tvmult_add | ( | BlockVectorType & | dst, |
const BlockVectorType & | src | ||
) | const |
Transposed matrix-vector multiplication adding to dst
.
Definition at line 146 of file block_matrix_array.cc.
number BlockMatrixArray< number, BlockVectorType >::matrix_scalar_product | ( | const BlockVectorType & | u, |
const BlockVectorType & | v | ||
) | const |
Matrix scalar product between two vectors (at least for a symmetric matrix).
Definition at line 189 of file block_matrix_array.cc.
number BlockMatrixArray< number, BlockVectorType >::matrix_norm_square | ( | const BlockVectorType & | u | ) | const |
Compute \(u^T M u\). This is the square of the norm induced by the matrix assuming the matrix is symmetric positive definitive.
Definition at line 229 of file block_matrix_array.cc.
void BlockMatrixArray< number, BlockVectorType >::print_latex | ( | StreamType & | out | ) | const |
Print the block structure as a LaTeX-array. This output will not be very intuitive, since the current object lacks knowledge about what the individual blocks represent or how they should be named. Instead, what you will see is an entry for each block showing all the matrices with their multiplication factors and possibly transpose marks. The matrices itself are named successively as they are encountered. If the same matrix is entered several times, it will be listed with different names.
As an example, consider the following code:
The current function will then produce output of the following kind:
Note how the individual blocks here are just numbered successively as M0
to M4
and that the output misses the fact that M2
and M3
are, in fact, the same matrix. Nevertheless, the output at least gives some kind of idea of the block structure of this matrix.
|
protected |
Array of block entries in the matrix.
Definition at line 337 of file block_matrix_array.h.
|
private |
Number of blocks per column.
Definition at line 343 of file block_matrix_array.h.
|
private |
number of blocks per row.
Definition at line 347 of file block_matrix_array.h.