16 #ifndef dealii_block_sparsity_pattern_h 17 #define dealii_block_sparsity_pattern_h 20 #include <deal.II/base/config.h> 22 #include <deal.II/base/exceptions.h> 23 #include <deal.II/base/smartpointer.h> 24 #include <deal.II/base/subscriptor.h> 25 #include <deal.II/base/table.h> 27 #include <deal.II/lac/block_indices.h> 28 #include <deal.II/lac/dynamic_sparsity_pattern.h> 29 #include <deal.II/lac/sparsity_pattern.h> 30 #include <deal.II/lac/trilinos_sparsity_pattern.h> 32 DEAL_II_NAMESPACE_OPEN
35 template <
typename number>
76 template <
typename SparsityPatternType>
159 SparsityPatternType &
167 const SparsityPatternType &
242 template <
typename ForwardIterator>
245 ForwardIterator begin,
247 const bool indices_are_sorted =
false);
297 print(std::ostream &out)
const;
322 <<
"The blocks [" << arg1 <<
',' << arg2 <<
"] and [" << arg3
323 <<
',' << arg4 <<
"] have differing row numbers.");
332 <<
"The blocks [" << arg1 <<
',' << arg2 <<
"] and [" << arg3
333 <<
',' << arg4 <<
"] have differing column numbers.");
384 template <
typename number>
439 const std::vector<std::vector<unsigned int>> &row_lengths);
535 const std::vector<size_type> &col_block_sizes);
564 reinit(
const std::vector<size_type> &row_block_sizes,
565 const std::vector<size_type> &col_block_sizes);
572 reinit(
const std::vector<IndexSet> &partitioning);
598 #ifdef DEAL_II_WITH_TRILINOS 651 const std::vector<size_type> &col_block_sizes);
674 const MPI_Comm &communicator = MPI_COMM_WORLD);
688 const std::vector<IndexSet> &row_parallel_partitioning,
689 const std::vector<IndexSet> &column_parallel_partitioning,
690 const std::vector<IndexSet> &writeable_rows,
691 const MPI_Comm & communicator = MPI_COMM_WORLD);
703 reinit(
const std::vector<size_type> &row_block_sizes,
704 const std::vector<size_type> &col_block_sizes);
715 reinit(
const std::vector<Epetra_Map> ¶llel_partitioning);
722 reinit(
const std::vector<IndexSet> ¶llel_partitioning,
723 const MPI_Comm & communicator = MPI_COMM_WORLD);
731 reinit(
const std::vector<IndexSet> &row_parallel_partitioning,
732 const std::vector<IndexSet> &column_parallel_partitioning,
733 const MPI_Comm & communicator = MPI_COMM_WORLD);
744 reinit(
const std::vector<IndexSet> &row_parallel_partitioning,
745 const std::vector<IndexSet> &column_parallel_partitioning,
746 const std::vector<IndexSet> &writeable_rows,
747 const MPI_Comm & communicator = MPI_COMM_WORLD);
765 template <
typename SparsityPatternType>
766 inline SparsityPatternType &
772 return *sub_objects[row][column];
777 template <
typename SparsityPatternType>
778 inline const SparsityPatternType &
785 return *sub_objects[row][column];
790 template <
typename SparsityPatternType>
799 template <
typename SparsityPatternType>
803 return column_indices;
808 template <
typename SparsityPatternType>
816 const std::pair<size_type, size_type> row_index =
817 row_indices.global_to_local(i),
819 column_indices.global_to_local(j);
820 sub_objects[row_index.first][col_index.first]->add(row_index.second,
826 template <
typename SparsityPatternType>
827 template <
typename ForwardIterator>
831 ForwardIterator begin,
833 const bool indices_are_sorted)
836 if (block_column_indices.size() < this->n_block_cols())
838 block_column_indices.resize(this->n_block_cols());
839 counter_within_block.resize(this->n_block_cols());
854 if (block_column_indices[0].size() < n_cols)
855 for (
size_type i = 0; i < this->n_block_cols(); ++i)
856 block_column_indices[i].resize(n_cols);
860 for (
size_type i = 0; i < this->n_block_cols(); ++i)
861 counter_within_block[i] = 0;
872 for (ForwardIterator it = begin; it != end; ++it)
876 const std::pair<size_type, size_type> col_index =
877 this->column_indices.global_to_local(col);
879 const size_type local_index = counter_within_block[col_index.first]++;
881 block_column_indices[col_index.first][local_index] = col_index.second;
888 for (
size_type i = 0; i < this->n_block_cols(); ++i)
889 length += counter_within_block[i];
898 const std::pair<size_type, size_type> row_index =
899 this->row_indices.global_to_local(row);
900 for (
size_type block_col = 0; block_col < n_block_cols(); ++block_col)
902 if (counter_within_block[block_col] == 0)
904 sub_objects[row_index.first][block_col]->add_entries(
906 block_column_indices[block_col].begin(),
907 block_column_indices[block_col].begin() +
908 counter_within_block[block_col],
915 template <
typename SparsityPatternType>
923 const std::pair<size_type, size_type> row_index =
924 row_indices.global_to_local(i),
926 column_indices.global_to_local(j);
927 return sub_objects[row_index.first][col_index.first]->exists(
928 row_index.second, col_index.second);
933 template <
typename SparsityPatternType>
938 const std::pair<size_type, size_type> row_index =
939 row_indices.global_to_local(row);
944 c += sub_objects[row_index.first][b]->row_length(row_index.second);
951 template <
typename SparsityPatternType>
960 template <
typename SparsityPatternType>
970 const unsigned int index)
const 973 const std::pair<size_type, size_type> row_index =
980 for (
unsigned int b = 0; b <
columns; ++b)
982 unsigned int rowlen =
983 sub_objects[row_index.first][b]->row_length(row_index.second);
984 if (index < c + rowlen)
985 return block_columns +
986 sub_objects[row_index.first][b]->column_number(row_index.second,
989 block_columns +=
sub_objects[row_index.first][b]->n_cols();
999 const size_type n_block_columns)
1006 DEAL_II_NAMESPACE_CLOSE
static ::ExceptionBase & ExcIncompatibleRowNumbers(int arg1, int arg2, int arg3, int arg4)
void reinit(const std::vector< size_type > &row_block_sizes, const std::vector< size_type > &col_block_sizes)
BlockIndices column_indices
size_type column_number(const size_type row, const unsigned int index) const
void reinit(const std::vector< size_type > &row_block_sizes, const std::vector< size_type > &col_block_sizes)
std::vector< std::vector< size_type > > block_column_indices
std::vector< size_type > counter_within_block
BlockSparsityPatternBase()
size_type n_block_cols() const
size_type n_block_rows() const
static ::ExceptionBase & ExcIndexRange(int arg1, int arg2, int arg3)
SparsityPatternType & block(const size_type row, const size_type column)
bool exists(const size_type i, const size_type j) const
void reinit(const size_type n_block_rows, const size_type n_block_columns)
void reinit(const size_type n_block_rows, const size_type n_block_columns)
static const size_type invalid_entry
std::size_t memory_consumption() const
void add(const size_type i, const size_type j)
void print(std::ostream &out) const
size_type max_entries_per_row() const
#define Assert(cond, exc)
void add_entries(const size_type row, ForwardIterator begin, ForwardIterator end, const bool indices_are_sorted=false)
const BlockIndices & get_row_indices() const
BlockSparsityPatternBase & operator=(const BlockSparsityPatternBase &)
BlockDynamicSparsityPattern()=default
static ::ExceptionBase & ExcIncompatibleColNumbers(int arg1, int arg2, int arg3, int arg4)
size_type n_nonzero_elements() const
~BlockSparsityPatternBase() override
unsigned int global_dof_index
Table< 2, SmartPointer< SparsityPatternType, BlockSparsityPatternBase< SparsityPatternType > > > sub_objects
BlockSparsityPattern()=default
#define DeclException4(Exception4, type1, type2, type3, type4, outsequence)
unsigned int row_length(const size_type row) const
void print_gnuplot(std::ostream &out) const
static const size_type invalid_entry
void copy_from(const BlockDynamicSparsityPattern &dsp)
types::global_dof_index size_type
bool is_compressed() const
BlockSparsityPattern()=default
std::pair< unsigned int, size_type > global_to_local(const size_type i) const
const BlockIndices & get_column_indices() const
static ::ExceptionBase & ExcInternalError()