16 #ifndef dealii_read_write_vector_h 17 #define dealii_read_write_vector_h 19 #include <deal.II/base/config.h> 20 #include <deal.II/base/index_set.h> 21 #include <deal.II/base/mpi.h> 22 #include <deal.II/base/template_constraints.h> 23 #include <deal.II/base/types.h> 24 #include <deal.II/base/utilities.h> 25 #include <deal.II/base/memory_consumption.h> 26 #include <deal.II/base/thread_management.h> 27 #include <deal.II/lac/vector_operation.h> 33 #ifdef DEAL_II_WITH_TRILINOS 34 # include <deal.II/lac/trilinos_epetra_communication_pattern.h> 35 # include <deal.II/lac/trilinos_epetra_vector.h> 37 # include <Epetra_MultiVector.h> 41 DEAL_II_NAMESPACE_OPEN
45 class CommunicationPatternBase;
48 template <
typename>
class Vector;
52 #ifdef DEAL_II_WITH_PETSC 62 #ifdef DEAL_II_WITH_TRILINOS 72 #ifdef DEAL_II_WITH_CUDA 77 template <
typename>
class Vector;
123 template <
typename Number>
182 const bool omit_zeroing_entries =
false);
192 template <
typename Number2>
194 const bool omit_zeroing_entries =
false);
206 const bool omit_zeroing_entries =
false);
209 #ifdef DEAL_II_WITH_TRILINOS 210 #ifdef DEAL_II_WITH_MPI 239 template <
typename Functor>
240 void apply(
const Functor &func);
265 template <
typename Number2>
285 const std::shared_ptr<const CommunicationPatternBase> &communication_pattern =
286 std::shared_ptr<const CommunicationPatternBase> ());
288 #ifdef DEAL_II_WITH_PETSC 299 const std::shared_ptr<const CommunicationPatternBase> &communication_pattern =
300 std::shared_ptr<const CommunicationPatternBase> ());
303 #ifdef DEAL_II_WITH_TRILINOS 316 std::shared_ptr<const CommunicationPatternBase> communication_pattern =
317 std::shared_ptr<const CommunicationPatternBase> ());
319 #ifdef DEAL_II_WITH_MPI 330 std::shared_ptr<const CommunicationPatternBase> communication_pattern =
331 std::shared_ptr<const CommunicationPatternBase> ());
335 #ifdef DEAL_II_WITH_CUDA 344 std::shared_ptr<const CommunicationPatternBase> communication_pattern =
345 std::shared_ptr<const CommunicationPatternBase> ());
356 size_type
size()
const;
381 const_iterator
begin ()
const;
393 const_iterator
end ()
const;
407 Number
operator () (
const size_type global_index)
const;
414 Number &
operator () (
const size_type global_index);
423 Number
operator [] (
const size_type global_index)
const;
432 Number &
operator [] (
const size_type global_index);
449 template <
typename Number2>
451 std::vector<Number2> &
values)
const;
480 template <
typename ForwardIterator,
typename OutputIterator>
482 const ForwardIterator indices_end,
483 OutputIterator values_begin)
const;
520 template <
typename Number2>
521 void add (
const std::vector<size_type> &indices,
522 const std::vector<Number2> &
values);
528 template <
typename Number2>
529 void add (
const std::vector<size_type> &indices,
537 template <
typename Number2>
539 const size_type *indices,
545 void print (std::ostream &out,
546 const unsigned int precision = 3,
547 const bool scientific =
true)
const;
556 #ifdef DEAL_II_WITH_TRILINOS 562 void import(
const Epetra_MultiVector &multivector,
563 const IndexSet &locally_owned_elements,
565 const MPI_Comm &mpi_comm,
566 const std::shared_ptr<const CommunicationPatternBase> &communication_pattern);
583 void resize_val (
const size_type new_allocated_size);
585 #if defined(DEAL_II_WITH_TRILINOS) && defined(DEAL_II_WITH_MPI) 592 const MPI_Comm &mpi_comm);
614 std::unique_ptr<Number[], decltype (free) *>
values;
633 template <
typename Functor>
647 const size_type
end);
669 template <
typename Number>
674 values(nullptr, free)
684 template <
typename Number>
696 template <
typename Number>
711 template <
typename Number>
726 template <
typename Number>
728 typename ReadWriteVector<Number>::size_type
736 template <
typename Number>
738 typename ReadWriteVector<Number>::size_type
746 template <
typename Number>
756 template <
typename Number>
758 typename ReadWriteVector<Number>::iterator
766 template <
typename Number>
768 typename ReadWriteVector<Number>::const_iterator
776 template <
typename Number>
778 typename ReadWriteVector<Number>::iterator
786 template <
typename Number>
788 typename ReadWriteVector<Number>::const_iterator
796 template <
typename Number>
806 template <
typename Number>
816 template <
typename Number>
826 template <
typename Number>
836 template <
typename Number>
837 template <
typename Number2>
840 std::vector<Number2> &extracted_values)
const 842 for (size_type i = 0; i < indices.size(); ++i)
843 extracted_values[i] =
operator()(indices[i]);
848 template <
typename Number>
849 template <
typename ForwardIterator,
typename OutputIterator>
852 const ForwardIterator indices_end,
853 OutputIterator values_begin)
const 855 while (indices_begin != indices_end)
865 template <
typename Number>
872 return values[local_index];
877 template <
typename Number>
884 return values[local_index];
889 template <
typename Number>
890 template <
typename Number2>
894 const std::vector<Number2> &
values)
897 add (indices.size(), indices.data(),
values.data());
902 template <
typename Number>
903 template <
typename Number2>
907 const ReadWriteVector<Number2> &
values)
909 const size_type
size = indices.size();
910 for (size_type i=0; i<
size; ++i)
913 ExcMessage(
"The given value is not finite but either infinite or Not A Number (NaN)"));
920 template <
typename Number>
921 template <
typename Number2>
925 const size_type *indices,
926 const Number2 *values_to_add)
928 for (size_type i=0; i<n_indices; ++i)
931 ExcMessage(
"The given value is not finite but either infinite or Not A Number (NaN)"));
932 this->
operator()(indices[i]) += values_to_add[i];
938 template <
typename Number>
939 template <
typename Functor>
942 ReadWriteVector<Number> &parent,
943 const Functor &functor)
951 template <
typename Number>
952 template <
typename Functor>
958 functor(parent.values[i]);
961 #endif // ifndef DOXYGEN 975 template <
typename Number>
984 DEAL_II_NAMESPACE_CLOSE
IndexSet source_stored_elements
~ReadWriteVector()=default
#define AssertDimension(dim1, dim2)
Number operator[](const size_type global_index) const
void swap(ReadWriteVector< Number > &v)
Number local_element(const size_type local_index) const
FunctorTemplate(ReadWriteVector< Number > &parent, const Functor &functor)
void resize_val(const size_type new_allocated_size)
#define AssertIndexRange(index, range)
std::size_t memory_consumption() const
void swap(LinearAlgebra::ReadWriteVector< Number > &u, LinearAlgebra::ReadWriteVector< Number > &v)
std::shared_ptr< ::parallel::internal::TBBPartitioner > thread_loop_partitioner
bool is_finite(const double x)
virtual void reinit(const size_type size, const bool omit_zeroing_entries=false)
static ::ExceptionBase & ExcMessage(std::string arg1)
unsigned int global_dof_index
#define Assert(cond, exc)
size_type index_within_set(const size_type global_index) const
Number operator()(const size_type global_index) const
ReadWriteVector< Number > & operator=(const ReadWriteVector< Number > &in_vector)
EpetraWrappers::CommunicationPattern create_epetra_comm_pattern(const IndexSet &source_index_set, const MPI_Comm &mpi_comm)
void add(const std::vector< size_type > &indices, const std::vector< Number2 > &values)
void print(std::ostream &out, const unsigned int precision=3, const bool scientific=true) const
virtual void operator()(const size_type begin, const size_type end)
std::shared_ptr< CommunicationPatternBase > comm_pattern
std::unique_ptr< Number[], decltype(free) * > values
void extract_subvector_to(const std::vector< size_type > &indices, std::vector< Number2 > &values) const
void apply(const Functor &func)
unsigned int global_to_local(const types::global_dof_index global_index) const
size_type n_elements() const
size_type n_elements() const
const IndexSet & get_stored_elements() const