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/std_cxx11/shared_ptr.h> 22 #include <deal.II/base/memory_consumption.h> 23 #include <deal.II/base/mg_level_object.h> 24 #include <deal.II/lac/block_indices.h> 25 #include <deal.II/lac/block_sparsity_pattern.h> 26 #include <deal.II/lac/sparse_matrix.h> 27 #include <deal.II/lac/full_matrix.h> 28 #include <deal.II/algorithms/any_data.h> 31 DEAL_II_NAMESPACE_OPEN
37 template <
typename MatrixType>
42 template <
typename number>
103 template <
typename MatrixType>
143 operator MatrixType &();
144 operator const MatrixType &()
const;
152 const typename MatrixType::value_type value);
169 template <
typename number>
170 void add (
const std::vector<size_type> &indices,
172 const bool elide_zero_values =
true);
188 template <
typename number>
190 const std::vector<size_type> &col_indices,
192 const bool elide_zero_values =
true);
210 template <
typename number>
212 const std::vector<size_type> &col_indices,
213 const std::vector<number> &values,
214 const bool elide_zero_values =
true);
225 template <
typename number>
229 const number *values,
230 const bool elide_zero_values =
true,
231 const bool col_indices_are_sorted =
false);
238 template<
class VectorType>
239 void vmult (VectorType &w,
const VectorType &v)
const;
246 template<
class VectorType>
247 void vmult_add (VectorType &w,
const VectorType &v)
const;
254 template<
class VectorType>
255 void Tvmult (VectorType &w,
const VectorType &v)
const;
262 template<
class VectorType>
263 void Tvmult_add (VectorType &w,
const VectorType &v)
const;
275 <<
"Block index " << arg1 <<
" does not match " << arg2);
306 template <
class OTHER_MatrixType>
311 template <
typename number>
327 template <
typename MatrixType>
347 typedef std_cxx11::shared_ptr<value_type>
ptr_type;
371 void clear (
bool really_clean =
false);
412 template <
typename MatrixType>
441 unsigned int size ()
const;
483 void clear (
bool really_clean =
false);
570 template <
typename MatrixType>
580 template <
typename number>
592 template <
typename MatrixType>
596 row(
numbers::invalid_size_type),
597 column(
numbers::invalid_size_type)
601 template <
typename MatrixType>
609 row_indices(M.row_indices),
610 column_indices(M.column_indices)
614 template <
typename MatrixType>
622 template <
typename MatrixType>
627 internal::reinit(*
this, sparsity);
631 template <
typename MatrixType>
639 template <
typename MatrixType>
647 template <
typename MatrixType>
651 const typename MatrixType::value_type value)
656 const std::pair<unsigned int, size_type> bi
657 = row_indices.global_to_local(gi);
658 const std::pair<unsigned int, size_type> bj
659 = column_indices.global_to_local(gj);
661 Assert (bi.first == row, ExcBlockIndexMismatch(bi.first, row));
662 Assert (bj.first == column, ExcBlockIndexMismatch(bj.first, column));
664 matrix.add(bi.second, bj.second, value);
668 template <
typename MatrixType>
669 template <
typename number>
673 const std::vector<size_type> &c_indices,
675 const bool elide_zero_values)
683 for (
size_type i=0; i<row_indices.size(); ++i)
684 add (r_indices[i], c_indices.size(), &c_indices[0], &values(i,0),
689 template <
typename MatrixType>
690 template <
typename number>
696 const number *values,
703 const std::pair<unsigned int, size_type> bi
704 = row_indices.global_to_local(b_row);
715 Assert(bi.first == row, ExcBlockIndexMismatch(bi.first, row));
719 const std::pair<unsigned int, size_type> bj
720 = column_indices.global_to_local(col_indices[j]);
721 Assert(bj.first == column, ExcBlockIndexMismatch(bj.first, column));
723 matrix.add(bi.second, bj.second, values[j]);
729 template <
typename MatrixType>
730 template <
typename number>
735 const bool elide_zero_values)
743 for (
size_type i=0; i<indices.size(); ++i)
744 add (indices[i], indices.size(), &indices[0], &values(i,0),
750 template <
typename MatrixType>
751 template <
typename number>
755 const std::vector<size_type> &col_indices,
756 const std::vector<number> &values,
757 const bool elide_zero_values)
763 add (row, col_indices.size(), &col_indices[0], &values[0],
768 template <
typename MatrixType>
769 template <
class VectorType>
778 template <
typename MatrixType>
779 template <
class VectorType>
784 matrix.vmult_add(w,v);
788 template <
typename MatrixType>
789 template <
class VectorType>
798 template <
typename MatrixType>
799 template <
class VectorType>
804 matrix.Tvmult_add(w,v);
808 template <
typename MatrixType>
813 return (
sizeof(*
this)
820 template <
typename MatrixType>
824 const std::string &name)
831 template <
typename MatrixType>
837 block(i).reinit(sparsity);
842 template <
typename MatrixType>
859 template <
typename MatrixType>
863 return *this->read<ptr_type>(i);
867 template <
typename MatrixType>
871 return *this->entry<ptr_type>(i);
875 template <
typename MatrixType>
879 return this->entry<ptr_type>(i)->matrix;
886 template <
typename MatrixType>
891 edge_flux_matrices(f)
895 template <
typename MatrixType>
900 return matrices.size();
904 template <
typename MatrixType>
908 const std::string &name)
912 p[0].column = column;
914 matrices.add(p, name);
917 matrices_in.add(p, name);
918 matrices_out.add(p, name);
920 if (edge_flux_matrices)
922 flux_matrices_up.add(p, name);
923 flux_matrices_down.add(p, name);
928 template <
typename MatrixType>
936 template <
typename MatrixType>
944 template <
typename MatrixType>
952 template <
typename MatrixType>
960 template <
typename MatrixType>
968 template <
typename MatrixType>
976 template <
typename MatrixType>
984 template <
typename MatrixType>
992 template <
typename MatrixType>
1000 template <
typename MatrixType>
1008 template <
typename MatrixType>
1012 for (
size_type i=0; i<this->size(); ++i)
1022 o[level].column = col;
1023 internal::reinit(o[level], sparsity[level]);
1029 template <
typename MatrixType>
1033 for (
size_type i=0; i<this->size(); ++i)
1043 block_in(i)[level].row = row;
1044 block_in(i)[level].column = col;
1045 internal::reinit(block_in(i)[level], sparsity[level]);
1046 block_out(i)[level].row = row;
1047 block_out(i)[level].column = col;
1048 internal::reinit(block_out(i)[level], sparsity[level]);
1054 template <
typename MatrixType>
1059 for (
size_type i=0; i<this->size(); ++i)
1069 block_up(i)[level].row = row;
1070 block_up(i)[level].column = col;
1071 internal::reinit(block_up(i)[level], sparsity[level]);
1072 block_down(i)[level].row = row;
1073 block_down(i)[level].column = col;
1074 internal::reinit(block_down(i)[level], sparsity[level]);
1081 template <
typename MatrixType>
1089 o[level].matrix.clear();
1094 template <
typename MatrixType>
1104 clear_object(matrices);
1105 clear_object(matrices_in);
1106 clear_object(matrices_out);
1107 clear_object(flux_matrices_up);
1108 clear_object(flux_matrices_down);
1116 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
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
void subscribe(const char *identifier=0) 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.
const BlockIndices & get_row_indices() const
std::size_t memory_consumption() const
types::global_dof_index size_type
void unsubscribe(const char *identifier=0) const
BlockIndices column_indices
const value_type & block_in(size_type i) const
void vmult_add(VectorType &w, const VectorType &v) const
static ::ExceptionBase & ExcNotQuadratic()
void add(size_type row, size_type column, const std::string &name)
std_cxx11::enable_if< std_cxx11::is_fundamental< T >::value, std::size_t >::type memory_consumption(const T &t)
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.
std_cxx11::shared_ptr< value_type > ptr_type
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