deal.II version GIT relicensing-2076-g6b43d56a25 2024-11-02 12:30:00+00:00
|
#include <deal.II/lac/matrix_block.h>
Public Types | |
using | size_type = types::global_dof_index |
using | value_type = typename MatrixType::value_type |
Static Public Member Functions | |
static ::ExceptionBase & | ExcBlockIndexMismatch (size_type arg1, size_type arg2) |
static ::ExceptionBase & | ExcInUse (int arg1, std::string arg2, std::string arg3) |
static ::ExceptionBase & | ExcNoSubscriber (std::string arg1, std::string arg2) |
Public Attributes | |
size_type | row |
size_type | column |
MatrixType | matrix |
Private Types | |
using | map_value_type = decltype(counter_map)::value_type |
using | map_iterator = decltype(counter_map)::iterator |
Private Member Functions | |
template<class OTHER_MatrixType > | |
friend | void::internal::reinit (MatrixBlock< OTHER_MatrixType > &, const BlockSparsityPattern &) |
void | check_no_subscribers () const noexcept |
Private Attributes | |
BlockIndices | row_indices |
BlockIndices | column_indices |
std::atomic< unsigned int > | counter |
std::map< std::string, unsigned int > | counter_map |
std::vector< std::atomic< bool > * > | validity_pointers |
const std::type_info * | object_info |
Static Private Attributes | |
static std::mutex | mutex |
Friends | |
template<typename number > | |
void | internal::reinit (MatrixBlock<::SparseMatrix< number > > &v, const BlockSparsityPattern &p) |
A wrapper around a matrix object, storing the coordinates in a block matrix as well.
This class is an alternative to BlockMatrixBase, if you only want to generate a single block of the system, not the whole system. Using the add() functions of this class, it is possible to use the standard assembling functions used for block matrices, but only enter in one of the blocks and still avoiding the index computations involved. The reason for this class is, that we may need a different number of matrices for different blocks in a block system. For example, a preconditioner for the Oseen system can be built as a block system, where the pressure block is of the form M-1FA-1 with M the pressure mass matrix, A the pressure Laplacian and F the advection diffusion operator applied to the pressure space. Since only a single matrix is needed for the other blocks, using BlockSparseMatrix or similar would be a waste of memory.
While the add() functions make a MatrixBlock appear like a block matrix for assembling, the functions vmult(), Tvmult(), vmult_add(), and Tvmult_add() make it behave like a MatrixType, when it comes to applying it to a vector. This behavior allows us to store MatrixBlock objects in vectors, for instance in MGLevelObject without extracting the matrix first.
Definition at line 92 of file matrix_block.h.
using MatrixBlock< MatrixType >::size_type = types::global_dof_index |
Declare type for container size.
Definition at line 98 of file matrix_block.h.
using MatrixBlock< MatrixType >::value_type = typename MatrixType::value_type |
Declare a type for matrix entries.
Definition at line 103 of file matrix_block.h.
|
privateinherited |
The data type used in counter_map.
Definition at line 238 of file enable_observer_pointer.h.
|
privateinherited |
The iterator type used in counter_map.
Definition at line 243 of file enable_observer_pointer.h.
|
inline |
Constructor rendering an uninitialized object.
Definition at line 619 of file matrix_block.h.
|
default |
Copy constructor.
|
inline |
Constructor setting block coordinates, but not initializing the matrix.
Definition at line 626 of file matrix_block.h.
|
default |
Assignment operator.
|
inline |
Reinitialize the matrix for a new BlockSparsityPattern. This adjusts the matrix as well as the row_indices and column_indices.
Definition at line 634 of file matrix_block.h.
|
inline |
Definition at line 641 of file matrix_block.h.
|
inline |
Definition at line 648 of file matrix_block.h.
|
inline |
Add value
to the element (i,j). Throws an error if the entry does not exist or if it is in a different block.
Definition at line 656 of file matrix_block.h.
|
inline |
Add all elements in a FullMatrix into sparse matrix locations given by indices
. This function assumes a quadratic sparse matrix and a quadratic full_matrix. The global locations are translated into locations in this block and ExcBlockIndexMismatch is thrown, if the global index does not point into the block referred to by row and column.
elide_zero_values
is currently ignored.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.
Definition at line 739 of file matrix_block.h.
|
inline |
Add all elements in a FullMatrix into global locations given by row_indices
and col_indices
, respectively. The global locations are translated into locations in this block and ExcBlockIndexMismatch is thrown, if the global index does not point into the block referred to by row and column.
elide_zero_values
is currently ignored.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.
Definition at line 677 of file matrix_block.h.
|
inline |
Set several elements in the specified row of the matrix with column indices as given by col_indices
to the respective value. This is the function doing the actual work for the ones adding full matrices. The global locations row_index
and col_indices
are translated into locations in this block and ExcBlockIndexMismatch is thrown, if the global index does not point into the block referred to by row and column.
elide_zero_values
is currently ignored.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.
Definition at line 762 of file matrix_block.h.
|
inline |
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.
Definition at line 700 of file matrix_block.h.
|
inline |
Matrix-vector-multiplication, forwarding to the same function in MatrixType. No index computations are done, thus, the vectors need to have sizes matching matrix.
Definition at line 782 of file matrix_block.h.
|
inline |
Matrix-vector-multiplication, forwarding to the same function in MatrixType. No index computations are done, thus, the vectors need to have sizes matching matrix.
Definition at line 791 of file matrix_block.h.
|
inline |
Matrix-vector-multiplication, forwarding to the same function in MatrixType. No index computations are done, thus, the vectors need to have sizes matching matrix.
Definition at line 800 of file matrix_block.h.
|
inline |
Matrix-vector-multiplication, forwarding to the same function in MatrixType. No index computations are done, thus, the vectors need to have sizes matching matrix.
Definition at line 809 of file matrix_block.h.
|
inline |
The memory used by this object.
Definition at line 817 of file matrix_block.h.
|
private |
|
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.
|
inherited |
Unsubscribes a user from the object.
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.
|
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.
|
inlineinherited |
List the subscribers to the input stream
.
Definition at line 339 of file enable_observer_pointer.h.
|
inherited |
List the subscribers to deallog
.
Definition at line 199 of file enable_observer_pointer.cc.
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.
|
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.
Definition at line 53 of file enable_observer_pointer.cc.
|
friend |
size_type MatrixBlock< MatrixType >::row |
Row coordinate. This is the position of the data member matrix on the global matrix.
Definition at line 287 of file matrix_block.h.
size_type MatrixBlock< MatrixType >::column |
Column coordinate. This is the position of the data member matrix on the global matrix.
Definition at line 292 of file matrix_block.h.
MatrixType MatrixBlock< MatrixType >::matrix |
The matrix itself
Definition at line 297 of file matrix_block.h.
|
private |
The row BlockIndices of the whole system. Using row(), this allows us to find the index of the first row degree of freedom for this block.
Definition at line 304 of file matrix_block.h.
|
private |
The column BlockIndices of the whole system. Using column(), this allows us to find the index of the first column degree of freedom for this block.
Definition at line 310 of file matrix_block.h.
|
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.
|
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.
|
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.
|
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.
|
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.