16 #ifndef dealii_matrix_block_h 17 #define dealii_matrix_block_h 19 #include <deal.II/base/config.h> 20 #include <deal.II/base/smartpointer.h> 21 #include <deal.II/base/memory_consumption.h> 22 #include <deal.II/base/mg_level_object.h> 23 #include <deal.II/lac/block_indices.h> 24 #include <deal.II/lac/block_sparsity_pattern.h> 25 #include <deal.II/lac/sparse_matrix.h> 26 #include <deal.II/lac/full_matrix.h> 27 #include <deal.II/algorithms/any_data.h> 32 DEAL_II_NAMESPACE_OPEN
38 template <
typename MatrixType>
43 template <
typename number>
104 template <
typename MatrixType>
144 operator MatrixType &();
145 operator const MatrixType &()
const;
153 const typename MatrixType::value_type value);
170 template <
typename number>
171 void add (
const std::vector<size_type> &indices,
173 const bool elide_zero_values =
true);
189 template <
typename number>
191 const std::vector<size_type> &col_indices,
193 const bool elide_zero_values =
true);
211 template <
typename number>
213 const std::vector<size_type> &col_indices,
214 const std::vector<number> &values,
215 const bool elide_zero_values =
true);
226 template <
typename number>
230 const number *values,
231 const bool elide_zero_values =
true,
232 const bool col_indices_are_sorted =
false);
239 template <
class VectorType>
240 void vmult (VectorType &w,
const VectorType &v)
const;
247 template <
class VectorType>
248 void vmult_add (VectorType &w,
const VectorType &v)
const;
255 template <
class VectorType>
256 void Tvmult (VectorType &w,
const VectorType &v)
const;
263 template <
class VectorType>
264 void Tvmult_add (VectorType &w,
const VectorType &v)
const;
276 <<
"Block index " << arg1 <<
" does not match " << arg2);
307 template <
class OTHER_MatrixType>
312 template <
typename number>
328 template <
typename MatrixType>
372 void clear (
bool really_clean =
false);
413 template <
typename MatrixType>
442 unsigned int size ()
const;
484 void clear (
bool really_clean =
false);
571 template <
typename MatrixType>
581 template <
typename number>
593 template <
typename MatrixType>
597 row(
numbers::invalid_size_type),
598 column(
numbers::invalid_size_type)
602 template <
typename MatrixType>
610 row_indices(M.row_indices),
611 column_indices(M.column_indices)
615 template <
typename MatrixType>
623 template <
typename MatrixType>
628 internal::reinit(*
this, sparsity);
632 template <
typename MatrixType>
640 template <
typename MatrixType>
648 template <
typename MatrixType>
652 const typename MatrixType::value_type value)
657 const std::pair<unsigned int, size_type> bi
658 = row_indices.global_to_local(gi);
659 const std::pair<unsigned int, size_type> bj
660 = column_indices.global_to_local(gj);
662 Assert (bi.first == row, ExcBlockIndexMismatch(bi.first, row));
663 Assert (bj.first == column, ExcBlockIndexMismatch(bj.first, column));
665 matrix.add(bi.second, bj.second, value);
669 template <
typename MatrixType>
670 template <
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)
685 add (r_indices[i], c_indices.size(), c_indices.data(), &values(i,0),
690 template <
typename MatrixType>
691 template <
typename number>
697 const number *values,
704 const std::pair<unsigned int, size_type> bi
705 = row_indices.global_to_local(b_row);
716 Assert(bi.first == row, ExcBlockIndexMismatch(bi.first, row));
720 const std::pair<unsigned int, size_type> bj
721 = column_indices.global_to_local(col_indices[j]);
722 Assert(bj.first == column, ExcBlockIndexMismatch(bj.first, column));
724 matrix.add(bi.second, bj.second, values[j]);
730 template <
typename MatrixType>
731 template <
typename number>
736 const bool elide_zero_values)
744 for (
size_type i=0; i<indices.size(); ++i)
745 add (indices[i], indices.size(), indices.data(), &values(i,0),
751 template <
typename MatrixType>
752 template <
typename number>
756 const std::vector<size_type> &col_indices,
757 const std::vector<number> &values,
758 const bool elide_zero_values)
764 add (row, col_indices.size(), col_indices.data(), values.data(),
769 template <
typename MatrixType>
770 template <
class VectorType>
779 template <
typename MatrixType>
780 template <
class VectorType>
785 matrix.vmult_add(w,v);
789 template <
typename MatrixType>
790 template <
class VectorType>
799 template <
typename MatrixType>
800 template <
class VectorType>
805 matrix.Tvmult_add(w,v);
809 template <
typename MatrixType>
814 return (
sizeof(*
this)
821 template <
typename MatrixType>
825 const std::string &name)
832 template <
typename MatrixType>
838 block(i).reinit(sparsity);
843 template <
typename MatrixType>
860 template <
typename MatrixType>
864 return *this->read<ptr_type>(i);
868 template <
typename MatrixType>
872 return *this->entry<ptr_type>(i);
876 template <
typename MatrixType>
880 return this->entry<ptr_type>(i)->matrix;
887 template <
typename MatrixType>
892 edge_flux_matrices(f)
896 template <
typename MatrixType>
901 return matrices.size();
905 template <
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);
929 template <
typename MatrixType>
937 template <
typename MatrixType>
945 template <
typename MatrixType>
953 template <
typename MatrixType>
961 template <
typename MatrixType>
969 template <
typename MatrixType>
977 template <
typename MatrixType>
985 template <
typename MatrixType>
993 template <
typename MatrixType>
1001 template <
typename MatrixType>
1009 template <
typename MatrixType>
1013 for (
size_type i=0; i<this->size(); ++i)
1023 o[level].column = col;
1024 internal::reinit(o[level], sparsity[level]);
1030 template <
typename MatrixType>
1034 for (
size_type i=0; i<this->size(); ++i)
1044 block_in(i)[level].row = row;
1045 block_in(i)[level].column = col;
1046 internal::reinit(block_in(i)[level], sparsity[level]);
1047 block_out(i)[level].row = row;
1048 block_out(i)[level].column = col;
1049 internal::reinit(block_out(i)[level], sparsity[level]);
1055 template <
typename MatrixType>
1060 for (
size_type i=0; i<this->size(); ++i)
1070 block_up(i)[level].row = row;
1071 block_up(i)[level].column = col;
1072 internal::reinit(block_up(i)[level], sparsity[level]);
1073 block_down(i)[level].row = row;
1074 block_down(i)[level].column = col;
1075 internal::reinit(block_down(i)[level], sparsity[level]);
1082 template <
typename MatrixType>
1090 o[level].matrix.clear();
1095 template <
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);
1117 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)
types::global_dof_index size_type
void unsubscribe(const char *identifier=nullptr) const
Contents is actually a matrix.
MatrixBlock< MatrixType > value_type
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
AnyData matrices_in
The matrix from the interior of a level to the refinement edge.
types::global_dof_index size_type
static ::ExceptionBase & ExcNotInitialized()
void add(const size_type i, const size_type j, const typename MatrixType::value_type value)
MatrixType::value_type value_type
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)
void reinit_edge(const MGLevelObject< BlockSparsityPattern > &sparsity)
MGMatrixBlockVector(const bool edge_matrices=false, const bool edge_flux_matrices=false)
unsigned int global_dof_index
#define Assert(cond, exc)
AnyData flux_matrices_down
The DG flux from a level to the lower level.
std::shared_ptr< value_type > ptr_type
const BlockIndices & get_row_indices() const
std::size_t memory_consumption() const
types::global_dof_index size_type
BlockIndices column_indices
const value_type & block_in(size_type i) const
void vmult_add(VectorType &w, const VectorType &v) const
void subscribe(const char *identifier=nullptr) const
static ::ExceptionBase & ExcNotQuadratic()
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
MGLevelObject< MatrixBlock< MatrixType > > value_type
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)
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)