16 #ifndef dealii_read_write_vector_h 17 #define dealii_read_write_vector_h 19 #include <deal.II/base/config.h> 21 #include <deal.II/base/index_set.h> 22 #include <deal.II/base/memory_consumption.h> 23 #include <deal.II/base/mpi.h> 24 #include <deal.II/base/template_constraints.h> 25 #include <deal.II/base/thread_management.h> 26 #include <deal.II/base/types.h> 27 #include <deal.II/base/utilities.h> 29 #include <deal.II/lac/vector_operation.h> 35 #ifdef DEAL_II_WITH_TRILINOS 36 # include <deal.II/lac/trilinos_epetra_communication_pattern.h> 37 # include <deal.II/lac/trilinos_epetra_vector.h> 39 # include <Epetra_MultiVector.h> 43 DEAL_II_NAMESPACE_OPEN
47 class CommunicationPatternBase;
55 #ifdef DEAL_II_WITH_PETSC 65 #ifdef DEAL_II_WITH_TRILINOS 75 #ifdef DEAL_II_WITH_CUDA 127 template <
typename Number>
186 reinit(
const size_type size,
const bool omit_zeroing_entries =
false);
196 template <
typename Number2>
199 const bool omit_zeroing_entries =
false);
211 reinit(
const IndexSet &locally_stored_indices,
212 const bool omit_zeroing_entries =
false);
215 #ifdef DEAL_II_WITH_TRILINOS 216 # ifdef DEAL_II_WITH_MPI 246 template <
typename Functor>
248 apply(
const Functor &func);
274 template <
typename Number2>
283 operator=(
const Number s);
296 const std::shared_ptr<const CommunicationPatternBase>
297 &communication_pattern =
298 std::shared_ptr<const CommunicationPatternBase>());
300 #ifdef DEAL_II_WITH_PETSC 312 const std::shared_ptr<const CommunicationPatternBase>
313 &communication_pattern =
314 std::shared_ptr<const CommunicationPatternBase>());
317 #ifdef DEAL_II_WITH_TRILINOS 332 std::shared_ptr<const CommunicationPatternBase> communication_pattern =
333 std::shared_ptr<const CommunicationPatternBase>());
335 # ifdef DEAL_II_WITH_MPI 348 std::shared_ptr<const CommunicationPatternBase> communication_pattern =
349 std::shared_ptr<const CommunicationPatternBase>());
353 #ifdef DEAL_II_WITH_CUDA 364 std::shared_ptr<const CommunicationPatternBase> communication_pattern =
365 std::shared_ptr<const CommunicationPatternBase>());
391 get_stored_elements()
const;
435 operator()(
const size_type global_index)
const;
443 operator()(
const size_type global_index);
452 Number operator[](
const size_type global_index)
const;
461 Number &operator[](
const size_type global_index);
478 template <
typename Number2>
480 extract_subvector_to(
const std::vector<size_type> &indices,
481 std::vector<Number2> & values)
const;
510 template <
typename ForwardIterator,
typename OutputIterator>
512 extract_subvector_to(ForwardIterator indices_begin,
513 const ForwardIterator indices_end,
514 OutputIterator values_begin)
const;
527 local_element(
const size_type local_index)
const;
540 local_element(
const size_type local_index);
553 template <
typename Number2>
555 add(
const std::vector<size_type> &indices,
556 const std::vector<Number2> & values);
562 template <
typename Number2>
564 add(
const std::vector<size_type> & indices,
572 template <
typename Number2>
574 add(
const size_type n_elements,
575 const size_type *indices,
576 const Number2 * values);
582 print(std::ostream & out,
583 const unsigned int precision = 3,
584 const bool scientific =
true)
const;
590 memory_consumption()
const;
594 #ifdef DEAL_II_WITH_TRILINOS 601 import(
const Epetra_MultiVector &multivector,
602 const IndexSet & locally_owned_elements,
604 const MPI_Comm & mpi_comm,
605 const std::shared_ptr<const CommunicationPatternBase>
606 &communication_pattern);
617 return static_cast<unsigned int>(
618 stored_elements.index_within_set(global_index));
625 resize_val(
const size_type new_allocated_size);
627 #if defined(DEAL_II_WITH_TRILINOS) && defined(DEAL_II_WITH_MPI) 633 create_epetra_comm_pattern(
const IndexSet &source_index_set,
634 const MPI_Comm &mpi_comm);
656 std::unique_ptr<Number[], decltype(free) *>
values;
662 mutable std::shared_ptr<::parallel::internal::TBBPartitioner>
668 template <
typename Number2>
677 template <
typename Functor>
690 operator()(
const size_type begin,
const size_type end);
712 template <
typename Number>
715 , values(nullptr, free)
725 template <
typename Number>
736 template <
typename Number>
749 template <
typename Number>
751 const IndexSet &locally_stored_indices)
763 template <
typename Number>
764 inline typename ReadWriteVector<Number>::size_type
767 return stored_elements.
size();
772 template <
typename Number>
773 inline typename ReadWriteVector<Number>::size_type
781 template <
typename Number>
790 template <
typename Number>
791 inline typename ReadWriteVector<Number>::iterator
799 template <
typename Number>
800 inline typename ReadWriteVector<Number>::const_iterator
808 template <
typename Number>
809 inline typename ReadWriteVector<Number>::iterator
817 template <
typename Number>
818 inline typename ReadWriteVector<Number>::const_iterator
826 template <
typename Number>
835 template <
typename Number>
844 template <
typename Number>
846 operator[](
const size_type global_index)
const 853 template <
typename Number>
862 template <
typename Number>
863 template <
typename Number2>
866 const std::vector<size_type> &indices,
867 std::vector<Number2> & extracted_values)
const 869 for (size_type i = 0; i < indices.size(); ++i)
870 extracted_values[i] =
operator()(indices[i]);
875 template <
typename Number>
876 template <
typename ForwardIterator,
typename OutputIterator>
879 ForwardIterator indices_begin,
880 const ForwardIterator indices_end,
881 OutputIterator values_begin)
const 883 while (indices_begin != indices_end)
893 template <
typename Number>
899 return values[local_index];
904 template <
typename Number>
910 return values[local_index];
915 template <
typename Number>
916 template <
typename Number2>
919 const std::vector<Number2> & values)
922 add(indices.size(), indices.data(), values.data());
927 template <
typename Number>
928 template <
typename Number2>
933 const size_type
size = indices.size();
934 for (size_type i = 0; i <
size; ++i)
939 "The given value is not finite but either infinite or Not A Number (NaN)"));
940 this->
operator()(indices[i]) += values[indices[i]];
946 template <
typename Number>
947 template <
typename Number2>
950 const size_type *indices,
951 const Number2 * values_to_add)
953 for (size_type i = 0; i < n_indices; ++i)
958 "The given value is not finite but either infinite or Not A Number (NaN)"));
959 this->
operator()(indices[i]) += values_to_add[i];
965 template <
typename Number>
966 template <
typename Functor>
976 template <
typename Number>
977 template <
typename Functor>
982 for (size_type i =
begin; i <
end; ++i)
986 #endif // ifndef DOXYGEN 999 template <
typename Number>
1008 DEAL_II_NAMESPACE_CLOSE
IndexSet source_stored_elements
#define AssertDimension(dim1, dim2)
void swap(ReadWriteVector< Number > &v)
#define AssertIndexRange(index, range)
size_type n_elements() const
void swap(LinearAlgebra::ReadWriteVector< Number > &u, LinearAlgebra::ReadWriteVector< Number > &v)
unsigned long long int global_dof_index
bool is_finite(const double x)
virtual void reinit(const size_type size, const bool omit_zeroing_entries=false)
Number operator[](const size_type global_index) const
std::unique_ptr< Number[], decltype(free)* > values
static::ExceptionBase & ExcMessage(std::string arg1)
#define Assert(cond, exc)
ReadWriteVector< Number > & operator=(const ReadWriteVector< Number > &in_vector)
unsigned int global_to_local(const types::global_dof_index global_index) const
void add(const std::vector< size_type > &indices, const std::vector< Number2 > &values)
Number operator()(const size_type global_index) const
virtual void operator()(const size_type begin, const size_type end)
std::shared_ptr< CommunicationPatternBase > comm_pattern
void swap(Vector< Number > &u, Vector< Number > &v)
const IndexSet & get_stored_elements() const
size_type n_elements() const
Number local_element(const size_type local_index) const
void extract_subvector_to(const std::vector< size_type > &indices, std::vector< Number2 > &values) const
std::shared_ptr<::parallel::internal::TBBPartitioner > thread_loop_partitioner