16 #ifndef dealii_chunk_sparsity_pattern_h 17 #define dealii_chunk_sparsity_pattern_h 329 const std::vector<size_type> &row_lengths,
352 const std::vector<size_type> &row_lengths,
399 const std::vector<size_type> &row_lengths,
501 template <
typename ForwardIterator>
505 const ForwardIterator
begin,
506 const ForwardIterator
end,
514 template <
typename SparsityPatternType>
525 template <
typename number>
546 template <
typename Sparsity>
550 const Sparsity &sparsity_pattern_for_chunks,
552 const bool optimize_diagonal =
true);
565 get_chunk_size()
const;
573 max_entries_per_row()
const;
638 n_nonzero_elements()
const;
644 is_compressed()
const;
659 stores_only_added_elements()
const;
708 block_write(std::ostream &out)
const;
724 block_read(std::istream &in);
732 print(std::ostream &out)
const;
748 print_gnuplot(std::ostream &out)
const;
766 <<
"The provided number is invalid here: " << arg1);
773 <<
"The given index " << arg1 <<
" should be less than " 781 <<
"Upon entering a new entry to row " << arg1
782 <<
": there was no free entry any more. " << std::endl
783 <<
"(Maximum number of entries for this row: " << arg2
784 <<
"; maybe the matrix is already compressed?)");
791 "The operation you attempted is only allowed after the SparsityPattern " 792 "has been set up and compress() was called.");
798 ExcMatrixIsCompressed,
799 "The operation you attempted changes the structure of the SparsityPattern " 800 "and is not possible after compress() has been called.");
811 <<
"The iterators denote a range of " << arg1
812 <<
" elements, but the given number of rows was " << arg2);
822 <<
"The number of partitions you gave is " << arg1
823 <<
", but must be greater than zero.");
830 <<
"The array has size " << arg1 <<
" but should have size " 873 : sparsity_pattern(sparsity_pattern)
875 *sparsity_pattern->sparsity_pattern.
end() :
876 *sparsity_pattern->sparsity_pattern.
begin(
877 row / sparsity_pattern->get_chunk_size()))
878 ,
chunk_row(row == sparsity_pattern->n_rows() ?
880 row % sparsity_pattern->get_chunk_size())
887 : sparsity_pattern(sparsity_pattern)
888 , reduced_accessor(*sparsity_pattern->sparsity_pattern.
end())
896 Accessor::is_valid_entry()
const 898 return reduced_accessor.is_valid_entry() &&
910 Accessor::row()
const 921 Accessor::column()
const 932 Accessor::reduced_index()
const 936 return reduced_accessor.linear_index;
947 return (reduced_accessor == other.reduced_accessor &&
948 chunk_row == other.chunk_row && chunk_col == other.chunk_col);
958 if (chunk_row != other.chunk_row)
960 if (reduced_accessor.linear_index ==
961 reduced_accessor.container->n_nonzero_elements())
963 if (other.reduced_accessor.linear_index ==
964 reduced_accessor.container->n_nonzero_elements())
968 reduced_accessor.row() +
971 other.reduced_accessor.row() +
973 if (global_row < other_global_row)
975 else if (global_row > other_global_row)
980 reduced_accessor.linear_index < other.reduced_accessor.linear_index ||
981 (reduced_accessor.linear_index == other.reduced_accessor.linear_index &&
982 chunk_col < other.chunk_col));
994 reduced_accessor.column() *
chunk_size + chunk_col <
999 reduced_accessor.advance();
1007 reduced_accessor.column() *
chunk_size + chunk_col ==
1010 const auto reduced_row = reduced_accessor.row();
1012 if (reduced_accessor.linear_index + 1 ==
1013 reduced_accessor.container->rowstart[reduced_row + 1])
1025 reduced_accessor.advance();
1030 reduced_accessor.linear_index =
1031 reduced_accessor.container->rowstart[reduced_row];
1036 reduced_accessor.advance();
1046 : accessor(sparsity_pattern, row)
1077 inline const Accessor *Iterator::operator->()
const 1086 return (accessor == other.accessor);
1094 return !(accessor == other.accessor);
1101 return accessor < other.accessor;
1136 return {
this, r + 1};
1172 template <
typename ForwardIterator>
1176 const ForwardIterator
begin,
1177 const ForwardIterator
end,
1180 Assert(static_cast<size_type>(std::distance(begin, end)) == n_rows,
1187 const bool is_square = (n_rows ==
n_cols);
1188 std::vector<size_type> row_lengths;
1189 row_lengths.reserve(n_rows);
1190 for (ForwardIterator i = begin; i !=
end; ++i)
1191 row_lengths.push_back(std::distance(i->begin(), i->end()) +
1192 (is_square ? 1 : 0));
1193 reinit(n_rows, n_cols, row_lengths, chunk_size);
1197 using inner_iterator =
1198 typename std::iterator_traits<ForwardIterator>::value_type::const_iterator;
1199 for (ForwardIterator i = begin; i !=
end; ++i, ++row)
1201 const inner_iterator end_of_row = i->end();
1202 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)
MatrixTableIterators::Accessor< TransposeTable< T >, Constness, MatrixTableIterators::Storage::column_major > Accessor
static ::ExceptionBase & ExcIteratorPastEnd()
unsigned int global_dof_index
MatrixTableIterators::Iterator< TransposeTable< T >, Constness, MatrixTableIterators::Storage::column_major > Iterator
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()