Reference documentation for deal.II version Git 24fafe1087 2021-11-29 17:11:51 +0100
BlockSparsityPatternBase< SparsityPatternType > Class Template Reference

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

Inheritance diagram for BlockSparsityPatternBase< SparsityPatternType >:
[legend]

## Public Types

using size_type = types::global_dof_index

## Public Member Functions

BlockSparsityPatternBase ()

BlockSparsityPatternBase (const size_type n_block_rows, const size_type n_block_columns)

BlockSparsityPatternBase (const BlockSparsityPatternBase &bsp)

~BlockSparsityPatternBase () override

void reinit (const size_type n_block_rows, const size_type n_block_columns)

BlockSparsityPatternBaseoperator= (const BlockSparsityPatternBase &)

void collect_sizes ()

SparsityPatternType & block (const size_type row, const size_type column)

const SparsityPatternType & block (const size_type row, const size_type column) const

const BlockIndicesget_row_indices () const

const BlockIndicesget_column_indices () const

void compress ()

size_type n_block_rows () const

size_type n_block_cols () const

bool empty () const

size_type max_entries_per_row () const

void add (const size_type i, const size_type j)

template<typename ForwardIterator >
void add_entries (const size_type row, ForwardIterator begin, ForwardIterator end, const bool indices_are_sorted=false)

size_type n_rows () const

size_type n_cols () const

bool exists (const size_type i, const size_type j) const

unsigned int row_length (const size_type row) const

size_type n_nonzero_elements () const

void print (std::ostream &out) const

void print_gnuplot (std::ostream &out) const

void print_svg (std::ostream &out) const

template<class Archive >
void serialize (Archive &ar, const unsigned int version)

Subscriptor functionality

Classes derived from Subscriptor provide a facility to subscribe to this object. This is mostly used by the SmartPointer class.

void subscribe (std::atomic< bool > *const validity, const std::string &identifier="") const

void unsubscribe (std::atomic< bool > *const validity, const std::string &identifier="") const

unsigned int n_subscriptions () const

template<typename StreamType >
void list_subscribers (StreamType &stream) const

void list_subscribers () const

## Static Public Member Functions

static ::ExceptionBaseExcIncompatibleRowNumbers (int arg1, int arg2, int arg3, int arg4)

static ::ExceptionBaseExcIncompatibleColNumbers (int arg1, int arg2, int arg3, int arg4)

static ::ExceptionBaseExcInUse (int arg1, std::string arg2, std::string arg3)

static ::ExceptionBaseExcNoSubscriber (std::string arg1, std::string arg2)

## Static Public Attributes

static const size_type invalid_entry = SparsityPattern::invalid_entry

## Protected Attributes

size_type rows

size_type columns

Table< 2, SmartPointer< SparsityPatternType, BlockSparsityPatternBase< SparsityPatternType > > > sub_objects

BlockIndices row_indices

BlockIndices column_indices

## Private Attributes

std::vector< size_typecounter_within_block

std::vector< std::vector< size_type > > block_column_indices

## Friends

template<typename number >
class BlockSparseMatrix

## Detailed Description

### template<typename SparsityPatternType> class BlockSparsityPatternBase< SparsityPatternType >

This is the base class for block versions of the sparsity pattern and dynamic sparsity pattern classes. It has not much functionality, but only administrates an array of sparsity pattern objects and delegates work to them. It has mostly the same interface as has the SparsityPattern, and DynamicSparsityPattern, and simply transforms calls to its member functions to calls to the respective member functions of the member sparsity patterns.

The largest difference between the SparsityPattern and DynamicSparsityPattern classes and this class is that mostly, the matrices have different properties and you will want to work on the blocks making up the matrix rather than the whole matrix. You can access the different blocks using the block(row,col) function.

Attention: this object is not automatically notified if the size of one of its subobjects' size is changed. After you initialize the sizes of the subobjects, you will therefore have to call the collect_sizes() function of this class! Note that, of course, all sub-matrices in a (block-)row have to have the same number of rows, and that all sub-matrices in a (block-)column have to have the same number of columns.

You will in general not want to use this class, but one of the derived classes.

Todo:
Handle optimization of diagonal elements of the underlying SparsityPattern correctly.
Block (linear algebra)

Definition at line 2354 of file affine_constraints.h.

## ◆ size_type

template<typename SparsityPatternType>
 using BlockSparsityPatternBase< SparsityPatternType >::size_type = types::global_dof_index

Declare type for container size.

Definition at line 84 of file block_sparsity_pattern.h.

## ◆ BlockSparsityPatternBase() [1/3]

template<class SparsityPatternBase >
 BlockSparsityPatternBase< SparsityPatternBase >::BlockSparsityPatternBase ( )

Initialize the matrix empty, that is with no memory allocated. This is useful if you want such objects as member variables in other classes. You can make the structure usable by calling the reinit() function.

Definition at line 25 of file block_sparsity_pattern.cc.

## ◆ BlockSparsityPatternBase() [2/3]

template<class SparsityPatternBase >
 BlockSparsityPatternBase< SparsityPatternBase >::BlockSparsityPatternBase ( const size_type n_block_rows, const size_type n_block_columns )

Initialize the matrix with the given number of block rows and columns. The blocks themselves are still empty, and you have to call collect_sizes() after you assign them sizes.

Definition at line 33 of file block_sparsity_pattern.cc.

## ◆ BlockSparsityPatternBase() [3/3]

template<class SparsityPatternBase >
 BlockSparsityPatternBase< SparsityPatternBase >::BlockSparsityPatternBase ( const BlockSparsityPatternBase< SparsityPatternType > & bsp )

Copy constructor. This constructor is only allowed to be called if the sparsity pattern to be copied is empty, i.e. there are no block allocated at present. This is for the same reason as for the SparsityPattern, see there for the details.

Definition at line 45 of file block_sparsity_pattern.cc.

## ◆ ~BlockSparsityPatternBase()

template<class SparsityPatternBase >
 BlockSparsityPatternBase< SparsityPatternBase >::~BlockSparsityPatternBase ( )
override

Destructor.

Definition at line 62 of file block_sparsity_pattern.cc.

## ◆ reinit()

template<class SparsityPatternBase >
 void BlockSparsityPatternBase< SparsityPatternBase >::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 they desire.

Definition at line 77 of file block_sparsity_pattern.cc.

## ◆ operator=()

template<typename SparsityPatternType>
 BlockSparsityPatternBase< SparsityPatternBase > & BlockSparsityPatternBase< SparsityPatternBase >::operator= ( const BlockSparsityPatternBase< SparsityPatternType > & )

Copy operator. For this the same holds as for the copy constructor: it is declared, defined and fine to be called, but the latter only for empty objects.

Definition at line 110 of file block_sparsity_pattern.cc.

## ◆ collect_sizes()

template<class SparsityPatternBase >
 void BlockSparsityPatternBase< SparsityPatternBase >::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 129 of file block_sparsity_pattern.cc.

## ◆ block() [1/2]

template<typename SparsityPatternType >
 SparsityPatternType & BlockSparsityPatternBase< SparsityPatternType >::block ( const size_type row, const size_type column )
inline

Access the block with the given coordinates.

Definition at line 756 of file block_sparsity_pattern.h.

## ◆ block() [2/2]

template<typename SparsityPatternType >
 const SparsityPatternType & BlockSparsityPatternBase< SparsityPatternType >::block ( const size_type row, const size_type column ) const
inline

Access the block with the given coordinates. Version for constant objects.

Definition at line 768 of file block_sparsity_pattern.h.

## ◆ get_row_indices()

template<typename SparsityPatternType >
 const BlockIndices & BlockSparsityPatternBase< SparsityPatternType >::get_row_indices ( ) const
inline

Grant access to the object describing the distribution of row indices to the individual blocks.

Definition at line 781 of file block_sparsity_pattern.h.

## ◆ get_column_indices()

template<typename SparsityPatternType >
 const BlockIndices & BlockSparsityPatternBase< SparsityPatternType >::get_column_indices ( ) const
inline

Grant access to the object describing the distribution of column indices to the individual blocks.

Definition at line 790 of file block_sparsity_pattern.h.

## ◆ compress()

template<class SparsityPatternBase >
 void BlockSparsityPatternBase< SparsityPatternBase >::compress ( )

This function compresses the sparsity structures that this object represents. It simply calls compress for all sub-objects.

Definition at line 168 of file block_sparsity_pattern.cc.

## ◆ n_block_rows()

template<typename SparsityPatternType >
 BlockSparsityPatternBase< SparsityPatternType >::size_type BlockSparsityPatternBase< SparsityPatternType >::n_block_rows ( ) const
inline

Return the number of blocks in a column.

Definition at line 951 of file block_sparsity_pattern.h.

## ◆ n_block_cols()

template<typename SparsityPatternType >
 BlockSparsityPatternBase< SparsityPatternType >::size_type BlockSparsityPatternBase< SparsityPatternType >::n_block_cols ( ) const
inline

Return the number of blocks in a row.

Definition at line 942 of file block_sparsity_pattern.h.

## ◆ empty()

template<class SparsityPatternBase >
 bool BlockSparsityPatternBase< SparsityPatternBase >::empty ( ) const

Return whether the object is empty. It is empty if no memory is allocated, which is the same as that both dimensions are zero. This function is just the concatenation of the respective call to all sub- matrices.

Definition at line 179 of file block_sparsity_pattern.cc.

## ◆ max_entries_per_row()

template<class SparsityPatternBase >
 BlockSparsityPatternBase< SparsityPatternBase >::size_type BlockSparsityPatternBase< SparsityPatternBase >::max_entries_per_row ( ) const

Return the maximum number of entries per row. It returns the maximal number of entries per row accumulated over all blocks in a row, and the maximum over all rows.

Definition at line 192 of file block_sparsity_pattern.cc.

template<typename SparsityPatternType >
 void BlockSparsityPatternBase< SparsityPatternType >::add ( const size_type i, const size_type j )
inline

Add a nonzero entry to the matrix. This function may only be called for non-compressed sparsity patterns.

This function simply finds out to which block (i,j) belongs and then relays to that block.

Definition at line 799 of file block_sparsity_pattern.h.

template<typename SparsityPatternType >
template<typename ForwardIterator >
 void BlockSparsityPatternBase< SparsityPatternType >::add_entries ( const size_type row, ForwardIterator begin, ForwardIterator end, const bool indices_are_sorted = false )

Add several nonzero entries to the specified matrix row. This function may only be called for non-compressed sparsity patterns.

This function simply finds out to which blocks (row,col) for col in the iterator range belong and then relays to those blocks.

Definition at line 818 of file block_sparsity_pattern.h.

## ◆ n_rows()

template<class SparsityPatternBase >
 BlockSparsityPatternBase< SparsityPatternBase >::size_type BlockSparsityPatternBase< SparsityPatternBase >::n_rows ( ) const

Return number of rows of this matrix, which equals the dimension of the image space. It is the sum of rows of the (block-)rows of sub-matrices.

Definition at line 211 of file block_sparsity_pattern.cc.

## ◆ n_cols()

template<class SparsityPatternBase >
 BlockSparsityPatternBase< SparsityPatternBase >::size_type BlockSparsityPatternBase< SparsityPatternBase >::n_cols ( ) const

Return number of columns of this matrix, which equals the dimension of the range space. It is the sum of columns of the (block-)columns of sub- matrices.

Definition at line 225 of file block_sparsity_pattern.cc.

## ◆ exists()

template<typename SparsityPatternType >
 bool BlockSparsityPatternBase< SparsityPatternType >::exists ( const size_type i, const size_type j ) const
inline

Check if a value at a certain position may be non-zero.

Definition at line 906 of file block_sparsity_pattern.h.

## ◆ row_length()

template<typename SparsityPatternType >
 unsigned int BlockSparsityPatternBase< SparsityPatternType >::row_length ( const size_type row ) const
inline

Number of entries in a specific row, added up over all the blocks that form this row.

Definition at line 924 of file block_sparsity_pattern.h.

## ◆ n_nonzero_elements()

template<class SparsityPatternBase >
 BlockSparsityPatternBase< SparsityPatternBase >::size_type BlockSparsityPatternBase< SparsityPatternBase >::n_nonzero_elements ( ) const

Return the number of nonzero elements of this matrix. Actually, it returns the number of entries in the sparsity pattern; if any of the entries should happen to be zero, it is counted anyway.

This function may only be called if the matrix struct is compressed. It does not make too much sense otherwise anyway.

In the present context, it is the sum of the values as returned by the sub-objects.

Definition at line 239 of file block_sparsity_pattern.cc.

## ◆ print()

template<class SparsityPatternBase >
 void BlockSparsityPatternBase< SparsityPatternBase >::print ( std::ostream & out ) const

Print the sparsity of the matrix. The output consists of one line per row of the format [i,j1,j2,j3,...]. i is the row number and jn are the allocated columns in this row.

Definition at line 252 of file block_sparsity_pattern.cc.

## ◆ print_gnuplot()

template<class SparsityPatternBase >
 void BlockSparsityPatternBase< SparsityPatternBase >::print_gnuplot ( std::ostream & out ) const

Print the sparsity of the matrix in a format that gnuplot understands and which can be used to plot the sparsity pattern in a graphical way. This is the same functionality implemented for usual sparsity patterns, see SparsityPatternBase::print_gnuplot().

Definition at line 309 of file block_sparsity_pattern.cc.

## ◆ print_svg()

template<class SparsityPatternBase >
 void BlockSparsityPatternBase< SparsityPatternBase >::print_svg ( std::ostream & out ) const

Print the sparsity of the matrix in svg format. This is the same functionality implemented for usual sparsity patterns, see SparsityPatternBase::print_svg().

Definition at line 336 of file block_sparsity_pattern.cc.

## ◆ subscribe()

 void Subscriptor::subscribe ( std::atomic< bool > *const validity, const std::string & identifier = "" ) const
inherited

Subscribes a user of the object by storing the pointer validity. The subscriber may be identified by text supplied as identifier.

Definition at line 136 of file subscriptor.cc.

## ◆ unsubscribe()

 void Subscriptor::unsubscribe ( std::atomic< bool > *const validity, const std::string & identifier = "" ) const
inherited

Unsubscribes a user from the object.

Note
The identifier and the validity pointer must be the same as the one supplied to subscribe().

Definition at line 156 of file subscriptor.cc.

## ◆ n_subscriptions()

 unsigned int Subscriptor::n_subscriptions ( ) const
inlineinherited

Return the present number of subscriptions to this object. This allows to use this class for reference counted lifetime determination where the last one to unsubscribe also deletes the object.

Definition at line 301 of file subscriptor.h.

## ◆ list_subscribers() [1/2]

template<typename StreamType >
 void Subscriptor::list_subscribers ( StreamType & stream ) const
inlineinherited

List the subscribers to the input stream.

Definition at line 318 of file subscriptor.h.

## ◆ list_subscribers() [2/2]

 void Subscriptor::list_subscribers ( ) const
inherited

List the subscribers to deallog.

Definition at line 204 of file subscriptor.cc.

## ◆ serialize()

template<class Archive >
 void Subscriptor::serialize ( Archive & ar, const unsigned int version )
inlineinherited

Read or write the data of this object to or from a stream for the purpose of serialization using the BOOST serialization library.

This function does not actually serialize any of the member variables of this class. The reason is that what this class stores is only who subscribes to this object, but who does so at the time of storing the contents of this object does not necessarily have anything to do with who subscribes to the object when it is restored. Consequently, we do not want to overwrite the subscribers at the time of restoring, and then there is no reason to write the subscribers out in the first place.

Definition at line 310 of file subscriptor.h.

## ◆ BlockSparseMatrix

template<typename SparsityPatternType>
template<typename number >
 friend class BlockSparseMatrix
friend

Typedef describing sparse matrices that consist of multiple blocks.

Typedef for the type used to describe sparse matrices that consist of multiple blocks.

Definition at line 392 of file block_sparsity_pattern.h.

## ◆ invalid_entry

template<typename SparsityPatternType>
 const size_type BlockSparsityPatternBase< SparsityPatternType >::invalid_entry = SparsityPattern::invalid_entry
static

Define a value which is used to indicate that a certain value in the colnums array is unused, i.e. does not represent a certain column number index.

This value is only an alias to the respective value of the SparsityPattern class.

Definition at line 94 of file block_sparsity_pattern.h.

## ◆ rows

template<typename SparsityPatternType>
 size_type BlockSparsityPatternBase< SparsityPatternType >::rows
protected

Number of block rows.

Definition at line 349 of file block_sparsity_pattern.h.

## ◆ columns

template<typename SparsityPatternType>
 size_type BlockSparsityPatternBase< SparsityPatternType >::columns
protected

Number of block columns.

Definition at line 354 of file block_sparsity_pattern.h.

## ◆ sub_objects

template<typename SparsityPatternType>
 Table<2, SmartPointer > > BlockSparsityPatternBase< SparsityPatternType >::sub_objects
protected

Array of sparsity patterns.

Definition at line 362 of file block_sparsity_pattern.h.

## ◆ row_indices

template<typename SparsityPatternType>
 BlockIndices BlockSparsityPatternBase< SparsityPatternType >::row_indices
protected

Object storing and managing the transformation of row indices to indices of the sub-objects.

Definition at line 368 of file block_sparsity_pattern.h.

## ◆ column_indices

template<typename SparsityPatternType>
 BlockIndices BlockSparsityPatternBase< SparsityPatternType >::column_indices
protected

Object storing and managing the transformation of column indices to indices of the sub-objects.

Definition at line 374 of file block_sparsity_pattern.h.

## ◆ counter_within_block

template<typename SparsityPatternType>
 std::vector BlockSparsityPatternBase< SparsityPatternType >::counter_within_block
private

Temporary vector for counting the elements written into the individual blocks when doing a collective add or set.

Definition at line 381 of file block_sparsity_pattern.h.

## ◆ block_column_indices

template<typename SparsityPatternType>
 std::vector > BlockSparsityPatternBase< SparsityPatternType >::block_column_indices
private

Temporary vector for column indices on each block when writing local to global data on each sparse matrix.

Definition at line 387 of file block_sparsity_pattern.h.

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