16#ifndef dealii_read_write_vector_h
17#define dealii_read_write_vector_h
37#ifdef DEAL_II_WITH_TRILINOS
42# include <Epetra_MultiVector.h>
56 template <
typename,
typename>
61# ifdef DEAL_II_WITH_PETSC
71# ifdef DEAL_II_WITH_TRILINOS
81# ifdef DEAL_II_WITH_CUDA
132 template <
typename Number>
201 template <
typename Number2>
204 const bool omit_zeroing_entries =
false);
217 const bool omit_zeroing_entries =
false);
220#ifdef DEAL_II_WITH_TRILINOS
249 template <
typename Functor>
277 template <
typename Number2>
298 import(const ::Vector<Number> &vec,
300 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
301 &communication_pattern = {});
315 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
316 &communication_pattern = {});
326 template <
typename MemorySpace>
330 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
331 &communication_pattern = {});
333#ifdef DEAL_II_WITH_PETSC
345 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
346 &communication_pattern = {});
349#ifdef DEAL_II_WITH_TRILINOS
363 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
364 &communication_pattern = {});
366# ifdef DEAL_II_TRILINOS_WITH_TPETRA
378 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
379 &communication_pattern = {});
393 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
394 &communication_pattern = {});
397#ifdef DEAL_II_WITH_CUDA
407 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
408 &communication_pattern = {});
533 template <
typename Number2>
536 std::vector<Number2> &
values)
const;
565 template <
typename ForwardIterator,
typename OutputIterator>
568 const ForwardIterator indices_end,
569 OutputIterator values_begin)
const;
608 template <
typename Number2>
610 add(
const std::vector<size_type> &indices,
611 const std::vector<Number2> &
values);
617 template <
typename Number2>
619 add(
const std::vector<size_type> & indices,
627 template <
typename Number2>
638 const unsigned int precision = 3,
639 const bool scientific =
true)
const;
649#ifdef DEAL_II_WITH_TRILINOS
650# ifdef DEAL_II_TRILINOS_WITH_TPETRA
658 const Tpetra::Vector<Number, int, types::global_dof_index> &tpetra_vector,
659 const IndexSet & locally_owned_elements,
662 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
663 &communication_pattern);
672 import(
const Epetra_MultiVector &multivector,
673 const IndexSet & locally_owned_elements,
676 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
677 &communication_pattern);
688 return static_cast<unsigned int>(
698#ifdef DEAL_II_WITH_TRILINOS
699# ifdef DEAL_II_TRILINOS_WITH_TPETRA
732 std::shared_ptr<Utilities::MPI::CommunicationPatternBase>
comm_pattern;
737 std::unique_ptr<Number[],
decltype(std::free) *>
values;
743 mutable std::shared_ptr<::parallel::internal::TBBPartitioner>
747 template <
typename Number2>
756 template <
typename Functor>
791 template <
typename Number>
794 , values(nullptr, free)
804 template <
typename Number>
806 const ReadWriteVector<Number> &v)
815 template <
typename Number>
828 template <
typename Number>
830 const IndexSet &locally_stored_indices)
842 template <
typename Number>
851 template <
typename Number>
860 template <
typename Number>
869 template <
typename Number>
878 template <
typename Number>
887 template <
typename Number>
896 template <
typename Number>
905 template <
typename Number>
914 template <
typename Number>
923 template <
typename Number>
932 template <
typename Number>
941 template <
typename Number>
950 template <
typename Number>
951 template <
typename Number2>
954 const std::vector<size_type> &indices,
955 std::vector<Number2> & extracted_values)
const
957 for (
size_type i = 0; i < indices.size(); ++i)
958 extracted_values[i] =
operator()(indices[i]);
963 template <
typename Number>
964 template <
typename ForwardIterator,
typename OutputIterator>
967 ForwardIterator indices_begin,
968 const ForwardIterator indices_end,
969 OutputIterator values_begin)
const
971 while (indices_begin != indices_end)
981 template <
typename Number>
987 return values[local_index];
992 template <
typename Number>
998 return values[local_index];
1003 template <
typename Number>
1004 template <
typename Number2>
1007 const std::vector<Number2> &
values)
1010 add(indices.size(), indices.data(),
values.data());
1015 template <
typename Number>
1016 template <
typename Number2>
1019 const ReadWriteVector<Number2> &
values)
1027 "The given value is not finite but either infinite or Not A Number (NaN)"));
1034 template <
typename Number>
1035 template <
typename Number2>
1039 const Number2 * values_to_add)
1041 for (
size_type i = 0; i < n_indices; ++i)
1046 "The given value is not finite but either infinite or Not A Number (NaN)"));
1047 this->
operator()(indices[i]) += values_to_add[i];
1053 template <
typename Number>
1054 template <
typename Functor>
1056 ReadWriteVector<Number> &parent,
1057 const Functor & functor)
1064 template <
typename Number>
1065 template <
typename Functor>
1072 functor(parent.values[i]);
1088template <
typename Number>
size_type index_within_set(const size_type global_index) const
size_type n_elements() const
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)
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::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)
Number & operator[](const size_type global_index)
void print(std::ostream &out, const unsigned int precision=3, const bool scientific=true) const
FunctorTemplate(ReadWriteVector< Number > &parent, const Functor &functor)
void add(const std::vector< size_type > &indices, const ReadWriteVector< Number2 > &values)
Number & local_element(const size_type local_index)
virtual void operator()(const size_type begin, const size_type end)
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)
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
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
const IndexSet & get_stored_elements() const
ReadWriteVector< Number > & operator=(const ReadWriteVector< Number2 > &in_vector)
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
bool is_finite(const double x)
unsigned int global_dof_index