13#ifndef dealii_matrix_block_h
14#define dealii_matrix_block_h
36template <
typename MatrixType>
42 template <
typename MatrixType>
46 template <
typename number>
89template <
typename MatrixType>
135 operator MatrixType &();
136 operator const MatrixType &()
const;
145 const typename MatrixType::value_type value);
162 template <
typename number>
164 add(
const std::vector<size_type> &indices,
166 const bool elide_zero_values =
true);
182 template <
typename number>
185 const std::vector<size_type> &col_indices,
187 const bool elide_zero_values =
true);
205 template <
typename number>
208 const std::vector<size_type> &col_indices,
209 const std::vector<number> &values,
210 const bool elide_zero_values =
true);
221 template <
typename number>
226 const number *values,
227 const bool elide_zero_values =
true,
228 const bool col_indices_are_sorted =
false);
235 template <
typename VectorType>
237 vmult(VectorType &w,
const VectorType &v)
const;
244 template <
typename VectorType>
253 template <
typename VectorType>
255 Tvmult(VectorType &w,
const VectorType &v)
const;
262 template <
typename VectorType>
279 <<
"Block index " << arg1 <<
" does not match " << arg2);
310 template <
class OTHER_MatrixType>
315 template <
typename number>
330template <
typename MatrixType>
375 clear(
bool really_clean =
false);
417template <
typename MatrixType>
493 clear(
bool really_clean =
false);
593 template <
typename MatrixType>
602 template <
typename number>
614template <
typename MatrixType>
616 : row(
numbers::invalid_size_type)
617 , column(
numbers::invalid_size_type)
621template <
typename MatrixType>
628template <
typename MatrixType>
636template <
typename MatrixType>
643template <
typename MatrixType>
650template <
typename MatrixType>
654 const typename MatrixType::value_type value)
659 const std::pair<unsigned int, size_type> bi = row_indices.global_to_local(gi);
660 const std::pair<unsigned int, size_type> bj =
661 column_indices.global_to_local(gj);
663 Assert(bi.first == row, ExcBlockIndexMismatch(bi.first, row));
664 Assert(bj.first == column, ExcBlockIndexMismatch(bj.first, column));
666 matrix.add(bi.second, bj.second, value);
670template <
typename MatrixType>
671template <
typename number>
674 const std::vector<size_type> &c_indices,
676 const bool elide_zero_values)
684 for (
size_type i = 0; i < row_indices.size(); ++i)
693template <
typename MatrixType>
694template <
typename number>
699 const number *values,
706 const std::pair<unsigned int, size_type> bi =
707 row_indices.global_to_local(b_row);
718 Assert(bi.first == row, ExcBlockIndexMismatch(bi.first, row));
722 const std::pair<unsigned int, size_type> bj =
723 column_indices.global_to_local(col_indices[j]);
724 Assert(bj.first == column, ExcBlockIndexMismatch(bj.first, column));
726 matrix.add(bi.second, bj.second, values[j]);
732template <
typename MatrixType>
733template <
typename number>
737 const bool elide_zero_values)
745 for (
size_type i = 0; i < indices.size(); ++i)
755template <
typename MatrixType>
756template <
typename number>
759 const std::vector<size_type> &col_indices,
760 const std::vector<number> &values,
761 const bool elide_zero_values)
775template <
typename MatrixType>
776template <
typename VectorType>
784template <
typename MatrixType>
785template <
typename VectorType>
789 matrix.vmult_add(w, v);
793template <
typename MatrixType>
794template <
typename VectorType>
802template <
typename MatrixType>
803template <
typename VectorType>
807 matrix.Tvmult_add(w, v);
811template <
typename MatrixType>
821template <
typename MatrixType>
825 const std::string &name)
832template <
typename MatrixType>
838 block(i).reinit(sparsity);
843template <
typename MatrixType>
860template <
typename MatrixType>
864 return *this->read<ptr_type>(i);
868template <
typename MatrixType>
872 return *this->entry<ptr_type>(i);
876template <
typename MatrixType>
880 return this->entry<ptr_type>(i)->matrix;
887template <
typename MatrixType>
891 , edge_flux_matrices(f)
895template <
typename MatrixType>
899 return matrices.size();
903template <
typename MatrixType>
907 const std::string &name)
911 p[0].column = column;
913 matrices.add(p, name);
916 matrices_in.add(p, name);
917 matrices_out.add(p, name);
919 if (edge_flux_matrices)
921 flux_matrices_up.add(p, name);
922 flux_matrices_down.add(p, name);
927template <
typename MatrixType>
935template <
typename MatrixType>
943template <
typename MatrixType>
951template <
typename MatrixType>
959template <
typename MatrixType>
967template <
typename MatrixType>
975template <
typename MatrixType>
983template <
typename MatrixType>
991template <
typename MatrixType>
999template <
typename MatrixType>
1007template <
typename MatrixType>
1022 o[
level].column = col;
1029template <
typename MatrixType>
1044 block_in(i)[
level].row = row;
1045 block_in(i)[
level].column = col;
1047 block_out(i)[
level].row = row;
1048 block_out(i)[
level].column = col;
1055template <
typename MatrixType>
1070 block_up(i)[
level].row = row;
1071 block_up(i)[
level].column = col;
1073 block_down(i)[
level].row = row;
1074 block_down(i)[
level].column = col;
1081template <
typename MatrixType>
1090 o[
level].matrix.clear();
1095template <
typename MatrixType>
1105 clear_object(matrices);
1106 clear_object(matrices_in);
1107 clear_object(matrices_out);
1108 clear_object(flux_matrices_up);
1109 clear_object(flux_matrices_down);
const std::string & name(const unsigned int i) const
Name of object at index.
type entry(const std::string &name)
Access to stored data object by name.
void add(type entry, const std::string &name)
Add a new data object.
unsigned int size() const
Number of stored data objects.
void reinit(const unsigned int n_blocks, const size_type n_elements_per_block)
SparsityPatternType & block(const size_type row, const size_type column)
const BlockIndices & get_column_indices() const
const BlockIndices & get_row_indices() const
void resize(const unsigned int new_minlevel, const unsigned int new_maxlevel, Args &&...args)
unsigned int max_level() const
unsigned int min_level() const
AnyData flux_matrices_up
The DG flux from the lower level to a level.
const value_type & block_down(size_type i) const
void clear_object(AnyData &)
Clear one of the matrix objects.
const value_type & block(size_type i) const
void clear(bool really_clean=false)
void reinit_edge_flux(const MGLevelObject< BlockSparsityPattern > &sparsity)
const bool edge_flux_matrices
Flag for storing flux_matrices_up and flux_matrices_down.
AnyData matrices_out
The matrix from the refinement edge to the interior of a level.
void reinit_matrix(const MGLevelObject< BlockSparsityPattern > &sparsity)
const value_type & block_in(size_type i) const
MGMatrixBlockVector(const bool edge_matrices=false, const bool edge_flux_matrices=false)
const value_type & block_out(size_type i) const
std::size_t memory_consumption() const
AnyData flux_matrices_down
The DG flux from a level to the lower level.
AnyData matrices
The level matrices.
void reinit_edge(const MGLevelObject< BlockSparsityPattern > &sparsity)
AnyData matrices_in
The matrix from the interior of a level to the refinement edge.
const bool edge_matrices
Flag for storing matrices_in and matrices_out.
void add(size_type row, size_type column, const std::string &name)
unsigned int size() const
const value_type & block_up(size_type i) const
const std::string & name(const unsigned int i) const
std::shared_ptr< value_type > ptr_type
void add(size_type row, size_type column, const std::string &name)
const value_type & block(size_type i) const
void clear(bool really_clean=false)
std::size_t memory_consumption() const
void reinit(const BlockSparsityPattern &sparsity)
MatrixType & matrix(size_type i)
MatrixBlock< MatrixType > & operator=(const MatrixBlock< MatrixType > &)=default
void vmult_add(VectorType &w, const VectorType &v) const
void reinit(const BlockSparsityPattern &sparsity)
BlockIndices column_indices
MatrixBlock(size_type i, size_type j)
void add(const size_type i, const size_type j, const typename MatrixType::value_type value)
std::size_t memory_consumption() const
void add(const std::vector< size_type > &row_indices, const std::vector< size_type > &col_indices, const FullMatrix< number > &full_matrix, const bool elide_zero_values=true)
void Tvmult_add(VectorType &w, const VectorType &v) const
void add(const std::vector< size_type > &indices, const FullMatrix< number > &full_matrix, const bool elide_zero_values=true)
void add(const size_type row_index, const std::vector< size_type > &col_indices, const std::vector< number > &values, const bool elide_zero_values=true)
void vmult(VectorType &w, const VectorType &v) const
void Tvmult(VectorType &w, const VectorType &v) const
typename MatrixType::value_type value_type
MatrixBlock(const MatrixBlock< MatrixType > &M)=default
void add(const size_type row, const size_type n_cols, const size_type *col_indices, const number *values, const bool elide_zero_values=true, const bool col_indices_are_sorted=false)
friend void internal::reinit(MatrixBlock<::SparseMatrix< number > > &v, const BlockSparsityPattern &p)
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_NOT_IMPLEMENTED()
static ::ExceptionBase & ExcBlockIndexMismatch(size_type arg1, size_type arg2)
#define Assert(cond, exc)
#define DeclException2(Exception2, type1, type2, outsequence)
#define AssertDimension(dim1, dim2)
static ::ExceptionBase & ExcNotInitialized()
static ::ExceptionBase & ExcNotQuadratic()
std::enable_if_t< std::is_fundamental_v< T >, std::size_t > memory_consumption(const T &t)
void reinit(MatrixBlock< MatrixType > &v, const BlockSparsityPattern &p)
unsigned int global_dof_index