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
74 const unsigned int index_within_row);
188 const unsigned int index_within_row);
405 max_entries_per_row()
const;
417 template <
typename ForwardIterator>
420 ForwardIterator begin,
422 const bool indices_are_unique_and_sorted =
false);
444 template <
typename SparsityPatternTypeLeft,
typename SparsityPatternTypeRight>
446 compute_mmult_pattern(
const SparsityPatternTypeLeft & left,
447 const SparsityPatternTypeRight &right);
455 print(std::ostream &out)
const;
471 print_gnuplot(std::ostream &out)
const;
572 n_nonzero_elements()
const;
580 row_index_set()
const;
593 stores_only_added_elements();
600 memory_consumption()
const;
649 template <
typename ForwardIterator>
651 add_entries(ForwardIterator begin,
653 const bool indices_are_sorted);
659 memory_consumption()
const;
680 const unsigned int index_within_row)
681 : sparsity_pattern(sparsity_pattern)
684 ((sparsity_pattern->rowset.size() == 0) ?
685 sparsity_pattern->lines[
current_row].entries.begin() :
687 ->lines[sparsity_pattern->rowset.index_within_set(
current_row)]
691 (sparsity_pattern->rowset.size() == 0) ?
692 sparsity_pattern->lines[
current_row].entries.end() :
694 ->lines[sparsity_pattern->rowset.index_within_set(
current_row)]
700 ExcMessage(
"You can't create an iterator into a " 701 "DynamicSparsityPattern's row that is not " 702 "actually stored by that sparsity pattern " 703 "based on the IndexSet argument to it."));
715 : sparsity_pattern(sparsity_pattern)
825 const unsigned int index_within_row)
826 : accessor(sparsity_pattern, row, index_within_row)
880 return !(*
this == other);
908 if ((entries.size() == 0) || (entries.back() < j))
910 entries.push_back(j);
915 std::vector<size_type>::iterator it =
924 entries.insert(it, j);
948 Assert(i < rows, ExcIndexRangeType<size_type>(i, 0, rows));
949 Assert(j < cols, ExcIndexRangeType<size_type>(j, 0, cols));
951 if (rowset.size() > 0 && !rowset.is_element(i))
957 rowset.size() == 0 ? i : rowset.index_within_set(i);
958 lines[rowindex].add(j);
963 template <
typename ForwardIterator>
966 ForwardIterator begin,
968 const bool indices_are_sorted)
970 Assert(row < rows, ExcIndexRangeType<size_type>(row, 0, rows));
972 if (rowset.size() > 0 && !rowset.is_element(row))
975 if (!have_entries && begin < end)
979 rowset.size() == 0 ? row : rowset.index_within_set(row);
980 lines[rowindex].add_entries(begin, end, indices_are_sorted);
988 Assert(row < n_rows(), ExcIndexRangeType<size_type>(row, 0, n_rows()));
993 if (rowset.size() > 0 && !rowset.is_element(row))
997 rowset.size() == 0 ? row : rowset.index_within_set(row);
998 return lines[rowindex].entries.size();
1007 Assert(row < n_rows(), ExcIndexRangeType<size_type>(row, 0, n_rows()));
1011 rowset.size() ? rowset.index_within_set(row) : row;
1012 Assert(index < lines[local_row].entries.size(),
1013 ExcIndexRangeType<size_type>(index,
1015 lines[local_row].entries.size()));
1016 return lines[local_row].entries[index];
1039 Assert(r < n_rows(), ExcIndexRangeType<size_type>(r, 0, n_rows()));
1044 if (rowset.size() > 0)
1055 if (it == rowset.end())
1062 size_type rowindex = rowset.index_within_set(*it);
1064 while (it != rowset.end() && lines[rowindex].entries.size() == 0)
1070 if (it == rowset.end())
1081 while (row < n_rows() && lines[row].entries.size() == 0)
1086 if (row == n_rows())
1097 Assert(r < n_rows(), ExcIndexRangeType<size_type>(r, 0, n_rows()));
1099 unsigned int row = r + 1;
1100 if (row == n_rows())
1123 DEAL_II_NAMESPACE_CLOSE
size_type row_length(const size_type row) const
bool operator==(const Iterator &) const
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
bool operator==(const Accessor &) const
const DynamicSparsityPattern * sparsity_pattern
std::vector< Line > lines
std::vector< size_type > entries
const Accessor * operator->() const
Iterator(const DynamicSparsityPattern *sp, const size_type row, const unsigned int index_within_row)
Accessor(const DynamicSparsityPattern *sparsity_pattern, const size_type row, const unsigned int index_within_row)
void add(const size_type i, const size_type j)
#define AssertIndexRange(index, range)
bool operator!=(const Iterator &) const
const Accessor & operator*() const
SymmetricTensor< rank_, dim, Number > operator*(const SymmetricTensor< rank_, dim, Number > &t, const Number &factor)
unsigned long long int global_dof_index
int operator-(const Iterator &p) const
bool operator<(const Iterator &) const
bool operator<(const Accessor &) const
static::ExceptionBase & ExcMessage(std::string arg1)
const IndexSet & row_index_set() const
#define Assert(cond, exc)
static bool stores_only_added_elements()
SymmetricTensor< 2, dim, Number > symmetrize(const Tensor< 2, dim, Number > &t)
types::global_dof_index size_type
size_type column_number(const size_type row, const size_type index) const
std::vector< size_type >::const_iterator current_entry
types::global_dof_index size_type
size_type index_within_set(const size_type global_index) 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()