16 #ifndef dealii__dynamic_sparsity_pattern_h 17 #define dealii__dynamic_sparsity_pattern_h 20 #include <deal.II/base/config.h> 21 #include <deal.II/base/subscriptor.h> 22 #include <deal.II/base/utilities.h> 23 #include <deal.II/lac/exceptions.h> 24 #include <deal.II/base/index_set.h> 30 DEAL_II_NAMESPACE_OPEN
72 const unsigned int index_within_row);
82 size_type
row ()
const;
87 size_type
index ()
const;
180 const unsigned int index_within_row);
206 const Accessor *operator-> ()
const;
216 bool operator != (
const Iterator &)
const;
233 int operator - (
const Iterator &p)
const;
369 void reinit (
const size_type m,
390 size_type max_entries_per_row ()
const;
395 void add (
const size_type i,
402 template <
typename ForwardIterator>
403 void add_entries (
const size_type
row,
404 ForwardIterator begin,
406 const bool indices_are_unique_and_sorted =
false);
411 bool exists (
const size_type i,
412 const size_type j)
const;
428 void print (std::ostream &out)
const;
443 void print_gnuplot (std::ostream &out)
const;
448 size_type n_rows ()
const;
454 size_type n_cols ()
const;
460 size_type row_length (
const size_type
row)
const;
466 size_type column_number (
const size_type
row,
467 const size_type
index)
const;
510 iterator begin (
const size_type r)
const;
520 iterator end (
const size_type r)
const;
529 size_type bandwidth ()
const;
535 size_type n_nonzero_elements ()
const;
542 const IndexSet &row_index_set ()
const;
555 bool stores_only_added_elements ();
561 size_type memory_consumption ()
const;
609 void add (
const size_type col_num);
614 template <
typename ForwardIterator>
615 void add_entries (ForwardIterator begin,
617 const bool indices_are_sorted);
622 size_type memory_consumption ()
const;
645 const unsigned int index_within_row)
647 sparsity_pattern(sparsity_pattern),
651 sparsity_pattern->lines[
current_row].entries.begin()
653 sparsity_pattern->lines[sparsity_pattern->rowset.index_within_set(
current_row)].entries.begin())
656 end_of_row((sparsity_pattern->rowset.size()==0)
660 sparsity_pattern->lines[sparsity_pattern->rowset.index_within_set(
current_row)].entries.end())
666 ExcMessage (
"You can't create an iterator into a " 667 "DynamicSparsityPattern's row that is not " 668 "actually stored by that sparsity pattern " 669 "based on the IndexSet argument to it."));
683 sparsity_pattern(sparsity_pattern),
695 Assert (current_row < sparsity_pattern->n_rows(),
706 Assert (current_row < sparsity_pattern->n_rows(),
717 Assert (current_row < sparsity_pattern->n_rows(),
758 Assert (current_row < sparsity_pattern->n_rows(),
779 Assert (current_row < sparsity_pattern->n_rows(),
808 const unsigned int index_within_row)
810 accessor(sparsity_pattern, row, index_within_row)
874 return ! (*
this == other);
905 if ( (entries.size()==0) || ( entries.back() < j) )
907 entries.push_back(j);
912 std::vector<size_type>::iterator
923 entries.insert(it, j);
951 Assert (i<rows, ExcIndexRangeType<size_type>(i, 0, rows));
952 Assert (j<cols, ExcIndexRangeType<size_type>(j, 0, cols));
954 if (rowset.size() > 0 && !rowset.is_element(i))
959 const size_type rowindex =
960 rowset.size()==0 ? i : rowset.index_within_set(i);
961 lines[rowindex].add (j);
966 template <
typename ForwardIterator>
970 ForwardIterator begin,
972 const bool indices_are_sorted)
974 Assert (row < rows, ExcIndexRangeType<size_type> (row, 0, rows));
976 if (rowset.size() > 0 && !rowset.is_element(row))
979 if (!have_entries && begin<end)
982 const size_type rowindex =
983 rowset.size()==0 ? row : rowset.index_within_set(row);
984 lines[rowindex].add_entries (begin, end, indices_are_sorted);
999 Assert (row < n_rows(), ExcIndexRangeType<size_type> (row, 0, n_rows()));
1004 if (rowset.size() > 0 && !rowset.is_element(row))
1007 const size_type rowindex =
1008 rowset.size()==0 ? row : rowset.index_within_set(row);
1009 return lines[rowindex].entries.size();
1017 const size_type index)
const 1019 Assert (row < n_rows(), ExcIndexRangeType<size_type> (row, 0, n_rows()));
1022 const size_type local_row = rowset.size() ? rowset.index_within_set(row) : row;
1023 Assert (index < lines[local_row].entries.size(),
1024 ExcIndexRangeType<size_type> (index, 0, lines[local_row].entries.size()));
1025 return lines[local_row].entries[index];
1051 Assert (r<n_rows(), ExcIndexRangeType<size_type>(r,0,n_rows()));
1056 if (rowset.size() > 0)
1067 if (it == rowset.end())
1074 size_type rowindex = rowset.index_within_set(*it);
1076 while (it!=rowset.end()
1077 && lines[rowindex].entries.size()==0)
1083 if (it == rowset.end())
1094 while (row<n_rows() && lines[row].entries.size()==0)
1099 if (row == n_rows())
1111 Assert (r<n_rows(), ExcIndexRangeType<size_type>(r,0,n_rows()));
1113 unsigned int row = r+1;
1114 if (row == n_rows())
1139 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)
types::global_dof_index size_type
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
DynamicSparsityPatternIterators::Iterator const_iterator
bool operator==(const Accessor &) const
const DynamicSparsityPattern * sparsity_pattern
std::vector< Line > lines
std::vector< size_type > entries
DynamicSparsityPatternIterators::Iterator iterator
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
types::global_dof_index size_type
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
unsigned int global_dof_index
#define Assert(cond, exc)
static bool stores_only_added_elements()
size_type column_number(const size_type row, const size_type index) const
std::vector< size_type >::const_iterator current_entry
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)
static::ExceptionBase & ExcInternalError()