![]() |
Reference documentation for deal.II version 8.1.0
|
#include <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) |
BlockMatrixArray (const unsigned int n_block_rows, const unsigned int n_block_cols, VectorMemory< Vector< number > > &mem) DEAL_II_DEPRECATED | |
void | initialize (const unsigned int n_block_rows, const unsigned int n_block_cols, VectorMemory< Vector< number > > &mem) DEAL_II_DEPRECATED |
void | reinit (const unsigned int n_block_rows, const unsigned int n_block_cols) |
template<class MATRIX > | |
void | enter (const MATRIX &matrix, const unsigned int row, const unsigned int col, const double prefix=1., const bool transpose=false) |
template<class MATRIX > | |
void | enter_aux (VectorMemory< Vector< number > > &mem, const MATRIX &matrix, const unsigned int row, const unsigned int col, const double prefix=1., const bool transpose=false) DEAL_II_DEPRECATED |
void | clear () |
unsigned int | n_block_rows () const |
unsigned int | n_block_cols () const |
void | vmult (BlockVector< number > &dst, const BlockVector< number > &src) const |
void | vmult_add (BlockVector< number > &dst, const BlockVector< number > &src) const |
void | Tvmult (BlockVector< number > &dst, const BlockVector< number > &src) const |
void | Tvmult_add (BlockVector< number > &dst, const BlockVector< number > &src) const |
number | matrix_scalar_product (const BlockVector< number > &u, const BlockVector< number > &v) const |
number | matrix_norm_square (const BlockVector< number > &u) const |
template<class STREAM > | |
void | print_latex (STREAM &out) const |
![]() | |
Subscriptor () | |
Subscriptor (const Subscriptor &) | |
virtual | ~Subscriptor () |
Subscriptor & | operator= (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"<< "(Additional information: "<< arg3<< ")\n"<< "Note the entry in the Frequently Asked Questions of "<< "deal.II (linked to from http://www.dealii.org/) for "<< "more information on what this error means.") | |
DeclException2 (ExcNoSubscriber, char *, char *,<< "No subscriber with identifier \""<< arg2<< "\" did subscribe to this object of class "<< arg1) | |
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 |
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 MATRIX
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.
The BlockMatrixArray needs a VectorMemory<Vector<number> > object to allocate auxiliary vectors. number
must equal the second template argument of BlockMatrixArray and also the number type of the BlockVector used later. We use the GrowingVectorMemory type, since it remembers the vector and avoids reallocating.
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 36 of file pointer_matrix.h.
typedef types::global_dof_index BlockMatrixArray< number >::size_type |
Declare the type for container size.
Definition at line 134 of file block_matrix_array.h.
BlockMatrixArray< number >::BlockMatrixArray | ( | ) |
Default constructor creating a useless object. initialize() must be called before using it.
BlockMatrixArray< number >::BlockMatrixArray | ( | const unsigned int | n_block_rows, |
const unsigned int | n_block_cols | ||
) |
Constructor fixing the dimensions.
BlockMatrixArray< number >::BlockMatrixArray | ( | const unsigned int | n_block_rows, |
const unsigned int | n_block_cols, | ||
VectorMemory< Vector< number > > & | mem | ||
) |
Constructor fixing the dimensions.
void BlockMatrixArray< number >::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.
void BlockMatrixArray< number >::initialize | ( | const unsigned int | n_block_rows, |
const unsigned int | n_block_cols, | ||
VectorMemory< Vector< number > > & | mem | ||
) |
Initialize object completely. This is the function to call for an object created by the default constructor.
void BlockMatrixArray< number >::reinit | ( | const unsigned int | n_block_rows, |
const unsigned int | n_block_cols | ||
) |
Adjust the matrix to a new size and delete all blocks.
void BlockMatrixArray< number >::enter | ( | const MATRIX & | matrix, |
const unsigned int | row, | ||
const unsigned int | col, | ||
const double | 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 >::enter_aux | ( | VectorMemory< Vector< number > > & | mem, |
const MATRIX & | matrix, | ||
const unsigned int | row, | ||
const unsigned int | col, | ||
const double | prefix = 1. , |
||
const bool | transpose = false |
||
) |
Add an entry like with enter, but use PointerMatrixAux for matrices not having functions vmult_add() and TVmult_add().
void BlockMatrixArray< number >::clear | ( | ) |
Delete all entries, i.e. reset the matrix to an empty state.
unsigned int BlockMatrixArray< number >::n_block_rows | ( | ) | const |
Number of block-entries per column.
unsigned int BlockMatrixArray< number >::n_block_cols | ( | ) | const |
Number of block-entries per row.
void BlockMatrixArray< number >::vmult | ( | BlockVector< number > & | dst, |
const BlockVector< number > & | src | ||
) | const |
Matrix-vector multiplication.
void BlockMatrixArray< number >::vmult_add | ( | BlockVector< number > & | dst, |
const BlockVector< number > & | src | ||
) | const |
Matrix-vector multiplication adding to dst
.
void BlockMatrixArray< number >::Tvmult | ( | BlockVector< number > & | dst, |
const BlockVector< number > & | src | ||
) | const |
Transposed matrix-vector multiplication.
void BlockMatrixArray< number >::Tvmult_add | ( | BlockVector< number > & | dst, |
const BlockVector< number > & | src | ||
) | const |
Transposed matrix-vector multiplication adding to dst
.
number BlockMatrixArray< number >::matrix_scalar_product | ( | const BlockVector< number > & | u, |
const BlockVector< number > & | v | ||
) | const |
Matrix scalar product between two vectors (at least for a symmetric matrix).
number BlockMatrixArray< number >::matrix_norm_square | ( | const BlockVector< number > & | u | ) | const |
Compute . This is the square of the norm induced by the matrix assuming the matrix is symmetric positive definitive.
void BlockMatrixArray< number >::print_latex | ( | STREAM & | out | ) | const |
Print the block structure as a LaTeX-array. This output will not be very intuitive, since the matrix object lacks important information. What you see is an entry for each block showing all the matrices with their multiplicaton factors and possibly transpose mark. The matrices itself are numbered successively upon being entred. If the same matrix is entered several times, it will be listed with the same number everytime.
|
protected |
Array of block entries in the matrix.
Definition at line 406 of file block_matrix_array.h.
|
private |
Number of blocks per column.
Definition at line 412 of file block_matrix_array.h.
|
private |
number of blocks per row.
Definition at line 416 of file block_matrix_array.h.