Reference documentation for deal.II version 9.5.0
|
#include <deal.II/lac/block_sparsity_pattern.h>
Public Types | |
using | size_type = types::global_dof_index |
Public Member Functions | |
BlockSparsityPattern ()=default | |
BlockSparsityPattern (const size_type n_rows, const size_type n_columns) | |
BlockSparsityPattern (const std::vector< size_type > &row_block_sizes, const std::vector< size_type > &col_block_sizes) | |
BlockSparsityPattern (const std::vector< IndexSet > ¶llel_partitioning, const MPI_Comm communicator=MPI_COMM_WORLD) | |
BlockSparsityPattern (const std::vector< IndexSet > &row_parallel_partitioning, const std::vector< IndexSet > &column_parallel_partitioning, const std::vector< IndexSet > &writeable_rows, const MPI_Comm communicator=MPI_COMM_WORLD) | |
void | reinit (const std::vector< size_type > &row_block_sizes, const std::vector< size_type > &col_block_sizes) |
void | reinit (const std::vector< IndexSet > ¶llel_partitioning, const MPI_Comm communicator=MPI_COMM_WORLD) |
void | reinit (const std::vector< IndexSet > &row_parallel_partitioning, const std::vector< IndexSet > &column_parallel_partitioning, const MPI_Comm communicator=MPI_COMM_WORLD) |
void | reinit (const std::vector< IndexSet > &row_parallel_partitioning, const std::vector< IndexSet > &column_parallel_partitioning, const std::vector< IndexSet > &writeable_rows, const MPI_Comm communicator=MPI_COMM_WORLD) |
void | reinit (const size_type n_block_rows, const size_type n_block_columns) |
void | collect_sizes () |
SparsityPattern & | block (const size_type row, const size_type column) |
const SparsityPattern & | block (const size_type row, const size_type column) const |
const BlockIndices & | get_row_indices () const |
const BlockIndices & | get_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) |
virtual void | add_entries (const ArrayView< const std::pair< size_type, size_type > > &entries) |
virtual void | add_row_entries (const size_type &row, const ArrayView< const size_type > &columns, const bool indices_are_sorted=false) override |
bool | exists (const size_type i, const size_type j) const |
unsigned int | row_length (const size_type row) const |
size_type | n_nonzero_elements () const |
void | print (std::ostream &out) const |
void | print_gnuplot (std::ostream &out) const |
void | print_svg (std::ostream &out) const |
std::size_t | memory_consumption () const |
size_type | n_rows () const |
size_type | n_cols () 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 ::ExceptionBase & | ExcNeedsCollectSizes () |
static ::ExceptionBase & | ExcIncompatibleRowNumbers (int arg1, int arg2, int arg3, int arg4) |
static ::ExceptionBase & | ExcIncompatibleColNumbers (int arg1, int arg2, int arg3, int arg4) |
static ::ExceptionBase & | ExcInUse (int arg1, std::string arg2, std::string arg3) |
static ::ExceptionBase & | ExcNoSubscriber (std::string arg1, std::string arg2) |
Static Public Attributes | |
static const size_type | invalid_entry |
Protected Member Functions | |
virtual void | resize (const size_type rows, const size_type cols) |
Protected Attributes | |
size_type | block_rows |
size_type | block_columns |
Table< 2, std::unique_ptr< SparsityPattern > > | sub_objects |
BlockIndices | row_indices |
BlockIndices | column_indices |
size_type | rows |
size_type | cols |
Private Types | |
using | map_value_type = decltype(counter_map)::value_type |
using | map_iterator = decltype(counter_map)::iterator |
Private Member Functions | |
size_type | compute_n_rows () const |
size_type | compute_n_cols () const |
void | check_no_subscribers () const noexcept |
Private Attributes | |
std::vector< size_type > | counter_within_block |
std::vector< std::vector< size_type > > | block_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 |
This class extends the base class to implement an array of Trilinos sparsity patterns that can be used to initialize Trilinos block sparse matrices that can be distributed among different processors. It is used in the same way as the BlockSparsityPattern except that it builds upon the TrilinosWrappers::SparsityPattern instead of the SparsityPattern.
This class is has properties of the "dynamic" type of Sparsity (in the sense that it can extend the memory if too little elements were allocated), but otherwise is more like the basic deal.II SparsityPattern (in the sense that the method compress() needs to be called before the pattern can be used).
This class is used in step-32.
Definition at line 664 of file block_sparsity_pattern.h.
|
inherited |
Declare type for container size.
Definition at line 86 of file block_sparsity_pattern.h.
|
privateinherited |
The data type used in counter_map.
Definition at line 230 of file subscriptor.h.
|
privateinherited |
The iterator type used in counter_map.
Definition at line 235 of file subscriptor.h.
|
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.
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 536 of file block_sparsity_pattern.cc.
BlockSparsityPattern::BlockSparsityPattern | ( | 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 543 of file block_sparsity_pattern.cc.
BlockSparsityPattern::BlockSparsityPattern | ( | const std::vector< IndexSet > & | parallel_partitioning, |
const MPI_Comm | communicator = MPI_COMM_WORLD |
||
) |
Initialize the pattern with an array of index sets that specifies both rows and columns of the matrix (so the final matrix will be a square matrix), where the size() of the IndexSets specifies the size of the blocks and the values in each IndexSet denotes the rows that are going to be saved in each block.
Definition at line 557 of file block_sparsity_pattern.cc.
BlockSparsityPattern::BlockSparsityPattern | ( | const std::vector< IndexSet > & | row_parallel_partitioning, |
const std::vector< IndexSet > & | column_parallel_partitioning, | ||
const std::vector< IndexSet > & | writeable_rows, | ||
const MPI_Comm | communicator = MPI_COMM_WORLD |
||
) |
Initialize the pattern with two arrays of index sets that specify rows and columns of the matrix, where the size() of the IndexSets specifies the size of the blocks and the values in each IndexSet denotes the rows that are going to be saved in each block. The additional index set writable_rows is used to set all rows that we allow to write locally. This constructor is used to create matrices that allow several threads to write simultaneously into the matrix (to different rows, of course), see the method TrilinosWrappers::SparsityPattern::reinit method with three index set arguments for more details.
Definition at line 573 of file block_sparsity_pattern.cc.
void BlockSparsityPattern::reinit | ( | const std::vector< size_type > & | row_block_sizes, |
const std::vector< size_type > & | col_block_sizes | ||
) |
Resize the matrix 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 594 of file block_sparsity_pattern.cc.
void BlockSparsityPattern::reinit | ( | const std::vector< IndexSet > & | parallel_partitioning, |
const MPI_Comm | communicator = MPI_COMM_WORLD |
||
) |
Resize the matrix to a square tensor product of matrices. See the constructor that takes a vector of IndexSets for details.
Definition at line 608 of file block_sparsity_pattern.cc.
void BlockSparsityPattern::reinit | ( | const std::vector< IndexSet > & | row_parallel_partitioning, |
const std::vector< IndexSet > & | column_parallel_partitioning, | ||
const MPI_Comm | communicator = MPI_COMM_WORLD |
||
) |
Resize the matrix to a rectangular block matrices. This method allows rows and columns to be different, both in the outer block structure and within the blocks.
Definition at line 625 of file block_sparsity_pattern.cc.
void BlockSparsityPattern::reinit | ( | const std::vector< IndexSet > & | row_parallel_partitioning, |
const std::vector< IndexSet > & | column_parallel_partitioning, | ||
const std::vector< IndexSet > & | writeable_rows, | ||
const MPI_Comm | communicator = MPI_COMM_WORLD |
||
) |
Resize the matrix to a rectangular block matrices that furthermore explicitly specify the writable rows in each of the blocks. This method is used to create matrices that allow several threads to write simultaneously into the matrix (to different rows, of course), see the method TrilinosWrappers::SparsityPattern::reinit method with three index set arguments for more details.
Definition at line 643 of file block_sparsity_pattern.cc.
|
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 135 of file block_sparsity_pattern.cc.
|
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 152 of file block_sparsity_pattern.cc.
|
inlineinherited |
Access the block with the given coordinates.
Definition at line 158 of file block_sparsity_pattern.h.
|
inlineinherited |
Access the block with the given coordinates. Version for constant objects.
Definition at line 165 of file block_sparsity_pattern.h.
|
inlineinherited |
Grant access to the object describing the distribution of row indices to the individual blocks.
Definition at line 172 of file block_sparsity_pattern.h.
|
inlineinherited |
Grant access to the object describing the distribution of column indices to the individual blocks.
Definition at line 179 of file block_sparsity_pattern.h.
|
inherited |
This function compresses the sparsity structures that this object represents. It simply calls compress
for all sub-objects.
Definition at line 186 of file block_sparsity_pattern.cc.
|
inlineinherited |
Return the number of blocks in a column.
Definition at line 192 of file block_sparsity_pattern.h.
|
inlineinherited |
Return the number of blocks in a row.
Definition at line 198 of file block_sparsity_pattern.h.
|
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 207 of file block_sparsity_pattern.cc.
|
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 215 of file block_sparsity_pattern.cc.
|
inlineinherited |
Add a nonzero entry to the matrix. This function may only be called for non-compressed sparsity patterns.
If the entry already exists, nothing bad happens.
This function simply finds out to which block (i,j)
belongs and then relays to that block.
Definition at line 227 of file block_sparsity_pattern.h.
|
inherited |
Add several nonzero entries to the specified matrix row. This function may only be called for non-compressed sparsity patterns.
If some of the entries already exist, nothing bad happens.
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 241 of file block_sparsity_pattern.h.
|
virtualinherited |
General function for adding new entries from an unsorted list of pairs.
This function is useful when multiple entries need to be added which do not correspond to a particular row, e.g., when assembling a flux sparsity pattern.
Reimplemented from SparsityPatternBase.
Definition at line 256 of file sparsity_pattern_base.cc.
|
overridevirtualinherited |
Add several nonzero entries to the specified matrix row. This function may only be called for non-compressed sparsity patterns and works the same way as the overload which takes iterators.
Implements SparsityPatternBase.
Definition at line 252 of file block_sparsity_pattern.h.
|
inlineinherited |
Check if a value at a certain position may be non-zero.
Definition at line 275 of file block_sparsity_pattern.h.
|
inlineinherited |
Number of entries in a specific row, added up over all the blocks that form this row.
Definition at line 282 of file block_sparsity_pattern.h.
|
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 296 of file block_sparsity_pattern.cc.
|
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 304 of file block_sparsity_pattern.cc.
|
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::print_gnuplot().
Definition at line 314 of file block_sparsity_pattern.cc.
|
inherited |
Print the sparsity of the matrix in svg
format. This is the same functionality implemented for usual sparsity patterns, see SparsityPattern::print_svg().
Definition at line 322 of file block_sparsity_pattern.cc.
|
inherited |
Determine an estimate for the memory consumption (in bytes) of this object.
Definition at line 329 of file block_sparsity_pattern.cc.
|
staticinherited |
Exception
|
staticinherited |
Exception
|
staticinherited |
Exception
|
privateinherited |
Internal utility function for computing the number of rows.
Definition at line 400 of file block_sparsity_pattern.cc.
|
privateinherited |
Internal utility function for computing the number of columns.
Definition at line 406 of file block_sparsity_pattern.cc.
|
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.
|
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.
|
protectedvirtualinherited |
Internal function for updating the stored size of the sparsity pattern.
|
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.
|
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 156 of file subscriptor.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 300 of file subscriptor.h.
|
inlineinherited |
List the subscribers to the input stream
.
Definition at line 317 of file subscriptor.h.
|
inherited |
List the subscribers to deallog
.
Definition at line 204 of file subscriptor.cc.
|
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.
|
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 subscriptor.cc.
|
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 96 of file block_sparsity_pattern.h.
|
protectedinherited |
Number of block rows.
Definition at line 371 of file block_sparsity_pattern.h.
|
protectedinherited |
Number of block columns.
Definition at line 376 of file block_sparsity_pattern.h.
|
protectedinherited |
Array of sparsity patterns.
Definition at line 381 of file block_sparsity_pattern.h.
|
protectedinherited |
Object storing and managing the transformation of row indices to indices of the sub-objects.
Definition at line 387 of file block_sparsity_pattern.h.
|
protectedinherited |
Object storing and managing the transformation of column indices to indices of the sub-objects.
Definition at line 393 of file block_sparsity_pattern.h.
|
privateinherited |
Temporary vector for counting the elements written into the individual blocks when doing a collective add or set.
Definition at line 412 of file block_sparsity_pattern.h.
|
privateinherited |
Temporary vector for column indices on each block when writing local to global data on each sparse matrix.
Definition at line 418 of file block_sparsity_pattern.h.
|
protectedinherited |
Number of rows that this sparsity pattern shall represent.
Definition at line 122 of file sparsity_pattern_base.h.
|
protectedinherited |
Number of columns that this sparsity pattern shall represent.
Definition at line 127 of file sparsity_pattern_base.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 219 of file subscriptor.h.
|
mutableprivateinherited |
In this map, we count subscriptions for each different identification string supplied to subscribe().
Definition at line 225 of file subscriptor.h.
|
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.
|
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.
|
staticprivateinherited |
A mutex used to ensure data consistency when printing out the list of subscribers.
Definition at line 271 of file subscriptor.h.