16#ifndef dealii_matrix_block_h
17#define dealii_matrix_block_h
39template <
typename MatrixType>
45 template <
typename MatrixType>
49 template <
typename number>
110template <
typename MatrixType>
156 operator MatrixType &();
157 operator const MatrixType &()
const;
166 const typename MatrixType::value_type value);
183 template <
typename number>
185 add(
const std::vector<size_type> &indices,
187 const bool elide_zero_values =
true);
203 template <
typename number>
206 const std::vector<size_type> &col_indices,
208 const bool elide_zero_values =
true);
226 template <
typename number>
229 const std::vector<size_type> &col_indices,
230 const std::vector<number> & values,
231 const bool elide_zero_values =
true);
242 template <
typename number>
247 const number * values,
248 const bool elide_zero_values =
true,
249 const bool col_indices_are_sorted =
false);
256 template <
class VectorType>
258 vmult(VectorType &w,
const VectorType &v)
const;
265 template <
class VectorType>
274 template <
class VectorType>
276 Tvmult(VectorType &w,
const VectorType &v)
const;
283 template <
class VectorType>
300 <<
"Block index " << arg1 <<
" does not match " << arg2);
331 template <
class OTHER_MatrixType>
336 template <
typename number>
351template <
typename MatrixType>
396 clear(
bool really_clean =
false);
440template <
typename MatrixType>
516 clear(
bool really_clean =
false);
616 template <
typename MatrixType>
625 template <
typename number>
637template <
typename MatrixType>
639 : row(
numbers::invalid_size_type)
640 , column(
numbers::invalid_size_type)
644template <
typename MatrixType>
651template <
typename MatrixType>
659template <
typename MatrixType>
666template <
typename MatrixType>
673template <
typename MatrixType>
677 const typename MatrixType::value_type value)
682 const std::pair<unsigned int, size_type> bi = row_indices.global_to_local(gi);
683 const std::pair<unsigned int, size_type> bj =
684 column_indices.global_to_local(gj);
686 Assert(bi.first == row, ExcBlockIndexMismatch(bi.first, row));
687 Assert(bj.first == column, ExcBlockIndexMismatch(bj.first, column));
689 matrix.add(bi.second, bj.second, value);
693template <
typename MatrixType>
694template <
typename number>
697 const std::vector<size_type> &c_indices,
699 const bool elide_zero_values)
707 for (
size_type i = 0; i < row_indices.size(); ++i)
716template <
typename MatrixType>
717template <
typename number>
722 const number * values,
729 const std::pair<unsigned int, size_type> bi =
730 row_indices.global_to_local(b_row);
741 Assert(bi.first == row, ExcBlockIndexMismatch(bi.first, row));
745 const std::pair<unsigned int, size_type> bj =
746 column_indices.global_to_local(col_indices[j]);
747 Assert(bj.first == column, ExcBlockIndexMismatch(bj.first, column));
749 matrix.add(bi.second, bj.second, values[j]);
755template <
typename MatrixType>
756template <
typename number>
760 const bool elide_zero_values)
768 for (
size_type i = 0; i < indices.size(); ++i)
778template <
typename MatrixType>
779template <
typename number>
782 const std::vector<size_type> &col_indices,
783 const std::vector<number> & values,
784 const bool elide_zero_values)
798template <
typename MatrixType>
799template <
class VectorType>
807template <
typename MatrixType>
808template <
class VectorType>
812 matrix.vmult_add(w, v);
816template <
typename MatrixType>
817template <
class VectorType>
825template <
typename MatrixType>
826template <
class VectorType>
830 matrix.Tvmult_add(w, v);
834template <
typename MatrixType>
844template <
typename MatrixType>
848 const std::string &name)
855template <
typename MatrixType>
859 for (
size_type i = 0; i < this->size(); ++i)
861 block(i).reinit(sparsity);
866template <
typename MatrixType>
876 for (
size_type i = 0; i < this->size(); ++i)
883template <
typename MatrixType>
887 return *this->read<ptr_type>(i);
891template <
typename MatrixType>
895 return *this->entry<ptr_type>(i);
899template <
typename MatrixType>
903 return this->entry<ptr_type>(i)->matrix;
910template <
typename MatrixType>
914 , edge_flux_matrices(f)
918template <
typename MatrixType>
922 return matrices.size();
926template <
typename MatrixType>
930 const std::string &name)
934 p[0].column = column;
936 matrices.add(p, name);
939 matrices_in.add(p, name);
940 matrices_out.add(p, name);
942 if (edge_flux_matrices)
944 flux_matrices_up.add(p, name);
945 flux_matrices_down.add(p, name);
950template <
typename MatrixType>
958template <
typename MatrixType>
966template <
typename MatrixType>
974template <
typename MatrixType>
982template <
typename MatrixType>
990template <
typename MatrixType>
998template <
typename MatrixType>
1006template <
typename MatrixType>
1014template <
typename MatrixType>
1022template <
typename MatrixType>
1030template <
typename MatrixType>
1035 for (
size_type i = 0; i < this->size(); ++i)
1045 o[
level].column = col;
1052template <
typename MatrixType>
1057 for (
size_type i = 0; i < this->size(); ++i)
1067 block_in(i)[
level].row = row;
1068 block_in(i)[
level].column = col;
1070 block_out(i)[
level].row = row;
1071 block_out(i)[
level].column = col;
1078template <
typename MatrixType>
1083 for (
size_type i = 0; i < this->size(); ++i)
1093 block_up(i)[
level].row = row;
1094 block_up(i)[
level].column = col;
1096 block_down(i)[
level].row = row;
1097 block_down(i)[
level].column = col;
1104template <
typename MatrixType>
1113 o[
level].matrix.clear();
1118template <
typename MatrixType>
1128 clear_object(matrices);
1129 clear_object(matrices_in);
1130 clear_object(matrices_out);
1131 clear_object(flux_matrices_up);
1132 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)
void unsubscribe(std::atomic< bool > *const validity, const std::string &identifier="") const
void subscribe(std::atomic< bool > *const validity, const std::string &identifier="") const
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
static ::ExceptionBase & ExcBlockIndexMismatch(size_type arg1, size_type arg2)
static ::ExceptionBase & ExcNotImplemented()
#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< T >::value, std::size_t > memory_consumption(const T &t)
void reinit(MatrixBlock< MatrixType > &v, const BlockSparsityPattern &p)
unsigned int global_dof_index