16#ifndef dealii_chunk_sparsity_pattern_h
17#define dealii_chunk_sparsity_pattern_h
324 const std::vector<size_type> &row_lengths,
347 const std::vector<size_type> &row_lengths,
394 const std::vector<size_type> &row_lengths,
496 template <
typename ForwardIterator>
500 const ForwardIterator
begin,
501 const ForwardIterator
end,
509 template <
typename SparsityPatternType>
520 template <
typename number>
541 template <
typename Sparsity>
545 const Sparsity &sparsity_pattern_for_chunks,
547 const bool optimize_diagonal =
true);
727 print(std::ostream &out)
const;
761 <<
"The provided number is invalid here: " << arg1);
768 <<
"The given index " << arg1 <<
" should be less than "
776 <<
"Upon entering a new entry to row " << arg1
777 <<
": there was no free entry any more. " << std::endl
778 <<
"(Maximum number of entries for this row: " << arg2
779 <<
"; maybe the matrix is already compressed?)");
786 "The operation you attempted is only allowed after the SparsityPattern "
787 "has been set up and compress() was called.");
794 "The operation you attempted changes the structure of the SparsityPattern "
795 "and is not possible after compress() has been called.");
806 <<
"The iterators denote a range of " << arg1
807 <<
" elements, but the given number of rows was " << arg2);
817 <<
"The number of partitions you gave is " << arg1
818 <<
", but must be greater than zero.");
825 <<
"The array has size " << arg1 <<
" but should have size "
868 : sparsity_pattern(sparsity_pattern)
869 , reduced_accessor(row == sparsity_pattern->n_rows() ?
870 *sparsity_pattern->sparsity_pattern.
end() :
871 *sparsity_pattern->sparsity_pattern.
begin(
872 row / sparsity_pattern->get_chunk_size()))
873 , chunk_row(row == sparsity_pattern->n_rows() ?
875 row % sparsity_pattern->get_chunk_size())
882 : sparsity_pattern(sparsity_pattern)
883 , reduced_accessor(*sparsity_pattern->sparsity_pattern.
end())
891 Accessor::is_valid_entry()
const
893 return reduced_accessor.is_valid_entry() &&
896 sparsity_pattern->n_rows() &&
897 sparsity_pattern->get_chunk_size() * reduced_accessor.column() +
899 sparsity_pattern->n_cols();
905 Accessor::row()
const
909 return sparsity_pattern->get_chunk_size() * reduced_accessor.row() +
916 Accessor::column()
const
920 return sparsity_pattern->get_chunk_size() * reduced_accessor.column() +
927 Accessor::reduced_index()
const
931 return reduced_accessor.linear_index;
942 return (reduced_accessor == other.reduced_accessor &&
943 chunk_row == other.chunk_row && chunk_col == other.chunk_col);
953 if (chunk_row != other.chunk_row)
955 if (reduced_accessor.linear_index ==
956 reduced_accessor.container->n_nonzero_elements())
958 if (other.reduced_accessor.linear_index ==
959 reduced_accessor.container->n_nonzero_elements())
962 const auto global_row = sparsity_pattern->get_chunk_size() *
963 reduced_accessor.row() +
965 other_global_row = sparsity_pattern->get_chunk_size() *
966 other.reduced_accessor.row() +
968 if (global_row < other_global_row)
970 else if (global_row > other_global_row)
975 reduced_accessor.linear_index < other.reduced_accessor.linear_index ||
976 (reduced_accessor.linear_index == other.reduced_accessor.linear_index &&
977 chunk_col < other.chunk_col));
984 const auto chunk_size = sparsity_pattern->get_chunk_size();
988 sparsity_pattern->n_rows() &&
989 reduced_accessor.column() *
chunk_size + chunk_col <
990 sparsity_pattern->n_cols(),
994 reduced_accessor.advance();
1002 reduced_accessor.column() *
chunk_size + chunk_col ==
1003 sparsity_pattern->n_cols())
1005 const auto reduced_row = reduced_accessor.row();
1007 if (reduced_accessor.linear_index + 1 ==
1008 reduced_accessor.container->rowstart[reduced_row + 1])
1017 sparsity_pattern->n_rows()))
1020 reduced_accessor.advance();
1025 reduced_accessor.linear_index =
1026 reduced_accessor.container->rowstart[reduced_row];
1031 reduced_accessor.advance();
1041 : accessor(sparsity_pattern, row)
1058 const Iterator iter = *
this;
1072 inline const Accessor *Iterator::operator->()
const
1081 return (accessor == other.accessor);
1089 return !(accessor == other.accessor);
1096 return accessor < other.accessor;
1131 return {
this, r + 1};
1167template <
typename ForwardIterator>
1171 const ForwardIterator
begin,
1172 const ForwardIterator
end,
1183 std::vector<size_type> row_lengths;
1184 row_lengths.reserve(
n_rows);
1185 for (ForwardIterator i =
begin; i !=
end; ++i)
1186 row_lengths.push_back(std::distance(i->begin(), i->end()) +
1187 (is_square ? 1 : 0));
1192 using inner_iterator =
1193 typename std::iterator_traits<ForwardIterator>::value_type::const_iterator;
1194 for (ForwardIterator i =
begin; i !=
end; ++i, ++row)
1196 const inner_iterator end_of_row = i->end();
1197 for (inner_iterator j = i->begin(); j != end_of_row; ++j)
bool operator!=(const AlignedVector< T > &lhs, const AlignedVector< T > &rhs)
bool operator==(const AlignedVector< T > &lhs, const AlignedVector< T > &rhs)
std::enable_if< std::is_floating_point< T >::value &&std::is_floating_point< U >::value, typenameProductType< std::complex< T >, std::complex< U > >::type >::type operator*(const std::complex< T > &left, const std::complex< U > &right)
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
#define DeclException0(Exception0)
static ::ExceptionBase & ExcInvalidIterator()
static ::ExceptionBase & ExcInvalidNumberOfPartitions(size_type arg1)
static ::ExceptionBase & ExcNotEnoughSpace(size_type arg1, size_type arg2)
static ::ExceptionBase & ExcMETISNotInstalled()
#define Assert(cond, exc)
static ::ExceptionBase & ExcNotCompressed()
static ::ExceptionBase & ExcIteratorPastEnd()
static ::ExceptionBase & ExcMatrixIsCompressed()
#define DeclException2(Exception2, type1, type2, outsequence)
#define AssertIndexRange(index, range)
#define DeclExceptionMsg(Exception, defaulttext)
static ::ExceptionBase & ExcInvalidArraySize(size_type arg1, size_type arg2)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcEmptyObject()
SparsityPattern sparsity_pattern
#define DeclException1(Exception1, type1, outsequence)
static ::ExceptionBase & ExcInvalidIndex(size_type arg1, size_type arg2)
static ::ExceptionBase & ExcIteratorRange(size_type arg1, size_type arg2)
static ::ExceptionBase & ExcInvalidNumber(size_type arg1)
void create_from(const size_type m, const size_type n, const Sparsity &sparsity_pattern_for_chunks, const size_type chunk_size, const bool optimize_diagonal=true)
void add(const size_type i, const size_type j)
void block_write(std::ostream &out) const
SparsityPatternIterators::Accessor reduced_accessor
bool stores_only_added_elements() const
bool operator!=(const Iterator &) const
bool is_valid_entry() const
~ChunkSparsityPattern() override=default
Accessor(const ChunkSparsityPattern *matrix, const size_type row)
static const size_type invalid_entry
std::size_t memory_consumption() const
types::global_dof_index size_type
bool operator==(const Iterator &) const
std::size_t reduced_index() const
bool operator<(const Accessor &) const
bool exists(const size_type i, const size_type j) const
size_type get_column_index_from_iterator(const size_type i)
Iterator(const ChunkSparsityPattern *sp, const size_type row)
iterator end(const size_type r) const
void reinit(const size_type m, const size_type n, const size_type max_per_row, const size_type chunk_size)
void print_gnuplot(std::ostream &out) const
void block_read(std::istream &in)
Accessor(const ChunkSparsityPattern *matrix)
static const size_type invalid_entry
bool operator<(const Iterator &) const
bool is_compressed() const
bool operator==(const Accessor &) const
const Accessor * operator->() const
ChunkSparsityPattern & operator=(const ChunkSparsityPattern &)
size_type max_entries_per_row() const
const ChunkSparsityPattern * sparsity_pattern
size_type bandwidth() const
size_type n_nonzero_elements() const
const Accessor & operator*() const
size_type row_length(const size_type row) const
void print(std::ostream &out) const
size_type get_chunk_size() const
void copy_from(const size_type n_rows, const size_type n_cols, const ForwardIterator begin, const ForwardIterator end, const size_type chunk_size)
iterator begin(const size_type r) const
@ matrix
Contents is actually a matrix.
types::global_dof_index size_type
VectorType::value_type * end(VectorType &V)
VectorType::value_type * begin(VectorType &V)
unsigned int global_dof_index
SynchronousIterators< Iterators > operator++(SynchronousIterators< Iterators > &a)
bool operator<(const SynchronousIterators< Iterators > &a, const SynchronousIterators< Iterators > &b)
void advance(std::tuple< I1, I2 > &t, const unsigned int n)