16 #ifndef dealii__filtered_matrix_h 17 #define dealii__filtered_matrix_h 21 #include <deal.II/base/config.h> 22 #include <deal.II/base/smartpointer.h> 23 #include <deal.II/base/thread_management.h> 24 #include <deal.II/base/memory_consumption.h> 25 #include <deal.II/lac/pointer_matrix.h> 26 #include <deal.II/lac/vector_memory.h> 30 DEAL_II_NAMESPACE_OPEN
32 template <
class VectorType>
class FilteredMatrixBlock;
191 template <
typename VectorType>
228 double value()
const;
342 template <
typename MatrixType>
360 template <
typename MatrixType>
394 template <
class Constra
intList>
414 const bool matrix_is_symmetric)
const DEAL_II_DEPRECATED;
425 void vmult (VectorType &dst,
426 const VectorType &src)
const;
433 void Tvmult (VectorType &dst,
434 const VectorType &src)
const;
444 const VectorType &src)
const;
454 const VectorType &src)
const;
515 std_cxx11::shared_ptr<PointerMatrixBase<VectorType> >
matrix;
535 VectorType &out)
const;
541 friend class FilteredMatrixBlock<VectorType>;
550 template<
typename VectorType>
559 Assert (index <= matrix->constraints.size(),
565 template<
typename VectorType>
575 template<
typename VectorType>
580 return matrix->constraints[index].first;
585 template<
typename VectorType>
590 return matrix->constraints[index].second;
595 template<
typename VectorType>
607 template<
typename VectorType>
618 template<
typename VectorType>
628 template <
typename number>
637 template <
typename number>
646 template <
typename number>
657 template <
typename number>
663 return ! (*
this == other);
670 template <
typename number>
679 template <
typename number>
688 template <
typename VectorType>
695 return (i1.first < i2.first);
700 template <
typename VectorType>
701 template <
typename MatrixType>
706 matrix.reset (new_pointer_matrix_base(m, VectorType()));
713 template <
typename VectorType>
722 template <
typename VectorType>
727 expect_constrained_source(fm.expect_constrained_source),
729 constraints (fm.constraints)
734 template <
typename VectorType>
735 template <
typename MatrixType>
741 expect_constrained_source (false)
748 template <
typename VectorType>
761 template <
typename VectorType>
772 template <
typename VectorType>
773 template <
class Constra
intList>
779 const size_type old_size = constraints.size();
780 constraints.reserve (old_size + new_constraints.size());
781 constraints.insert (constraints.end(),
782 new_constraints.begin(),
783 new_constraints.end());
786 std::inplace_merge (constraints.begin(),
787 constraints.begin()+old_size,
794 template <
typename VectorType>
800 std::vector<IndexValuePair> empty;
801 constraints.swap (empty);
806 template <
typename VectorType>
817 template <
typename VectorType>
824 apply_constraints(v);
828 template <
typename VectorType>
835 tmp_vector->reinit(v);
841 (*tmp_vector)(i->first) = -i->second;
847 matrix->vmult_add(v, *tmp_vector);
850 for (i=constraints.begin(); i!=e; ++i)
853 v(i->first) = i->second;
858 template <
typename VectorType>
873 template <
typename VectorType>
877 VectorType &out)
const 886 out(i->first) = in(i->first);
892 template <
typename VectorType>
897 if (!expect_constrained_source)
900 VectorType *tmp_vector = mem.
alloc();
903 tmp_vector->reinit(src,
true);
905 pre_filter (*tmp_vector);
907 matrix->vmult (dst, *tmp_vector);
908 mem.
free(tmp_vector);
912 matrix->vmult (dst, src);
916 post_filter (src, dst);
921 template <
typename VectorType>
926 if (!expect_constrained_source)
929 VectorType *tmp_vector = mem.
alloc();
932 tmp_vector->reinit(src,
true);
934 pre_filter (*tmp_vector);
936 matrix->Tvmult (dst, *tmp_vector);
937 mem.
free(tmp_vector);
941 matrix->Tvmult (dst, src);
945 post_filter (src, dst);
950 template <
typename VectorType>
955 if (!expect_constrained_source)
958 VectorType *tmp_vector = mem.
alloc();
961 tmp_vector->reinit(src,
true);
963 pre_filter (*tmp_vector);
965 matrix->vmult_add (dst, *tmp_vector);
966 mem.
free(tmp_vector);
970 matrix->vmult_add (dst, src);
974 post_filter (src, dst);
979 template <
typename VectorType>
984 if (!expect_constrained_source)
987 VectorType *tmp_vector = mem.
alloc();
990 tmp_vector->reinit(src,
true);
992 pre_filter (*tmp_vector);
994 matrix->Tvmult_add (dst, *tmp_vector);
995 mem.
free(tmp_vector);
999 matrix->Tvmult_add (dst, src);
1003 post_filter (src, dst);
1008 template <
typename VectorType>
1019 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
std_cxx11::shared_ptr< PointerMatrixBase< VectorType > > matrix
types::global_dof_index size_type
void vmult_add(VectorType &dst, const VectorType &src) const
const_iterator & operator++()
bool operator<(const const_iterator &) const
void pre_filter(VectorType &v) const
void apply_constraints(VectorType &v, const bool matrix_is_symmetric) const 1
std::vector< IndexValuePair >::const_iterator const_index_value_iterator
void post_filter(const VectorType &in, VectorType &out) const
bool operator>(const const_iterator &) const
std::vector< IndexValuePair > constraints
static ::ExceptionBase & ExcIndexRange(int arg1, int arg2, int arg3)
FilteredMatrix & operator=(const FilteredMatrix &fm)
Accessor(const FilteredMatrix< VectorType > *matrix, const size_type index)
void add_constraint(const size_type i, const double v)
const Accessor & operator*() const
void vmult(VectorType &dst, const VectorType &src) const
unsigned int global_dof_index
void Tvmult(VectorType &dst, const VectorType &src) const
virtual VectorType * alloc()
#define Assert(cond, exc)
bool expect_constrained_source
bool operator()(const IndexValuePair &i1, const IndexValuePair &i2) const
bool operator!=(const const_iterator &) const
virtual void free(const VectorType *const)
bool operator==(const const_iterator &) const
void Tvmult_add(VectorType &dst, const VectorType &src) const
void add_constraints(const ConstraintList &new_constraints)
static ::ExceptionBase & ExcIteratorPastEnd()
std_cxx11::enable_if< std_cxx11::is_fundamental< T >::value, std::size_t >::type memory_consumption(const T &t)
std::pair< size_type, double > IndexValuePair
const_iterator(const FilteredMatrix< VectorType > *matrix, const size_type index)
#define AssertIsFinite(number)
std::size_t memory_consumption() const
const_iterator end() const