15#ifndef dealii_read_write_vector_h
16#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
124 template <
typename Number>
193 template <
typename Number2>
196 const bool omit_zeroing_entries =
false);
209 const bool omit_zeroing_entries =
false);
212#ifdef DEAL_II_WITH_TRILINOS
241 template <
typename Functor>
269 template <
typename Number2>
291 const ::Vector<Number> &vec,
293 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
294 &communication_pattern = {});
301 import(const ::Vector<Number> &V,
303 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
304 &communication_pattern = {})
317 template <
typename MemorySpace>
322 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
323 &communication_pattern = {});
328 template <
typename MemorySpace>
332 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
333 &communication_pattern = {})
339#ifdef DEAL_II_WITH_PETSC
352 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
353 &communication_pattern = {});
362 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
363 &communication_pattern = {})
369#ifdef DEAL_II_WITH_TRILINOS
384 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
385 &communication_pattern = {});
394 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
395 &communication_pattern = {})
400# ifdef DEAL_II_TRILINOS_WITH_TPETRA
409 template <
typename MemorySpace,
typename Dummy = Number>
410 std::enable_if_t<std::is_same_v<Dummy, Number> &&
415 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
416 &communication_pattern = {});
421 template <
typename MemorySpace,
typename Dummy = Number>
426 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
427 &communication_pattern = {})
445 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
446 &communication_pattern = {});
455 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
456 &communication_pattern = {})
573 template <
typename Number2>
576 std::vector<Number2> &
values)
const;
613 template <
typename ForwardIterator,
typename OutputIterator>
616 const ForwardIterator indices_end,
617 OutputIterator values_begin)
const;
656 template <
typename Number2>
658 add(
const std::vector<size_type> &indices,
659 const std::vector<Number2> &
values);
665 template <
typename Number2>
667 add(
const std::vector<size_type> &indices,
675 template <
typename Number2>
686 const unsigned int precision = 3,
687 const bool scientific =
true)
const;
697#ifdef DEAL_II_WITH_TRILINOS
698# ifdef DEAL_II_TRILINOS_WITH_TPETRA
704 template <
typename MemorySpace,
typename Dummy = Number>
705 std::enable_if_t<std::is_same_v<Dummy, Number> &&
711 const
IndexSet &locally_owned_elements,
715 &communication_pattern);
725 const Epetra_MultiVector &multivector,
726 const IndexSet &locally_owned_elements,
729 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
730 &communication_pattern);
739#ifdef DEAL_II_WITH_TRILINOS
740# ifdef DEAL_II_TRILINOS_WITH_TPETRA
745 template <
typename MemorySpace = ::MemorySpace::Host>
774 std::shared_ptr<Utilities::MPI::CommunicationPatternBase>
comm_pattern;
785 mutable std::shared_ptr<::parallel::internal::TBBPartitioner>
789 template <
typename Number2>
798 template <
typename Functor>
834 template <
typename Number>
845 template <
typename Number>
847 const ReadWriteVector<Number> &v)
854 template <
typename Number>
865 template <
typename Number>
867 const IndexSet &locally_stored_indices)
877 template <
typename Number>
881 return stored_elements.size();
886 template <
typename Number>
890 return stored_elements.n_elements();
895 template <
typename Number>
899 return stored_elements;
904 template <
typename Number>
913 template <
typename Number>
922 template <
typename Number>
931 template <
typename Number>
940 template <
typename Number>
944 return values[global_to_local(global_index)];
949 template <
typename Number>
953 return values[global_to_local(global_index)];
958 template <
typename Number>
962 return operator()(global_index);
967 template <
typename Number>
971 return operator()(global_index);
976 template <
typename Number>
977 template <
typename Number2>
980 const std::vector<size_type> &indices,
981 std::vector<Number2> &extracted_values)
const
983 for (size_type i = 0; i < indices.size(); ++i)
984 extracted_values[i] =
operator()(indices[i]);
989 template <
typename Number>
996 for (
unsigned int i = 0; i < indices.
size(); ++i)
997 entries[i] = (*
this)[indices[i]];
1002 template <
typename Number>
1003 template <
typename ForwardIterator,
typename OutputIterator>
1006 ForwardIterator indices_begin,
1007 const ForwardIterator indices_end,
1008 OutputIterator values_begin)
const
1010 while (indices_begin != indices_end)
1012 *values_begin = operator()(*indices_begin);
1020 template <
typename Number>
1026 return values[local_index];
1031 template <
typename Number>
1037 return values[local_index];
1042 template <
typename Number>
1043 template <
typename Number2>
1046 const std::vector<Number2> &values)
1049 add(indices.size(), indices.data(),
values.data());
1054 template <
typename Number>
1055 template <
typename Number2>
1058 const ReadWriteVector<Number2> &values)
1061 for (size_type i = 0; i <
size; ++i)
1066 "The given value is not finite but either infinite or Not A Number (NaN)"));
1067 this->operator()(indices[i]) +=
values[indices[i]];
1073 template <
typename Number>
1074 template <
typename Number2>
1077 const size_type *indices,
1078 const Number2 *values_to_add)
1080 for (size_type i = 0; i < n_indices; ++i)
1085 "The given value is not finite but either infinite or Not A Number (NaN)"));
1086 this->operator()(indices[i]) += values_to_add[i];
1092 template <
typename Number>
1099 return static_cast<unsigned int>(
1100 stored_elements.index_within_set(global_index));
1105 template <
typename Number>
1106 template <
typename Functor>
1108 ReadWriteVector<Number> &parent,
1109 const Functor &functor)
1116 template <
typename Number>
1117 template <
typename Functor>
1124 functor(parent.values[i]);
1140template <
typename Number>
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
virtual void extract_subvector_to(const ArrayView< const types::global_dof_index > &indices, const ArrayView< Number > &entries) const override
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)
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)
types::global_dof_index locally_owned_size
types::global_dof_index size_type
bool is_finite(const double x)
unsigned int global_dof_index