Reference documentation for deal.II version 9.5.0
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
BlockSparseMatrixEZ< Number > Class Template Reference

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

Inheritance diagram for BlockSparseMatrixEZ< Number >:
[legend]

Public Types

using size_type = types::global_dof_index
 

Public Member Functions

 BlockSparseMatrixEZ ()=default
 
 BlockSparseMatrixEZ (const unsigned int block_rows, const unsigned int block_cols)
 
 BlockSparseMatrixEZ (const BlockSparseMatrixEZ< Number > &)
 
BlockSparseMatrixEZoperator= (const BlockSparseMatrixEZ< Number > &)
 
BlockSparseMatrixEZoperator= (const double d)
 
void clear ()
 
void reinit (const unsigned int n_block_rows, const unsigned int n_block_cols)
 
void collect_sizes ()
 
SparseMatrixEZ< Number > & block (const unsigned int row, const unsigned int column)
 
const SparseMatrixEZ< Number > & block (const unsigned int row, const unsigned int column) const
 
unsigned int n_block_rows () const
 
unsigned int n_block_cols () const
 
bool empty () const
 
size_type m () const
 
size_type n () const
 
void set (const size_type i, const size_type j, const Number value)
 
void add (const size_type i, const size_type j, const Number value)
 
template<typename somenumber >
void vmult (BlockVector< somenumber > &dst, const BlockVector< somenumber > &src) const
 
template<typename somenumber >
void Tvmult (BlockVector< somenumber > &dst, const BlockVector< somenumber > &src) const
 
template<typename somenumber >
void vmult_add (BlockVector< somenumber > &dst, const BlockVector< somenumber > &src) const
 
template<typename somenumber >
void Tvmult_add (BlockVector< somenumber > &dst, const BlockVector< somenumber > &src) const
 
template<class StreamType >
void print_statistics (StreamType &s, bool full=false)
 
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 ::ExceptionBaseExcInUse (int arg1, std::string arg2, std::string arg3)
 
static ::ExceptionBaseExcNoSubscriber (std::string arg1, std::string arg2)
 

Private Types

using map_value_type = decltype(counter_map)::value_type
 
using map_iterator = decltype(counter_map)::iterator
 

Private Member Functions

void check_no_subscribers () const noexcept
 

Private Attributes

BlockIndices row_indices
 
BlockIndices column_indices
 
Table< 2, SparseMatrixEZ< Number > > blocks
 
std::atomic< unsigned intcounter
 
std::map< std::string, unsigned intcounter_map
 
std::vector< std::atomic< bool > * > validity_pointers
 
const std::type_info * object_info
 

Static Private Attributes

static std::mutex mutex
 

Detailed Description

template<typename Number>
class BlockSparseMatrixEZ< Number >

A block matrix consisting of blocks of type SparseMatrixEZ.

Like the other Block-objects, this matrix can be used like a SparseMatrixEZ, when it comes to access to entries. Then, there are functions for the multiplication with BlockVector and access to the individual blocks.

See also
Block (linear algebra)

Definition at line 61 of file block_sparse_matrix_ez.h.

Member Typedef Documentation

◆ size_type

template<typename Number >
using BlockSparseMatrixEZ< Number >::size_type = types::global_dof_index

Declare type for container size.

Definition at line 67 of file block_sparse_matrix_ez.h.

◆ map_value_type

using Subscriptor::map_value_type = decltype(counter_map)::value_type
privateinherited

The data type used in counter_map.

Definition at line 230 of file subscriptor.h.

◆ map_iterator

using Subscriptor::map_iterator = decltype(counter_map)::iterator
privateinherited

The iterator type used in counter_map.

Definition at line 235 of file subscriptor.h.

Constructor & Destructor Documentation

◆ BlockSparseMatrixEZ() [1/3]

template<typename Number >
BlockSparseMatrixEZ< Number >::BlockSparseMatrixEZ ( )
default

Default constructor. The result is an empty object with zero dimensions.

◆ BlockSparseMatrixEZ() [2/3]

template<typename Number >
BlockSparseMatrixEZ< Number >::BlockSparseMatrixEZ ( const unsigned int  block_rows,
const unsigned int  block_cols 
)

Constructor setting up an object with given number of block rows and columns. The blocks themselves still have zero dimension.

◆ BlockSparseMatrixEZ() [3/3]

template<typename Number >
BlockSparseMatrixEZ< Number >::BlockSparseMatrixEZ ( const BlockSparseMatrixEZ< Number > &  )

Copy constructor. This is needed for some container classes. It creates an object of the same number of block rows and columns. Since it calls the copy constructor of SparseMatrixEZ, the block s must be empty.

Member Function Documentation

◆ operator=() [1/2]

template<typename Number >
BlockSparseMatrixEZ & BlockSparseMatrixEZ< Number >::operator= ( const BlockSparseMatrixEZ< Number > &  )

Copy operator. Like the copy constructor, this may be called for objects with empty blocks only.

◆ operator=() [2/2]

template<typename Number >
BlockSparseMatrixEZ & BlockSparseMatrixEZ< Number >::operator= ( const double  d)

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.

◆ clear()

template<typename Number >
void BlockSparseMatrixEZ< Number >::clear ( )

Set matrix to zero dimensions and release memory.

◆ reinit()

template<typename Number >
void BlockSparseMatrixEZ< Number >::reinit ( const unsigned int  n_block_rows,
const unsigned int  n_block_cols 
)

Initialize to given block numbers. After this operation, the matrix will have the block dimensions provided. Each block will have zero dimensions and must be initialized subsequently. After setting the sizes of the blocks, collect_sizes() must be called to update internal data structures.

◆ collect_sizes()

template<typename Number >
void BlockSparseMatrixEZ< 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.

◆ block() [1/2]

template<typename Number >
SparseMatrixEZ< Number > & BlockSparseMatrixEZ< Number >::block ( const unsigned int  row,
const unsigned int  column 
)
inline

Access the block with the given coordinates.

Definition at line 291 of file block_sparse_matrix_ez.h.

◆ block() [2/2]

template<typename Number >
const SparseMatrixEZ< Number > & BlockSparseMatrixEZ< Number >::block ( const unsigned int  row,
const unsigned int  column 
) const
inline

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

Definition at line 304 of file block_sparse_matrix_ez.h.

◆ n_block_rows()

template<typename Number >
unsigned int BlockSparseMatrixEZ< Number >::n_block_rows
inline

Return the number of blocks in a column.

Definition at line 273 of file block_sparse_matrix_ez.h.

◆ n_block_cols()

template<typename Number >
unsigned int BlockSparseMatrixEZ< Number >::n_block_cols
inline

Return the number of blocks in a row.

Definition at line 282 of file block_sparse_matrix_ez.h.

◆ empty()

template<typename Number >
bool BlockSparseMatrixEZ< Number >::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.

◆ m()

template<typename Number >
BlockSparseMatrixEZ< Number >::size_type BlockSparseMatrixEZ< Number >::m
inline

Return number of rows of this matrix, which equals the dimension of the codomain (or range) space. It is the sum of the number of rows over the sub-matrix blocks of this matrix. Recall that the matrix is of size m() times n().

Definition at line 317 of file block_sparse_matrix_ez.h.

◆ n()

template<typename Number >
BlockSparseMatrixEZ< Number >::size_type BlockSparseMatrixEZ< Number >::n
inline

Return number of columns of this matrix, which equals the dimension of the domain space. It is the sum of the number of columns over the sub- matrix blocks of this matrix. Recall that the matrix is of size m() times n().

Definition at line 326 of file block_sparse_matrix_ez.h.

◆ set()

template<typename Number >
void BlockSparseMatrixEZ< Number >::set ( const size_type  i,
const size_type  j,
const Number  value 
)
inline

Set the element (i,j) to value. Throws an error if the entry does not exist or if value is not a finite number. Still, it is allowed to store zero values in non-existent fields.

Definition at line 335 of file block_sparse_matrix_ez.h.

◆ add()

template<typename Number >
void BlockSparseMatrixEZ< Number >::add ( const size_type  i,
const size_type  j,
const Number  value 
)
inline

Add value to the element (i,j). Throws an error if the entry does not exist or if value is not a finite number. Still, it is allowed to store zero values in non-existent fields.

Definition at line 353 of file block_sparse_matrix_ez.h.

◆ vmult()

template<typename Number >
template<typename somenumber >
void BlockSparseMatrixEZ< Number >::vmult ( BlockVector< somenumber > &  dst,
const BlockVector< somenumber > &  src 
) const

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

Definition at line 371 of file block_sparse_matrix_ez.h.

◆ Tvmult()

template<typename Number >
template<typename somenumber >
void BlockSparseMatrixEZ< Number >::Tvmult ( BlockVector< somenumber > &  dst,
const BlockVector< somenumber > &  src 
) const

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 409 of file block_sparse_matrix_ez.h.

◆ vmult_add()

template<typename Number >
template<typename somenumber >
void BlockSparseMatrixEZ< Number >::vmult_add ( BlockVector< somenumber > &  dst,
const BlockVector< somenumber > &  src 
) const

Adding Matrix-vector multiplication. Add \(M*src\) on \(dst\) with \(M\) being this matrix.

Definition at line 391 of file block_sparse_matrix_ez.h.

◆ Tvmult_add()

template<typename Number >
template<typename somenumber >
void BlockSparseMatrixEZ< Number >::Tvmult_add ( BlockVector< somenumber > &  dst,
const BlockVector< somenumber > &  src 
) const

Adding Matrix-vector multiplication. Add \(M^T*src\) to \(dst\) with \(M\) being this matrix. This function does the same as vmult_add() but takes the transposed matrix.

Definition at line 429 of file block_sparse_matrix_ez.h.

◆ print_statistics()

template<typename number >
template<class StreamType >
void BlockSparseMatrixEZ< number >::print_statistics ( StreamType &  s,
bool  full = false 
)
inline

Print statistics. If full is true, prints a histogram of all existing row lengths and allocated row lengths. Otherwise, just the relation of allocated and used entries is shown.

Definition at line 447 of file block_sparse_matrix_ez.h.

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

◆ check_no_subscribers()

void Subscriptor::check_no_subscribers ( ) const
privatenoexceptinherited

Check that there are no objects subscribing to this object. If this check passes then it is safe to destroy the current object. It this check fails then this function will either abort or print an error message to deallog (by using the AssertNothrow mechanism), but will not throw an exception.

Note
Since this function is just a consistency check it does nothing in release mode.
If this function is called when there is an uncaught exception then, rather than aborting, this function prints an error message to the standard error stream and returns.

Definition at line 53 of file subscriptor.cc.

Member Data Documentation

◆ row_indices

template<typename Number >
BlockIndices BlockSparseMatrixEZ< Number >::row_indices
private

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

Definition at line 253 of file block_sparse_matrix_ez.h.

◆ column_indices

template<typename Number >
BlockIndices BlockSparseMatrixEZ< Number >::column_indices
private

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

Definition at line 259 of file block_sparse_matrix_ez.h.

◆ blocks

template<typename Number >
Table<2, SparseMatrixEZ<Number> > BlockSparseMatrixEZ< Number >::blocks
private

The actual matrices

Definition at line 264 of file block_sparse_matrix_ez.h.

◆ counter

std::atomic<unsigned int> Subscriptor::counter
mutableprivateinherited

Store the number of objects which subscribed to this object. Initially, this number is zero, and upon destruction it shall be zero again (i.e. all objects which subscribed should have unsubscribed again).

The creator (and owner) of an object is counted in the map below if HE manages to supply identification.

We use the mutable keyword in order to allow subscription to constant objects also.

This counter may be read from and written to concurrently in multithreaded code: hence we use the std::atomic class template.

Definition at line 219 of file subscriptor.h.

◆ counter_map

std::map<std::string, unsigned int> Subscriptor::counter_map
mutableprivateinherited

In this map, we count subscriptions for each different identification string supplied to subscribe().

Definition at line 225 of file subscriptor.h.

◆ validity_pointers

std::vector<std::atomic<bool> *> Subscriptor::validity_pointers
mutableprivateinherited

In this vector, we store pointers to the validity bool in the SmartPointer objects that subscribe to this class.

Definition at line 241 of file subscriptor.h.

◆ object_info

const std::type_info* Subscriptor::object_info
mutableprivateinherited

Pointer to the typeinfo object of this object, from which we can later deduce the class name. Since this information on the derived class is neither available in the destructor, nor in the constructor, we obtain it in between and store it here.

Definition at line 249 of file subscriptor.h.

◆ mutex

std::mutex Subscriptor::mutex
staticprivateinherited

A mutex used to ensure data consistency when printing out the list of subscribers.

Definition at line 271 of file subscriptor.h.


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