15#ifndef dealii_read_write_vector_h
16#define dealii_read_write_vector_h
37#ifdef DEAL_II_WITH_TRILINOS
42# include <Epetra_MultiVector.h>
59 template <
typename,
typename>
64# ifdef DEAL_II_WITH_PETSC
74# ifdef DEAL_II_WITH_TRILINOS
84# 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 = {});
312 import(const ::Vector<Number> &V,
314 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
315 &communication_pattern = {})
328 template <
typename MemorySpace>
333 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
334 &communication_pattern = {});
339 template <
typename MemorySpace>
343 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
344 &communication_pattern = {})
350#ifdef DEAL_II_WITH_PETSC
363 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
364 &communication_pattern = {});
373 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
374 &communication_pattern = {})
380#ifdef DEAL_II_WITH_TRILINOS
395 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
396 &communication_pattern = {});
405 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
406 &communication_pattern = {})
411# ifdef DEAL_II_TRILINOS_WITH_TPETRA
420 template <
typename MemorySpace,
typename Dummy = Number>
421 std::enable_if_t<std::is_same_v<Dummy, Number> &&
426 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
427 &communication_pattern = {});
432 template <
typename MemorySpace,
typename Dummy = Number>
437 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
438 &communication_pattern = {})
456 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
457 &communication_pattern = {});
466 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
467 &communication_pattern = {})
473#ifdef DEAL_II_WITH_CUDA
484 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
485 &communication_pattern = {});
495 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
496 &communication_pattern = {})
613 template <
typename Number2>
616 std::vector<Number2> &values)
const;
653 template <
typename ForwardIterator,
typename OutputIterator>
656 const ForwardIterator indices_end,
657 OutputIterator values_begin)
const;
696 template <
typename Number2>
698 add(
const std::vector<size_type> &indices,
699 const std::vector<Number2> &values);
705 template <
typename Number2>
707 add(
const std::vector<size_type> &indices,
715 template <
typename Number2>
719 const Number2 *values);
726 const unsigned int precision = 3,
727 const bool scientific =
true)
const;
737#ifdef DEAL_II_WITH_TRILINOS
738# ifdef DEAL_II_TRILINOS_WITH_TPETRA
744 template <
typename MemorySpace,
typename Dummy = Number>
745 std::enable_if_t<std::is_same_v<Dummy, Number> &&
751 const
IndexSet &locally_owned_elements,
755 &communication_pattern);
765 const Epetra_MultiVector &multivector,
766 const IndexSet &locally_owned_elements,
769 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
770 &communication_pattern);
779#ifdef DEAL_II_WITH_TRILINOS
780# ifdef DEAL_II_TRILINOS_WITH_TPETRA
785 template <
typename MemorySpace = ::MemorySpace::Host>
814 std::shared_ptr<Utilities::MPI::CommunicationPatternBase>
comm_pattern;
825 mutable std::shared_ptr<::parallel::internal::TBBPartitioner>
829 template <
typename Number2>
838 template <
typename Functor>
874 template <
typename Number>
885 template <
typename Number>
887 const ReadWriteVector<Number> &v)
895 template <
typename Number>
906 template <
typename Number>
908 const IndexSet &locally_stored_indices)
918 template <
typename Number>
927 template <
typename Number>
936 template <
typename Number>
945 template <
typename Number>
949 return values.begin();
954 template <
typename Number>
958 return values.begin();
963 template <
typename Number>
972 template <
typename Number>
981 template <
typename Number>
990 template <
typename Number>
999 template <
typename Number>
1008 template <
typename Number>
1017 template <
typename Number>
1018 template <
typename Number2>
1021 const std::vector<size_type> &indices,
1022 std::vector<Number2> &extracted_values)
const
1024 for (size_type i = 0; i < indices.size(); ++i)
1025 extracted_values[i] =
operator()(indices[i]);
1030 template <
typename Number>
1037 for (
unsigned int i = 0; i < indices.
size(); ++i)
1038 entries[i] = (*
this)[indices[i]];
1043 template <
typename Number>
1044 template <
typename ForwardIterator,
typename OutputIterator>
1047 ForwardIterator indices_begin,
1048 const ForwardIterator indices_end,
1049 OutputIterator values_begin)
const
1051 while (indices_begin != indices_end)
1061 template <
typename Number>
1067 return values[local_index];
1072 template <
typename Number>
1078 return values[local_index];
1083 template <
typename Number>
1084 template <
typename Number2>
1087 const std::vector<Number2> &values)
1090 add(indices.size(), indices.data(), values.data());
1095 template <
typename Number>
1096 template <
typename Number2>
1101 const size_type
size = indices.size();
1102 for (size_type i = 0; i <
size; ++i)
1107 "The given value is not finite but either infinite or Not A Number (NaN)"));
1108 this->
operator()(indices[i]) += values[indices[i]];
1114 template <
typename Number>
1115 template <
typename Number2>
1118 const size_type *indices,
1119 const Number2 *values_to_add)
1121 for (size_type i = 0; i < n_indices; ++i)
1126 "The given value is not finite but either infinite or Not A Number (NaN)"));
1127 this->
operator()(indices[i]) += values_to_add[i];
1133 template <
typename Number>
1140 return static_cast<unsigned int>(
1146 template <
typename Number>
1147 template <
typename Functor>
1150 const Functor &functor)
1157 template <
typename Number>
1158 template <
typename Functor>
1161 const size_type
begin,
1162 const size_type
end)
1164 for (size_type i =
begin; i <
end; ++i)
1165 functor(parent.values[i]);
1181template <
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)
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
size_type size() const override
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={})
AlignedVector< Number > values
unsigned int global_to_local(const types::global_dof_index global_index) const
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)
TpetraWrappers::CommunicationPattern< MemorySpace > create_tpetra_comm_pattern(const IndexSet &source_index_set, const MPI_Comm mpi_comm)
virtual void extract_subvector_to(const ArrayView< const types::global_dof_index > &indices, ArrayView< Number > &entries) const override
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)
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
void swap(ReadWriteVector< Number > &v) noexcept
const value_type * const_iterator
const_iterator begin() const
std::enable_if_t< std::is_same_v< Dummy, Number > &&::is_tpetra_type< Number >::value > import_elements(const Tpetra::Vector< Number, int, types::signed_global_dof_index, MemorySpace > &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)
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)
types::global_dof_index size_type
std::enable_if_t< std::is_same_v< Dummy, Number > &&::is_tpetra_type< Number >::value > import_elements(const TpetraWrappers::Vector< Number, MemorySpace > &tpetra_vec, VectorOperation::values operation, const std::shared_ptr< const Utilities::MPI::CommunicationPatternBase > &communication_pattern={})
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={})
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) noexcept
#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