16 #ifndef dealii_read_write_vector_h 17 #define dealii_read_write_vector_h 19 #include <deal.II/base/config.h> 21 #include <deal.II/base/index_set.h> 22 #include <deal.II/base/memory_consumption.h> 23 #include <deal.II/base/mpi.h> 24 #include <deal.II/base/template_constraints.h> 25 #include <deal.II/base/thread_management.h> 26 #include <deal.II/base/types.h> 27 #include <deal.II/base/utilities.h> 29 #include <deal.II/lac/vector_operation.h> 35 #ifdef DEAL_II_WITH_TRILINOS 36 # include <deal.II/lac/trilinos_epetra_communication_pattern.h> 37 # include <deal.II/lac/trilinos_epetra_vector.h> 38 # include <deal.II/lac/trilinos_tpetra_vector.h> 40 # include <Epetra_MultiVector.h> 44 DEAL_II_NAMESPACE_OPEN
48 class CommunicationPatternBase;
51 template <
typename,
typename>
56 #ifdef DEAL_II_WITH_PETSC 66 #ifdef DEAL_II_WITH_TRILINOS 76 #ifdef DEAL_II_WITH_CUDA 128 template <
typename Number>
187 reinit(
const size_type
size,
const bool omit_zeroing_entries =
false);
197 template <
typename Number2>
200 const bool omit_zeroing_entries =
false);
213 const bool omit_zeroing_entries =
false);
216 #ifdef DEAL_II_WITH_TRILINOS 217 # ifdef DEAL_II_WITH_MPI 247 template <
typename Functor>
249 apply(
const Functor &func);
275 template <
typename Number2>
294 template <
typename MemorySpace>
298 const std::shared_ptr<const CommunicationPatternBase>
299 &communication_pattern =
300 std::shared_ptr<const CommunicationPatternBase>());
302 #ifdef DEAL_II_WITH_PETSC 314 const std::shared_ptr<const CommunicationPatternBase>
315 &communication_pattern =
316 std::shared_ptr<const CommunicationPatternBase>());
319 #ifdef DEAL_II_WITH_TRILINOS 333 const std::shared_ptr<const CommunicationPatternBase>
334 &communication_pattern =
335 std::shared_ptr<const CommunicationPatternBase>());
337 # ifdef DEAL_II_WITH_MPI 338 # ifdef DEAL_II_TRILINOS_WITH_TPETRA 348 import(
const TpetraWrappers::Vector<Number> &tpetra_vec,
350 const std::shared_ptr<const CommunicationPatternBase>
351 &communication_pattern =
352 std::shared_ptr<const CommunicationPatternBase>());
366 const std::shared_ptr<const CommunicationPatternBase>
367 &communication_pattern =
368 std::shared_ptr<const CommunicationPatternBase>());
372 #ifdef DEAL_II_WITH_CUDA 382 const std::shared_ptr<const CommunicationPatternBase>
383 &communication_pattern =
384 std::shared_ptr<const CommunicationPatternBase>());
454 operator()(
const size_type global_index)
const;
471 Number
operator[](
const size_type global_index)
const;
480 Number &
operator[](
const size_type global_index);
497 template <
typename Number2>
500 std::vector<Number2> &
values)
const;
529 template <
typename ForwardIterator,
typename OutputIterator>
532 const ForwardIterator indices_end,
533 OutputIterator values_begin)
const;
572 template <
typename Number2>
574 add(
const std::vector<size_type> &indices,
575 const std::vector<Number2> &
values);
581 template <
typename Number2>
583 add(
const std::vector<size_type> & indices,
591 template <
typename Number2>
594 const size_type *indices,
601 print(std::ostream & out,
602 const unsigned int precision = 3,
603 const bool scientific =
true)
const;
613 #ifdef DEAL_II_WITH_TRILINOS 614 # ifdef DEAL_II_TRILINOS_WITH_TPETRA 622 const Tpetra::Vector<Number, int, types::global_dof_index> &tpetra_vector,
623 const IndexSet & locally_owned_elements,
625 const MPI_Comm & mpi_comm,
626 const std::shared_ptr<const CommunicationPatternBase>
627 &communication_pattern);
636 import(
const Epetra_MultiVector &multivector,
637 const IndexSet & locally_owned_elements,
639 const MPI_Comm & mpi_comm,
640 const std::shared_ptr<const CommunicationPatternBase>
641 &communication_pattern);
652 return static_cast<unsigned int>(
660 resize_val(
const size_type new_allocated_size);
662 #if defined(DEAL_II_WITH_TRILINOS) && defined(DEAL_II_WITH_MPI) 663 # ifdef DEAL_II_TRILINOS_WITH_TPETRA 668 TpetraWrappers::CommunicationPattern
669 create_tpetra_comm_pattern(
const IndexSet &source_index_set,
670 const MPI_Comm &mpi_comm);
679 const MPI_Comm &mpi_comm);
701 std::unique_ptr<Number[], decltype(free) *>
values;
707 mutable std::shared_ptr<::parallel::internal::TBBPartitioner>
713 template <
typename Number2>
722 template <
typename Functor>
757 template <
typename Number>
760 , values(nullptr, free)
770 template <
typename Number>
772 const ReadWriteVector<Number> &v)
781 template <
typename Number>
794 template <
typename Number>
796 const IndexSet &locally_stored_indices)
808 template <
typename Number>
809 inline typename ReadWriteVector<Number>::size_type
817 template <
typename Number>
818 inline typename ReadWriteVector<Number>::size_type
826 template <
typename Number>
835 template <
typename Number>
836 inline typename ReadWriteVector<Number>::iterator
844 template <
typename Number>
845 inline typename ReadWriteVector<Number>::const_iterator
853 template <
typename Number>
854 inline typename ReadWriteVector<Number>::iterator
862 template <
typename Number>
863 inline typename ReadWriteVector<Number>::const_iterator
871 template <
typename Number>
880 template <
typename Number>
889 template <
typename Number>
891 operator[](
const size_type global_index)
const 898 template <
typename Number>
907 template <
typename Number>
908 template <
typename Number2>
911 const std::vector<size_type> &indices,
912 std::vector<Number2> & extracted_values)
const 914 for (size_type i = 0; i < indices.size(); ++i)
915 extracted_values[i] =
operator()(indices[i]);
920 template <
typename Number>
921 template <
typename ForwardIterator,
typename OutputIterator>
924 ForwardIterator indices_begin,
925 const ForwardIterator indices_end,
926 OutputIterator values_begin)
const 928 while (indices_begin != indices_end)
938 template <
typename Number>
944 return values[local_index];
949 template <
typename Number>
955 return values[local_index];
960 template <
typename Number>
961 template <
typename Number2>
964 const std::vector<Number2> &
values)
967 add(indices.size(), indices.data(),
values.data());
972 template <
typename Number>
973 template <
typename Number2>
976 const ReadWriteVector<Number2> &
values)
978 const size_type
size = indices.size();
979 for (size_type i = 0; i <
size; ++i)
984 "The given value is not finite but either infinite or Not A Number (NaN)"));
991 template <
typename Number>
992 template <
typename Number2>
995 const size_type *indices,
996 const Number2 * values_to_add)
998 for (size_type i = 0; i < n_indices; ++i)
1003 "The given value is not finite but either infinite or Not A Number (NaN)"));
1004 this->
operator()(indices[i]) += values_to_add[i];
1010 template <
typename Number>
1011 template <
typename Functor>
1013 ReadWriteVector<Number> &parent,
1014 const Functor & functor)
1021 template <
typename Number>
1022 template <
typename Functor>
1027 for (size_type i =
begin; i <
end; ++i)
1028 functor(parent.values[i]);
1031 #endif // ifndef DOXYGEN 1044 template <
typename Number>
1053 DEAL_II_NAMESPACE_CLOSE
IndexSet source_stored_elements
#define AssertDimension(dim1, dim2)
Number operator[](const size_type global_index) const
void swap(ReadWriteVector< Number > &v)
Number local_element(const size_type local_index) const
FunctorTemplate(ReadWriteVector< Number > &parent, const Functor &functor)
void resize_val(const size_type new_allocated_size)
#define AssertIndexRange(index, range)
std::size_t memory_consumption() const
~ReadWriteVector() override=default
void swap(LinearAlgebra::ReadWriteVector< Number > &u, LinearAlgebra::ReadWriteVector< Number > &v)
LinearAlgebra::distributed::Vector< Number > Vector
bool is_finite(const double x)
virtual void reinit(const size_type size, const bool omit_zeroing_entries=false)
std::unique_ptr< Number[], decltype(free) * > values
static ::ExceptionBase & ExcMessage(std::string arg1)
#define Assert(cond, exc)
size_type index_within_set(const size_type global_index) const
Number operator()(const size_type global_index) const
ReadWriteVector< Number > & operator=(const ReadWriteVector< Number > &in_vector)
EpetraWrappers::CommunicationPattern create_epetra_comm_pattern(const IndexSet &source_index_set, const MPI_Comm &mpi_comm)
void add(const std::vector< size_type > &indices, const std::vector< Number2 > &values)
void print(std::ostream &out, const unsigned int precision=3, const bool scientific=true) const
virtual void operator()(const size_type begin, const size_type end)
std::shared_ptr< CommunicationPatternBase > comm_pattern
unsigned int global_dof_index
void extract_subvector_to(const std::vector< size_type > &indices, std::vector< Number2 > &values) const
void apply(const Functor &func)
unsigned int global_to_local(const types::global_dof_index global_index) const
size_type n_elements() const
size_type n_elements() const
const IndexSet & get_stored_elements() const
std::shared_ptr<::parallel::internal::TBBPartitioner > thread_loop_partitioner