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);
421template <
typename MatrixType>
497 clear(
bool really_clean =
false);
597 template <
typename MatrixType>
606 template <
typename number>
618template <
typename MatrixType>
620 : row(
numbers::invalid_size_type)
621 , column(
numbers::invalid_size_type)
625template <
typename MatrixType>
632template <
typename MatrixType>
640template <
typename MatrixType>
647template <
typename MatrixType>
654template <
typename MatrixType>
658 const typename MatrixType::value_type value)
663 const std::pair<unsigned int, size_type> bi = row_indices.global_to_local(gi);
664 const std::pair<unsigned int, size_type> bj =
665 column_indices.global_to_local(gj);
667 Assert(bi.first == row, ExcBlockIndexMismatch(bi.first, row));
668 Assert(bj.first == column, ExcBlockIndexMismatch(bj.first, column));
670 matrix.add(bi.second, bj.second, value);
674template <
typename MatrixType>
675template <
typename number>
678 const std::vector<size_type> &c_indices,
680 const bool elide_zero_values)
688 for (
size_type i = 0; i < row_indices.size(); ++i)
697template <
typename MatrixType>
698template <
typename number>
703 const number *values,
710 const std::pair<unsigned int, size_type> bi =
711 row_indices.global_to_local(b_row);
722 Assert(bi.first == row, ExcBlockIndexMismatch(bi.first, row));
726 const std::pair<unsigned int, size_type> bj =
727 column_indices.global_to_local(col_indices[j]);
728 Assert(bj.first == column, ExcBlockIndexMismatch(bj.first, column));
730 matrix.add(bi.second, bj.second, values[j]);
736template <
typename MatrixType>
737template <
typename number>
741 const bool elide_zero_values)
749 for (
size_type i = 0; i < indices.size(); ++i)
759template <
typename MatrixType>
760template <
typename number>
763 const std::vector<size_type> &col_indices,
764 const std::vector<number> &values,
765 const bool elide_zero_values)
779template <
typename MatrixType>
780template <
typename VectorType>
788template <
typename MatrixType>
789template <
typename VectorType>
793 matrix.vmult_add(w, v);
797template <
typename MatrixType>
798template <
typename VectorType>
806template <
typename MatrixType>
807template <
typename VectorType>
811 matrix.Tvmult_add(w, v);
815template <
typename MatrixType>
825template <
typename MatrixType>
829 const std::string &name)
836template <
typename MatrixType>
842 block(i).reinit(sparsity);
847template <
typename MatrixType>
864template <
typename MatrixType>
868 return *this->read<ptr_type>(i);
872template <
typename MatrixType>
876 return *this->entry<ptr_type>(i);
880template <
typename MatrixType>
884 return this->entry<ptr_type>(i)->matrix;
891template <
typename MatrixType>
895 , edge_flux_matrices(f)
899template <
typename MatrixType>
903 return matrices.size();
907template <
typename MatrixType>
911 const std::string &name)
915 p[0].column = column;
917 matrices.add(p, name);
920 matrices_in.add(p, name);
921 matrices_out.add(p, name);
923 if (edge_flux_matrices)
925 flux_matrices_up.add(p, name);
926 flux_matrices_down.add(p, name);
931template <
typename MatrixType>
939template <
typename MatrixType>
947template <
typename MatrixType>
955template <
typename MatrixType>
963template <
typename MatrixType>
971template <
typename MatrixType>
979template <
typename MatrixType>
987template <
typename MatrixType>
995template <
typename MatrixType>
1003template <
typename MatrixType>
1011template <
typename MatrixType>
1026 o[
level].column = col;
1033template <
typename MatrixType>
1048 block_in(i)[
level].row = row;
1049 block_in(i)[
level].column = col;
1051 block_out(i)[
level].row = row;
1052 block_out(i)[
level].column = col;
1059template <
typename MatrixType>
1074 block_up(i)[
level].row = row;
1075 block_up(i)[
level].column = col;
1077 block_down(i)[
level].row = row;
1078 block_down(i)[
level].column = col;
1085template <
typename MatrixType>
1094 o[
level].matrix.clear();
1099template <
typename MatrixType>
1109 clear_object(matrices);
1110 clear_object(matrices_in);
1111 clear_object(matrices_out);
1112 clear_object(flux_matrices_up);
1113 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 subscribe(std::atomic< bool > *const validity, const std::string &identifier="") const
void unsubscribe(std::atomic< bool > *const validity, const std::string &identifier="") 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
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()
#define DEAL_II_NOT_IMPLEMENTED()
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