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>
197 add(
const std::vector<size_type> &row_indices,
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;
283 memory_consumption()
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);
395 memory_consumption()
const;
434 template <
typename MatrixType>
457 const bool edge_flux_matrices =
false);
510 clear(
bool really_clean =
false);
580 memory_consumption()
const;
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>
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)
688 const std::pair<unsigned int, size_type> bj =
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)
721 template <
typename MatrixType>
722 template <
typename number>
727 const number * values,
734 const std::pair<unsigned int, size_type> bi =
750 const std::pair<unsigned int, size_type> bj =
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>
821 template <
typename MatrixType>
822 template <
class VectorType>
830 template <
typename MatrixType>
831 template <
class VectorType>
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>
931 template <
typename MatrixType>
935 const std::string &name)
939 p[0].column = column;
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>
1050 o[level].column = col;
1051 internal::reinit(o[level], sparsity[level]);
1057 template <
typename MatrixType>
1074 internal::reinit(
block_in(i)[level], sparsity[level]);
1077 internal::reinit(
block_out(i)[level], sparsity[level]);
1083 template <
typename MatrixType>
1100 internal::reinit(
block_up(i)[level], sparsity[level]);
1103 internal::reinit(
block_down(i)[level], sparsity[level]);
1109 template <
typename MatrixType>
1118 o[level].matrix.clear();
1123 template <
typename MatrixType>
1143 DEAL_II_NAMESPACE_CLOSE
void reinit_matrix(const MGLevelObject< BlockSparsityPattern > &sparsity)
const BlockIndices & get_row_indices() 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)
void subscribe(const char *identifier=nullptr) const
AnyData matrices_out
The matrix from the refinement edge to the interior of a level.
const value_type & block(size_type i) const
MatrixType & matrix(size_type i)
void Tvmult_add(VectorType &w, const VectorType &v) 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)
void unsubscribe(const char *identifier=nullptr) const
std::size_t memory_consumption() const
unsigned long long int global_dof_index
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 std::string & name(const unsigned int i) const
Name of object at index.
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)
const value_type & block_up(size_type i) const
#define Assert(cond, exc)
AnyData flux_matrices_down
The DG flux from a level to the lower level.
unsigned int max_level() const
void vmult(VectorType &w, const VectorType &v) const
const value_type & block_in(size_type i) const
const value_type & block_out(size_type i) const
BlockIndices column_indices
std::pair< unsigned int, size_type > global_to_local(const size_type i) const
std::shared_ptr< value_type > ptr_type
typename FullMatrix< number >::value_type value_type
types::global_dof_index size_type
static::ExceptionBase & ExcNotQuadratic()
const type read(const std::string &name) const
Dedicated read only access by name.
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)
void reinit_edge_flux(const MGLevelObject< BlockSparsityPattern > &sparsity)
void reinit(const BlockSparsityPattern &sparsity)
const value_type & block(size_type i) const
void add(type entry, const std::string &name)
Add a new data object.
const BlockIndices & get_column_indices() const
void Tvmult(VectorType &w, const VectorType &v) const
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.
unsigned int size() const
unsigned int min_level() const
static::ExceptionBase & ExcNotImplemented()
unsigned int size() const
void resize(const unsigned int new_minlevel, const unsigned int new_maxlevel)
void vmult_add(VectorType &w, const VectorType &v) const
void clear_object(AnyData &)
Clear one of the matrix objects.
const value_type & block_down(size_type i) const
unsigned int size() const
Number of stored data objects.
std::enable_if< std::is_fundamental< T >::value, std::size_t >::type memory_consumption(const T &t)