17 #include <deal.II/base/memory_consumption.h> 19 #include <deal.II/lac/block_sparsity_pattern.h> 21 DEAL_II_NAMESPACE_OPEN
24 template <
class SparsityPatternBase>
32 template <
class SparsityPatternBase>
44 template <
class SparsityPatternBase>
54 "This constructor can only be called if the provided argument " 55 "is the sparsity pattern for an empty matrix. This constructor can " 56 "not be used to copy-construct a non-empty sparsity pattern."));
61 template <
class SparsityPatternBase>
75 template <
class SparsityPatternBase>
88 sub_objects[i][j] =
nullptr;
95 columns = n_block_columns;
96 sub_objects.reinit(rows, columns);
103 sub_objects[i][j] = p;
108 template <
class SparsityPatternBase>
127 template <
class SparsityPatternBase>
131 std::vector<size_type> row_sizes(rows);
132 std::vector<size_type> col_sizes(columns);
137 row_sizes[r] = sub_objects[r][0]->n_rows();
143 Assert(row_sizes[r] == sub_objects[r][c]->n_rows(),
144 ExcIncompatibleRowNumbers(r, 0, r, c));
148 row_indices.reinit(row_sizes);
153 col_sizes[c] = sub_objects[0][c]->n_cols();
156 Assert(col_sizes[c] == sub_objects[r][c]->n_cols(),
157 ExcIncompatibleRowNumbers(0, c, r, c));
161 column_indices.reinit(col_sizes);
166 template <
class SparsityPatternBase>
172 sub_objects[i][j]->compress();
177 template <
class SparsityPatternBase>
183 if (sub_objects[i][j]->empty() ==
false)
190 template <
class SparsityPatternBase>
195 for (
size_type block_row = 0; block_row < rows; ++block_row)
199 this_row += sub_objects[block_row][c]->max_entries_per_row();
201 if (this_row > max_entries)
202 max_entries = this_row;
209 template <
class SparsityPatternBase>
217 count += sub_objects[r][0]->n_rows();
223 template <
class SparsityPatternBase>
231 count += sub_objects[0][c]->n_cols();
237 template <
class SparsityPatternBase>
244 count += sub_objects[i][j]->n_nonzero_elements();
250 template <
class SparsityPatternBase>
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 for (
size_type j = 0; j < b.n_cols(); ++j)
269 out <<
']' << std::endl;
271 k += block(ib, 0).n_rows();
290 if (b.row_index_set().size() == 0 ||
291 b.row_index_set().is_element(i))
292 for (
size_type j = 0; j < b.n_cols(); ++j)
297 out <<
']' << std::endl;
299 k +=
block(ib, 0).n_rows();
304 template <
class SparsityPatternBase>
307 std::ostream &out)
const 310 for (
size_type ib = 0; ib < n_block_rows(); ++ib)
312 for (
size_type i = 0; i < block(ib, 0).n_rows(); ++i)
315 for (
size_type jb = 0; jb < n_block_cols(); ++jb)
318 for (
size_type j = 0; j < b.n_cols(); ++j)
320 out << l + j <<
" " << -static_cast<signed int>(i + k)
325 k += block(ib, 0).n_rows();
341 const std::vector<std::vector<unsigned int>> &row_lengths)
352 if (row_lengths[j].size() == 1)
358 Assert(row_lengths[j].begin() + start + length <=
359 row_lengths[j].end(),
432 const std::vector<size_type> &row_indices,
433 const std::vector<size_type> &col_indices)
438 for (
size_type j = 0; j < col_indices.size(); ++j)
445 const std::vector<IndexSet> &partitioning)
449 for (
size_type i = 0; i < partitioning.size(); ++i)
450 for (
size_type j = 0; j < partitioning.size(); ++j)
452 partitioning[j].size(),
468 const std::vector<size_type> &row_block_sizes,
469 const std::vector<size_type> &col_block_sizes)
472 row_block_sizes.size(), col_block_sizes.size());
473 for (
size_type i = 0; i < row_block_sizes.size(); ++i)
474 for (
size_type j = 0; j < col_block_sizes.size(); ++j)
475 this->
block(i, j).
reinit(row_block_sizes[i], col_block_sizes[j]);
483 partitioning.size());
484 for (
size_type i = 0; i < partitioning.size(); ++i)
485 for (
size_type j = 0; j < partitioning.size(); ++j)
487 partitioning[j].size(),
506 #ifdef DEAL_II_WITH_TRILINOS 517 const std::vector<size_type> &row_indices,
518 const std::vector<size_type> &col_indices)
523 for (
size_type j = 0; j < col_indices.size(); ++j)
531 const std::vector<Epetra_Map> ¶llel_partitioning)
533 parallel_partitioning.size())
535 for (
size_type i = 0; i < parallel_partitioning.size(); ++i)
536 for (
size_type j = 0; j < parallel_partitioning.size(); ++j)
538 parallel_partitioning[j]);
545 const std::vector<IndexSet> ¶llel_partitioning,
546 const MPI_Comm & communicator)
548 parallel_partitioning.size())
550 for (
size_type i = 0; i < parallel_partitioning.size(); ++i)
551 for (
size_type j = 0; j < parallel_partitioning.size(); ++j)
553 parallel_partitioning[j],
561 const std::vector<IndexSet> &row_parallel_partitioning,
562 const std::vector<IndexSet> &col_parallel_partitioning,
563 const std::vector<IndexSet> &writable_rows,
564 const MPI_Comm & communicator)
566 row_parallel_partitioning.size(),
567 col_parallel_partitioning.size())
569 for (
size_type i = 0; i < row_parallel_partitioning.size(); ++i)
570 for (
size_type j = 0; j < col_parallel_partitioning.size(); ++j)
571 this->
block(i, j).
reinit(row_parallel_partitioning[i],
572 col_parallel_partitioning[j],
582 const std::vector<size_type> &col_block_sizes)
585 row_block_sizes.size(), col_block_sizes.size());
586 for (
size_type i = 0; i < row_block_sizes.size(); ++i)
587 for (
size_type j = 0; j < col_block_sizes.size(); ++j)
588 this->
block(i, j).
reinit(row_block_sizes[i], col_block_sizes[j]);
596 const std::vector<Epetra_Map> ¶llel_partitioning)
599 parallel_partitioning.size(), parallel_partitioning.size());
600 for (
size_type i = 0; i < parallel_partitioning.size(); ++i)
601 for (
size_type j = 0; j < parallel_partitioning.size(); ++j)
603 parallel_partitioning[j]);
611 const std::vector<IndexSet> ¶llel_partitioning,
612 const MPI_Comm & communicator)
615 parallel_partitioning.size(), parallel_partitioning.size());
616 for (
size_type i = 0; i < parallel_partitioning.size(); ++i)
617 for (
size_type j = 0; j < parallel_partitioning.size(); ++j)
619 parallel_partitioning[j],
628 const std::vector<IndexSet> &row_parallel_partitioning,
629 const std::vector<IndexSet> &col_parallel_partitioning,
630 const MPI_Comm & communicator)
633 row_parallel_partitioning.size(), col_parallel_partitioning.size());
634 for (
size_type i = 0; i < row_parallel_partitioning.size(); ++i)
635 for (
size_type j = 0; j < col_parallel_partitioning.size(); ++j)
636 this->
block(i, j).
reinit(row_parallel_partitioning[i],
637 col_parallel_partitioning[j],
646 const std::vector<IndexSet> &row_parallel_partitioning,
647 const std::vector<IndexSet> &col_parallel_partitioning,
648 const std::vector<IndexSet> &writable_rows,
649 const MPI_Comm & communicator)
651 AssertDimension(writable_rows.size(), row_parallel_partitioning.size());
653 row_parallel_partitioning.size(), col_parallel_partitioning.size());
654 for (
size_type i = 0; i < row_parallel_partitioning.size(); ++i)
655 for (
size_type j = 0; j < col_parallel_partitioning.size(); ++j)
656 this->
block(i, j).
reinit(row_parallel_partitioning[i],
657 col_parallel_partitioning[j],
669 #ifdef DEAL_II_WITH_TRILINOS 673 DEAL_II_NAMESPACE_CLOSE
void reinit(const std::vector< size_type > &row_block_sizes, const std::vector< size_type > &col_block_sizes)
BlockIndices column_indices
#define AssertDimension(dim1, dim2)
void reinit(const std::vector< size_type > &row_block_sizes, const std::vector< size_type > &col_block_sizes)
BlockSparsityPatternBase()
size_type n_block_cols() const
size_type n_block_rows() const
size_type block_size(const unsigned int i) const
void reinit(const size_type m, const size_type n, const unsigned int max_per_row)
SparsityPatternType & block(const size_type row, const size_type column)
void reinit(const size_type n_block_rows, const size_type n_block_columns)
void reinit(const size_type n_block_rows, const size_type n_block_columns)
virtual void reinit(const size_type m, const size_type n, const ArrayView< const unsigned int > &row_lengths) override
static ::ExceptionBase & ExcMessage(std::string arg1)
std::size_t memory_consumption() const
void print(std::ostream &out) const
size_type max_entries_per_row() const
#define Assert(cond, exc)
void reinit(const size_type m, const size_type n, const IndexSet &rowset=IndexSet())
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
BlockSparsityPatternBase & operator=(const BlockSparsityPatternBase &)
BlockDynamicSparsityPattern()=default
size_type n_nonzero_elements() const
void copy_from(const size_type n_rows, const size_type n_cols, const ForwardIterator begin, const ForwardIterator end)
~BlockSparsityPatternBase() override
Table< 2, SmartPointer< SparsityPatternType, BlockSparsityPatternBase< SparsityPatternType > > > sub_objects
BlockSparsityPattern()=default
void print_gnuplot(std::ostream &out) const
void copy_from(const BlockDynamicSparsityPattern &dsp)
unsigned int size() const
types::global_dof_index size_type
bool is_compressed() const
BlockSparsityPattern()=default
std::enable_if< std::is_fundamental< T >::value, std::size_t >::type memory_consumption(const T &t)
static ::ExceptionBase & ExcInternalError()