Reference documentation for deal.II version Git f0d9923401 2020-09-28 19:47:38 -0600
BlockDynamicSparsityPattern Class Reference

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

Inheritance diagram for BlockDynamicSparsityPattern:
[legend]

## Public Types

using size_type = types::global_dof_index

## Public Member Functions

BlockDynamicSparsityPattern ()=default

BlockDynamicSparsityPattern (const size_type n_rows, const size_type n_columns)

BlockDynamicSparsityPattern (const std::vector< size_type > &row_block_sizes, const std::vector< size_type > &col_block_sizes)

BlockDynamicSparsityPattern (const std::vector< IndexSet > &partitioning)

BlockDynamicSparsityPattern (const BlockIndices &row_indices, const BlockIndices &col_indices)

void reinit (const std::vector< size_type > &row_block_sizes, const std::vector< size_type > &col_block_sizes)

void reinit (const std::vector< IndexSet > &partitioning)

void reinit (const BlockIndices &row_indices, const BlockIndices &col_indices)

size_type column_number (const size_type row, const unsigned int index) const

void reinit (const size_type n_block_rows, const size_type n_block_columns)

void collect_sizes ()

DynamicSparsityPatternblock (const size_type row, const size_type column)

const DynamicSparsityPatternblock (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)

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

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

## Protected Attributes

size_type rows

size_type columns

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

BlockIndices row_indices

BlockIndices column_indices

## Detailed Description

This class extends the base class to implement an array of compressed sparsity patterns that can be used to initialize objects of type BlockSparsityPattern. It does not add additional member functions, but rather acts as an alias to introduce the name of this class, without requiring the user to specify the templated name of the base class. For information on the interface of this class refer to the base class. The individual blocks are based on the DynamicSparsityPattern class.

This class is an example of the "dynamic" type of Sparsity patterns.

### Example

Usage of this class is very similar to DynamicSparsityPattern, but since the use of block indices causes some additional complications, we give a short example.

After the DoFHandler dof and the AffineConstraints constraints have been set up with a system element, we must count the degrees of freedom in each matrix block:

const std::vector<unsigned int> dofs_per_block =

Now, we are ready to set up the BlockDynamicSparsityPattern.

BlockDynamicSparsityPattern dsp(fe.n_blocks(), fe.n_blocks());
for (unsigned int i = 0; i < fe.n_blocks(); ++i)
for (unsigned int j = 0; j < fe.n_blocks(); ++j)
dsp.block(i, j).reinit(dofs_per_block[i], dofs_per_block[j]);
dsp.collect_sizes();

It is filled as if it were a normal pattern

constraints.condense(dsp);

In the end, it is copied to a normal BlockSparsityPattern for later use.

sparsity.copy_from(dsp);

Definition at line 516 of file block_sparsity_pattern.h.

## ◆ size_type

 inherited

Declare type for container size.

Definition at line 84 of file block_sparsity_pattern.h.

## ◆ BlockDynamicSparsityPattern() [1/5]

 BlockDynamicSparsityPattern::BlockDynamicSparsityPattern ( )
default

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.

## ◆ BlockDynamicSparsityPattern() [2/5]

 BlockDynamicSparsityPattern::BlockDynamicSparsityPattern ( const size_type n_rows, const size_type n_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 425 of file block_sparsity_pattern.cc.

## ◆ BlockDynamicSparsityPattern() [3/5]

 BlockDynamicSparsityPattern::BlockDynamicSparsityPattern ( const std::vector< size_type > & row_block_sizes, const std::vector< size_type > & col_block_sizes )

Initialize the pattern with two BlockIndices for the block structures of matrix rows and columns. This function is equivalent to calling the previous constructor with the length of the two index vector and then entering the index values.

Definition at line 433 of file block_sparsity_pattern.cc.

## ◆ BlockDynamicSparsityPattern() [4/5]

 BlockDynamicSparsityPattern::BlockDynamicSparsityPattern ( const std::vector< IndexSet > & partitioning )

Initialize the pattern with symmetric blocks. The number of IndexSets in the vector determine the number of rows and columns of blocks. The size of each block is determined by the size() of the respective IndexSet. Each block only stores the rows given by the values in the IndexSet, which is useful for distributed memory parallel computations and usually corresponds to the locally owned DoFs.

Definition at line 446 of file block_sparsity_pattern.cc.

## ◆ BlockDynamicSparsityPattern() [5/5]

 BlockDynamicSparsityPattern::BlockDynamicSparsityPattern ( const BlockIndices & row_indices, const BlockIndices & col_indices )

Initialize the pattern with two BlockIndices for the block structures of matrix rows and columns.

Definition at line 460 of file block_sparsity_pattern.cc.

## ◆ reinit() [1/4]

 void BlockDynamicSparsityPattern::reinit ( const std::vector< size_type > & row_block_sizes, const std::vector< size_type > & col_block_sizes )

Resize the pattern to a tensor product of matrices with dimensions defined by the arguments.

The matrix will have as many block rows and columns as there are entries in the two arguments. The block at position (i,j) will have the dimensions row_block_sizes[i] times col_block_sizes[j].

Definition at line 469 of file block_sparsity_pattern.cc.

## ◆ reinit() [2/4]

 void BlockDynamicSparsityPattern::reinit ( const std::vector< IndexSet > & partitioning )

Resize the pattern with symmetric blocks determined by the size() of each IndexSet. See the constructor taking a vector of IndexSets for details.

Definition at line 482 of file block_sparsity_pattern.cc.

## ◆ reinit() [3/4]

 void BlockDynamicSparsityPattern::reinit ( const BlockIndices & row_indices, const BlockIndices & col_indices )

Resize the matrix to a tensor product of matrices with dimensions defined by the arguments. The two BlockIndices objects must be initialized and the sparsity pattern will have the same block structure afterwards.

Definition at line 495 of file block_sparsity_pattern.cc.

## ◆ column_number()

 BlockDynamicSparsityPattern::size_type BlockDynamicSparsityPattern::column_number ( const size_type row, const unsigned int index ) const
inline

Access to column number field. Return the column number of the index th entry in row row.

Definition at line 950 of file block_sparsity_pattern.h.

## ◆ reinit() [4/4]

 void BlockSparsityPatternBase< SparsityPatternBase >::reinit ( const size_type n_block_rows, const size_type n_block_columns )
inherited

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.

## ◆ collect_sizes()

 void BlockSparsityPatternBase< SparsityPatternBase >::collect_sizes ( )
inherited

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]

 DynamicSparsityPattern & BlockSparsityPatternBase< DynamicSparsityPattern >::block ( const size_type row, const size_type column )
inlineinherited

Access the block with the given coordinates.

Definition at line 748 of file block_sparsity_pattern.h.

## ◆ block() [2/2]

 const DynamicSparsityPattern & BlockSparsityPatternBase< DynamicSparsityPattern >::block ( const size_type row, const size_type column ) const
inlineinherited

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

Definition at line 760 of file block_sparsity_pattern.h.

## ◆ get_row_indices()

 const BlockIndices & BlockSparsityPatternBase< DynamicSparsityPattern >::get_row_indices ( ) const
inlineinherited

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

Definition at line 773 of file block_sparsity_pattern.h.

## ◆ get_column_indices()

 const BlockIndices & BlockSparsityPatternBase< DynamicSparsityPattern >::get_column_indices ( ) const
inlineinherited

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

Definition at line 782 of file block_sparsity_pattern.h.

## ◆ compress()

 void BlockSparsityPatternBase< SparsityPatternBase >::compress ( )
inherited

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()

 BlockSparsityPatternBase< DynamicSparsityPattern >::size_type BlockSparsityPatternBase< DynamicSparsityPattern >::n_block_rows ( ) const
inlineinherited

Return the number of blocks in a column.

Definition at line 943 of file block_sparsity_pattern.h.

## ◆ n_block_cols()

 BlockSparsityPatternBase< DynamicSparsityPattern >::size_type BlockSparsityPatternBase< DynamicSparsityPattern >::n_block_cols ( ) const
inlineinherited

Return the number of blocks in a row.

Definition at line 934 of file block_sparsity_pattern.h.

## ◆ empty()

 bool BlockSparsityPatternBase< SparsityPatternBase >::empty ( ) const
inherited

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()

 BlockSparsityPatternBase< SparsityPatternBase >::size_type BlockSparsityPatternBase< SparsityPatternBase >::max_entries_per_row ( ) const
inherited

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.

 void BlockSparsityPatternBase< DynamicSparsityPattern >::add ( const size_type i, const size_type j )
inlineinherited

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 791 of file block_sparsity_pattern.h.

 void BlockSparsityPatternBase< DynamicSparsityPattern >::add_entries ( const size_type row, ForwardIterator begin, ForwardIterator end, const bool indices_are_sorted = false )
inherited

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 810 of file block_sparsity_pattern.h.

## ◆ n_rows()

 BlockSparsityPatternBase< SparsityPatternBase >::size_type BlockSparsityPatternBase< SparsityPatternBase >::n_rows ( ) const
inherited

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()

 BlockSparsityPatternBase< SparsityPatternBase >::size_type BlockSparsityPatternBase< SparsityPatternBase >::n_cols ( ) const
inherited

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()

 bool BlockSparsityPatternBase< DynamicSparsityPattern >::exists ( const size_type i, const size_type j ) const
inlineinherited

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

Definition at line 898 of file block_sparsity_pattern.h.

## ◆ row_length()

 unsigned int BlockSparsityPatternBase< DynamicSparsityPattern >::row_length ( const size_type row ) const
inlineinherited

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

Definition at line 916 of file block_sparsity_pattern.h.

## ◆ n_nonzero_elements()

 BlockSparsityPatternBase< SparsityPatternBase >::size_type BlockSparsityPatternBase< SparsityPatternBase >::n_nonzero_elements ( ) const
inherited

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()

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

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()

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

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 SparsityPattern.

Definition at line 308 of file block_sparsity_pattern.cc.

## ◆ ExcIncompatibleRowNumbers()

 static ::ExceptionBase& BlockSparsityPatternBase< DynamicSparsityPattern >::ExcIncompatibleRowNumbers ( int arg1, int arg2, int arg3, int arg4 )
staticinherited

Exception

Note
The message that will be printed by this exception reads:
<< "The blocks [" << arg1 << ',' << arg2 << "] and [" << arg3 << ',' << arg4 << "] have differing row numbers."

## ◆ ExcIncompatibleColNumbers()

 static ::ExceptionBase& BlockSparsityPatternBase< DynamicSparsityPattern >::ExcIncompatibleColNumbers ( int arg1, int arg2, int arg3, int arg4 )
staticinherited

Exception

Note
The message that will be printed by this exception reads:
<< "The blocks [" << arg1 << ',' << arg2 << "] and [" << arg3 << ',' << arg4 << "] have differing column numbers."

## ◆ 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 300 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 317 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.

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 309 of file subscriptor.h.

## ◆ invalid_entry

 const size_type BlockSparsityPatternBase< DynamicSparsityPattern >::invalid_entry
staticinherited

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

 protectedinherited

Number of block rows.

Definition at line 341 of file block_sparsity_pattern.h.

## ◆ columns

 size_type BlockSparsityPatternBase< DynamicSparsityPattern >::columns
protectedinherited

Number of block columns.

Definition at line 346 of file block_sparsity_pattern.h.

## ◆ sub_objects

 Table<2, SmartPointer > > BlockSparsityPatternBase< DynamicSparsityPattern >::sub_objects
protectedinherited

Array of sparsity patterns.

Definition at line 354 of file block_sparsity_pattern.h.

## ◆ row_indices

 BlockIndices BlockSparsityPatternBase< DynamicSparsityPattern >::row_indices
protectedinherited

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

Definition at line 360 of file block_sparsity_pattern.h.

## ◆ column_indices

 BlockIndices BlockSparsityPatternBase< DynamicSparsityPattern >::column_indices
protectedinherited

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

Definition at line 366 of file block_sparsity_pattern.h.

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