17 #ifndef __deal2__chunk_sparsity_pattern_h 18 #define __deal2__chunk_sparsity_pattern_h 21 #include <deal.II/base/config.h> 23 #include <deal.II/base/subscriptor.h> 24 #include <deal.II/base/vector_slice.h> 26 #include <deal.II/lac/sparsity_pattern.h> 70 const unsigned int row);
81 unsigned int row ()
const;
92 unsigned int column ()
const;
166 const unsigned int row);
186 const Accessor *operator-> ()
const;
196 bool operator != (
const Iterator &)
const;
297 const size_type max_chunks_per_row,
298 const size_type chunk_size);
306 const size_type max_chunks_per_row,
307 const size_type chunk_size,
320 const std::vector<size_type> &row_lengths,
321 const size_type chunk_size);
329 const std::vector<size_type> &row_lengths,
330 const size_type chunk_size,
342 const size_type max_per_row,
343 const size_type chunk_size);
353 const std::vector<size_type> &row_lengths,
354 const size_type chunk_size);
361 const std::vector<size_type> &row_lengths,
362 const size_type chunk_size,
385 void reinit (
const size_type m,
387 const size_type max_per_row,
388 const size_type chunk_size);
394 void reinit (
const size_type m,
396 const size_type max_per_row,
397 const size_type chunk_size,
417 void reinit (
const size_type m,
419 const std::vector<size_type> &row_lengths,
420 const size_type chunk_size);
426 void reinit (
const size_type m,
428 const std::vector<size_type > &row_lengths,
429 const size_type chunk_size,
435 void reinit (
const size_type m,
437 const VectorSlice<
const std::vector<size_type> > &row_lengths,
438 const size_type chunk_size);
444 void reinit (
const size_type m,
446 const VectorSlice<
const std::vector<size_type> > &row_lengths,
447 const size_type chunk_size,
540 template <
typename ForwardIterator>
541 void copy_from (
const size_type n_rows,
542 const size_type n_cols,
543 const ForwardIterator begin,
544 const ForwardIterator end,
545 const size_type chunk_size);
551 template <
typename ForwardIterator>
552 void copy_from (
const size_type n_rows,
553 const size_type n_cols,
554 const ForwardIterator begin,
555 const ForwardIterator end,
556 const size_type chunk_size,
565 template <
typename SparsityType>
566 void copy_from (
const SparsityType &csp,
567 const size_type chunk_size);
573 template <
typename SparsityType>
574 void copy_from (
const SparsityType &csp,
575 const size_type chunk_size,
585 template <
typename number>
587 const size_type chunk_size);
593 template <
typename number>
595 const size_type chunk_size,
615 template <
typename Sparsity>
616 void create_from (
const unsigned int m,
617 const unsigned int n,
618 const Sparsity &sparsity_pattern_for_chunks,
619 const unsigned int chunk_size,
620 const bool optimize_diagonal =
true);
631 size_type get_chunk_size ()
const;
638 size_type max_entries_per_row ()
const;
646 void add (
const size_type i,
662 inline size_type n_rows ()
const;
668 inline size_type n_cols ()
const;
673 bool exists (
const size_type i,
674 const size_type j)
const;
679 size_type row_length (
const size_type
row)
const;
687 size_type bandwidth ()
const;
697 size_type n_nonzero_elements ()
const;
702 bool is_compressed ()
const;
711 bool optimize_diagonal () const DEAL_II_DEPRECATED;
724 bool stores_only_added_elements () const;
731 iterator begin () const;
736 iterator end () const;
746 iterator begin (const
unsigned int r) const;
756 iterator end (const
unsigned int r) const;
768 void block_write (
std::ostream &out) const;
783 void block_read (
std::istream &in);
790 void print (
std::ostream &out) const;
805 void print_gnuplot (
std::ostream &out) const;
811 std::
size_t memory_consumption () const;
820 << "The provided number is invalid here: " << arg1);
826 << "The given index " << arg1
827 << " should be less than " << arg2 << ".");
833 << "Upon entering a new entry to
row " << arg1
834 << ": there was no free entry any more. " <<
std::endl
835 << "(Maximum number of entries for this
row: "
836 << arg2 << "; maybe the matrix is already compressed?)");
858 << "The iterators denote a range of " << arg1
859 << " elements, but the given number of rows was " << arg2);
869 << "The number of partitions you gave is " << arg1
870 << ", but must be greater than zero.");
876 << "The array has size " << arg1 << " but should have size "
893 size_type chunk_size;
923 const unsigned int row)
956 sparsity_pattern->
n_rows()
959 sparsity_pattern->
n_cols();
1026 if (other.reduced_accessor.index_within_sparsity ==
1034 other.reduced_accessor.row()+other.chunk_row;
1035 if (global_row < other_global_row)
1037 else if (global_row > other_global_row)
1042 other.reduced_accessor.index_within_sparsity ||
1044 other.reduced_accessor.index_within_sparsity &&
1053 const unsigned int chunk_size = sparsity_pattern->
get_chunk_size();
1057 sparsity_pattern->
n_rows()
1060 sparsity_pattern->
n_cols(),
1062 if (chunk_size == 1)
1074 sparsity_pattern->
n_cols())
1087 (reduced_row * chunk_size +
chunk_row ==
1088 sparsity_pattern->
n_rows()))
1112 const unsigned int row)
1114 accessor(sparsity_pattern, row)
1123 accessor.advance ();
1134 accessor.advance ();
1161 return (accessor == other.accessor);
1170 return ! (accessor == other.accessor);
1178 return accessor < other.accessor;
1189 return iterator(
this, 0);
1197 return iterator(
this, n_rows());
1207 return iterator(
this, r);
1217 return iterator(
this, r+1);
1266 template <
typename ForwardIterator>
1270 const size_type n_cols,
1271 const ForwardIterator begin,
1272 const ForwardIterator end,
1273 const size_type chunk_size,
1276 copy_from (n_rows, n_cols, begin, end, chunk_size);
1281 template <
typename ForwardIterator>
1284 const size_type n_cols,
1285 const ForwardIterator begin,
1286 const ForwardIterator end,
1287 const size_type chunk_size)
1289 Assert (static_cast<size_type>(std::distance (begin, end)) == n_rows,
1290 ExcIteratorRange (std::distance (begin, end), n_rows));
1296 const bool is_square = (n_rows == n_cols);
1297 std::vector<size_type> row_lengths;
1298 row_lengths.reserve(n_rows);
1299 for (ForwardIterator i=begin; i!=end; ++i)
1300 row_lengths.push_back (std::distance (i->begin(), i->end())
1302 (is_square ? 1 : 0));
1303 reinit (n_rows, n_cols, row_lengths, chunk_size);
1307 typedef typename std::iterator_traits<ForwardIterator>::value_type::const_iterator inner_iterator;
1308 for (ForwardIterator i=begin; i!=end; ++i, ++
row)
1310 const inner_iterator end_of_row = i->end();
1311 for (inner_iterator j=i->begin(); j!=end_of_row; ++j)
1314 = internal::SparsityPatternTools::get_column_index_from_iterator(*j);
1315 Assert (col < n_cols, ExcInvalidIndex(col,n_cols));
1328 DEAL_II_NAMESPACE_CLOSE
bool optimize_diagonal() const DEAL_II_DEPRECATED
void copy_from(const size_type n_rows, const size_type n_cols, const ForwardIterator begin, const ForwardIterator end, const size_type chunk_size)
std::size_t index_within_sparsity
#define DeclException2(Exception2, type1, type2, outsequence)
Iterator(const ChunkSparsityPattern *sp, const unsigned int row)
bool is_compressed() const
std::size_t reduced_index() const
ChunkSparsityPatternIterators::Iterator const_iterator
bool operator==(const Accessor &) const
size_type n_nonzero_elements() const
const Accessor * operator->() const
const ChunkSparsityPattern * sparsity_pattern
SparsityPattern sparsity_pattern
bool is_valid_entry() const
size_type get_chunk_size() const
#define DeclException1(Exception1, type1, outsequence)
unsigned int global_dof_index
ChunkSparsityPatternIterators::Iterator iterator
#define Assert(cond, exc)
::ExceptionBase & ExcEmptyObject()
bool operator<(const Accessor &) const
#define DeclException0(Exception0)
::ExceptionBase & ExcIndexRange(int arg1, int arg2, int arg3)
::ExceptionBase & ExcInvalidConstructorCall()
BlockCompressedSparsityPattern CompressedBlockSparsityPattern DEAL_II_DEPRECATED
bool operator<(const Iterator &) const
types::global_dof_index size_type
Accessor(const ChunkSparsityPattern *matrix, const unsigned int row)
::ExceptionBase & ExcIteratorPastEnd()
bool operator==(const Iterator &) const
bool store_diagonal_first_in_row
const SparsityPattern * sparsity_pattern
bool is_valid_entry() const
::ExceptionBase & ExcInvalidIterator()
bool operator!=(const Iterator &) const
::ExceptionBase & ExcInternalError()
SparsityPatternIterators::Accessor reduced_accessor
const Accessor & operator*() const
unsigned int column() const
static const size_type invalid_entry