17 #ifndef __deal2__block_sparse_matrix_ez_h
18 #define __deal2__block_sparse_matrix_ez_h
23 #include <deal.II/base/config.h>
25 #include <deal.II/base/subscriptor.h>
26 #include <deal.II/base/table.h>
27 #include <deal.II/base/smartpointer.h>
28 #include <deal.II/lac/block_indices.h>
29 #include <deal.II/lac/sparse_matrix_ez.h>
31 DEAL_II_NAMESPACE_OPEN
51 template<
typename Number>
75 const unsigned int block_cols);
157 block (
const unsigned int row,
158 const unsigned int column);
167 block (
const unsigned int row,
168 const unsigned int column)
const;
261 template <
typename somenumber>
273 template <
typename somenumber>
283 template <
typename somenumber>
295 template <
typename somenumber>
309 template <
class STREAM>
339 template <
typename Number>
344 return row_indices.size();
349 template <
typename Number>
354 return row_indices.total_size();
359 template <
typename Number>
364 return column_indices.size();
369 template <
typename Number>
374 return column_indices.total_size();
379 template <
typename Number>
383 const unsigned int column)
388 return blocks[row][column];
393 template <
typename Number>
397 const unsigned int column)
const
402 return blocks[row][column];
407 template <
typename Number>
417 template <
typename Number>
427 template <
typename Number>
437 const std::pair<size_type,size_type>
438 row_index = row_indices.global_to_local (i),
439 col_index = column_indices.global_to_local (j);
440 block(row_index.first,col_index.first).set (row_index.second,
447 template <
typename Number>
457 const std::pair<unsigned int,size_type>
458 row_index = row_indices.global_to_local (i),
459 col_index = column_indices.global_to_local (j);
460 block(row_index.first,col_index.first).add (row_index.second,
466 template <
typename Number>
467 template <
typename somenumber>
479 for (
unsigned int row=0; row<n_block_rows(); ++row)
480 for (
unsigned int col=0; col<n_block_cols(); ++col)
481 block(row,col).vmult_add (dst.
block(row),
487 template <
typename Number>
488 template <
typename somenumber>
499 for (
unsigned int row=0; row<n_block_rows(); ++row)
500 for (
unsigned int col=0; col<n_block_cols(); ++col)
501 block(row,col).vmult_add (dst.
block(row),
508 template <
typename Number>
509 template <
typename somenumber>
522 for (
unsigned int row=0; row<n_block_rows(); ++row)
523 for (
unsigned int col=0; col<n_block_cols(); ++col)
524 block(row,col).Tvmult_add (dst.
block(col),
530 template <
typename Number>
531 template <
typename somenumber>
542 for (
unsigned int row=0; row<n_block_rows(); ++row)
543 for (
unsigned int col=0; col<n_block_cols(); ++col)
544 block(row,col).Tvmult_add (dst.
block(col),
549 template <
typename number>
550 template <
class STREAM>
558 std::vector<size_type> used_by_line_total;
563 std::vector<size_type> used_by_line;
565 for (
size_type i=0; i<n_block_rows(); ++i)
566 for (
size_type j=0; j<n_block_cols(); ++j)
568 used_by_line.clear();
569 out <<
"block:\t" << i <<
'\t' << j << std::endl;
570 block(i,j).compute_statistics (used, allocated, reserved,
573 out <<
"used:" << used << std::endl
574 <<
"allocated:" << allocated << std::endl
575 <<
"reserved:" << reserved << std::endl;
578 allocated_total += allocated;
579 reserved_total += reserved;
583 used_by_line_total.resize(used_by_line.size());
584 for (
size_type i=0; i< used_by_line.size(); ++i)
585 if (used_by_line[i] != 0)
587 out <<
"row-entries\t" << i
588 <<
"\trows\t" << used_by_line[i]
590 used_by_line_total[i] += used_by_line[i];
594 out <<
"Total" << std::endl
595 <<
"used:" << used_total << std::endl
596 <<
"allocated:" << allocated_total << std::endl
597 <<
"reserved:" << reserved_total << std::endl;
598 for (
size_type i=0; i< used_by_line_total.size(); ++i)
599 if (used_by_line_total[i] != 0)
601 out <<
"row-entries\t" << i
602 <<
"\trows\t" << used_by_line_total[i]
608 DEAL_II_NAMESPACE_CLOSE
610 #endif //__deal2__block_sparse_matrix_ez_h
Auxiliary class aiding in the handling of block structures like in BlockVector or FESystem...
void vmult(BlockVector< somenumber > &dst, const BlockVector< somenumber > &src) const
SparseMatrixEZ< Number > & block(const unsigned int row, const unsigned int column)
void Tvmult_add(BlockVector< somenumber > &dst, const BlockVector< somenumber > &src) const
bool is_finite(const double x)
unsigned int n_block_rows() const
void add(const size_type i, const size_type j, const Number value)
BlockSparseMatrixEZ & operator=(const BlockSparseMatrixEZ< Number > &)
unsigned int n_block_cols() const
unsigned int global_dof_index
void Tvmult(BlockVector< somenumber > &dst, const BlockVector< somenumber > &src) const
#define Assert(cond, exc)
BlockType & block(const unsigned int i)
::ExceptionBase & ExcIndexRange(int arg1, int arg2, int arg3)
unsigned int n_blocks() const
void vmult_add(BlockVector< somenumber > &dst, const BlockVector< somenumber > &src) const
Table< 2, SparseMatrixEZ< Number > > blocks
void set(const size_type i, const size_type j, const Number value)
BlockIndices column_indices
::ExceptionBase & ExcNumberNotFinite()
void print_statistics(STREAM &s, bool full=false)
::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
types::global_dof_index size_type
void reinit(const unsigned int n_block_rows, const unsigned int n_block_cols)