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
221# ifdef DEAL_II_WITH_MPI
251 template <
typename Functor>
279 template <
typename Number2>
300 import(const ::Vector<Number> &vec,
302 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
303 &communication_pattern = {});
317 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
318 &communication_pattern = {});
328 template <
typename MemorySpace>
332 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
333 &communication_pattern = {});
335#ifdef DEAL_II_WITH_PETSC
347 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
348 &communication_pattern = {});
351#ifdef DEAL_II_WITH_TRILINOS
365 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
366 &communication_pattern = {});
368# ifdef DEAL_II_WITH_MPI
369# ifdef DEAL_II_TRILINOS_WITH_TPETRA
381 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
382 &communication_pattern = {});
396 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
397 &communication_pattern = {});
401#ifdef DEAL_II_WITH_CUDA
411 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
412 &communication_pattern = {});
535 template <
typename Number2>
538 std::vector<Number2> &
values)
const;
567 template <
typename ForwardIterator,
typename OutputIterator>
570 const ForwardIterator indices_end,
571 OutputIterator values_begin)
const;
610 template <
typename Number2>
612 add(
const std::vector<size_type> &indices,
613 const std::vector<Number2> &
values);
619 template <
typename Number2>
621 add(
const std::vector<size_type> & indices,
629 template <
typename Number2>
640 const unsigned int precision = 3,
641 const bool scientific =
true)
const;
651#ifdef DEAL_II_WITH_TRILINOS
652# ifdef DEAL_II_TRILINOS_WITH_TPETRA
660 const Tpetra::Vector<Number, int, types::global_dof_index> &tpetra_vector,
661 const IndexSet & locally_owned_elements,
664 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
665 &communication_pattern);
674 import(
const Epetra_MultiVector &multivector,
675 const IndexSet & locally_owned_elements,
678 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
679 &communication_pattern);
690 return static_cast<unsigned int>(
700#if defined(DEAL_II_WITH_TRILINOS) && defined(DEAL_II_WITH_MPI)
701# ifdef DEAL_II_TRILINOS_WITH_TPETRA
734 std::shared_ptr<Utilities::MPI::CommunicationPatternBase>
comm_pattern;
745 mutable std::shared_ptr<::parallel::internal::TBBPartitioner>
749 template <
typename Number2>
758 template <
typename Functor>
793 template <
typename Number>
806 template <
typename Number>
808 const ReadWriteVector<Number> &v)
817 template <
typename Number>
830 template <
typename Number>
832 const IndexSet &locally_stored_indices)
844 template <
typename Number>
853 template <
typename Number>
862 template <
typename Number>
871 template <
typename Number>
880 template <
typename Number>
889 template <
typename Number>
898 template <
typename Number>
907 template <
typename Number>
916 template <
typename Number>
925 template <
typename Number>
934 template <
typename Number>
943 template <
typename Number>
952 template <
typename Number>
953 template <
typename Number2>
956 const std::vector<size_type> &indices,
957 std::vector<Number2> & extracted_values)
const
959 for (
size_type i = 0; i < indices.size(); ++i)
960 extracted_values[i] =
operator()(indices[i]);
965 template <
typename Number>
966 template <
typename ForwardIterator,
typename OutputIterator>
969 ForwardIterator indices_begin,
970 const ForwardIterator indices_end,
971 OutputIterator values_begin)
const
973 while (indices_begin != indices_end)
983 template <
typename Number>
989 return values[local_index];
994 template <
typename Number>
1000 return values[local_index];
1005 template <
typename Number>
1006 template <
typename Number2>
1009 const std::vector<Number2> &
values)
1012 add(indices.size(), indices.data(),
values.data());
1017 template <
typename Number>
1018 template <
typename Number2>
1021 const ReadWriteVector<Number2> &
values)
1029 "The given value is not finite but either infinite or Not A Number (NaN)"));
1036 template <
typename Number>
1037 template <
typename Number2>
1041 const Number2 * values_to_add)
1043 for (
size_type i = 0; i < n_indices; ++i)
1048 "The given value is not finite but either infinite or Not A Number (NaN)"));
1049 this->
operator()(indices[i]) += values_to_add[i];
1055 template <
typename Number>
1056 template <
typename Functor>
1058 ReadWriteVector<Number> &parent,
1059 const Functor & functor)
1066 template <
typename Number>
1067 template <
typename Functor>
1073 functor(parent.values[i]);
1089template <
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_NAMESPACE_OPEN
#define DEAL_II_DEPRECATED_EARLY
#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
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