16 #ifndef dealii_block_sparsity_pattern_h 17 #define dealii_block_sparsity_pattern_h 20 #include <deal.II/base/config.h> 21 #include <deal.II/base/exceptions.h> 22 #include <deal.II/base/table.h> 23 #include <deal.II/base/subscriptor.h> 24 #include <deal.II/base/smartpointer.h> 25 #include <deal.II/lac/sparsity_pattern.h> 26 #include <deal.II/lac/trilinos_sparsity_pattern.h> 27 #include <deal.II/lac/dynamic_sparsity_pattern.h> 28 #include <deal.II/lac/block_indices.h> 30 DEAL_II_NAMESPACE_OPEN
73 template <
typename SparsityPatternType>
154 SparsityPatternType &
163 const SparsityPatternType &
233 template <
typename ForwardIterator>
235 ForwardIterator begin,
237 const bool indices_are_sorted =
false);
281 void print (std::ostream &out)
const;
302 <<
"The blocks [" << arg1 <<
',' << arg2 <<
"] and [" 303 << arg3 <<
',' << arg4 <<
"] have differing row numbers.");
309 <<
"The blocks [" << arg1 <<
',' << arg2 <<
"] and [" 310 << arg3 <<
',' << arg4 <<
"] have differing column numbers.");
359 template <
typename number>
415 const std::vector<std::vector<unsigned int> > &row_lengths);
508 const std::vector<size_type> &col_block_sizes);
536 void reinit (
const std::vector<size_type> &row_block_sizes,
537 const std::vector<size_type> &col_block_sizes);
543 void reinit(
const std::vector<IndexSet> &partitioning);
557 const unsigned int index)
const;
568 #ifdef DEAL_II_WITH_TRILINOS 624 const std::vector<size_type> &col_block_sizes);
647 const MPI_Comm &communicator = MPI_COMM_WORLD);
661 const std::vector<IndexSet> &column_parallel_partitioning,
662 const std::vector<IndexSet> &writeable_rows,
663 const MPI_Comm &communicator = MPI_COMM_WORLD);
674 void reinit (
const std::vector<size_type> &row_block_sizes,
675 const std::vector<size_type> &col_block_sizes);
685 void reinit (
const std::vector<Epetra_Map> ¶llel_partitioning);
691 void reinit (
const std::vector<IndexSet> ¶llel_partitioning,
692 const MPI_Comm &communicator = MPI_COMM_WORLD);
699 void reinit (
const std::vector<IndexSet> &row_parallel_partitioning,
700 const std::vector<IndexSet> &column_parallel_partitioning,
701 const MPI_Comm &communicator = MPI_COMM_WORLD);
711 void reinit (
const std::vector<IndexSet> &row_parallel_partitioning,
712 const std::vector<IndexSet> &column_parallel_partitioning,
713 const std::vector<IndexSet> &writeable_rows,
714 const MPI_Comm &communicator = MPI_COMM_WORLD);
732 template <
typename SparsityPatternType>
734 SparsityPatternType &
740 return *sub_objects[row][column];
745 template <
typename SparsityPatternType>
747 const SparsityPatternType &
753 return *sub_objects[row][column];
758 template <
typename SparsityPatternType>
768 template <
typename SparsityPatternType>
773 return column_indices;
778 template <
typename SparsityPatternType>
787 const std::pair<size_type,size_type>
788 row_index = row_indices.global_to_local (i),
789 col_index = column_indices.global_to_local (j);
790 sub_objects[row_index.first][col_index.first]->add (row_index.second,
796 template <
typename SparsityPatternType>
797 template <
typename ForwardIterator>
800 ForwardIterator begin,
802 const bool indices_are_sorted)
805 if (block_column_indices.size() < this->n_block_cols())
807 block_column_indices.resize (this->n_block_cols());
808 counter_within_block.resize (this->n_block_cols());
823 if (block_column_indices[0].size() < n_cols)
824 for (
size_type i=0; i<this->n_block_cols(); ++i)
825 block_column_indices[i].resize(n_cols);
829 for (
size_type i=0; i<this->n_block_cols(); ++i)
830 counter_within_block[i] = 0;
841 for (ForwardIterator it = begin; it != end; ++it)
845 const std::pair<size_type, size_type>
846 col_index = this->column_indices.global_to_local(col);
848 const size_type local_index = counter_within_block[col_index.first]++;
850 block_column_indices[col_index.first][local_index] = col_index.second;
857 for (
size_type i=0; i<this->n_block_cols(); ++i)
858 length += counter_within_block[i];
867 const std::pair<size_type, size_type>
868 row_index = this->row_indices.global_to_local (row);
869 for (
size_type block_col=0; block_col<n_block_cols(); ++block_col)
871 if (counter_within_block[block_col] == 0)
873 sub_objects[row_index.first][block_col]->
874 add_entries (row_index.second,
875 block_column_indices[block_col].begin(),
876 block_column_indices[block_col].begin()+counter_within_block[block_col],
883 template <
typename SparsityPatternType>
892 const std::pair<size_type, size_type>
893 row_index = row_indices.global_to_local (i),
894 col_index = column_indices.global_to_local (j);
895 return sub_objects[row_index.first][col_index.first]->exists (row_index.second,
901 template <
typename SparsityPatternType>
907 const std::pair<size_type, size_type>
908 row_index = row_indices.global_to_local (row);
913 c += sub_objects[row_index.first][b]->row_length (row_index.second);
920 template <
typename SparsityPatternType>
930 template <
typename SparsityPatternType>
942 const unsigned int index)
const 945 const std::pair<size_type,size_type >
952 for (
unsigned int b=0; b<
columns; ++b)
954 unsigned int rowlen =
sub_objects[row_index.first][b]->row_length (row_index.second);
956 return block_columns+
sub_objects[row_index.first][b]->column_number(row_index.second, index-c);
958 block_columns +=
sub_objects[row_index.first][b]->n_cols();
969 const size_type n_block_rows,
970 const size_type n_block_columns)
977 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)
BlockSparsityPatternBase()
static const size_type invalid_entry
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
std::vector< size_type > counter_within_block
~BlockSparsityPatternBase()
void reinit(const size_type n_block_rows, const size_type n_block_columns)
types::global_dof_index size_type
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)
unsigned int global_dof_index
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
std::vector< std::vector< size_type > > block_column_indices
BlockSparsityPattern()=default
Table< 2, SmartPointer< SparsityPatternType, BlockSparsityPatternBase< SparsityPatternType > > > sub_objects
#define DeclException4(Exception4, type1, type2, type3, type4, outsequence)
unsigned int row_length(const size_type row) const
void print_gnuplot(std::ostream &out) const
void copy_from(const BlockDynamicSparsityPattern &dsp)
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()