24template <
class SparsityPatternType>
32template <
class SparsityPatternType>
43template <
class SparsityPatternType>
51 "This constructor can only be called if the provided argument "
52 "is the sparsity pattern for an empty matrix. This constructor can "
53 "not be used to copy-construct a non-empty sparsity pattern."));
58template <
class SparsityPatternType>
64 sub_objects.reinit(0, 0);
66 block_rows = new_block_rows;
67 block_columns = new_block_columns;
69 sub_objects.reinit(block_rows, block_columns);
70 for (
size_type i = 0; i < n_block_rows(); ++i)
71 for (
size_type j = 0; j < n_block_cols(); ++j)
72 sub_objects[i][j] = std::make_unique<SparsityPatternType>();
76template <
class SparsityPatternType>
84 for (
size_type i = 0; i < n_block_rows(); ++i)
85 for (
size_type j = 0; j < n_block_cols(); ++j)
95template <
class SparsityPatternType>
102 for (
size_type r = 0; r < n_block_rows(); ++r)
103 count += sub_objects[r][0]->n_rows();
109template <
class SparsityPatternType>
116 for (
size_type c = 0; c < n_block_cols(); ++c)
117 count += sub_objects[0][c]->n_cols();
123template <
class SparsityPatternType>
129 std::vector<size_type> row_sizes(n_block_rows());
130 std::vector<size_type> col_sizes(n_block_cols());
134 for (
size_type r = 0; r < n_block_rows(); ++r)
135 row_sizes[r] = sub_objects[r][0]->n_rows();
139 for (
size_type c = 1; c < n_block_cols(); ++c)
140 for (
size_type r = 0; r < n_block_rows(); ++r)
141 Assert(row_sizes[r] == sub_objects[r][c]->n_rows(),
142 ExcIncompatibleRowNumbers(r, 0, r, c));
146 row_indices.reinit(row_sizes);
150 for (
size_type c = 0; c < n_block_cols(); ++c)
151 col_sizes[c] = sub_objects[0][c]->n_cols();
153 for (
size_type c = 0; c < n_block_cols(); ++c)
154 Assert(col_sizes[c] == sub_objects[r][c]->n_cols(),
155 ExcIncompatibleRowNumbers(0, c, r, c));
159 column_indices.reinit(col_sizes);
162 block_column_indices.resize(n_block_cols());
163 counter_within_block.resize(n_block_cols());
168template <
class SparsityPatternType>
172 for (
size_type i = 0; i < n_block_rows(); ++i)
173 for (
size_type j = 0; j < n_block_cols(); ++j)
174 sub_objects[i][j]->compress();
179template <
class SparsityPatternType>
183 for (
size_type i = 0; i < n_block_rows(); ++i)
184 for (
size_type j = 0; j < n_block_cols(); ++j)
185 if (sub_objects[i][j]->empty() ==
false)
192template <
class SparsityPatternType>
197 for (
size_type block_row = 0; block_row < n_block_rows(); ++block_row)
200 for (
size_type c = 0; c < n_block_cols(); ++c)
201 this_row += sub_objects[block_row][c]->max_entries_per_row();
203 if (this_row > max_entries)
204 max_entries = this_row;
211template <
class SparsityPatternType>
216 for (
size_type i = 0; i < n_block_rows(); ++i)
217 for (
size_type j = 0; j < n_block_cols(); ++j)
218 count += sub_objects[i][j]->n_nonzero_elements();
224template <
class SparsityPatternType>
229 for (
size_type ib = 0; ib < n_block_rows(); ++ib)
231 for (
size_type i = 0; i < block(ib, 0).n_rows(); ++i)
235 for (
size_type jb = 0; jb < n_block_cols(); ++jb)
237 const SparsityPatternType &b = block(ib, jb);
238 for (
size_type j = 0; j < b.n_cols(); ++j)
243 out <<
']' << std::endl;
245 k += block(ib, 0).n_rows();
256 for (size_type ib = 0; ib < n_block_rows(); ++ib)
258 for (size_type i = 0; i < block(ib, 0).n_rows(); ++i)
262 for (size_type jb = 0; jb < n_block_cols(); ++jb)
265 if (b.row_index_set().size() == 0 ||
266 b.row_index_set().is_element(i))
267 for (size_type j = 0; j < b.n_cols(); ++j)
272 out <<
']' << std::endl;
274 k += block(ib, 0).n_rows();
281template <
class SparsityPatternType>
284 std::ostream &out)
const
287 for (
size_type ib = 0; ib < n_block_rows(); ++ib)
289 for (
size_type i = 0; i < block(ib, 0).n_rows(); ++i)
292 for (
size_type jb = 0; jb < n_block_cols(); ++jb)
294 const SparsityPatternType &b = block(ib, jb);
295 for (
size_type j = 0; j < b.n_cols(); ++j)
297 out << l + j <<
" " << -
static_cast<signed int>(i + k)
302 k += block(ib, 0).n_rows();
308template <
class SparsityPatternType>
311 std::ostream &out)
const
313 const unsigned int m = this->n_rows();
314 const unsigned int n = this->n_cols();
316 <<
"<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" viewBox=\"0 0 "
317 << n + 2 <<
" " << m + 2
319 "<style type=\"text/css\" >\n"
327 << n + 2 <<
"\" height=\"" << m + 2
328 <<
"\" fill=\"rgb(128, 128, 128)\"/>\n"
329 " <rect x=\"1\" y=\"1\" width=\""
330 << n + 0.1 <<
"\" height=\"" << m + 0.1
331 <<
"\" fill=\"rgb(255, 255, 255)\"/>\n\n";
333 for (
unsigned int block_i = 0; block_i < n_block_rows(); ++block_i)
334 for (
unsigned int block_j = 0; block_j < n_block_cols(); ++block_j)
335 for (
const auto &entry : block(block_i, block_j))
337 out <<
" <rect class=\"pixel\" x=\""
338 << column_indices.local_to_global(block_j, entry.column()) + 1
340 << row_indices.local_to_global(block_i, entry.row()) + 1
341 <<
"\" width=\".9\" height=\".9\"/>\n";
344 out <<
"</svg>" << std::endl;
349template <
class SparsityPatternType>
359 for (
size_type r = 0; r < n_block_rows(); ++r)
360 for (
size_type c = 0; c < n_block_cols(); ++c)
378 const std::vector<std::vector<unsigned int>> &row_lengths)
389 if (row_lengths[j].size() == 1)
395 Assert(row_lengths[j].begin() + start + length <=
396 row_lengths[j].end(),
452 const std::vector<size_type> &row_indices,
453 const std::vector<size_type> &col_indices)
458 for (
size_type j = 0; j < col_indices.size(); ++j)
466 const std::vector<IndexSet> &partitioning)
470 for (
size_type i = 0; i < partitioning.size(); ++i)
471 for (
size_type j = 0; j < partitioning.size(); ++j)
473 partitioning[j].size(),
491 const std::vector<size_type> &row_block_sizes,
492 const std::vector<size_type> &col_block_sizes)
495 row_block_sizes.size(), col_block_sizes.size());
496 for (
size_type i = 0; i < row_block_sizes.size(); ++i)
497 for (
size_type j = 0; j < col_block_sizes.size(); ++j)
498 this->
block(i, j).
reinit(row_block_sizes[i], col_block_sizes[j]);
508 partitioning.size());
509 for (
size_type i = 0; i < partitioning.size(); ++i)
510 for (
size_type j = 0; j < partitioning.size(); ++j)
512 partitioning[j].size(),
533#ifdef DEAL_II_WITH_TRILINOS
544 const std::vector<size_type> &row_indices,
545 const std::vector<size_type> &col_indices)
550 for (
size_type j = 0; j < col_indices.size(); ++j)
558 const std::vector<IndexSet> ¶llel_partitioning,
561 parallel_partitioning.size())
563 for (
size_type i = 0; i < parallel_partitioning.size(); ++i)
564 for (
size_type j = 0; j < parallel_partitioning.size(); ++j)
566 parallel_partitioning[j],
574 const std::vector<IndexSet> &row_parallel_partitioning,
575 const std::vector<IndexSet> &col_parallel_partitioning,
576 const std::vector<IndexSet> &writable_rows,
579 row_parallel_partitioning.size(),
580 col_parallel_partitioning.size())
582 for (
size_type i = 0; i < row_parallel_partitioning.size(); ++i)
583 for (
size_type j = 0; j < col_parallel_partitioning.size(); ++j)
584 this->
block(i, j).
reinit(row_parallel_partitioning[i],
585 col_parallel_partitioning[j],
595 const std::vector<size_type> &col_block_sizes)
598 row_block_sizes.size(), col_block_sizes.size());
599 for (
size_type i = 0; i < row_block_sizes.size(); ++i)
600 for (
size_type j = 0; j < col_block_sizes.size(); ++j)
601 this->
block(i, j).
reinit(row_block_sizes[i], col_block_sizes[j]);
609 const std::vector<IndexSet> ¶llel_partitioning,
613 parallel_partitioning.size(), parallel_partitioning.size());
614 for (
size_type i = 0; i < parallel_partitioning.size(); ++i)
615 for (
size_type j = 0; j < parallel_partitioning.size(); ++j)
617 parallel_partitioning[j],
626 const std::vector<IndexSet> &row_parallel_partitioning,
627 const std::vector<IndexSet> &col_parallel_partitioning,
631 row_parallel_partitioning.size(), col_parallel_partitioning.size());
632 for (
size_type i = 0; i < row_parallel_partitioning.size(); ++i)
633 for (
size_type j = 0; j < col_parallel_partitioning.size(); ++j)
634 this->
block(i, j).
reinit(row_parallel_partitioning[i],
635 col_parallel_partitioning[j],
644 const std::vector<IndexSet> &row_parallel_partitioning,
645 const std::vector<IndexSet> &col_parallel_partitioning,
646 const std::vector<IndexSet> &writable_rows,
649 AssertDimension(writable_rows.size(), row_parallel_partitioning.size());
651 row_parallel_partitioning.size(), col_parallel_partitioning.size());
652 for (
size_type i = 0; i < row_parallel_partitioning.size(); ++i)
653 for (
size_type j = 0; j < col_parallel_partitioning.size(); ++j)
654 this->
block(i, j).
reinit(row_parallel_partitioning[i],
655 col_parallel_partitioning[j],
667#ifdef DEAL_II_WITH_TRILINOS
void reinit(const std::vector< size_type > &row_block_sizes, const std::vector< size_type > &col_block_sizes)
BlockDynamicSparsityPattern()=default
size_type block_size(const unsigned int i) const
unsigned int size() const
void print_gnuplot(std::ostream &out) const
size_type n_block_rows() const
BlockSparsityPatternBase()
Table< 2, std::unique_ptr< SparsityPatternType > > sub_objects
SparsityPattern & block(const size_type row, const size_type column)
size_type n_nonzero_elements() const
void print(std::ostream &out) const
std::size_t memory_consumption() const
void print_svg(std::ostream &out) const
size_type max_entries_per_row() const
size_type compute_n_rows() const
void reinit(const size_type n_block_rows, const size_type n_block_columns)
size_type n_block_cols() const
BlockIndices column_indices
BlockSparsityPatternBase & operator=(const BlockSparsityPatternBase &)
size_type compute_n_cols() const
void copy_from(const BlockDynamicSparsityPattern &dsp)
void reinit(const size_type n_block_rows, const size_type n_block_columns)
BlockSparsityPattern()=default
bool is_compressed() const
void reinit(const size_type m, const size_type n, const IndexSet &rowset=IndexSet())
virtual void resize(const size_type rows, const size_type cols)
void reinit(const size_type m, const size_type n, const ArrayView< const unsigned int > &row_lengths)
void copy_from(const size_type n_rows, const size_type n_cols, const ForwardIterator begin, const ForwardIterator end)
BlockSparsityPattern()=default
void reinit(const std::vector< size_type > &row_block_sizes, const std::vector< size_type > &col_block_sizes)
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
#define Assert(cond, exc)
#define AssertDimension(dim1, dim2)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcMessage(std::string arg1)
std::enable_if_t< std::is_fundamental< T >::value, std::size_t > memory_consumption(const T &t)