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);
646 const MPI_Comm &communicator = MPI_COMM_WORLD);
660 const std::vector<IndexSet> &column_parallel_partitioning,
661 const std::vector<IndexSet> &writeable_rows,
662 const MPI_Comm &communicator = MPI_COMM_WORLD);
673 void reinit (
const std::vector<size_type> &row_block_sizes,
674 const std::vector<size_type> &col_block_sizes);
683 void reinit (
const std::vector<Epetra_Map> ¶llel_partitioning) DEAL_II_DEPRECATED;
689 void reinit (
const std::vector<IndexSet> ¶llel_partitioning,
690 const MPI_Comm &communicator = MPI_COMM_WORLD);
697 void reinit (
const std::vector<IndexSet> &row_parallel_partitioning,
698 const std::vector<IndexSet> &column_parallel_partitioning,
699 const MPI_Comm &communicator = MPI_COMM_WORLD);
709 void reinit (
const std::vector<IndexSet> &row_parallel_partitioning,
710 const std::vector<IndexSet> &column_parallel_partitioning,
711 const std::vector<IndexSet> &writeable_rows,
712 const MPI_Comm &communicator = MPI_COMM_WORLD);
730 template <
typename SparsityPatternType>
732 SparsityPatternType &
738 return *sub_objects[row][column];
743 template <
typename SparsityPatternType>
745 const SparsityPatternType &
751 return *sub_objects[row][column];
756 template <
typename SparsityPatternType>
766 template <
typename SparsityPatternType>
771 return column_indices;
776 template <
typename SparsityPatternType>
785 const std::pair<size_type,size_type>
786 row_index = row_indices.global_to_local (i),
787 col_index = column_indices.global_to_local (j);
788 sub_objects[row_index.first][col_index.first]->add (row_index.second,
794 template <
typename SparsityPatternType>
795 template <
typename ForwardIterator>
798 ForwardIterator begin,
800 const bool indices_are_sorted)
803 if (block_column_indices.size() < this->n_block_cols())
805 block_column_indices.resize (this->n_block_cols());
806 counter_within_block.resize (this->n_block_cols());
821 if (block_column_indices[0].size() < n_cols)
822 for (
size_type i=0; i<this->n_block_cols(); ++i)
823 block_column_indices[i].resize(n_cols);
827 for (
size_type i=0; i<this->n_block_cols(); ++i)
828 counter_within_block[i] = 0;
839 for (ForwardIterator it = begin; it != end; ++it)
843 const std::pair<size_type , size_type>
844 col_index = this->column_indices.global_to_local(col);
846 const size_type local_index = counter_within_block[col_index.first]++;
848 block_column_indices[col_index.first][local_index] = col_index.second;
855 for (
size_type i=0; i<this->n_block_cols(); ++i)
856 length += counter_within_block[i];
865 const std::pair<size_type , size_type>
866 row_index = this->row_indices.global_to_local (row);
867 for (
size_type block_col=0; block_col<n_block_cols(); ++block_col)
869 if (counter_within_block[block_col] == 0)
871 sub_objects[row_index.first][block_col]->
872 add_entries (row_index.second,
873 block_column_indices[block_col].begin(),
874 block_column_indices[block_col].begin()+counter_within_block[block_col],
881 template <
typename SparsityPatternType>
890 const std::pair<size_type , size_type>
891 row_index = row_indices.global_to_local (i),
892 col_index = column_indices.global_to_local (j);
893 return sub_objects[row_index.first][col_index.first]->exists (row_index.second,
899 template <
typename SparsityPatternType>
905 const std::pair<size_type , size_type>
906 row_index = row_indices.global_to_local (row);
911 c += sub_objects[row_index.first][b]->row_length (row_index.second);
918 template <
typename SparsityPatternType>
928 template <
typename SparsityPatternType>
940 const unsigned int index)
const 943 const std::pair<size_type ,size_type >
950 for (
unsigned int b=0; b<
columns; ++b)
952 unsigned int rowlen =
sub_objects[row_index.first][b]->row_length (row_index.second);
954 return block_columns+
sub_objects[row_index.first][b]->column_number(row_index.second, index-c);
956 block_columns +=
sub_objects[row_index.first][b]->n_cols();
967 const size_type n_block_rows,
968 const size_type n_block_columns)
975 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 &)
static ::ExceptionBase & ExcIncompatibleColNumbers(int arg1, int arg2, int arg3, int arg4)
size_type n_nonzero_elements() const
BlockDynamicSparsityPattern()
std::vector< std::vector< size_type > > block_column_indices
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
std::pair< unsigned int, size_type > global_to_local(const size_type i) const
const BlockIndices & get_column_indices() const
static ::ExceptionBase & ExcInternalError()