17 #ifndef __deal2__block_sparse_matrix_templates_h 18 #define __deal2__block_sparse_matrix_templates_h 21 #include <deal.II/base/config.h> 22 #include <deal.II/base/memory_consumption.h> 23 #include <deal.II/lac/block_sparse_matrix.h> 28 template <
typename number>
34 template <
typename number>
43 template <
typename number>
54 template <
typename number>
60 ExcBlockDimensionMismatch());
61 Assert (this->column_block_indices == m.column_block_indices,
62 ExcBlockDimensionMismatch());
68 for (size_type r=0; r<this->n_block_rows(); ++r)
69 for (size_type c=0; c<this->n_block_cols(); ++c)
70 this->block(r,c) = m.
block(r,c);
77 template <
typename number>
87 template <
typename number>
99 sparsity_pattern = &sparsity;
108 for (size_type r=0; r<this->n_block_rows(); ++r)
109 for (size_type c=0; c<this->n_block_cols(); ++c)
113 this->sub_objects[r][c] = p;
119 template <
typename number>
123 for (size_type r=0; r<this->n_block_rows(); ++r)
124 for (size_type c=0; c<this->n_block_cols(); ++c)
125 if (this->block(r,c).empty () ==
false)
134 template <
typename number>
135 typename BlockSparseMatrix<number>::size_type
138 return sparsity_pattern->row_length(row);
143 template <
typename number>
144 typename BlockSparseMatrix<number>::size_type
147 return sparsity_pattern->n_nonzero_elements ();
152 template <
typename number>
153 typename BlockSparseMatrix<number>::size_type
157 for (size_type i=0; i<this->n_block_rows(); ++i)
158 for (size_type j=0; j<this->n_block_cols(); ++j)
159 count += this->sub_objects[i][j]->n_actually_nonzero_elements (threshold);
166 template <
typename number>
170 return *sparsity_pattern;
175 template <
typename number>
179 const unsigned int precision,
180 const bool scientific,
181 const unsigned int width,
182 const char *zero_string,
183 const double denominator)
const 185 for (size_type r=0; r<this->n_block_rows(); ++r)
186 for (size_type c=0; c<this->n_block_cols(); ++c)
188 out <<
"Component (" << r <<
"," << c <<
")" << std::endl;
189 this->block(r,c).print_formatted (out, precision, scientific,
190 width, zero_string, denominator);
196 template <
typename number>
200 std::size_t mem =
sizeof(*this);
202 for (size_type r=0; r<this->n_block_rows(); ++r)
203 for (size_type c=0; c<this->n_block_cols(); ++c)
211 DEAL_II_NAMESPACE_CLOSE
213 #endif // ifdef block_sparse_matrix_templates_h BlockIndices column_indices
std::size_t memory_consumption() const
size_type n_nonzero_elements() const
SparsityPatternBase & block(const size_type row, const size_type column)
size_type n_actually_nonzero_elements(const double threshold=0.0) const
#define Assert(cond, exc)
std::size_t memory_consumption(const T &t)
void reinit(const unsigned int n_blocks, const size_type n_elements_per_block)
void print_formatted(std::ostream &out, const unsigned int precision=3, const bool scientific=true, const unsigned int width=0, const char *zero_string=" ", const double denominator=1.) const
size_type get_row_length(const size_type row) const
virtual void reinit(const SparsityPattern &sparsity)
BlockType & block(const unsigned int row, const unsigned int column)
size_type n_block_rows() const
BlockIndices row_block_indices
virtual ~BlockSparseMatrix()
size_type n_block_cols() const
virtual void reinit(const BlockSparsityPattern &sparsity)
BlockSparseMatrix & operator=(const BlockSparseMatrix &)
const BlockSparsityPattern & get_sparsity_pattern() const