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
133 template <
typename Number>
202 template <
typename Number2>
205 const bool omit_zeroing_entries =
false);
218 const bool omit_zeroing_entries =
false);
221 #ifdef DEAL_II_WITH_TRILINOS
250 template <
typename Functor>
278 template <
typename Number2>
299 import(const ::Vector<Number> &vec,
301 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
302 &communication_pattern = {});
316 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
317 &communication_pattern = {});
327 template <
typename MemorySpace>
331 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
332 &communication_pattern = {});
334 #ifdef DEAL_II_WITH_PETSC
346 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
347 &communication_pattern = {});
350 #ifdef DEAL_II_WITH_TRILINOS
364 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
365 &communication_pattern = {});
367 # ifdef DEAL_II_TRILINOS_WITH_TPETRA
379 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
380 &communication_pattern = {});
394 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
395 &communication_pattern = {});
398 #ifdef DEAL_II_WITH_CUDA
408 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
409 &communication_pattern = {});
534 template <
typename Number2>
537 std::vector<Number2> &
values)
const;
566 template <
typename ForwardIterator,
typename OutputIterator>
569 const ForwardIterator indices_end,
570 OutputIterator values_begin)
const;
609 template <
typename Number2>
611 add(
const std::vector<size_type> &indices,
612 const std::vector<Number2> &
values);
618 template <
typename Number2>
620 add(
const std::vector<size_type> & indices,
628 template <
typename Number2>
639 const unsigned int precision = 3,
640 const bool scientific =
true)
const;
650 #ifdef DEAL_II_WITH_TRILINOS
651 # ifdef DEAL_II_TRILINOS_WITH_TPETRA
659 const Tpetra::Vector<Number, int, types::global_dof_index> &tpetra_vector,
660 const IndexSet & locally_owned_elements,
662 const MPI_Comm & mpi_comm,
663 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
664 &communication_pattern);
673 import(
const Epetra_MultiVector &multivector,
674 const IndexSet & locally_owned_elements,
676 const MPI_Comm & mpi_comm,
677 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
678 &communication_pattern);
689 return static_cast<unsigned int>(
699 #ifdef DEAL_II_WITH_TRILINOS
700 # ifdef DEAL_II_TRILINOS_WITH_TPETRA
707 const MPI_Comm &mpi_comm);
716 const MPI_Comm &mpi_comm);
733 std::shared_ptr<Utilities::MPI::CommunicationPatternBase>
comm_pattern;
744 mutable std::shared_ptr<::parallel::internal::TBBPartitioner>
748 template <
typename Number2>
757 template <
typename Functor>
792 template <
typename Number>
805 template <
typename Number>
807 const ReadWriteVector<Number> &v)
816 template <
typename Number>
829 template <
typename Number>
831 const IndexSet &locally_stored_indices)
843 template <
typename Number>
852 template <
typename Number>
861 template <
typename Number>
870 template <
typename Number>
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>
952 template <
typename Number2>
955 const std::vector<size_type> &indices,
956 std::vector<Number2> & extracted_values)
const
958 for (
size_type i = 0; i < indices.size(); ++i)
959 extracted_values[i] =
operator()(indices[i]);
964 template <
typename Number>
965 template <
typename ForwardIterator,
typename OutputIterator>
968 ForwardIterator indices_begin,
969 const ForwardIterator indices_end,
970 OutputIterator values_begin)
const
972 while (indices_begin != indices_end)
982 template <
typename Number>
988 return values[local_index];
993 template <
typename Number>
999 return values[local_index];
1004 template <
typename Number>
1005 template <
typename Number2>
1008 const std::vector<Number2> &
values)
1011 add(indices.size(), indices.data(),
values.data());
1016 template <
typename Number>
1017 template <
typename Number2>
1020 const ReadWriteVector<Number2> &
values)
1028 "The given value is not finite but either infinite or Not A Number (NaN)"));
1035 template <
typename Number>
1036 template <
typename Number2>
1040 const Number2 * values_to_add)
1042 for (
size_type i = 0; i < n_indices; ++i)
1047 "The given value is not finite but either infinite or Not A Number (NaN)"));
1048 this->
operator()(indices[i]) += values_to_add[i];
1054 template <
typename Number>
1055 template <
typename Functor>
1057 ReadWriteVector<Number> &parent,
1058 const Functor & functor)
1065 template <
typename Number>
1066 template <
typename Functor>
1073 functor(parent.values[i]);
1089 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