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);
560 get_chunk_size()
const;
568 max_entries_per_row()
const;
633 n_nonzero_elements()
const;
639 is_compressed()
const;
654 stores_only_added_elements()
const;
703 block_write(std::ostream &out)
const;
719 block_read(std::istream &in);
727 print(std::ostream &out)
const;
743 print_gnuplot(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.");
793 ExcMatrixIsCompressed,
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)
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() &&
905 Accessor::row()
const 916 Accessor::column()
const 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())
963 reduced_accessor.row() +
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));
989 reduced_accessor.column() *
chunk_size + chunk_col <
994 reduced_accessor.advance();
1002 reduced_accessor.column() *
chunk_size + chunk_col ==
1005 const auto reduced_row = reduced_accessor.row();
1007 if (reduced_accessor.linear_index + 1 ==
1008 reduced_accessor.container->rowstart[reduced_row + 1])
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};
1167 template <
typename ForwardIterator>
1171 const ForwardIterator
begin,
1172 const ForwardIterator
end,
1175 Assert(static_cast<size_type>(std::distance(begin, end)) == n_rows,
1182 const bool is_square = (n_rows ==
n_cols);
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));
1188 reinit(n_rows, n_cols, row_lengths, chunk_size);
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)
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)
void reinit(MatrixBlock< MatrixType > &v, const BlockSparsityPattern &p)
#define DeclException2(Exception2, type1, type2, outsequence)
bool is_valid_entry() const
Contents is actually a matrix.
constexpr SymmetricTensor< 2, dim, Number > symmetrize(const Tensor< 2, dim, Number > &t)
types::global_dof_index size_type
types::global_dof_index size_type
bool operator!=(const AlignedVector< T > &lhs, const AlignedVector< T > &rhs)
static ::ExceptionBase & ExcMETISNotInstalled()
#define AssertIndexRange(index, range)
bool operator<(const SynchronousIterators< Iterators > &a, const SynchronousIterators< Iterators > &b)
const ChunkSparsityPattern * sparsity_pattern
void add(const size_type i, const size_type j)
bool operator==(const AlignedVector< T > &lhs, const AlignedVector< T > &rhs)
SparsityPattern sparsity_pattern
std::size_t reduced_index() const
static ::ExceptionBase & ExcInvalidIterator()
static ::ExceptionBase & ExcInvalidNumberOfPartitions(int arg1)
std::string compress(const std::string &input)
#define DeclException1(Exception1, type1, outsequence)
Accessor(const ChunkSparsityPattern *matrix, const size_type row)
bool is_compressed() const
#define Assert(cond, exc)
static ::ExceptionBase & ExcInvalidArraySize(int arg1, int arg2)
#define DeclExceptionMsg(Exception, defaulttext)
#define DeclException0(Exception0)
static ::ExceptionBase & ExcInvalidNumber(unsigned int arg1)
#define DEAL_II_NAMESPACE_CLOSE
VectorType::value_type * end(VectorType &V)
SynchronousIterators< Iterators > operator++(SynchronousIterators< Iterators > &a)
static ::ExceptionBase & ExcInvalidIndex(size_type arg1, size_type arg2)
static ::ExceptionBase & ExcIteratorPastEnd()
unsigned int global_dof_index
static ::ExceptionBase & ExcIteratorRange(size_type arg1, size_type arg2)
void advance(std::tuple< I1, I2 > &t, const unsigned int n)
#define DEAL_II_NAMESPACE_OPEN
VectorType::value_type * begin(VectorType &V)
static ::ExceptionBase & ExcEmptyObject()
static const size_type invalid_entry
bool operator<(const Accessor &) const
std::enable_if< std::is_floating_point< T >::value &&std::is_floating_point< U >::value, typename ProductType< std::complex< T >, std::complex< U > >::type >::type operator*(const std::complex< T > &left, const std::complex< U > &right)
SparsityPatternIterators::Accessor reduced_accessor
void reinit(const size_type m, const size_type n, const size_type max_per_row, const size_type chunk_size)
bool operator==(const Accessor &) const
std::enable_if< std::is_fundamental< T >::value, std::size_t >::type memory_consumption(const T &t)
static ::ExceptionBase & ExcInternalError()