15#ifndef dealii_matrix_block_h
16#define dealii_matrix_block_h
38template <
typename MatrixType>
44 template <
typename MatrixType>
48 template <
typename number>
91template <
typename MatrixType>
137 operator MatrixType &();
138 operator const MatrixType &()
const;
147 const typename MatrixType::value_type value);
164 template <
typename number>
166 add(
const std::vector<size_type> &indices,
168 const bool elide_zero_values =
true);
184 template <
typename number>
187 const std::vector<size_type> &col_indices,
189 const bool elide_zero_values =
true);
207 template <
typename number>
210 const std::vector<size_type> &col_indices,
211 const std::vector<number> &values,
212 const bool elide_zero_values =
true);
223 template <
typename number>
228 const number *values,
229 const bool elide_zero_values =
true,
230 const bool col_indices_are_sorted =
false);
237 template <
typename VectorType>
239 vmult(VectorType &w,
const VectorType &v)
const;
246 template <
typename VectorType>
255 template <
typename VectorType>
257 Tvmult(VectorType &w,
const VectorType &v)
const;
264 template <
typename VectorType>
281 <<
"Block index " << arg1 <<
" does not match " << arg2);
312 template <
class OTHER_MatrixType>
317 template <
typename number>
332template <
typename MatrixType>
377 clear(
bool really_clean =
false);
419template <
typename MatrixType>
495 clear(
bool really_clean =
false);
595 template <
typename MatrixType>
604 template <
typename number>
616template <
typename MatrixType>
618 : row(
numbers::invalid_size_type)
619 , column(
numbers::invalid_size_type)
623template <
typename MatrixType>
630template <
typename MatrixType>
638template <
typename MatrixType>
645template <
typename MatrixType>
652template <
typename MatrixType>
656 const typename MatrixType::value_type value)
661 const std::pair<unsigned int, size_type> bi = row_indices.global_to_local(gi);
662 const std::pair<unsigned int, size_type> bj =
663 column_indices.global_to_local(gj);
665 Assert(bi.first == row, ExcBlockIndexMismatch(bi.first, row));
666 Assert(bj.first == column, ExcBlockIndexMismatch(bj.first, column));
668 matrix.add(bi.second, bj.second, value);
672template <
typename MatrixType>
673template <
typename number>
676 const std::vector<size_type> &c_indices,
678 const bool elide_zero_values)
686 for (
size_type i = 0; i < row_indices.size(); ++i)
695template <
typename MatrixType>
696template <
typename number>
701 const number *values,
708 const std::pair<unsigned int, size_type> bi =
709 row_indices.global_to_local(b_row);
720 Assert(bi.first == row, ExcBlockIndexMismatch(bi.first, row));
724 const std::pair<unsigned int, size_type> bj =
725 column_indices.global_to_local(col_indices[j]);
726 Assert(bj.first == column, ExcBlockIndexMismatch(bj.first, column));
728 matrix.add(bi.second, bj.second, values[j]);
734template <
typename MatrixType>
735template <
typename number>
739 const bool elide_zero_values)
747 for (
size_type i = 0; i < indices.size(); ++i)
757template <
typename MatrixType>
758template <
typename number>
761 const std::vector<size_type> &col_indices,
762 const std::vector<number> &values,
763 const bool elide_zero_values)
777template <
typename MatrixType>
778template <
typename VectorType>
786template <
typename MatrixType>
787template <
typename VectorType>
791 matrix.vmult_add(w, v);
795template <
typename MatrixType>
796template <
typename VectorType>
804template <
typename MatrixType>
805template <
typename VectorType>
809 matrix.Tvmult_add(w, v);
813template <
typename MatrixType>
823template <
typename MatrixType>
827 const std::string &name)
834template <
typename MatrixType>
840 block(i).reinit(sparsity);
845template <
typename MatrixType>
862template <
typename MatrixType>
866 return *this->read<ptr_type>(i);
870template <
typename MatrixType>
874 return *this->entry<ptr_type>(i);
878template <
typename MatrixType>
882 return this->entry<ptr_type>(i)->matrix;
889template <
typename MatrixType>
893 , edge_flux_matrices(f)
897template <
typename MatrixType>
901 return matrices.size();
905template <
typename MatrixType>
909 const std::string &name)
913 p[0].column = column;
915 matrices.add(p, name);
918 matrices_in.add(p, name);
919 matrices_out.add(p, name);
921 if (edge_flux_matrices)
923 flux_matrices_up.add(p, name);
924 flux_matrices_down.add(p, name);
929template <
typename MatrixType>
937template <
typename MatrixType>
945template <
typename MatrixType>
953template <
typename MatrixType>
961template <
typename MatrixType>
969template <
typename MatrixType>
977template <
typename MatrixType>
985template <
typename MatrixType>
993template <
typename MatrixType>
1001template <
typename MatrixType>
1009template <
typename MatrixType>
1024 o[
level].column = col;
1031template <
typename MatrixType>
1046 block_in(i)[
level].row = row;
1047 block_in(i)[
level].column = col;
1049 block_out(i)[
level].row = row;
1050 block_out(i)[
level].column = col;
1057template <
typename MatrixType>
1072 block_up(i)[
level].row = row;
1073 block_up(i)[
level].column = col;
1075 block_down(i)[
level].row = row;
1076 block_down(i)[
level].column = col;
1083template <
typename MatrixType>
1092 o[
level].matrix.clear();
1097template <
typename MatrixType>
1107 clear_object(matrices);
1108 clear_object(matrices_in);
1109 clear_object(matrices_out);
1110 clear_object(flux_matrices_up);
1111 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