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>
301 import(const ::Vector<Number> &vec,
303 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
304 &communication_pattern = {});
318 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
319 &communication_pattern = {});
329 template <
typename MemorySpace>
333 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
334 &communication_pattern = {});
336 #ifdef DEAL_II_WITH_PETSC
348 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
349 &communication_pattern = {});
352 #ifdef DEAL_II_WITH_TRILINOS
366 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
367 &communication_pattern = {});
369 # ifdef DEAL_II_TRILINOS_WITH_TPETRA
381 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
382 &communication_pattern = {});
396 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
397 &communication_pattern = {});
400 #ifdef DEAL_II_WITH_CUDA
410 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
411 &communication_pattern = {});
536 template <
typename Number2>
539 std::vector<Number2> &
values)
const;
568 template <
typename ForwardIterator,
typename OutputIterator>
571 const ForwardIterator indices_end,
572 OutputIterator values_begin)
const;
611 template <
typename Number2>
613 add(
const std::vector<size_type> &indices,
614 const std::vector<Number2> &
values);
620 template <
typename Number2>
622 add(
const std::vector<size_type> & indices,
630 template <
typename Number2>
641 const unsigned int precision = 3,
642 const bool scientific =
true)
const;
652 #ifdef DEAL_II_WITH_TRILINOS
653 # ifdef DEAL_II_TRILINOS_WITH_TPETRA
661 const Tpetra::Vector<Number, int, types::global_dof_index> &tpetra_vector,
662 const IndexSet & locally_owned_elements,
664 const MPI_Comm & mpi_comm,
665 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
666 &communication_pattern);
675 import(
const Epetra_MultiVector &multivector,
676 const IndexSet & locally_owned_elements,
678 const MPI_Comm & mpi_comm,
679 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
680 &communication_pattern);
691 return static_cast<unsigned int>(
701 #ifdef DEAL_II_WITH_TRILINOS
702 # ifdef DEAL_II_TRILINOS_WITH_TPETRA
709 const MPI_Comm &mpi_comm);
718 const MPI_Comm &mpi_comm);
735 std::shared_ptr<Utilities::MPI::CommunicationPatternBase>
comm_pattern;
746 mutable std::shared_ptr<::parallel::internal::TBBPartitioner>
750 template <
typename Number2>
759 template <
typename Functor>
794 template <
typename Number>
807 template <
typename Number>
809 const ReadWriteVector<Number> &v)
818 template <
typename Number>
831 template <
typename Number>
833 const IndexSet &locally_stored_indices)
845 template <
typename Number>
854 template <
typename Number>
863 template <
typename Number>
872 template <
typename Number>
881 template <
typename Number>
890 template <
typename Number>
899 template <
typename Number>
908 template <
typename Number>
917 template <
typename Number>
926 template <
typename Number>
935 template <
typename Number>
944 template <
typename Number>
953 template <
typename Number>
954 template <
typename Number2>
957 const std::vector<size_type> &indices,
958 std::vector<Number2> & extracted_values)
const
960 for (
size_type i = 0; i < indices.size(); ++i)
961 extracted_values[i] =
operator()(indices[i]);
966 template <
typename Number>
967 template <
typename ForwardIterator,
typename OutputIterator>
970 ForwardIterator indices_begin,
971 const ForwardIterator indices_end,
972 OutputIterator values_begin)
const
974 while (indices_begin != indices_end)
984 template <
typename Number>
990 return values[local_index];
995 template <
typename Number>
1001 return values[local_index];
1006 template <
typename Number>
1007 template <
typename Number2>
1010 const std::vector<Number2> &
values)
1013 add(indices.size(), indices.data(),
values.data());
1018 template <
typename Number>
1019 template <
typename Number2>
1022 const ReadWriteVector<Number2> &
values)
1030 "The given value is not finite but either infinite or Not A Number (NaN)"));
1037 template <
typename Number>
1038 template <
typename Number2>
1042 const Number2 * values_to_add)
1044 for (
size_type i = 0; i < n_indices; ++i)
1049 "The given value is not finite but either infinite or Not A Number (NaN)"));
1050 this->
operator()(indices[i]) += values_to_add[i];
1056 template <
typename Number>
1057 template <
typename Functor>
1059 ReadWriteVector<Number> &parent,
1060 const Functor & functor)
1067 template <
typename Number>
1068 template <
typename Functor>
1075 functor(parent.values[i]);
1091 template <
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)
ReadWriteVector< Number > & operator=(const ReadWriteVector< Number2 > &in_vector)
void reinit(const ReadWriteVector< Number2 > &in_vector, const bool omit_zeroing_entries=false)
ReadWriteVector(const ReadWriteVector< Number > &in_vector)
ReadWriteVector(const size_type size)
std::unique_ptr< Number[], decltype(std::free) * > values
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
TpetraWrappers::CommunicationPattern create_tpetra_comm_pattern(const IndexSet &source_index_set, const MPI_Comm &mpi_comm)
void print(std::ostream &out, const unsigned int precision=3, const bool scientific=true) const
Number & operator()(const size_type global_index)
void add(const std::vector< size_type > &indices, const ReadWriteVector< Number2 > &values)
ReadWriteVector< Number > & operator=(const ReadWriteVector< Number > &in_vector)
ReadWriteVector< Number > & operator=(const Number s)
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)
EpetraWrappers::CommunicationPattern create_epetra_comm_pattern(const IndexSet &source_index_set, const MPI_Comm &mpi_comm)
Number & local_element(const size_type local_index)
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)
const IndexSet & get_stored_elements() const
size_type locally_owned_size() const
const_iterator end() const
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
const value_type & const_reference
~ReadWriteVector() override=default
ReadWriteVector(const IndexSet &locally_stored_indices)
types::global_dof_index size_type
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
Number & operator[](const size_type global_index)
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)
TrilinosWrappers::types::int_type global_index(const Epetra_BlockMap &map, const ::types::global_dof_index i)
bool is_finite(const double x)
unsigned int global_dof_index