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
125 template <
typename Number>
194 template <
typename Number2>
197 const bool omit_zeroing_entries =
false);
210 const bool omit_zeroing_entries =
false);
213#ifdef DEAL_II_WITH_TRILINOS
242 template <
typename Functor>
270 template <
typename Number2>
292 const ::Vector<Number> &vec,
294 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
295 &communication_pattern = {});
302 import(const ::Vector<Number> &V,
304 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
305 &communication_pattern = {})
318 template <
typename MemorySpace>
323 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
324 &communication_pattern = {});
329 template <
typename MemorySpace>
333 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
334 &communication_pattern = {})
340#ifdef DEAL_II_WITH_PETSC
353 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
354 &communication_pattern = {});
363 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
364 &communication_pattern = {})
370#ifdef DEAL_II_WITH_TRILINOS
385 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
386 &communication_pattern = {});
395 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
396 &communication_pattern = {})
401# ifdef DEAL_II_TRILINOS_WITH_TPETRA
410 template <
typename MemorySpace,
typename Dummy = Number>
411 std::enable_if_t<std::is_same_v<Dummy, Number> &&
416 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
417 &communication_pattern = {});
422 template <
typename MemorySpace,
typename Dummy = Number>
427 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
428 &communication_pattern = {})
446 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
447 &communication_pattern = {});
456 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
457 &communication_pattern = {})
574 template <
typename Number2>
577 std::vector<Number2> &
values)
const;
614 template <
typename ForwardIterator,
typename OutputIterator>
617 const ForwardIterator indices_end,
618 OutputIterator values_begin)
const;
657 template <
typename Number2>
659 add(
const std::vector<size_type> &indices,
660 const std::vector<Number2> &
values);
666 template <
typename Number2>
668 add(
const std::vector<size_type> &indices,
676 template <
typename Number2>
687 const unsigned int precision = 3,
688 const bool scientific =
true)
const;
698#ifdef DEAL_II_WITH_TRILINOS
699# ifdef DEAL_II_TRILINOS_WITH_TPETRA
705 template <
typename MemorySpace,
typename Dummy = Number>
706 std::enable_if_t<std::is_same_v<Dummy, Number> &&
712 const
IndexSet &locally_owned_elements,
716 &communication_pattern);
726 const Epetra_MultiVector &multivector,
727 const IndexSet &locally_owned_elements,
730 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
731 &communication_pattern);
740#ifdef DEAL_II_WITH_TRILINOS
741# ifdef DEAL_II_TRILINOS_WITH_TPETRA
746 template <
typename MemorySpace = ::MemorySpace::Host>
775 std::shared_ptr<Utilities::MPI::CommunicationPatternBase>
comm_pattern;
786 mutable std::shared_ptr<::parallel::internal::TBBPartitioner>
790 template <
typename Number2>
799 template <
typename Functor>
835 template <
typename Number>
846 template <
typename Number>
848 const ReadWriteVector<Number> &v)
856 template <
typename Number>
867 template <
typename Number>
869 const IndexSet &locally_stored_indices)
879 template <
typename Number>
888 template <
typename Number>
897 template <
typename Number>
906 template <
typename Number>
915 template <
typename Number>
924 template <
typename Number>
933 template <
typename Number>
942 template <
typename Number>
951 template <
typename Number>
960 template <
typename Number>
969 template <
typename Number>
978 template <
typename Number>
979 template <
typename Number2>
982 const std::vector<size_type> &indices,
983 std::vector<Number2> &extracted_values)
const
985 for (
size_type i = 0; i < indices.size(); ++i)
986 extracted_values[i] =
operator()(indices[i]);
991 template <
typename Number>
998 for (
unsigned int i = 0; i < indices.
size(); ++i)
999 entries[i] = (*
this)[indices[i]];
1004 template <
typename Number>
1005 template <
typename ForwardIterator,
typename OutputIterator>
1008 ForwardIterator indices_begin,
1009 const ForwardIterator indices_end,
1010 OutputIterator values_begin)
const
1012 while (indices_begin != indices_end)
1022 template <
typename Number>
1028 return values[local_index];
1033 template <
typename Number>
1039 return values[local_index];
1044 template <
typename Number>
1045 template <
typename Number2>
1048 const std::vector<Number2> &
values)
1056 template <
typename Number>
1057 template <
typename Number2>
1060 const ReadWriteVector<Number2> &
values)
1068 "The given value is not finite but either infinite or Not A Number (NaN)"));
1075 template <
typename Number>
1076 template <
typename Number2>
1080 const Number2 *values_to_add)
1082 for (
size_type i = 0; i < n_indices; ++i)
1087 "The given value is not finite but either infinite or Not A Number (NaN)"));
1088 this->
operator()(indices[i]) += values_to_add[i];
1094 template <
typename Number>
1101 return static_cast<unsigned int>(
1107 template <
typename Number>
1108 template <
typename Functor>
1110 ReadWriteVector<Number> &parent,
1111 const Functor &functor)
1118 template <
typename Number>
1119 template <
typename Functor>
1126 functor(parent.values[i]);
1142template <
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
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