16 #ifndef dealii_matrix_block_h 17 #define dealii_matrix_block_h 19 #include <deal.II/base/config.h> 21 #include <deal.II/algorithms/any_data.h> 23 #include <deal.II/base/memory_consumption.h> 24 #include <deal.II/base/mg_level_object.h> 25 #include <deal.II/base/smartpointer.h> 27 #include <deal.II/lac/block_indices.h> 28 #include <deal.II/lac/block_sparsity_pattern.h> 29 #include <deal.II/lac/full_matrix.h> 30 #include <deal.II/lac/sparse_matrix.h> 35 DEAL_II_NAMESPACE_OPEN
37 template <
typename MatrixType>
42 template <
typename MatrixType>
46 template <
typename number>
108 template <
typename MatrixType>
148 operator MatrixType &();
149 operator const MatrixType &()
const;
158 const typename MatrixType::value_type value);
175 template <
typename number>
177 add(
const std::vector<size_type> &indices,
179 const bool elide_zero_values =
true);
195 template <
typename number>
198 const std::vector<size_type> &col_indices,
200 const bool elide_zero_values =
true);
218 template <
typename number>
221 const std::vector<size_type> &col_indices,
222 const std::vector<number> & values,
223 const bool elide_zero_values =
true);
234 template <
typename number>
239 const number * values,
240 const bool elide_zero_values =
true,
241 const bool col_indices_are_sorted =
false);
248 template <
class VectorType>
250 vmult(VectorType &w,
const VectorType &v)
const;
257 template <
class VectorType>
259 vmult_add(VectorType &w,
const VectorType &v)
const;
266 template <
class VectorType>
268 Tvmult(VectorType &w,
const VectorType &v)
const;
275 template <
class VectorType>
277 Tvmult_add(VectorType &w,
const VectorType &v)
const;
292 <<
"Block index " << arg1 <<
" does not match " << arg2);
323 template <
class OTHER_MatrixType>
328 template <
typename number>
344 template <
typename MatrixType>
389 clear(
bool really_clean =
false);
434 template <
typename MatrixType>
510 clear(
bool really_clean =
false);
610 template <
typename MatrixType>
619 template <
typename number>
631 template <
typename MatrixType>
633 : row(
numbers::invalid_size_type)
634 , column(
numbers::invalid_size_type)
638 template <
typename MatrixType>
644 , row_indices(M.row_indices)
645 , column_indices(M.column_indices)
649 template <
typename MatrixType>
656 template <
typename MatrixType>
660 internal::reinit(*
this, sparsity);
664 template <
typename MatrixType>
671 template <
typename MatrixType>
678 template <
typename MatrixType>
682 const typename MatrixType::value_type value)
687 const std::pair<unsigned int, size_type> bi = row_indices.global_to_local(gi);
688 const std::pair<unsigned int, size_type> bj =
689 column_indices.global_to_local(gj);
691 Assert(bi.first == row, ExcBlockIndexMismatch(bi.first, row));
692 Assert(bj.first == column, ExcBlockIndexMismatch(bj.first, column));
694 matrix.add(bi.second, bj.second, value);
698 template <
typename MatrixType>
699 template <
typename number>
702 const std::vector<size_type> &c_indices,
704 const bool elide_zero_values)
712 for (
size_type i = 0; i < row_indices.size(); ++i)
721 template <
typename MatrixType>
722 template <
typename number>
727 const number * values,
734 const std::pair<unsigned int, size_type> bi =
735 row_indices.global_to_local(b_row);
746 Assert(bi.first == row, ExcBlockIndexMismatch(bi.first, row));
750 const std::pair<unsigned int, size_type> bj =
751 column_indices.global_to_local(col_indices[j]);
752 Assert(bj.first == column, ExcBlockIndexMismatch(bj.first, column));
754 matrix.add(bi.second, bj.second, values[j]);
760 template <
typename MatrixType>
761 template <
typename number>
765 const bool elide_zero_values)
773 for (
size_type i = 0; i < indices.size(); ++i)
783 template <
typename MatrixType>
784 template <
typename number>
787 const std::vector<size_type> &col_indices,
788 const std::vector<number> & values,
789 const bool elide_zero_values)
803 template <
typename MatrixType>
804 template <
class VectorType>
812 template <
typename MatrixType>
813 template <
class VectorType>
817 matrix.vmult_add(w, v);
821 template <
typename MatrixType>
822 template <
class VectorType>
830 template <
typename MatrixType>
831 template <
class VectorType>
835 matrix.Tvmult_add(w, v);
839 template <
typename MatrixType>
849 template <
typename MatrixType>
853 const std::string &name)
860 template <
typename MatrixType>
864 for (
size_type i = 0; i < this->size(); ++i)
866 block(i).reinit(sparsity);
871 template <
typename MatrixType>
881 for (
size_type i = 0; i < this->size(); ++i)
888 template <
typename MatrixType>
892 return *this->read<ptr_type>(i);
896 template <
typename MatrixType>
900 return *this->entry<ptr_type>(i);
904 template <
typename MatrixType>
908 return this->entry<ptr_type>(i)->matrix;
915 template <
typename MatrixType>
919 , edge_flux_matrices(f)
923 template <
typename MatrixType>
927 return matrices.size();
931 template <
typename MatrixType>
935 const std::string &name)
939 p[0].column = column;
941 matrices.add(p, name);
944 matrices_in.add(p, name);
945 matrices_out.add(p, name);
947 if (edge_flux_matrices)
949 flux_matrices_up.add(p, name);
950 flux_matrices_down.add(p, name);
955 template <
typename MatrixType>
963 template <
typename MatrixType>
971 template <
typename MatrixType>
979 template <
typename MatrixType>
987 template <
typename MatrixType>
995 template <
typename MatrixType>
1003 template <
typename MatrixType>
1011 template <
typename MatrixType>
1019 template <
typename MatrixType>
1027 template <
typename MatrixType>
1035 template <
typename MatrixType>
1040 for (
size_type i = 0; i < this->size(); ++i)
1050 o[level].column = col;
1051 internal::reinit(o[level], sparsity[level]);
1057 template <
typename MatrixType>
1062 for (
size_type i = 0; i < this->size(); ++i)
1072 block_in(i)[level].row = row;
1073 block_in(i)[level].column = col;
1074 internal::reinit(block_in(i)[level], sparsity[level]);
1075 block_out(i)[level].row = row;
1076 block_out(i)[level].column = col;
1077 internal::reinit(block_out(i)[level], sparsity[level]);
1083 template <
typename MatrixType>
1088 for (
size_type i = 0; i < this->size(); ++i)
1098 block_up(i)[level].row = row;
1099 block_up(i)[level].column = col;
1100 internal::reinit(block_up(i)[level], sparsity[level]);
1101 block_down(i)[level].row = row;
1102 block_down(i)[level].column = col;
1103 internal::reinit(block_down(i)[level], sparsity[level]);
1109 template <
typename MatrixType>
1118 o[level].matrix.clear();
1123 template <
typename MatrixType>
1133 clear_object(matrices);
1134 clear_object(matrices_in);
1135 clear_object(matrices_out);
1136 clear_object(flux_matrices_up);
1137 clear_object(flux_matrices_down);
1143 DEAL_II_NAMESPACE_CLOSE
void reinit_matrix(const MGLevelObject< BlockSparsityPattern > &sparsity)
unsigned int max_level() const
const bool edge_matrices
Flag for storing matrices_in and matrices_out.
type entry(const std::string &name)
Access to stored data object by name.
AnyData matrices
The level matrices.
#define DeclException2(Exception2, type1, type2, outsequence)
#define AssertDimension(dim1, dim2)
Contents is actually a matrix.
AnyData matrices_out
The matrix from the refinement edge to the interior of a level.
MatrixType & matrix(size_type i)
const value_type & block(size_type i) const
void Tvmult(VectorType &w, const VectorType &v) const
void vmult(VectorType &w, const VectorType &v) const
const value_type & block(size_type i) const
void unsubscribe(std::atomic< bool > *const validity, const std::string &identifier="") const
AnyData matrices_in
The matrix from the interior of a level to the refinement edge.
static ::ExceptionBase & ExcNotInitialized()
void add(const size_type i, const size_type j, const typename MatrixType::value_type value)
unsigned int min_level() const
SparsityPatternType & block(const size_type row, const size_type column)
const bool edge_flux_matrices
Flag for storing flux_matrices_up and flux_matrices_down.
void clear(bool really_clean=false)
const value_type & block_out(size_type i) const
void add(size_type row, size_type column, const std::string &name)
types::global_dof_index size_type
void reinit_edge(const MGLevelObject< BlockSparsityPattern > &sparsity)
MGMatrixBlockVector(const bool edge_matrices=false, const bool edge_flux_matrices=false)
void subscribe(std::atomic< bool > *const validity, const std::string &identifier="") const
#define Assert(cond, exc)
AnyData flux_matrices_down
The DG flux from a level to the lower level.
const BlockIndices & get_row_indices() const
std::size_t memory_consumption() const
BlockIndices column_indices
const value_type & block_in(size_type i) const
void vmult_add(VectorType &w, const VectorType &v) const
std::shared_ptr< value_type > ptr_type
typename FullMatrix< number > ::value_type value_type
types::global_dof_index size_type
static ::ExceptionBase & ExcNotQuadratic()
unsigned int global_dof_index
void add(size_type row, size_type column, const std::string &name)
static ::ExceptionBase & ExcBlockIndexMismatch(size_type arg1, size_type arg2)
void clear(bool really_clean=false)
unsigned int size() const
void reinit_edge_flux(const MGLevelObject< BlockSparsityPattern > &sparsity)
void reinit(const BlockSparsityPattern &sparsity)
const value_type & block_up(size_type i) const
std::size_t memory_consumption() const
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 BlockSparsityPattern &sparsity)
types::global_dof_index size_type
AnyData flux_matrices_up
The DG flux from the lower level to a level.
const value_type & block_down(size_type i) const
static ::ExceptionBase & ExcNotImplemented()
void resize(const unsigned int new_minlevel, const unsigned int new_maxlevel)
void clear_object(AnyData &)
Clear one of the matrix objects.
const BlockIndices & get_column_indices() const
void Tvmult_add(VectorType &w, const VectorType &v) const
const std::string & name(const unsigned int i) const
Name of object at index.
std::size_t memory_consumption() const
std::enable_if< std::is_fundamental< T >::value, std::size_t >::type memory_consumption(const T &t)