16 #ifndef dealii_block_sparse_matrix_ez_h 17 #define dealii_block_sparse_matrix_ez_h 25 #include <deal.II/base/config.h> 27 #include <deal.II/base/exceptions.h> 28 #include <deal.II/base/smartpointer.h> 29 #include <deal.II/base/subscriptor.h> 30 #include <deal.II/base/table.h> 32 #include <deal.II/lac/block_indices.h> 33 #include <deal.II/lac/sparse_matrix_ez.h> 35 DEAL_II_NAMESPACE_OPEN
37 template <
typename Number>
57 template <
typename Number>
76 const unsigned int block_cols);
132 block(
const unsigned int row,
const unsigned int column);
140 block(
const unsigned int row,
const unsigned int column)
const;
202 template <
typename somenumber>
211 template <
typename somenumber>
220 template <
typename somenumber>
230 template <
typename somenumber>
241 template <
class StreamType>
268 template <
typename Number>
272 return row_indices.size();
277 template <
typename Number>
281 return column_indices.size();
286 template <
typename Number>
289 const unsigned int column)
294 return blocks[row][column];
299 template <
typename Number>
302 const unsigned int column)
const 307 return blocks[row][column];
312 template <
typename Number>
316 return row_indices.total_size();
321 template <
typename Number>
325 return column_indices.total_size();
330 template <
typename Number>
338 const std::pair<size_type, size_type> row_index =
339 row_indices.global_to_local(i),
341 column_indices.global_to_local(j);
342 block(row_index.first, col_index.first)
343 .set(row_index.second, col_index.second, value);
348 template <
typename Number>
356 const std::pair<unsigned int, size_type> row_index =
357 row_indices.global_to_local(i),
359 column_indices.global_to_local(j);
360 block(row_index.first, col_index.first)
361 .add(row_index.second, col_index.second, value);
365 template <
typename Number>
366 template <
typename somenumber>
378 for (
unsigned int row = 0; row < n_block_rows(); ++row)
379 for (
unsigned int col = 0; col < n_block_cols(); ++col)
380 block(row, col).vmult_add(dst.
block(row), src.
block(col));
385 template <
typename Number>
386 template <
typename somenumber>
396 for (
unsigned int row = 0; row < n_block_rows(); ++row)
397 for (
unsigned int col = 0; col < n_block_cols(); ++col)
398 block(row, col).vmult_add(dst.
block(row), src.
block(col));
403 template <
typename Number>
404 template <
typename somenumber>
416 for (
unsigned int row = 0; row < n_block_rows(); ++row)
417 for (
unsigned int col = 0; col < n_block_cols(); ++col)
418 block(row, col).Tvmult_add(dst.
block(col), src.
block(row));
423 template <
typename Number>
424 template <
typename somenumber>
435 for (
unsigned int row = 0; row < n_block_rows(); ++row)
436 for (
unsigned int col = 0; col < n_block_cols(); ++col)
437 block(row, col).Tvmult_add(dst.
block(col), src.
block(row));
441 template <
typename number>
442 template <
class StreamType>
449 std::vector<size_type> used_by_line_total;
454 std::vector<size_type> used_by_line;
456 for (
size_type i = 0; i < n_block_rows(); ++i)
457 for (
size_type j = 0; j < n_block_cols(); ++j)
459 used_by_line.clear();
460 out <<
"block:\t" << i <<
'\t' << j << std::endl;
461 block(i, j).compute_statistics(
462 used, allocated, reserved, used_by_line, full);
464 out <<
"used:" << used << std::endl
465 <<
"allocated:" << allocated << std::endl
466 <<
"reserved:" << reserved << std::endl;
469 allocated_total += allocated;
470 reserved_total += reserved;
474 used_by_line_total.resize(used_by_line.size());
475 for (
size_type i = 0; i < used_by_line.size(); ++i)
476 if (used_by_line[i] != 0)
478 out <<
"row-entries\t" << i <<
"\trows\t" << used_by_line[i]
480 used_by_line_total[i] += used_by_line[i];
484 out <<
"Total" << std::endl
485 <<
"used:" << used_total << std::endl
486 <<
"allocated:" << allocated_total << std::endl
487 <<
"reserved:" << reserved_total << std::endl;
488 for (
size_type i = 0; i < used_by_line_total.size(); ++i)
489 if (used_by_line_total[i] != 0)
491 out <<
"row-entries\t" << i <<
"\trows\t" << used_by_line_total[i]
497 DEAL_II_NAMESPACE_CLOSE
499 #endif // dealii_block_sparse_matrix_ez_h void Tvmult_add(BlockVector< somenumber > &dst, const BlockVector< somenumber > &src) const
Table< 2, SparseMatrixEZ< Number > > blocks
SparseMatrixEZ< Number > & block(const unsigned int row, const unsigned int column)
static ::ExceptionBase & ExcIndexRange(int arg1, int arg2, int arg3)
void add(const size_type i, const size_type j, const Number value)
unsigned int n_block_cols() const
types::global_dof_index size_type
void vmult(BlockVector< somenumber > &dst, const BlockVector< somenumber > &src) const
#define Assert(cond, exc)
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
void reinit(const unsigned int n_block_rows, const unsigned int n_block_cols)
BlockSparseMatrixEZ()=default
void set(const size_type i, const size_type j, const Number value)
unsigned int global_dof_index
unsigned int n_blocks() const
void Tvmult(BlockVector< somenumber > &dst, const BlockVector< somenumber > &src) const
BlockIndices column_indices
BlockSparseMatrixEZ & operator=(const BlockSparseMatrixEZ< Number > &)
void print_statistics(StreamType &s, bool full=false)
void vmult_add(BlockVector< somenumber > &dst, const BlockVector< somenumber > &src) const
BlockType & block(const unsigned int i)
#define AssertIsFinite(number)
unsigned int n_block_rows() const