23template <
typename SparsityPatternType>
31template <
typename SparsityPatternType>
42template <
typename SparsityPatternType>
50 "This constructor can only be called if the provided argument "
51 "is the sparsity pattern for an empty matrix. This constructor can "
52 "not be used to copy-construct a non-empty sparsity pattern."));
57template <
typename SparsityPatternType>
63 sub_objects.reinit(0, 0);
65 block_rows = new_block_rows;
66 block_columns = new_block_columns;
68 sub_objects.reinit(block_rows, block_columns);
69 for (
size_type i = 0; i < n_block_rows(); ++i)
70 for (
size_type j = 0; j < n_block_cols(); ++j)
71 sub_objects[i][j] = std::make_unique<SparsityPatternType>();
75template <
typename SparsityPatternType>
83 for (
size_type i = 0; i < n_block_rows(); ++i)
84 for (
size_type j = 0; j < n_block_cols(); ++j)
94template <
typename SparsityPatternType>
101 for (
size_type r = 0; r < n_block_rows(); ++r)
102 count += sub_objects[r][0]->n_rows();
108template <
typename SparsityPatternType>
115 for (
size_type c = 0; c < n_block_cols(); ++c)
116 count += sub_objects[0][c]->n_cols();
122template <
typename SparsityPatternType>
128 std::vector<size_type> row_sizes(n_block_rows());
129 std::vector<size_type> col_sizes(n_block_cols());
133 for (
size_type r = 0; r < n_block_rows(); ++r)
134 row_sizes[r] = sub_objects[r][0]->n_rows();
138 for (
size_type c = 1; c < n_block_cols(); ++c)
139 for (
size_type r = 0; r < n_block_rows(); ++r)
140 Assert(row_sizes[r] == sub_objects[r][c]->n_rows(),
141 ExcIncompatibleRowNumbers(r, 0, r, c));
145 row_indices.reinit(row_sizes);
149 for (
size_type c = 0; c < n_block_cols(); ++c)
150 col_sizes[c] = sub_objects[0][c]->n_cols();
152 for (
size_type c = 0; c < n_block_cols(); ++c)
153 Assert(col_sizes[c] == sub_objects[r][c]->n_cols(),
154 ExcIncompatibleRowNumbers(0, c, r, c));
158 column_indices.reinit(col_sizes);
161 block_column_indices.resize(n_block_cols());
162 counter_within_block.resize(n_block_cols());
167template <
typename SparsityPatternType>
171 for (
size_type i = 0; i < n_block_rows(); ++i)
172 for (
size_type j = 0; j < n_block_cols(); ++j)
173 sub_objects[i][j]->compress();
178template <
typename SparsityPatternType>
182 for (
size_type i = 0; i < n_block_rows(); ++i)
183 for (
size_type j = 0; j < n_block_cols(); ++j)
184 if (sub_objects[i][j]->empty() ==
false)
191template <
typename SparsityPatternType>
196 for (
size_type block_row = 0; block_row < n_block_rows(); ++block_row)
199 for (
size_type c = 0; c < n_block_cols(); ++c)
200 this_row += sub_objects[block_row][c]->max_entries_per_row();
202 if (this_row > max_entries)
203 max_entries = this_row;
210template <
typename SparsityPatternType>
215 for (
size_type i = 0; i < n_block_rows(); ++i)
216 for (
size_type j = 0; j < n_block_cols(); ++j)
217 count += sub_objects[i][j]->n_nonzero_elements();
223template <
typename SparsityPatternType>
228 for (
size_type ib = 0; ib < n_block_rows(); ++ib)
230 for (
size_type i = 0; i < block(ib, 0).n_rows(); ++i)
234 for (
size_type jb = 0; jb < n_block_cols(); ++jb)
236 const SparsityPatternType &b = block(ib, jb);
237 for (
size_type j = 0; j < b.n_cols(); ++j)
242 out <<
']' << std::endl;
244 k += block(ib, 0).n_rows();
255 for (size_type ib = 0; ib < n_block_rows(); ++ib)
257 for (size_type i = 0; i < block(ib, 0).n_rows(); ++i)
261 for (size_type jb = 0; jb < n_block_cols(); ++jb)
264 if (b.row_index_set().size() == 0 ||
265 b.row_index_set().is_element(i))
266 for (size_type j = 0; j < b.n_cols(); ++j)
271 out <<
']' << std::endl;
273 k += block(ib, 0).n_rows();
280template <
typename SparsityPatternType>
283 std::ostream &out)
const
286 for (
size_type ib = 0; ib < n_block_rows(); ++ib)
288 for (
size_type i = 0; i < block(ib, 0).n_rows(); ++i)
291 for (
size_type jb = 0; jb < n_block_cols(); ++jb)
293 const SparsityPatternType &b = block(ib, jb);
294 for (
size_type j = 0; j < b.n_cols(); ++j)
296 out << l + j <<
" " << -
static_cast<signed int>(i + k)
301 k += block(ib, 0).n_rows();
307template <
typename SparsityPatternType>
310 std::ostream &out)
const
312 const unsigned int m = this->n_rows();
313 const unsigned int n = this->n_cols();
315 <<
"<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" viewBox=\"0 0 "
316 << n + 2 <<
" " << m + 2
318 "<style type=\"text/css\" >\n"
326 << n + 2 <<
"\" height=\"" << m + 2
327 <<
"\" fill=\"rgb(128, 128, 128)\"/>\n"
328 " <rect x=\"1\" y=\"1\" width=\""
329 << n + 0.1 <<
"\" height=\"" << m + 0.1
330 <<
"\" fill=\"rgb(255, 255, 255)\"/>\n\n";
332 for (
unsigned int block_i = 0; block_i < n_block_rows(); ++block_i)
333 for (
unsigned int block_j = 0; block_j < n_block_cols(); ++block_j)
334 for (
const auto &entry : block(block_i, block_j))
336 out <<
" <rect class=\"pixel\" x=\""
337 << column_indices.local_to_global(block_j, entry.column()) + 1
339 << row_indices.local_to_global(block_i, entry.row()) + 1
340 <<
"\" width=\".9\" height=\".9\"/>\n";
343 out <<
"</svg>" << std::endl;
348template <
typename SparsityPatternType>
358 for (
size_type r = 0; r < n_block_rows(); ++r)
359 for (
size_type c = 0; c < n_block_cols(); ++c)
377 const std::vector<std::vector<unsigned int>> &row_lengths)
388 if (row_lengths[j].
size() == 1)
394 Assert(row_lengths[j].begin() + start + length <=
395 row_lengths[j].end(),
451 const std::vector<size_type> &row_indices,
452 const std::vector<size_type> &col_indices)
457 for (
size_type j = 0; j < col_indices.size(); ++j)
465 const std::vector<IndexSet> &partitioning)
469 for (
size_type i = 0; i < partitioning.size(); ++i)
470 for (
size_type j = 0; j < partitioning.size(); ++j)
472 partitioning[j].
size(),
490 const std::vector<size_type> &row_block_sizes,
491 const std::vector<size_type> &col_block_sizes)
494 row_block_sizes.size(), col_block_sizes.size());
495 for (
size_type i = 0; i < row_block_sizes.size(); ++i)
496 for (
size_type j = 0; j < col_block_sizes.size(); ++j)
497 this->
block(i, j).
reinit(row_block_sizes[i], col_block_sizes[j]);
507 partitioning.size());
508 for (
size_type i = 0; i < partitioning.size(); ++i)
509 for (
size_type j = 0; j < partitioning.size(); ++j)
511 partitioning[j].
size(),
532#ifdef DEAL_II_WITH_TRILINOS
543 const std::vector<size_type> &row_indices,
544 const std::vector<size_type> &col_indices)
549 for (
size_type j = 0; j < col_indices.size(); ++j)
557 const std::vector<IndexSet> ¶llel_partitioning,
560 parallel_partitioning.
size())
562 for (
size_type i = 0; i < parallel_partitioning.size(); ++i)
563 for (
size_type j = 0; j < parallel_partitioning.size(); ++j)
565 parallel_partitioning[j],
573 const std::vector<IndexSet> &row_parallel_partitioning,
574 const std::vector<IndexSet> &col_parallel_partitioning,
575 const std::vector<IndexSet> &writable_rows,
578 row_parallel_partitioning.
size(),
579 col_parallel_partitioning.
size())
581 for (
size_type i = 0; i < row_parallel_partitioning.size(); ++i)
582 for (
size_type j = 0; j < col_parallel_partitioning.size(); ++j)
583 this->
block(i, j).
reinit(row_parallel_partitioning[i],
584 col_parallel_partitioning[j],
594 const std::vector<size_type> &col_block_sizes)
597 row_block_sizes.size(), col_block_sizes.size());
598 for (
size_type i = 0; i < row_block_sizes.size(); ++i)
599 for (
size_type j = 0; j < col_block_sizes.size(); ++j)
600 this->
block(i, j).
reinit(row_block_sizes[i], col_block_sizes[j]);
608 const std::vector<IndexSet> ¶llel_partitioning,
612 parallel_partitioning.size(), parallel_partitioning.size());
613 for (
size_type i = 0; i < parallel_partitioning.size(); ++i)
614 for (
size_type j = 0; j < parallel_partitioning.size(); ++j)
616 parallel_partitioning[j],
625 const std::vector<IndexSet> &row_parallel_partitioning,
626 const std::vector<IndexSet> &col_parallel_partitioning,
630 row_parallel_partitioning.size(), col_parallel_partitioning.size());
631 for (
size_type i = 0; i < row_parallel_partitioning.size(); ++i)
632 for (
size_type j = 0; j < col_parallel_partitioning.size(); ++j)
633 this->
block(i, j).
reinit(row_parallel_partitioning[i],
634 col_parallel_partitioning[j],
643 const std::vector<IndexSet> &row_parallel_partitioning,
644 const std::vector<IndexSet> &col_parallel_partitioning,
645 const std::vector<IndexSet> &writable_rows,
648 AssertDimension(writable_rows.size(), row_parallel_partitioning.size());
650 row_parallel_partitioning.size(), col_parallel_partitioning.size());
651 for (
size_type i = 0; i < row_parallel_partitioning.size(); ++i)
652 for (
size_type j = 0; j < col_parallel_partitioning.size(); ++j)
653 this->
block(i, j).
reinit(row_parallel_partitioning[i],
654 col_parallel_partitioning[j],
666#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::vector< index_type > data
std::enable_if_t< std::is_fundamental_v< T >, std::size_t > memory_consumption(const T &t)