deal.II version GIT relicensing-2169-gec1b43f35b 2024-11-22 07:10:00+00:00
\(\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 | Protected Member Functions | Protected Attributes | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
LinearAlgebra::TpetraWrappers::BlockSparseMatrix< Number, MemorySpace > Class Template Reference

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

Inheritance diagram for LinearAlgebra::TpetraWrappers::BlockSparseMatrix< Number, MemorySpace >:
Inheritance graph
[legend]

Public Types

using BaseClass = BlockMatrixBase< SparseMatrix< Number, MemorySpace > >
 
using BlockType = typename BaseClass::BlockType
 
using value_type = typename BaseClass::value_type
 
using pointer = typename BaseClass::pointer
 
using const_pointer = typename BaseClass::const_pointer
 
using reference = typename BaseClass::reference
 
using const_reference = typename BaseClass::const_reference
 
using size_type = typename BaseClass::size_type
 
using iterator = typename BaseClass::iterator
 
using const_iterator = typename BaseClass::const_iterator
 
using real_type = typename numbers::NumberTraits< value_type >::real_type
 

Public Member Functions

 BlockSparseMatrix ()=default
 
 ~BlockSparseMatrix () override
 
BlockSparseMatrix< Number, MemorySpace > & operator= (const BlockSparseMatrix< Number, MemorySpace > &)=default
 
BlockSparseMatrix< Number, MemorySpace > & operator= (const Number d)
 
void reinit (const size_type n_block_rows, const size_type n_block_columns)
 
template<typename BlockSparsityPatternType >
void reinit (const std::vector< IndexSet > &input_maps, const BlockSparsityPatternType &block_sparsity_pattern, const MPI_Comm communicator=MPI_COMM_WORLD, const bool exchange_data=false)
 
template<typename BlockSparsityPatternType >
void reinit (const BlockSparsityPatternType &block_sparsity_pattern)
 
void reinit (const std::vector< IndexSet > &parallel_partitioning, const ::BlockSparseMatrix< double > &dealii_block_sparse_matrix, const MPI_Comm communicator=MPI_COMM_WORLD, const double drop_tolerance=1e-13)
 
void reinit (const ::BlockSparseMatrix< double > &deal_ii_sparse_matrix, const double drop_tolerance=1e-13)
 
bool is_compressed () const
 
void collect_sizes ()
 
std::uint64_t n_nonzero_elements () const
 
MPI_Comm get_mpi_communicator () const
 
std::vector< IndexSetlocally_owned_domain_indices () const
 
std::vector< IndexSetlocally_owned_range_indices () const
 
template<typename VectorType1 , typename VectorType2 >
void vmult (VectorType1 &dst, const VectorType2 &src) const
 
template<typename VectorType1 , typename VectorType2 >
void Tvmult (VectorType1 &dst, const VectorType2 &src) const
 
template<typename VectorType1 , typename VectorType2 , typename VectorType3 >
Number residual (VectorType1 &dst, const VectorType2 &x, const VectorType3 &b) const
 
template<typename BlockMatrixType >
BlockMatrixBasecopy_from (const BlockMatrixType &source)
 
BlockTypeblock (const unsigned int row, const unsigned int column)
 
const BlockTypeblock (const unsigned int row, const unsigned int column) const
 
size_type m () const
 
size_type n () const
 
unsigned int n_block_rows () const
 
unsigned int n_block_cols () const
 
void set (const size_type i, const size_type j, const value_type value)
 
template<typename number >
void set (const std::vector< size_type > &indices, const FullMatrix< number > &full_matrix, const bool elide_zero_values=false)
 
template<typename number >
void set (const std::vector< size_type > &row_indices, const std::vector< size_type > &col_indices, const FullMatrix< number > &full_matrix, const bool elide_zero_values=false)
 
template<typename number >
void set (const size_type row, const std::vector< size_type > &col_indices, const std::vector< number > &values, const bool elide_zero_values=false)
 
template<typename number >
void set (const size_type row, const size_type n_cols, const size_type *col_indices, const number *values, const bool elide_zero_values=false)
 
void add (const size_type i, const size_type j, const value_type value)
 
template<typename number >
void add (const std::vector< size_type > &indices, const FullMatrix< number > &full_matrix, const bool elide_zero_values=true)
 
template<typename number >
void add (const std::vector< size_type > &row_indices, const std::vector< size_type > &col_indices, const FullMatrix< number > &full_matrix, const bool elide_zero_values=true)
 
template<typename number >
void add (const size_type row, const std::vector< size_type > &col_indices, const std::vector< number > &values, const bool elide_zero_values=true)
 
template<typename number >
void add (const size_type row, const size_type n_cols, const size_type *col_indices, const number *values, const bool elide_zero_values=true, const bool col_indices_are_sorted=false)
 
void add (const value_type factor, const BlockMatrixBase< MatrixType > &matrix)
 
value_type operator() (const size_type i, const size_type j) const
 
value_type el (const size_type i, const size_type j) const
 
value_type diag_element (const size_type i) const
 
void compress (VectorOperation::values operation)
 
BlockMatrixBaseoperator*= (const value_type factor)
 
BlockMatrixBaseoperator/= (const value_type factor)
 
template<typename BlockVectorType >
void vmult_add (BlockVectorType &dst, const BlockVectorType &src) const
 
template<typename BlockVectorType >
void Tvmult_add (BlockVectorType &dst, const BlockVectorType &src) const
 
template<typename BlockVectorType >
value_type matrix_norm_square (const BlockVectorType &v) const
 
real_type frobenius_norm () const
 
template<typename BlockVectorType >
value_type matrix_scalar_product (const BlockVectorType &u, const BlockVectorType &v) const
 
template<typename BlockVectorType >
value_type residual (BlockVectorType &dst, const BlockVectorType &x, const BlockVectorType &b) const
 
void print (std::ostream &out, const bool alternative_output=false) const
 
iterator begin ()
 
iterator begin (const size_type r)
 
const_iterator begin () const
 
const_iterator begin (const size_type r) const
 
iterator end ()
 
iterator end (const size_type r)
 
const_iterator end () const
 
const_iterator end (const size_type r) const
 
const BlockIndicesget_row_indices () const
 
const BlockIndicesget_column_indices () const
 
std::size_t memory_consumption () const
 
template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 
EnableObserverPointer functionality

Classes derived from EnableObserverPointer provide a facility to subscribe to this object. This is mostly used by the ObserverPointer 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)
 

Protected Member Functions

void clear ()
 
template<typename BlockVectorType >
void vmult_block_block (BlockVectorType &dst, const BlockVectorType &src) const
 
template<typename BlockVectorType , typename VectorType >
void vmult_block_nonblock (BlockVectorType &dst, const VectorType &src) const
 
template<typename BlockVectorType , typename VectorType >
void vmult_nonblock_block (VectorType &dst, const BlockVectorType &src) const
 
template<typename VectorType >
void vmult_nonblock_nonblock (VectorType &dst, const VectorType &src) const
 
template<typename BlockVectorType >
void Tvmult_block_block (BlockVectorType &dst, const BlockVectorType &src) const
 
template<typename BlockVectorType , typename VectorType >
void Tvmult_block_nonblock (BlockVectorType &dst, const VectorType &src) const
 
template<typename BlockVectorType , typename VectorType >
void Tvmult_nonblock_block (VectorType &dst, const BlockVectorType &src) const
 
template<typename VectorType >
void Tvmult_nonblock_nonblock (VectorType &dst, const VectorType &src) const
 
void prepare_add_operation ()
 
void prepare_set_operation ()
 

Protected Attributes

BlockIndices row_block_indices
 
BlockIndices column_block_indices
 
Table< 2, ObserverPointer< BlockType, BlockMatrixBase< MatrixType > > > sub_objects
 

Private Types

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

Private Member Functions

template<typename VectorType1 , typename VectorType2 >
void vmult (VectorType1 &dst, const VectorType2 &src, const bool transpose, const std::bool_constant< true >, const std::bool_constant< true >) const
 
template<typename VectorType1 , typename VectorType2 >
void vmult (VectorType1 &dst, const VectorType2 &src, const bool transpose, const std::bool_constant< false >, const std::bool_constant< true >) const
 
template<typename VectorType1 , typename VectorType2 >
void vmult (VectorType1 &dst, const VectorType2 &src, const bool transpose, const std::bool_constant< true >, const std::bool_constant< false >) const
 
template<typename VectorType1 , typename VectorType2 >
void vmult (VectorType1 &dst, const VectorType2 &src, const bool transpose, const std::bool_constant< false >, const std::bool_constant< false >) const
 
void check_no_subscribers () const noexcept
 

Private Attributes

TemporaryData temporary_data
 
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, typename MemorySpace = ::MemorySpace::Host>
class LinearAlgebra::TpetraWrappers::BlockSparseMatrix< Number, MemorySpace >

Blocked sparse matrix based on the LinearAlgebra::TpetraWrappers::SparseMatrix class. This class implements the functions that are specific to the Trilinos SparseMatrix base objects for a blocked sparse matrix, and leaves the actual work relaying most of the calls to the individual blocks to the functions implemented in the base class. See there also for a description of when this class is useful.

In contrast to the deal.II-type SparseMatrix class, the Trilinos matrices do not have external objects for the sparsity patterns. Thus, one does not determine the size of the individual blocks of a block matrix of this type by attaching a block sparsity pattern, but by calling reinit() to set the number of blocks and then by setting the size of each block separately. In order to fix the data structures of the block matrix, it is then necessary to let it know that we have changed the sizes of the underlying matrices. For this, one has to call the collect_sizes() function, for much the same reason as is documented with the BlockSparsityPattern class.

See also
Block (linear algebra)

Definition at line 75 of file trilinos_tpetra_block_sparse_matrix.h.

Member Typedef Documentation

◆ BaseClass

template<typename Number , typename MemorySpace = ::MemorySpace::Host>
using LinearAlgebra::TpetraWrappers::BlockSparseMatrix< Number, MemorySpace >::BaseClass = BlockMatrixBase<SparseMatrix<Number, MemorySpace> >

Typedef the base class for simpler access to its own alias.

Definition at line 82 of file trilinos_tpetra_block_sparse_matrix.h.

◆ BlockType

template<typename Number , typename MemorySpace = ::MemorySpace::Host>
using LinearAlgebra::TpetraWrappers::BlockSparseMatrix< Number, MemorySpace >::BlockType = typename BaseClass::BlockType

Typedef the type of the underlying matrix.

Definition at line 87 of file trilinos_tpetra_block_sparse_matrix.h.

◆ value_type

template<typename Number , typename MemorySpace = ::MemorySpace::Host>
using LinearAlgebra::TpetraWrappers::BlockSparseMatrix< Number, MemorySpace >::value_type = typename BaseClass::value_type

Import the alias from the base class.

Definition at line 92 of file trilinos_tpetra_block_sparse_matrix.h.

◆ pointer

template<typename Number , typename MemorySpace = ::MemorySpace::Host>
using LinearAlgebra::TpetraWrappers::BlockSparseMatrix< Number, MemorySpace >::pointer = typename BaseClass::pointer

Definition at line 93 of file trilinos_tpetra_block_sparse_matrix.h.

◆ const_pointer

template<typename Number , typename MemorySpace = ::MemorySpace::Host>
using LinearAlgebra::TpetraWrappers::BlockSparseMatrix< Number, MemorySpace >::const_pointer = typename BaseClass::const_pointer

Definition at line 94 of file trilinos_tpetra_block_sparse_matrix.h.

◆ reference

template<typename Number , typename MemorySpace = ::MemorySpace::Host>
using LinearAlgebra::TpetraWrappers::BlockSparseMatrix< Number, MemorySpace >::reference = typename BaseClass::reference

Definition at line 95 of file trilinos_tpetra_block_sparse_matrix.h.

◆ const_reference

template<typename Number , typename MemorySpace = ::MemorySpace::Host>
using LinearAlgebra::TpetraWrappers::BlockSparseMatrix< Number, MemorySpace >::const_reference = typename BaseClass::const_reference

Definition at line 96 of file trilinos_tpetra_block_sparse_matrix.h.

◆ size_type

template<typename Number , typename MemorySpace = ::MemorySpace::Host>
using LinearAlgebra::TpetraWrappers::BlockSparseMatrix< Number, MemorySpace >::size_type = typename BaseClass::size_type

Definition at line 97 of file trilinos_tpetra_block_sparse_matrix.h.

◆ iterator

template<typename Number , typename MemorySpace = ::MemorySpace::Host>
using LinearAlgebra::TpetraWrappers::BlockSparseMatrix< Number, MemorySpace >::iterator = typename BaseClass::iterator

Definition at line 98 of file trilinos_tpetra_block_sparse_matrix.h.

◆ const_iterator

template<typename Number , typename MemorySpace = ::MemorySpace::Host>
using LinearAlgebra::TpetraWrappers::BlockSparseMatrix< Number, MemorySpace >::const_iterator = typename BaseClass::const_iterator

Definition at line 99 of file trilinos_tpetra_block_sparse_matrix.h.

◆ real_type

template<typename MatrixType >
using BlockMatrixBase< MatrixType >::real_type = typename numbers::NumberTraits<value_type>::real_type
inherited

Definition at line 362 of file block_matrix_base.h.

◆ map_value_type

The data type used in counter_map.

Definition at line 238 of file enable_observer_pointer.h.

◆ map_iterator

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

The iterator type used in counter_map.

Definition at line 243 of file enable_observer_pointer.h.

Constructor & Destructor Documentation

◆ BlockSparseMatrix()

template<typename Number , typename MemorySpace = ::MemorySpace::Host>
LinearAlgebra::TpetraWrappers::BlockSparseMatrix< Number, MemorySpace >::BlockSparseMatrix ( )
default

Constructor; initializes the matrix to be empty, without any structure, i.e. the matrix is not usable at all. This constructor is therefore only useful for matrices which are members of a class. All other matrices should be created at a point in the data flow where all necessary information is available.

You have to initialize the matrix before usage with reinit(BlockSparsityPattern). The number of blocks per row and column are then determined by that function.

◆ ~BlockSparseMatrix()

template<typename Number , typename MemorySpace = ::MemorySpace::Host>
LinearAlgebra::TpetraWrappers::BlockSparseMatrix< Number, MemorySpace >::~BlockSparseMatrix ( )
override

Destructor.

Member Function Documentation

◆ operator=() [1/2]

template<typename Number , typename MemorySpace = ::MemorySpace::Host>
BlockSparseMatrix< Number, MemorySpace > & LinearAlgebra::TpetraWrappers::BlockSparseMatrix< Number, MemorySpace >::operator= ( const BlockSparseMatrix< Number, MemorySpace > &  )
default

Pseudo copy operator only copying empty objects. The sizes of the block matrices need to be the same.

◆ operator=() [2/2]

template<typename Number , typename MemorySpace = ::MemorySpace::Host>
BlockSparseMatrix< Number, MemorySpace > & LinearAlgebra::TpetraWrappers::BlockSparseMatrix< Number, MemorySpace >::operator= ( const Number  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.

◆ reinit() [1/5]

template<typename Number , typename MemorySpace = ::MemorySpace::Host>
void LinearAlgebra::TpetraWrappers::BlockSparseMatrix< Number, MemorySpace >::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.

◆ reinit() [2/5]

template<typename Number , typename MemorySpace = ::MemorySpace::Host>
template<typename BlockSparsityPatternType >
void LinearAlgebra::TpetraWrappers::BlockSparseMatrix< Number, MemorySpace >::reinit ( const std::vector< IndexSet > &  input_maps,
const BlockSparsityPatternType &  block_sparsity_pattern,
const MPI_Comm  communicator = MPI_COMM_WORLD,
const bool  exchange_data = false 
)

Resize the matrix, by using an array of index sets to determine the parallel distribution of the individual matrices. This function assumes that a quadratic block matrix is generated.

◆ reinit() [3/5]

template<typename Number , typename MemorySpace = ::MemorySpace::Host>
template<typename BlockSparsityPatternType >
void LinearAlgebra::TpetraWrappers::BlockSparseMatrix< Number, MemorySpace >::reinit ( const BlockSparsityPatternType &  block_sparsity_pattern)

Resize the matrix and initialize it by the given sparsity pattern. Since no distribution map is given, the result is a block matrix for which all elements are stored locally.

◆ reinit() [4/5]

template<typename Number , typename MemorySpace = ::MemorySpace::Host>
void LinearAlgebra::TpetraWrappers::BlockSparseMatrix< Number, MemorySpace >::reinit ( const std::vector< IndexSet > &  parallel_partitioning,
const ::BlockSparseMatrix< double > &  dealii_block_sparse_matrix,
const MPI_Comm  communicator = MPI_COMM_WORLD,
const double  drop_tolerance = 1e-13 
)

This function initializes the Trilinos matrix using the deal.II sparse matrix and the entries stored therein. It uses a threshold to copy only elements whose modulus is larger than the threshold (so zeros in the deal.II matrix can be filtered away).

◆ reinit() [5/5]

template<typename Number , typename MemorySpace = ::MemorySpace::Host>
void LinearAlgebra::TpetraWrappers::BlockSparseMatrix< Number, MemorySpace >::reinit ( const ::BlockSparseMatrix< double > &  deal_ii_sparse_matrix,
const double  drop_tolerance = 1e-13 
)

This function initializes the Trilinos matrix using the deal.II sparse matrix and the entries stored therein. It uses a threshold to copy only elements whose modulus is larger than the threshold (so zeros in the deal.II matrix can be filtered away). Since no Epetra_Map is given, all the elements will be locally stored.

◆ is_compressed()

template<typename Number , typename MemorySpace = ::MemorySpace::Host>
bool LinearAlgebra::TpetraWrappers::BlockSparseMatrix< Number, MemorySpace >::is_compressed ( ) const

Return the state of the matrix, i.e., whether compress() needs to be called after an operation requiring data exchange. Does only return non-true values when used in debug mode, since it is quite expensive to keep track of all operations that lead to the need for compress().

◆ collect_sizes()

template<typename Number , typename MemorySpace = ::MemorySpace::Host>
void LinearAlgebra::TpetraWrappers::BlockSparseMatrix< Number, MemorySpace >::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. Note that this is a collective operation, i.e., it needs to be called on all MPI processes. This command internally calls the method compress(), so you don't need to call that function in case you use collect_sizes().

◆ n_nonzero_elements()

template<typename Number , typename MemorySpace = ::MemorySpace::Host>
std::uint64_t LinearAlgebra::TpetraWrappers::BlockSparseMatrix< Number, MemorySpace >::n_nonzero_elements ( ) const

Return the total number of nonzero elements of this matrix (summed over all MPI processes).

◆ get_mpi_communicator()

template<typename Number , typename MemorySpace = ::MemorySpace::Host>
MPI_Comm LinearAlgebra::TpetraWrappers::BlockSparseMatrix< Number, MemorySpace >::get_mpi_communicator ( ) const

Return the underlying MPI communicator.

◆ locally_owned_domain_indices()

template<typename Number , typename MemorySpace = ::MemorySpace::Host>
std::vector< IndexSet > LinearAlgebra::TpetraWrappers::BlockSparseMatrix< Number, MemorySpace >::locally_owned_domain_indices ( ) const

Return the partitioning of the domain space for the individual blocks of this matrix, i.e., the partitioning of the block vectors this matrix has to be multiplied with.

◆ locally_owned_range_indices()

template<typename Number , typename MemorySpace = ::MemorySpace::Host>
std::vector< IndexSet > LinearAlgebra::TpetraWrappers::BlockSparseMatrix< Number, MemorySpace >::locally_owned_range_indices ( ) const

Return the partitioning of the range space for the individual blocks of this matrix, i.e., the partitioning of the block vectors that result from matrix-vector products.

◆ vmult() [1/5]

template<typename Number , typename MemorySpace >
template<typename VectorType1 , typename VectorType2 >
void BlockSparseMatrix< Number, MemorySpace >::vmult ( VectorType1 &  dst,
const VectorType2 &  src 
) const
inline

Matrix-vector multiplication: let \(dst = M*src\) with \(M\) being this matrix. The vector types can be block vectors or non-block vectors (only if the matrix has only one row or column, respectively), and need to define TrilinosWrappers::SparseMatrix::vmult.

Definition at line 357 of file trilinos_tpetra_block_sparse_matrix.h.

◆ Tvmult()

template<typename Number , typename MemorySpace >
template<typename VectorType1 , typename VectorType2 >
void BlockSparseMatrix< Number, MemorySpace >::Tvmult ( VectorType1 &  dst,
const VectorType2 &  src 
) const
inline

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 372 of file trilinos_tpetra_block_sparse_matrix.h.

◆ residual() [1/2]

template<typename Number , typename MemorySpace = ::MemorySpace::Host>
template<typename VectorType1 , typename VectorType2 , typename VectorType3 >
Number LinearAlgebra::TpetraWrappers::BlockSparseMatrix< Number, MemorySpace >::residual ( VectorType1 &  dst,
const VectorType2 &  x,
const VectorType3 &  b 
) const

Compute the residual of an equation Mx=b, where the residual is defined to be r=b-Mx. Write the residual into dst. The l2 norm of the residual vector is returned.

Source x and destination dst must not be the same vector.

Note that both vectors have to be distributed vectors generated using the same Map as was used for the matrix.

This function only applicable if the matrix only has one block row.

◆ vmult() [2/5]

template<typename Number , typename MemorySpace >
template<typename VectorType1 , typename VectorType2 >
void BlockSparseMatrix< Number, MemorySpace >::vmult ( VectorType1 &  dst,
const VectorType2 &  src,
const bool  transpose,
const std::bool_constant< true >  ,
const std::bool_constant< true >   
) const
inlineprivate

Internal version of (T)vmult with two block vectors

Definition at line 387 of file trilinos_tpetra_block_sparse_matrix.h.

◆ vmult() [3/5]

template<typename Number , typename MemorySpace >
template<typename VectorType1 , typename VectorType2 >
void BlockSparseMatrix< Number, MemorySpace >::vmult ( VectorType1 &  dst,
const VectorType2 &  src,
const bool  transpose,
const std::bool_constant< false >  ,
const std::bool_constant< true >   
) const
inlineprivate

Internal version of (T)vmult where the source vector is a block vector but the destination vector is a non-block vector

Definition at line 405 of file trilinos_tpetra_block_sparse_matrix.h.

◆ vmult() [4/5]

template<typename Number , typename MemorySpace >
template<typename VectorType1 , typename VectorType2 >
void BlockSparseMatrix< Number, MemorySpace >::vmult ( VectorType1 &  dst,
const VectorType2 &  src,
const bool  transpose,
const std::bool_constant< true >  ,
const std::bool_constant< false >   
) const
inlineprivate

Internal version of (T)vmult where the source vector is a non-block vector but the destination vector is a block vector

Definition at line 423 of file trilinos_tpetra_block_sparse_matrix.h.

◆ vmult() [5/5]

template<typename Number , typename MemorySpace >
template<typename VectorType1 , typename VectorType2 >
void BlockSparseMatrix< Number, MemorySpace >::vmult ( VectorType1 &  dst,
const VectorType2 &  src,
const bool  transpose,
const std::bool_constant< false >  ,
const std::bool_constant< false >   
) const
inlineprivate

Internal version of (T)vmult where both source vector and the destination vector are non-block vectors (only defined if the matrix consists of only one block)

Definition at line 441 of file trilinos_tpetra_block_sparse_matrix.h.

◆ copy_from()

template<typename MatrixType >
template<typename BlockMatrixType >
BlockMatrixBase & BlockMatrixBase< MatrixType >::copy_from ( const BlockMatrixType &  source)
inherited

Copy the matrix given as argument into the current object.

Copying matrices is an expensive operation that we do not want to happen by accident through compiler generated code for operator=. (This would happen, for example, if one accidentally declared a function argument of the current type by value rather than by reference.) The functionality of copying matrices is implemented in this member function instead. All copy operations of objects of this type therefore require an explicit function call.

The source matrix may be a matrix of arbitrary type, as long as its data type is convertible to the data type of this matrix.

The function returns a reference to this.

◆ block() [1/2]

template<typename MatrixType >
BlockType & BlockMatrixBase< MatrixType >::block ( const unsigned int  row,
const unsigned int  column 
)
inherited

Access the block with the given coordinates.

◆ block() [2/2]

template<typename MatrixType >
const BlockType & BlockMatrixBase< MatrixType >::block ( const unsigned int  row,
const unsigned int  column 
) const
inherited

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

◆ m()

template<typename MatrixType >
size_type BlockMatrixBase< MatrixType >::m ( ) const
inherited

Return the dimension of the codomain (or range) space. Note that the matrix is of dimension \(m \times n\).

◆ n()

template<typename MatrixType >
size_type BlockMatrixBase< MatrixType >::n ( ) const
inherited

Return the dimension of the domain space. Note that the matrix is of dimension \(m \times n\).

◆ n_block_rows()

template<typename MatrixType >
unsigned int BlockMatrixBase< MatrixType >::n_block_rows ( ) const
inherited

Return the number of blocks in a column. Returns zero if no sparsity pattern is presently associated to this matrix.

◆ n_block_cols()

template<typename MatrixType >
unsigned int BlockMatrixBase< MatrixType >::n_block_cols ( ) const
inherited

Return the number of blocks in a row. Returns zero if no sparsity pattern is presently associated to this matrix.

◆ set() [1/5]

template<typename MatrixType >
void BlockMatrixBase< MatrixType >::set ( const size_type  i,
const size_type  j,
const value_type  value 
)
inherited

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.

◆ set() [2/5]

template<typename MatrixType >
template<typename number >
void BlockMatrixBase< MatrixType >::set ( const std::vector< size_type > &  indices,
const FullMatrix< number > &  full_matrix,
const bool  elide_zero_values = false 
)
inherited

Set all elements given in a FullMatrix into the sparse matrix locations given by indices. In other words, this function writes the elements in full_matrix into the calling matrix, using the local-to-global indexing specified by indices for both the rows and the columns of the matrix. This function assumes a quadratic sparse matrix and a quadratic full_matrix, the usual situation in FE calculations.

The optional parameter elide_zero_values can be used to specify whether zero values should be set anyway or they should be filtered away (and not change the previous content in the respective element if it exists). The default value is false, i.e., even zero values are treated.

◆ set() [3/5]

template<typename MatrixType >
template<typename number >
void BlockMatrixBase< MatrixType >::set ( const std::vector< size_type > &  row_indices,
const std::vector< size_type > &  col_indices,
const FullMatrix< number > &  full_matrix,
const bool  elide_zero_values = false 
)
inherited

Same function as before, but now including the possibility to use rectangular full_matrices and different local-to-global indexing on rows and columns, respectively.

◆ set() [4/5]

template<typename MatrixType >
template<typename number >
void BlockMatrixBase< MatrixType >::set ( const size_type  row,
const std::vector< size_type > &  col_indices,
const std::vector< number > &  values,
const bool  elide_zero_values = false 
)
inherited

Set several elements in the specified row of the matrix with column indices as given by col_indices to the respective value.

The optional parameter elide_zero_values can be used to specify whether zero values should be set anyway or they should be filtered away (and not change the previous content in the respective element if it exists). The default value is false, i.e., even zero values are treated.

◆ set() [5/5]

template<typename MatrixType >
template<typename number >
void BlockMatrixBase< MatrixType >::set ( const size_type  row,
const size_type  n_cols,
const size_type col_indices,
const number *  values,
const bool  elide_zero_values = false 
)
inherited

Set several elements to values given by values in a given row in columns given by col_indices into the sparse matrix.

The optional parameter elide_zero_values can be used to specify whether zero values should be inserted anyway or they should be filtered away. The default value is false, i.e., even zero values are inserted/replaced.

◆ add() [1/6]

template<typename MatrixType >
void BlockMatrixBase< MatrixType >::add ( const size_type  i,
const size_type  j,
const value_type  value 
)
inherited

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.

◆ add() [2/6]

template<typename MatrixType >
template<typename number >
void BlockMatrixBase< MatrixType >::add ( const std::vector< size_type > &  indices,
const FullMatrix< number > &  full_matrix,
const bool  elide_zero_values = true 
)
inherited

Add all elements given in a FullMatrix<double> into sparse matrix locations given by indices. In other words, this function adds the elements in full_matrix to the respective entries in calling matrix, using the local-to-global indexing specified by indices for both the rows and the columns of the matrix. This function assumes a quadratic sparse matrix and a quadratic full_matrix, the usual situation in FE calculations.

The optional parameter elide_zero_values can be used to specify whether zero values should be added anyway or these should be filtered away and only non-zero data is added. The default value is true, i.e., zero values won't be added into the matrix.

◆ add() [3/6]

template<typename MatrixType >
template<typename number >
void BlockMatrixBase< MatrixType >::add ( const std::vector< size_type > &  row_indices,
const std::vector< size_type > &  col_indices,
const FullMatrix< number > &  full_matrix,
const bool  elide_zero_values = true 
)
inherited

Same function as before, but now including the possibility to use rectangular full_matrices and different local-to-global indexing on rows and columns, respectively.

◆ add() [4/6]

template<typename MatrixType >
template<typename number >
void BlockMatrixBase< MatrixType >::add ( const size_type  row,
const std::vector< size_type > &  col_indices,
const std::vector< number > &  values,
const bool  elide_zero_values = true 
)
inherited

Set several elements in the specified row of the matrix with column indices as given by col_indices to the respective value.

The optional parameter elide_zero_values can be used to specify whether zero values should be added anyway or these should be filtered away and only non-zero data is added. The default value is true, i.e., zero values won't be added into the matrix.

◆ add() [5/6]

template<typename MatrixType >
template<typename number >
void BlockMatrixBase< MatrixType >::add ( const size_type  row,
const size_type  n_cols,
const size_type col_indices,
const number *  values,
const bool  elide_zero_values = true,
const bool  col_indices_are_sorted = false 
)
inherited

Add an array of values given by values in the given global matrix row at columns specified by col_indices in the sparse matrix.

The optional parameter elide_zero_values can be used to specify whether zero values should be added anyway or these should be filtered away and only non-zero data is added. The default value is true, i.e., zero values won't be added into the matrix.

◆ add() [6/6]

template<typename MatrixType >
void BlockMatrixBase< MatrixType >::add ( const value_type  factor,
const BlockMatrixBase< MatrixType > &  matrix 
)
inherited

Add matrix scaled by factor to this matrix, i.e. the matrix factor*matrix is added to this. If the sparsity pattern of the calling matrix does not contain all the elements in the sparsity pattern of the input matrix, this function will throw an exception.

Depending on MatrixType, however, additional restrictions might arise. Some sparse matrix formats require matrix to be based on the same sparsity pattern as the calling matrix.

◆ operator()()

template<typename MatrixType >
value_type BlockMatrixBase< MatrixType >::operator() ( const size_type  i,
const size_type  j 
) const
inherited

Return the value of the entry (i,j). This may be an expensive operation and you should always take care where to call this function. In order to avoid abuse, this function throws an exception if the wanted element does not exist in the matrix.

◆ el()

template<typename MatrixType >
value_type BlockMatrixBase< MatrixType >::el ( const size_type  i,
const size_type  j 
) const
inherited

This function is mostly like operator()() in that it returns the value of the matrix entry (i,j). The only difference is that if this entry does not exist in the sparsity pattern, then instead of raising an exception, zero is returned. While this may be convenient in some cases, note that it is simple to write algorithms that are slow compared to an optimal solution, since the sparsity of the matrix is not used.

◆ diag_element()

template<typename MatrixType >
value_type BlockMatrixBase< MatrixType >::diag_element ( const size_type  i) const
inherited

Return the main diagonal element in the ith row. This function throws an error if the matrix is not quadratic and also if the diagonal blocks of the matrix are not quadratic.

This function is considerably faster than the operator()(), since for quadratic matrices, the diagonal entry may be the first to be stored in each row and access therefore does not involve searching for the right column number.

◆ compress()

template<typename MatrixType >
void BlockMatrixBase< MatrixType >::compress ( VectorOperation::values  operation)
inherited

Call the compress() function on all the subblocks of the matrix.

See Compressing distributed objects for more information.

◆ operator*=()

template<typename MatrixType >
BlockMatrixBase & BlockMatrixBase< MatrixType >::operator*= ( const value_type  factor)
inherited

Multiply the entire matrix by a fixed factor.

◆ operator/=()

template<typename MatrixType >
BlockMatrixBase & BlockMatrixBase< MatrixType >::operator/= ( const value_type  factor)
inherited

Divide the entire matrix by a fixed factor.

◆ vmult_add()

template<typename MatrixType >
template<typename BlockVectorType >
void BlockMatrixBase< MatrixType >::vmult_add ( BlockVectorType &  dst,
const BlockVectorType &  src 
) const
inherited

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

◆ Tvmult_add()

template<typename MatrixType >
template<typename BlockVectorType >
void BlockMatrixBase< MatrixType >::Tvmult_add ( BlockVectorType &  dst,
const BlockVectorType &  src 
) const
inherited

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

◆ matrix_norm_square()

template<typename MatrixType >
template<typename BlockVectorType >
value_type BlockMatrixBase< MatrixType >::matrix_norm_square ( const BlockVectorType &  v) const
inherited

Return the norm of the vector v with respect to the norm induced by this matrix, i.e. vTMv). This is useful, e.g. in the finite element context, where the LT-norm of a function equals the matrix norm with respect to the mass matrix of the vector representing the nodal values of the finite element function. Note that even though the function's name might suggest something different, for historic reasons not the norm but its square is returned, as defined above by the scalar product.

Obviously, the matrix needs to be square for this operation.

◆ frobenius_norm()

template<typename MatrixType >
real_type BlockMatrixBase< MatrixType >::frobenius_norm ( ) const
inherited

Return the frobenius norm of the matrix, i.e. the square root of the sum of squares of all entries in the matrix.

◆ matrix_scalar_product()

template<typename MatrixType >
template<typename BlockVectorType >
value_type BlockMatrixBase< MatrixType >::matrix_scalar_product ( const BlockVectorType &  u,
const BlockVectorType &  v 
) const
inherited

Compute the matrix scalar product \(\left(u,Mv\right)\).

◆ residual() [2/2]

template<typename MatrixType >
template<typename BlockVectorType >
value_type BlockMatrixBase< MatrixType >::residual ( BlockVectorType &  dst,
const BlockVectorType &  x,
const BlockVectorType &  b 
) const
inherited

Compute the residual r=b-Ax. Write the residual into dst.

◆ print()

template<typename MatrixType >
void BlockMatrixBase< MatrixType >::print ( std::ostream &  out,
const bool  alternative_output = false 
) const
inherited

Print the matrix to the given stream, using the format (line,col) value, i.e. one nonzero entry of the matrix per line. The optional flag outputs the sparsity pattern in a different style according to the underlying sparse matrix type.

◆ begin() [1/4]

template<typename MatrixType >
iterator BlockMatrixBase< MatrixType >::begin ( )
inherited

Iterator starting at the first entry.

◆ begin() [2/4]

template<typename MatrixType >
iterator BlockMatrixBase< MatrixType >::begin ( const size_type  r)
inherited

Iterator starting at the first entry of row r.

◆ begin() [3/4]

template<typename MatrixType >
const_iterator BlockMatrixBase< MatrixType >::begin ( ) const
inherited

Iterator starting at the first entry.

◆ begin() [4/4]

template<typename MatrixType >
const_iterator BlockMatrixBase< MatrixType >::begin ( const size_type  r) const
inherited

Iterator starting at the first entry of row r.

◆ end() [1/4]

template<typename MatrixType >
iterator BlockMatrixBase< MatrixType >::end ( )
inherited

Final iterator.

◆ end() [2/4]

template<typename MatrixType >
iterator BlockMatrixBase< MatrixType >::end ( const size_type  r)
inherited

Final iterator of row r.

◆ end() [3/4]

template<typename MatrixType >
const_iterator BlockMatrixBase< MatrixType >::end ( ) const
inherited

Final iterator.

◆ end() [4/4]

template<typename MatrixType >
const_iterator BlockMatrixBase< MatrixType >::end ( const size_type  r) const
inherited

Final iterator of row r.

◆ get_row_indices()

template<typename MatrixType >
const BlockIndices & BlockMatrixBase< MatrixType >::get_row_indices ( ) const
inherited

Return a reference to the underlying BlockIndices data of the rows.

◆ get_column_indices()

template<typename MatrixType >
const BlockIndices & BlockMatrixBase< MatrixType >::get_column_indices ( ) const
inherited

Return a reference to the underlying BlockIndices data of the columns.

◆ memory_consumption()

template<typename MatrixType >
std::size_t BlockMatrixBase< MatrixType >::memory_consumption ( ) const
inherited

Determine an estimate for the memory consumption (in bytes) of this object. Note that only the memory reserved on the current processor is returned in case this is called in an MPI-based program.

◆ clear()

template<typename MatrixType >
void BlockMatrixBase< MatrixType >::clear ( )
protectedinherited

Release all memory and return to a state just like after having called the default constructor. It also forgets the sparsity pattern it was previously tied to.

This calls clear for all sub-matrices and then resets this object to have no blocks at all.

This function is protected since it may be necessary to release additional structures. A derived class can make it public again, if it is sufficient.

◆ vmult_block_block()

template<typename MatrixType >
template<typename BlockVectorType >
void BlockMatrixBase< MatrixType >::vmult_block_block ( BlockVectorType &  dst,
const BlockVectorType &  src 
) const
protectedinherited

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

Due to problems with deriving template arguments between the block and non-block versions of the vmult/Tvmult functions, the actual functions are implemented in derived classes, with implementations forwarding the calls to the implementations provided here under a unique name for which template arguments can be derived by the compiler.

◆ vmult_block_nonblock()

template<typename MatrixType >
template<typename BlockVectorType , typename VectorType >
void BlockMatrixBase< MatrixType >::vmult_block_nonblock ( BlockVectorType &  dst,
const VectorType &  src 
) const
protectedinherited

Matrix-vector multiplication. Just like the previous function, but only applicable if the matrix has only one block column.

Due to problems with deriving template arguments between the block and non-block versions of the vmult/Tvmult functions, the actual functions are implemented in derived classes, with implementations forwarding the calls to the implementations provided here under a unique name for which template arguments can be derived by the compiler.

◆ vmult_nonblock_block()

template<typename MatrixType >
template<typename BlockVectorType , typename VectorType >
void BlockMatrixBase< MatrixType >::vmult_nonblock_block ( VectorType &  dst,
const BlockVectorType &  src 
) const
protectedinherited

Matrix-vector multiplication. Just like the previous function, but only applicable if the matrix has only one block row.

Due to problems with deriving template arguments between the block and non-block versions of the vmult/Tvmult functions, the actual functions are implemented in derived classes, with implementations forwarding the calls to the implementations provided here under a unique name for which template arguments can be derived by the compiler.

◆ vmult_nonblock_nonblock()

template<typename MatrixType >
template<typename VectorType >
void BlockMatrixBase< MatrixType >::vmult_nonblock_nonblock ( VectorType &  dst,
const VectorType &  src 
) const
protectedinherited

Matrix-vector multiplication. Just like the previous function, but only applicable if the matrix has only one block.

Due to problems with deriving template arguments between the block and non-block versions of the vmult/Tvmult functions, the actual functions are implemented in derived classes, with implementations forwarding the calls to the implementations provided here under a unique name for which template arguments can be derived by the compiler.

◆ Tvmult_block_block()

template<typename MatrixType >
template<typename BlockVectorType >
void BlockMatrixBase< MatrixType >::Tvmult_block_block ( BlockVectorType &  dst,
const BlockVectorType &  src 
) const
protectedinherited

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.

Due to problems with deriving template arguments between the block and non-block versions of the vmult/Tvmult functions, the actual functions are implemented in derived classes, with implementations forwarding the calls to the implementations provided here under a unique name for which template arguments can be derived by the compiler.

◆ Tvmult_block_nonblock()

template<typename MatrixType >
template<typename BlockVectorType , typename VectorType >
void BlockMatrixBase< MatrixType >::Tvmult_block_nonblock ( BlockVectorType &  dst,
const VectorType &  src 
) const
protectedinherited

Matrix-vector multiplication. Just like the previous function, but only applicable if the matrix has only one block row.

Due to problems with deriving template arguments between the block and non-block versions of the vmult/Tvmult functions, the actual functions are implemented in derived classes, with implementations forwarding the calls to the implementations provided here under a unique name for which template arguments can be derived by the compiler.

◆ Tvmult_nonblock_block()

template<typename MatrixType >
template<typename BlockVectorType , typename VectorType >
void BlockMatrixBase< MatrixType >::Tvmult_nonblock_block ( VectorType &  dst,
const BlockVectorType &  src 
) const
protectedinherited

Matrix-vector multiplication. Just like the previous function, but only applicable if the matrix has only one block column.

Due to problems with deriving template arguments between the block and non-block versions of the vmult/Tvmult functions, the actual functions are implemented in derived classes, with implementations forwarding the calls to the implementations provided here under a unique name for which template arguments can be derived by the compiler.

◆ Tvmult_nonblock_nonblock()

template<typename MatrixType >
template<typename VectorType >
void BlockMatrixBase< MatrixType >::Tvmult_nonblock_nonblock ( VectorType &  dst,
const VectorType &  src 
) const
protectedinherited

Matrix-vector multiplication. Just like the previous function, but only applicable if the matrix has only one block.

Due to problems with deriving template arguments between the block and non-block versions of the vmult/Tvmult functions, the actual functions are implemented in derived classes, with implementations forwarding the calls to the implementations provided here under a unique name for which template arguments can be derived by the compiler.

◆ prepare_add_operation()

template<typename MatrixType >
void BlockMatrixBase< MatrixType >::prepare_add_operation ( )
protectedinherited

Some matrix types, in particular PETSc, need to synchronize set and add operations. This has to be done for all matrices in the BlockMatrix. This routine prepares adding of elements by notifying all blocks. Called by all internal routines before adding elements.

◆ prepare_set_operation()

template<typename MatrixType >
void BlockMatrixBase< MatrixType >::prepare_set_operation ( )
protectedinherited

Notifies all blocks to let them prepare for setting elements, see prepare_add_operation().

◆ subscribe()

void EnableObserverPointer::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 131 of file enable_observer_pointer.cc.

◆ unsubscribe()

void EnableObserverPointer::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 151 of file enable_observer_pointer.cc.

◆ n_subscriptions()

unsigned int EnableObserverPointer::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 322 of file enable_observer_pointer.h.

◆ list_subscribers() [1/2]

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

List the subscribers to the input stream.

Definition at line 339 of file enable_observer_pointer.h.

◆ list_subscribers() [2/2]

void EnableObserverPointer::list_subscribers ( ) const
inherited

List the subscribers to deallog.

Definition at line 199 of file enable_observer_pointer.cc.

◆ serialize()

template<class Archive >
void EnableObserverPointer::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 331 of file enable_observer_pointer.h.

◆ check_no_subscribers()

void EnableObserverPointer::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 enable_observer_pointer.cc.

Member Data Documentation

◆ row_block_indices

template<typename MatrixType >
BlockIndices BlockMatrixBase< MatrixType >::row_block_indices
protectedinherited

Index arrays for rows and columns.

Definition at line 846 of file block_matrix_base.h.

◆ column_block_indices

template<typename MatrixType >
BlockIndices BlockMatrixBase< MatrixType >::column_block_indices
protectedinherited

Definition at line 847 of file block_matrix_base.h.

◆ sub_objects

template<typename MatrixType >
Table<2, ObserverPointer<BlockType, BlockMatrixBase<MatrixType> > > BlockMatrixBase< MatrixType >::sub_objects
protectedinherited

Array of sub-matrices.

Definition at line 852 of file block_matrix_base.h.

◆ temporary_data

template<typename MatrixType >
TemporaryData BlockMatrixBase< MatrixType >::temporary_data
privateinherited

A set of scratch arrays that can be used by the add() and set() functions that take pointers to data to pre-sort indices before use. Access from multiple threads is synchronized via the mutex variable that is part of the structure.

Definition at line 1064 of file block_matrix_base.h.

◆ counter

std::atomic<unsigned int> EnableObserverPointer::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 227 of file enable_observer_pointer.h.

◆ counter_map

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

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

Definition at line 233 of file enable_observer_pointer.h.

◆ validity_pointers

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

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

Definition at line 249 of file enable_observer_pointer.h.

◆ object_info

const std::type_info* EnableObserverPointer::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 257 of file enable_observer_pointer.h.

◆ mutex

std::mutex EnableObserverPointer::mutex
staticprivateinherited

A mutex used to ensure data consistency when accessing the mutable members of this class. This lock is used in the subscribe() and unsubscribe() functions, as well as in list_subscribers().

Definition at line 280 of file enable_observer_pointer.h.


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