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;
150 void add (
const size_type i,
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>
189 void add (
const std::vector<size_type> &row_indices,
190 const std::vector<size_type> &col_indices,
192 const bool elide_zero_values =
true);
210 template <
typename number>
211 void add (
const size_type row_index,
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>
226 void add (
const size_type row,
227 const size_type n_cols,
228 const size_type *col_indices,
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;
268 std::size_t memory_consumption ()
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;
353 void add(size_type row, size_type column,
const std::string &name);
371 void clear (
bool really_clean =
false);
376 std::size_t memory_consumption ()
const;
381 const value_type &block(size_type i)
const;
386 value_type &block(size_type i);
391 MatrixType &matrix(size_type i);
412 template <
typename MatrixType>
436 const bool edge_flux_matrices =
false);
441 unsigned int size ()
const;
448 void add(size_type row, size_type column,
const std::string &name);
483 void clear (
bool really_clean =
false);
488 const value_type &block(size_type i)
const;
493 value_type &block(size_type i);
499 const value_type &block_in(size_type i)
const;
504 value_type &block_in(size_type i);
510 const value_type &block_out(size_type i)
const;
515 value_type &block_out(size_type i);
521 const value_type &block_up(size_type i)
const;
526 value_type &block_up(size_type i);
532 const value_type &block_down(size_type i)
const;
537 value_type &block_down(size_type i);
542 std::size_t memory_consumption ()
const;
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>
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
658 const std::pair<unsigned int, size_type> bj
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)
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
719 const std::pair<unsigned int, size_type> bj
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>
788 template <
typename MatrixType>
789 template <
class VectorType>
798 template <
typename MatrixType>
799 template <
class VectorType>
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>
904 template <
typename MatrixType>
908 const std::string &name)
912 p[0].column = column;
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>
1022 o[level].column = col;
1023 internal::reinit(o[level], sparsity[level]);
1029 template <
typename MatrixType>
1045 internal::reinit(
block_in(i)[level], sparsity[level]);
1048 internal::reinit(
block_out(i)[level], sparsity[level]);
1054 template <
typename MatrixType>
1071 internal::reinit(
block_up(i)[level], sparsity[level]);
1074 internal::reinit(
block_down(i)[level], sparsity[level]);
1081 template <
typename MatrixType>
1089 o[level].matrix.clear();
1094 template <
typename MatrixType>
1116 DEAL_II_NAMESPACE_CLOSE
void reinit_matrix(const MGLevelObject< BlockSparsityPattern > &sparsity)
void unsubscribe(const char *identifier=0) const
const BlockIndices & get_row_indices() const
const bool edge_matrices
Flag for storing matrices_in and matrices_out.
void subscribe(const char *identifier=0) const
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.
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.
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)
std::size_t memory_consumption() const
MatrixType::value_type value_type
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)
void reinit_edge(const MGLevelObject< BlockSparsityPattern > &sparsity)
MGMatrixBlockVector(const bool edge_matrices=false, const bool edge_flux_matrices=false)
unsigned int global_dof_index
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
types::global_dof_index size_type
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
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)
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)
void reinit_edge_flux(const MGLevelObject< BlockSparsityPattern > &sparsity)
void reinit(const BlockSparsityPattern &sparsity)
const value_type & block(size_type i) const
MGLevelObject< MatrixBlock< MatrixType > > value_type
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)
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.
std_cxx11::shared_ptr< value_type > ptr_type
const value_type & block_down(size_type i) const
unsigned int size() const
Number of stored data objects.