17 #ifndef __deal2__matrix_block_h 18 #define __deal2__matrix_block_h 20 #include <deal.II/base/config.h> 21 #include <deal.II/base/named_data.h> 22 #include <deal.II/base/smartpointer.h> 23 #include <deal.II/base/std_cxx1x/shared_ptr.h> 24 #include <deal.II/base/memory_consumption.h> 25 #include <deal.II/base/mg_level_object.h> 26 #include <deal.II/lac/block_indices.h> 27 #include <deal.II/lac/block_sparsity_pattern.h> 28 #include <deal.II/lac/sparse_matrix.h> 29 #include <deal.II/lac/full_matrix.h> 38 template <
class MATRIX>
42 template <
typename number>
104 template <
class MATRIX>
147 operator const MATRIX &()
const;
156 void add (
const size_type i,
158 const typename MATRIX::value_type value);
190 template <
typename number>
191 void add (
const std::vector<size_type> &indices,
193 const bool elide_zero_values =
true);
224 template <
typename number>
225 void add (
const std::vector<size_type> &row_indices,
226 const std::vector<size_type> &col_indices,
228 const bool elide_zero_values =
true);
264 template <
typename number>
265 void add (
const size_type row_index,
266 const std::vector<size_type> &col_indices,
267 const std::vector<number> &values,
268 const bool elide_zero_values =
true);
287 template <
typename number>
288 void add (
const size_type row,
289 const size_type n_cols,
290 const size_type *col_indices,
291 const number *values,
292 const bool elide_zero_values =
true,
293 const bool col_indices_are_sorted =
false);
303 template<
class VECTOR>
304 void vmult (VECTOR &w,
const VECTOR &v)
const;
314 template<
class VECTOR>
315 void vmult_add (VECTOR &w,
const VECTOR &v)
const;
325 template<
class VECTOR>
326 void Tvmult (VECTOR &w,
const VECTOR &v)
const;
336 template<
class VECTOR>
337 void Tvmult_add (VECTOR &w,
const VECTOR &v)
const;
342 std::size_t memory_consumption ()
const;
352 <<
"Block index " << arg1 <<
" does not match " << arg2);
404 template <
class MATRIX>
407 private NamedData<std_cxx1x::shared_ptr<MatrixBlock<MATRIX> > >
425 void add(size_type row, size_type column,
const std::string &name);
453 void clear (
bool really_clean =
false);
458 std::size_t memory_consumption ()
const;
464 const value_type &block(size_type i)
const;
470 value_type &block(size_type i);
477 MATRIX &matrix(size_type i);
498 template <
class MATRIX>
528 const bool edge_flux_matrices =
false);
533 unsigned int size ()
const;
543 void add(size_type row, size_type column,
const std::string &name);
598 void clear (
bool really_clean =
false);
604 const value_type &block(size_type i)
const;
610 value_type &block(size_type i);
616 const value_type &block_in(size_type i)
const;
622 value_type &block_in(size_type i);
628 const value_type &block_out(size_type i)
const;
634 value_type &block_out(size_type i);
640 const value_type &block_up(size_type i)
const;
646 value_type &block_up(size_type i);
652 const value_type &block_down(size_type i)
const;
658 value_type &block_down(size_type i);
663 std::size_t memory_consumption ()
const;
691 template <
class MATRIX>
700 template <
typename number>
711 template <
class MATRIX>
720 template <
class MATRIX>
733 template <
class MATRIX>
741 template <
class MATRIX>
746 internal::reinit(*
this, sparsity);
750 template <
class MATRIX>
758 template <
class MATRIX>
766 template <
class MATRIX>
771 const typename MATRIX::value_type value)
776 const std::pair<unsigned int, size_type> bi
778 const std::pair<unsigned int, size_type> bj
781 Assert (bi.first ==
row, ExcBlockIndexMismatch(bi.first,
row));
784 matrix.add(bi.second, bj.second, value);
788 template <
class MATRIX>
789 template <
typename number>
793 const std::vector<size_type> &c_indices,
795 const bool elide_zero_values)
804 add (r_indices[i], c_indices.size(), &c_indices[0], &values(i,0),
809 template <
class MATRIX>
810 template <
typename number>
816 const number *values,
823 const std::pair<unsigned int, size_type> bi
835 Assert(bi.first ==
row, ExcBlockIndexMismatch(bi.first,
row));
839 const std::pair<unsigned int, size_type> bj
843 matrix.add(bi.second, bj.second, values[j]);
849 template <
class MATRIX>
850 template <
typename number>
855 const bool elide_zero_values)
861 Assert (values.
n() == values.
m(), ExcNotQuadratic());
863 for (
size_type i=0; i<indices.size(); ++i)
864 add (indices[i], indices.size(), &indices[0], &values(i,0),
870 template <
class MATRIX>
871 template <
typename number>
875 const std::vector<size_type> &col_indices,
876 const std::vector<number> &values,
877 const bool elide_zero_values)
883 add (row, col_indices.size(), &col_indices[0], &values[0],
888 template <
class MATRIX>
889 template <
class VECTOR>
898 template <
class MATRIX>
899 template <
class VECTOR>
908 template <
class MATRIX>
909 template <
class VECTOR>
918 template <
class MATRIX>
919 template <
class VECTOR>
928 template <
class MATRIX>
933 return (
sizeof(*
this)
940 template <
class MATRIX>
944 const std::string &name)
946 std_cxx1x::shared_ptr<value_type> p(
new value_type(row, column));
951 template <
class MATRIX>
957 block(i).reinit(sparsity);
962 template <
class MATRIX>
979 template <
class MATRIX>
983 return *this->read(i);
987 template <
class MATRIX>
995 template <
class MATRIX>
999 return (*
this)(i)->
matrix;
1006 template <
class MATRIX>
1009 const bool e,
const bool f)
1012 edge_flux_matrices(f)
1016 template <
class MATRIX>
1025 template <
class MATRIX>
1029 const std::string &name)
1033 p[0].column = column;
1049 template <
class MATRIX>
1057 template <
class MATRIX>
1065 template <
class MATRIX>
1073 template <
class MATRIX>
1081 template <
class MATRIX>
1089 template <
class MATRIX>
1097 template <
class MATRIX>
1105 template <
class MATRIX>
1113 template <
class MATRIX>
1121 template <
class MATRIX>
1129 template <
class MATRIX>
1143 o[level].column = col;
1144 internal::reinit(o[level], sparsity[level]);
1150 template <
class MATRIX>
1166 internal::reinit(
block_in(i)[level], sparsity[level]);
1169 internal::reinit(
block_out(i)[level], sparsity[level]);
1175 template <
class MATRIX>
1191 internal::reinit(
block_up(i)[level], sparsity[level]);
1194 internal::reinit(
block_down(i)[level], sparsity[level]);
1201 template <
class MATRIX>
1209 o[level].matrix.clear();
1214 template <
class MATRIX>
1236 DEAL_II_NAMESPACE_CLOSE
MatrixBlock< MATRIX > value_type
BlockIndices column_indices
const value_type & block_down(size_type i) const
const value_type & block_up(size_type i) const
void Tvmult(VECTOR &u, const VECTOR &v) const
void clear_object(NamedData< MGLevelObject< MatrixBlock< MATRIX > > > &)
Clear one of the matrix objects.
NamedData< MGLevelObject< MatrixBlock< MATRIX > > > matrices
The level matrices.
#define DeclException2(Exception2, type1, type2, outsequence)
const value_type & block_in(size_type i) const
#define AssertDimension(dim1, dim2)
void Tvmult(VECTOR &w, const VECTOR &v) const
void Tvmult_add(VECTOR &w, const VECTOR &v) const
void add(DATA &v, const std::string &name)
void vmult(VECTOR &u, const VECTOR &v) const
unsigned int size() const
NamedData< MGLevelObject< MatrixBlock< MATRIX > > > flux_matrices_down
The DG flux from a level to the lower level.
void vmult_add(VECTOR &w, const VECTOR &v) const
std::size_t memory_consumption() const
Auxiliary class aiding in the handling of block structures like in BlockVector or FESystem...
const value_type & block(size_type i) const
void add(const size_type i, const size_type j, const typename MATRIX::value_type value)
void add(size_type row, size_type column, const std::string &name)
const bool edge_matrices
Flag for storing matrices_in and matrices_out.
MGMatrixBlockVector(const bool edge_matrices=false, const bool edge_flux_matrices=false)
types::global_dof_index size_type
const DATA & read(unsigned int i) const
Read only access for a non-const object.
SparsityPatternBase & block(const size_type row, const size_type column)
void reinit(const BlockSparsityPattern &sparsity)
types::global_dof_index size_type
types::global_dof_index size_type
void clear(bool really_clean=false)
void reinit_matrix(const MGLevelObject< BlockSparsityPattern > &sparsity)
unsigned int global_dof_index
#define Assert(cond, exc)
std::size_t memory_consumption(const T &t)
unsigned int max_level() const
void vmult(VECTOR &w, const VECTOR &v) const
const BlockIndices & get_column_indices() const
void reinit(const BlockSparsityPattern &sparsity)
unsigned int size() const
Number of stored data objects.
NamedData< MGLevelObject< MatrixBlock< MATRIX > > > matrices_out
The matrix from the refinement edge to the interior of a level.
void Tvmult_add(VECTOR &u, const VECTOR &v) const
void reinit_edge(const MGLevelObject< BlockSparsityPattern > &sparsity)
std::pair< unsigned int, size_type > global_to_local(const size_type i) const
void clear(bool really_clean=false)
const BlockIndices & get_row_indices() const
NamedData< MGLevelObject< MatrixBlock< MATRIX > > > flux_matrices_up
The DG flux from the lower level to a level.
void vmult_add(VECTOR &u, const VECTOR &v) const
void reinit_edge_flux(const MGLevelObject< BlockSparsityPattern > &sparsity)
const value_type & block(size_type i) const
unsigned int min_level() const
::ExceptionBase & ExcNotImplemented()
::ExceptionBase & ExcNotInitialized()
unsigned int size() const
const value_type & block_out(size_type i) const
NamedData< MGLevelObject< MatrixBlock< MATRIX > > > matrices_in
The matrix from the interior of a level to the refinement edge.
const bool edge_flux_matrices
Flag for storing flux_matrices_up and flux_matrices_down.
void resize(const unsigned int new_minlevel, const unsigned int new_maxlevel)
void add(size_type row, size_type column, const std::string &name)
MATRIX & matrix(size_type i)
MGLevelObject< MatrixBlock< MATRIX > > value_type