16 #ifndef dealii_filtered_matrix_h 17 # define dealii_filtered_matrix_h 21 # include <deal.II/base/config.h> 23 # include <deal.II/base/memory_consumption.h> 24 # include <deal.II/base/smartpointer.h> 25 # include <deal.II/base/thread_management.h> 27 # include <deal.II/lac/pointer_matrix.h> 28 # include <deal.II/lac/vector_memory.h> 33 DEAL_II_NAMESPACE_OPEN
35 template <
class VectorType>
36 class FilteredMatrixBlock;
198 template <
typename VectorType>
358 template <
typename MatrixType>
360 const bool expect_constrained_source =
false);
377 template <
typename MatrixType>
379 initialize(
const MatrixType &m,
const bool expect_constrained_source =
false);
396 add_constraint(
const size_type i,
const double v);
413 template <
class Constra
intList>
415 add_constraints(
const ConstraintList &new_constraints);
436 apply_constraints(VectorType &v,
const bool matrix_is_symmetric)
const;
442 apply_constraints(VectorType &v)
const;
449 vmult(VectorType &dst,
const VectorType &src)
const;
457 Tvmult(VectorType &dst,
const VectorType &src)
const;
467 vmult_add(VectorType &dst,
const VectorType &src)
const;
477 Tvmult_add(VectorType &dst,
const VectorType &src)
const;
502 memory_consumption()
const;
524 typename std::vector<IndexValuePair>::const_iterator;
542 std::shared_ptr<PointerMatrixBase<VectorType>>
matrix;
555 pre_filter(VectorType &v)
const;
563 post_filter(
const VectorType &in, VectorType &out)
const;
569 friend class FilteredMatrixBlock<VectorType>;
578 template <
typename VectorType>
591 template <
typename VectorType>
595 return matrix->constraints[index].first;
600 template <
typename VectorType>
604 return matrix->constraints[index].first;
609 template <
typename VectorType>
613 return matrix->constraints[index].second;
618 template <
typename VectorType>
628 template <
typename VectorType>
637 template <
typename VectorType>
646 template <
typename number>
654 template <
typename number>
662 template <
typename number>
672 template <
typename number>
677 return !(*
this == other);
684 template <
typename number>
692 template <
typename number>
700 template <
typename VectorType>
705 return (i1.first < i2.first);
710 template <
typename VectorType>
711 template <
typename MatrixType>
722 template <
typename VectorType>
729 template <
typename VectorType>
732 , expect_constrained_source(fm.expect_constrained_source)
734 , constraints(fm.constraints)
739 template <
typename VectorType>
740 template <
typename MatrixType>
743 : expect_constrained_source(false)
750 template <
typename VectorType>
762 template <
typename VectorType>
773 template <
typename VectorType>
774 template <
class Constra
intList>
777 const ConstraintList &new_constraints)
780 const size_type old_size = constraints.size();
781 constraints.reserve(old_size + new_constraints.size());
782 constraints.insert(constraints.end(),
783 new_constraints.begin(),
784 new_constraints.end());
787 std::inplace_merge(constraints.begin(),
788 constraints.begin() + old_size,
795 template <
typename VectorType>
800 std::vector<IndexValuePair> empty;
801 constraints.swap(empty);
806 template <
typename VectorType>
816 template <
typename VectorType>
822 apply_constraints(v);
826 template <
typename VectorType>
832 tmp_vector->reinit(v);
838 (*tmp_vector)(i->first) = -i->second;
844 matrix->vmult_add(v, *tmp_vector);
847 for (i = constraints.begin(); i != e; ++i)
850 v(i->first) = i->second;
855 template <
typename VectorType>
869 template <
typename VectorType>
872 VectorType & out)
const 881 out(i->first) = in(i->first);
887 template <
typename VectorType>
891 if (!expect_constrained_source)
897 tmp_vector->reinit(src,
true);
899 pre_filter(*tmp_vector);
901 matrix->vmult(dst, *tmp_vector);
905 matrix->vmult(dst, src);
909 post_filter(src, dst);
914 template <
typename VectorType>
918 if (!expect_constrained_source)
924 tmp_vector->reinit(src,
true);
926 pre_filter(*tmp_vector);
928 matrix->Tvmult(dst, *tmp_vector);
932 matrix->Tvmult(dst, src);
936 post_filter(src, dst);
941 template <
typename VectorType>
944 const VectorType &src)
const 946 if (!expect_constrained_source)
952 tmp_vector->reinit(src,
true);
954 pre_filter(*tmp_vector);
956 matrix->vmult_add(dst, *tmp_vector);
960 matrix->vmult_add(dst, src);
964 post_filter(src, dst);
969 template <
typename VectorType>
972 const VectorType &src)
const 974 if (!expect_constrained_source)
980 tmp_vector->reinit(src,
true);
982 pre_filter(*tmp_vector);
984 matrix->Tvmult_add(dst, *tmp_vector);
988 matrix->Tvmult_add(dst, src);
992 post_filter(src, dst);
997 template <
typename VectorType>
1007 DEAL_II_NAMESPACE_CLOSE
void initialize(const MatrixType &m, const bool expect_constrained_source=false)
const FilteredMatrix< VectorType > * matrix
const Accessor * operator->() const
const_iterator begin() const
Subscriptor & operator=(const Subscriptor &)
void vmult_add(VectorType &dst, const VectorType &src) const
const_iterator & operator++()
void pre_filter(VectorType &v) const
std::shared_ptr< PointerMatrixBase< VectorType > > matrix
void apply_constraints(VectorType &v, const bool matrix_is_symmetric) const
void post_filter(const VectorType &in, VectorType &out) const
std::vector< IndexValuePair > constraints
static ::ExceptionBase & ExcIndexRange(int arg1, int arg2, int arg3)
SymmetricTensor< rank_, dim, Number > operator*(const SymmetricTensor< rank_, dim, Number > &t, const Number &factor)
FilteredMatrix & operator=(const FilteredMatrix &fm)
Accessor(const FilteredMatrix< VectorType > *matrix, const size_type index)
void add_constraint(const size_type i, const double v)
PointerMatrixBase< VectorType > * new_pointer_matrix_base(MatrixType &matrix, const VectorType &, const char *name="PointerMatrixAux")
const Accessor & operator*() const
void vmult(VectorType &dst, const VectorType &src) const
void Tvmult(VectorType &dst, const VectorType &src) const
#define Assert(cond, exc)
std::pair< size_type, double > IndexValuePair
bool expect_constrained_source
bool operator()(const IndexValuePair &i1, const IndexValuePair &i2) const
bool operator!=(const const_iterator &) const
bool operator==(const const_iterator &) const
void Tvmult_add(VectorType &dst, const VectorType &src) const
typename std::vector< IndexValuePair >::const_iterator const_index_value_iterator
void add_constraints(const ConstraintList &new_constraints)
static ::ExceptionBase & ExcIteratorPastEnd()
unsigned int global_dof_index
const_iterator(const FilteredMatrix< VectorType > *matrix, const size_type index)
#define AssertIsFinite(number)
std::size_t memory_consumption() const
types::global_dof_index size_type
std::enable_if< std::is_fundamental< T >::value, std::size_t >::type memory_consumption(const T &t)
const_iterator end() const