16#ifndef dealii_read_write_vector_h
17#define dealii_read_write_vector_h
36#ifdef DEAL_II_WITH_TRILINOS
41# include <Epetra_MultiVector.h>
58 template <
typename,
typename>
63# ifdef DEAL_II_WITH_PETSC
73# ifdef DEAL_II_WITH_TRILINOS
83# ifdef DEAL_II_WITH_CUDA
135 template <
typename Number>
204 template <
typename Number2>
207 const bool omit_zeroing_entries =
false);
220 const bool omit_zeroing_entries =
false);
223#ifdef DEAL_II_WITH_TRILINOS
252 template <
typename Functor>
280 template <
typename Number2>
302 const ::Vector<Number> &vec,
304 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
305 &communication_pattern = {});
310 DEAL_II_DEPRECATED_EARLY
312 import(const ::Vector<Number> &V,
314 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
315 &communication_pattern = {})
333 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
334 &communication_pattern = {});
339 DEAL_II_DEPRECATED_EARLY
343 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
344 &communication_pattern = {})
357 template <
typename MemorySpace>
362 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
363 &communication_pattern = {});
368 template <
typename MemorySpace>
369 DEAL_II_DEPRECATED_EARLY
void
372 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
373 &communication_pattern = {})
379#ifdef DEAL_II_WITH_PETSC
392 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
393 &communication_pattern = {});
398 DEAL_II_DEPRECATED_EARLY
402 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
403 &communication_pattern = {})
409#ifdef DEAL_II_WITH_TRILINOS
424 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
425 &communication_pattern = {});
430 DEAL_II_DEPRECATED_EARLY
434 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
435 &communication_pattern = {})
440# ifdef DEAL_II_TRILINOS_WITH_TPETRA
449 template <
typename Dummy = Number>
450 std::enable_if_t<std::is_same<Dummy, Number>::value &&
455 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
456 &communication_pattern = {});
461 template <
typename Dummy = Number>
462 DEAL_II_DEPRECATED_EARLY
463 std::enable_if_t<std::is_same<Dummy, Number>::value &&
468 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
469 &communication_pattern = {})
487 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
488 &communication_pattern = {});
493 DEAL_II_DEPRECATED_EARLY
497 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
498 &communication_pattern = {})
504#ifdef DEAL_II_WITH_CUDA
515 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
516 &communication_pattern = {});
522 DEAL_II_DEPRECATED_EARLY
526 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
527 &communication_pattern = {})
655 template <
typename Number2>
658 std::vector<Number2> &
values)
const;
687 template <
typename ForwardIterator,
typename OutputIterator>
690 const ForwardIterator indices_end,
691 OutputIterator values_begin)
const;
730 template <
typename Number2>
732 add(
const std::vector<size_type> &indices,
733 const std::vector<Number2> &
values);
739 template <
typename Number2>
741 add(
const std::vector<size_type> & indices,
749 template <
typename Number2>
760 const unsigned int precision = 3,
761 const bool scientific =
true)
const;
771#ifdef DEAL_II_WITH_TRILINOS
772# ifdef DEAL_II_TRILINOS_WITH_TPETRA
778 template <
typename Dummy = Number>
779 std::enable_if_t<std::is_same<Dummy, Number>::value &&
782 const Tpetra::Vector<Number, int, types::signed_global_dof_index>
784 const IndexSet & locally_owned_elements,
787 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
788 &communication_pattern);
798 const Epetra_MultiVector &multivector,
799 const IndexSet & locally_owned_elements,
802 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
803 &communication_pattern);
818#ifdef DEAL_II_WITH_TRILINOS
819# ifdef DEAL_II_TRILINOS_WITH_TPETRA
852 std::shared_ptr<Utilities::MPI::CommunicationPatternBase>
comm_pattern;
857 std::unique_ptr<Number[], void (*)(
void *)>
864 mutable std::shared_ptr<::parallel::internal::TBBPartitioner>
868 template <
typename Number2>
877 template <
typename Functor>
913 template <
typename Number>
916 , values(nullptr, free)
926 template <
typename Number>
928 const ReadWriteVector<Number> &v)
937 template <
typename Number>
950 template <
typename Number>
952 const IndexSet &locally_stored_indices)
964 template <
typename Number>
973 template <
typename Number>
982 template <
typename Number>
991 template <
typename Number>
1000 template <
typename Number>
1009 template <
typename Number>
1018 template <
typename Number>
1027 template <
typename Number>
1036 template <
typename Number>
1045 template <
typename Number>
1054 template <
typename Number>
1063 template <
typename Number>
1072 template <
typename Number>
1073 template <
typename Number2>
1076 const std::vector<size_type> &indices,
1077 std::vector<Number2> & extracted_values)
const
1079 for (
size_type i = 0; i < indices.size(); ++i)
1080 extracted_values[i] =
operator()(indices[i]);
1085 template <
typename Number>
1086 template <
typename ForwardIterator,
typename OutputIterator>
1089 ForwardIterator indices_begin,
1090 const ForwardIterator indices_end,
1091 OutputIterator values_begin)
const
1093 while (indices_begin != indices_end)
1103 template <
typename Number>
1109 return values[local_index];
1114 template <
typename Number>
1120 return values[local_index];
1125 template <
typename Number>
1126 template <
typename Number2>
1129 const std::vector<Number2> &
values)
1132 add(indices.size(), indices.data(),
values.data());
1137 template <
typename Number>
1138 template <
typename Number2>
1141 const ReadWriteVector<Number2> &
values)
1149 "The given value is not finite but either infinite or Not A Number (NaN)"));
1156 template <
typename Number>
1157 template <
typename Number2>
1161 const Number2 * values_to_add)
1163 for (
size_type i = 0; i < n_indices; ++i)
1168 "The given value is not finite but either infinite or Not A Number (NaN)"));
1169 this->
operator()(indices[i]) += values_to_add[i];
1175 template <
typename Number>
1182 return static_cast<unsigned int>(
1188 template <
typename Number>
1189 template <
typename Functor>
1191 ReadWriteVector<Number> &parent,
1192 const Functor & functor)
1199 template <
typename Number>
1200 template <
typename Functor>
1207 functor(parent.values[i]);
1223template <
typename Number>
size_type index_within_set(const size_type global_index) const
size_type n_elements() const
FunctorTemplate(ReadWriteVector< Number > &parent, const Functor &functor)
virtual void operator()(const size_type begin, const size_type end)
void import_elements(const ::Vector< Number > &vec, VectorOperation::values operation, const std::shared_ptr< const Utilities::MPI::CommunicationPatternBase > &communication_pattern={})
void reinit(const ReadWriteVector< Number2 > &in_vector, const bool omit_zeroing_entries=false)
Number & operator()(const size_type global_index)
ReadWriteVector(const ReadWriteVector< Number > &in_vector)
ReadWriteVector(const size_type size)
std::enable_if_t< std::is_same< Dummy, Number >::value &&::is_tpetra_type< Number >::value > import_elements(const TpetraWrappers::Vector< Number > &tpetra_vec, VectorOperation::values operation, const std::shared_ptr< const Utilities::MPI::CommunicationPatternBase > &communication_pattern={})
void import_elements(const TrilinosWrappers::MPI::Vector &trilinos_vec, VectorOperation::values operation, const std::shared_ptr< const Utilities::MPI::CommunicationPatternBase > &communication_pattern={})
friend class ReadWriteVector
void add(const std::vector< size_type > &indices, const std::vector< Number2 > &values)
Number operator()(const size_type global_index) const
void apply(const Functor &func)
std::size_t memory_consumption() const
void import_elements(const CUDAWrappers::Vector< Number > &cuda_vec, VectorOperation::values operation, const std::shared_ptr< const Utilities::MPI::CommunicationPatternBase > &communication_pattern={})
Number & operator[](const size_type global_index)
void print(std::ostream &out, const unsigned int precision=3, const bool scientific=true) const
void add(const std::vector< size_type > &indices, const ReadWriteVector< Number2 > &values)
Number & local_element(const size_type local_index)
void import_elements(const EpetraWrappers::Vector &epetra_vec, VectorOperation::values operation, const std::shared_ptr< const Utilities::MPI::CommunicationPatternBase > &communication_pattern={})
unsigned int global_to_local(const types::global_dof_index global_index) const
void resize_val(const size_type new_allocated_size)
Number operator[](const size_type global_index) const
Number local_element(const size_type local_index) const
void add(const size_type n_elements, const size_type *indices, const Number2 *values)
void import_elements(const PETScWrappers::MPI::Vector &petsc_vec, VectorOperation::values operation, const std::shared_ptr< const Utilities::MPI::CommunicationPatternBase > &communication_pattern={})
ReadWriteVector< Number > & operator=(const Number s)
TpetraWrappers::CommunicationPattern create_tpetra_comm_pattern(const IndexSet &source_index_set, const MPI_Comm mpi_comm)
std::enable_if_t< std::is_same< Dummy, Number >::value &&::is_tpetra_type< Number >::value > import_elements(const Tpetra::Vector< Number, int, types::signed_global_dof_index > &tpetra_vector, const IndexSet &locally_owned_elements, VectorOperation::values operation, const MPI_Comm mpi_comm, const std::shared_ptr< const Utilities::MPI::CommunicationPatternBase > &communication_pattern)
void reinit(const TrilinosWrappers::MPI::Vector &trilinos_vec)
virtual void reinit(const IndexSet &locally_stored_indices, const bool omit_zeroing_entries=false)
const value_type * const_pointer
void extract_subvector_to(ForwardIterator indices_begin, const ForwardIterator indices_end, OutputIterator values_begin) const
virtual void reinit(const size_type size, const bool omit_zeroing_entries=false)
size_type locally_owned_size() const
const_iterator end() const
ReadWriteVector< Number > & operator=(const ReadWriteVector< Number > &in_vector)
IndexSet source_stored_elements
void extract_subvector_to(const std::vector< size_type > &indices, std::vector< Number2 > &values) const
const value_type * const_iterator
const_iterator begin() const
void import_elements(const LinearAlgebra::Vector< Number > &vec, VectorOperation::values operation, const std::shared_ptr< const Utilities::MPI::CommunicationPatternBase > &communication_pattern={})
const value_type & const_reference
~ReadWriteVector() override=default
ReadWriteVector(const IndexSet &locally_stored_indices)
EpetraWrappers::CommunicationPattern create_epetra_comm_pattern(const IndexSet &source_index_set, const MPI_Comm mpi_comm)
std::unique_ptr< Number[], void(*)(void *)> values
types::global_dof_index size_type
const IndexSet & get_stored_elements() const
ReadWriteVector< Number > & operator=(const ReadWriteVector< Number2 > &in_vector)
void import_elements(const distributed::Vector< Number, MemorySpace > &vec, VectorOperation::values operation, const std::shared_ptr< const Utilities::MPI::CommunicationPatternBase > &communication_pattern={})
void swap(ReadWriteVector< Number > &v)
size_type n_elements() const
std::shared_ptr< Utilities::MPI::CommunicationPatternBase > comm_pattern
std::shared_ptr<::parallel::internal::TBBPartitioner > thread_loop_partitioner
typename numbers::NumberTraits< Number >::real_type real_type
void import_elements(const Epetra_MultiVector &multivector, const IndexSet &locally_owned_elements, VectorOperation::values operation, const MPI_Comm mpi_comm, const std::shared_ptr< const Utilities::MPI::CommunicationPatternBase > &communication_pattern)
void swap(LinearAlgebra::ReadWriteVector< Number > &u, LinearAlgebra::ReadWriteVector< Number > &v)
#define DEAL_II_DEPRECATED
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
#define Assert(cond, exc)
#define AssertDimension(dim1, dim2)
#define AssertIndexRange(index, range)
static ::ExceptionBase & ExcMessage(std::string arg1)
bool is_finite(const double x)
unsigned int global_dof_index