16 #ifndef dealii_dynamic_sparsity_pattern_h 17 #define dealii_dynamic_sparsity_pattern_h 20 #include <deal.II/base/config.h> 22 #include <deal.II/base/index_set.h> 23 #include <deal.II/base/subscriptor.h> 24 #include <deal.II/base/utilities.h> 26 #include <deal.II/lac/exceptions.h> 32 DEAL_II_NAMESPACE_OPEN
73 const unsigned int index_within_row);
123 "The instance of this class was initialized" 124 " without DynamicSparsityPattern object, which" 125 " means that it is a dummy accessor that can" 126 " not do any operations.");
200 const unsigned int index_within_row);
424 max_entries_per_row()
const;
436 template <
typename ForwardIterator>
439 ForwardIterator begin,
441 const bool indices_are_unique_and_sorted =
false);
456 get_view(
const IndexSet &rows)
const;
472 template <
typename SparsityPatternTypeLeft,
typename SparsityPatternTypeRight>
474 compute_mmult_pattern(
const SparsityPatternTypeLeft & left,
475 const SparsityPatternTypeRight &right);
481 template <
typename SparsityPatternTypeLeft,
typename SparsityPatternTypeRight>
483 compute_Tmmult_pattern(
const SparsityPatternTypeLeft & left,
484 const SparsityPatternTypeRight &right);
492 print(std::ostream &out)
const;
508 print_gnuplot(std::ostream &out)
const;
623 n_nonzero_elements()
const;
631 row_index_set()
const;
640 nonempty_cols()
const;
649 nonempty_rows()
const;
662 stores_only_added_elements();
669 memory_consumption()
const;
718 template <
typename ForwardIterator>
720 add_entries(ForwardIterator begin,
722 const bool indices_are_sorted);
728 memory_consumption()
const;
749 const unsigned int index_within_row)
750 : sparsity_pattern(sparsity_pattern)
753 ((sparsity_pattern->rowset.size() == 0) ?
754 sparsity_pattern->lines[
current_row].entries.begin() :
756 ->lines[sparsity_pattern->rowset.index_within_set(
current_row)]
760 (sparsity_pattern->rowset.size() == 0) ?
761 sparsity_pattern->lines[
current_row].entries.end() :
763 ->lines[sparsity_pattern->rowset.index_within_set(
current_row)]
769 ExcMessage(
"You can't create an iterator into a " 770 "DynamicSparsityPattern's row that is not " 771 "actually stored by that sparsity pattern " 772 "based on the IndexSet argument to it."));
784 : sparsity_pattern(sparsity_pattern)
910 const unsigned int index_within_row)
911 : accessor(sparsity_pattern, row, index_within_row)
965 return !(*
this == other);
993 if ((entries.size() == 0) || (entries.back() < j))
995 entries.push_back(j);
1000 std::vector<size_type>::iterator it =
1009 entries.insert(it, j);
1033 Assert(i < rows, ExcIndexRangeType<size_type>(i, 0, rows));
1034 Assert(j < cols, ExcIndexRangeType<size_type>(j, 0, cols));
1036 if (rowset.size() > 0 && !rowset.is_element(i))
1039 have_entries =
true;
1042 rowset.size() == 0 ? i : rowset.index_within_set(i);
1043 lines[rowindex].add(j);
1048 template <
typename ForwardIterator>
1051 ForwardIterator begin,
1052 ForwardIterator end,
1053 const bool indices_are_sorted)
1055 Assert(row < rows, ExcIndexRangeType<size_type>(row, 0, rows));
1057 if (rowset.size() > 0 && !rowset.is_element(row))
1060 if (!have_entries && begin < end)
1061 have_entries =
true;
1064 rowset.size() == 0 ? row : rowset.index_within_set(row);
1065 lines[rowindex].add_entries(begin, end, indices_are_sorted);
1073 Assert(row < n_rows(), ExcIndexRangeType<size_type>(row, 0, n_rows()));
1078 if (rowset.size() > 0 && !rowset.is_element(row))
1082 rowset.size() == 0 ? row : rowset.index_within_set(row);
1083 return lines[rowindex].entries.size();
1092 Assert(row < n_rows(), ExcIndexRangeType<size_type>(row, 0, n_rows()));
1096 rowset.size() ? rowset.index_within_set(row) : row;
1097 Assert(index < lines[local_row].entries.size(),
1098 ExcIndexRangeType<size_type>(index,
1100 lines[local_row].entries.size()));
1101 return lines[local_row].entries[index];
1127 Assert(r < n_rows(), ExcIndexRangeType<size_type>(r, 0, n_rows()));
1132 if (rowset.size() > 0)
1143 if (it == rowset.end())
1150 size_type rowindex = rowset.index_within_set(*it);
1152 while (it != rowset.end() && lines[rowindex].entries.size() == 0)
1158 if (it == rowset.end())
1161 return {
this, *it, 0};
1169 while (row < n_rows() && lines[row].entries.size() == 0)
1174 if (row == n_rows())
1177 return {
this, row, 0};
1185 Assert(r < n_rows(), ExcIndexRangeType<size_type>(r, 0, n_rows()));
1187 unsigned int row = r + 1;
1188 if (row == n_rows())
1211 DEAL_II_NAMESPACE_CLOSE
Iterator lower_bound(Iterator first, Iterator last, const T &val)
const types::global_dof_index invalid_size_type
void add_entries(const size_type row, ForwardIterator begin, ForwardIterator end, const bool indices_are_unique_and_sorted=false)
std::vector< size_type >::const_iterator end_of_row
const DynamicSparsityPattern * sparsity_pattern
std::vector< Line > lines
std::vector< size_type > entries
int operator-(const Iterator &p) const
const Accessor & operator*() const
size_type column_number(const size_type row, const size_type index) const
void add(const size_type i, const size_type j)
#define AssertIndexRange(index, range)
bool operator<(const Iterator &) const
SymmetricTensor< rank_, dim, Number > operator*(const SymmetricTensor< rank_, dim, Number > &t, const Number &factor)
bool operator==(const Iterator &) const
static ::ExceptionBase & ExcMessage(std::string arg1)
static ::ExceptionBase & DummyAccessor()
#define Assert(cond, exc)
size_type index_within_set(const size_type global_index) const
bool operator<(const Accessor &) const
#define DeclExceptionMsg(Exception, defaulttext)
const IndexSet & row_index_set() const
static bool stores_only_added_elements()
SymmetricTensor< 2, dim, Number > symmetrize(const Tensor< 2, dim, Number > &t)
types::global_dof_index size_type
const Accessor * operator->() const
std::vector< size_type >::const_iterator current_entry
unsigned int global_dof_index
types::global_dof_index size_type
size_type row_length(const size_type row) const
bool operator==(const Accessor &) const
bool operator!=(const Iterator &) const
static ::ExceptionBase & ExcNotImplemented()
bool is_element(const size_type index) const
void add(const size_type col_num)
SymmetricTensor< rank_, dim, typename ProductType< Number, OtherNumber >::type > operator-(const SymmetricTensor< rank_, dim, Number > &left, const SymmetricTensor< rank_, dim, OtherNumber > &right)
static ::ExceptionBase & ExcInternalError()