Reference documentation for deal.II version Git d902c8c1aa 2019-12-15 00:36:45 -0500
\(\newcommand{\dealcoloneq}{\mathrel{\vcenter{:}}=}\)
la_parallel_vector.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2011 - 2019 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE.md at
12 // the top level directory of deal.II.
13 //
14 // ---------------------------------------------------------------------
15 
16 #ifndef dealii_la_parallel_vector_h
17 #define dealii_la_parallel_vector_h
18 
19 #include <deal.II/base/config.h>
20 
21 #include <deal.II/base/memory_space.h>
22 #include <deal.II/base/mpi.h>
23 #include <deal.II/base/numbers.h>
24 #include <deal.II/base/partitioner.h>
25 #include <deal.II/base/thread_management.h>
26 
27 #include <deal.II/lac/vector_operation.h>
28 #include <deal.II/lac/vector_space_vector.h>
29 #include <deal.II/lac/vector_type_traits.h>
30 
31 #include <iomanip>
32 #include <memory>
33 
34 DEAL_II_NAMESPACE_OPEN
35 
36 // Forward declarations
37 #ifndef DOXYGEN
38 namespace LinearAlgebra
39 {
43  namespace distributed
44  {
45  template <typename>
46  class BlockVector;
47  }
48 
49  template <typename>
50  class ReadWriteVector;
51 } // namespace LinearAlgebra
52 
53 # ifdef DEAL_II_WITH_PETSC
54 namespace PETScWrappers
55 {
56  namespace MPI
57  {
58  class Vector;
59  }
60 } // namespace PETScWrappers
61 # endif
62 
63 # ifdef DEAL_II_WITH_TRILINOS
64 namespace TrilinosWrappers
65 {
66  namespace MPI
67  {
68  class Vector;
69  }
70 } // namespace TrilinosWrappers
71 # endif
72 #endif
73 
74 namespace LinearAlgebra
75 {
76  namespace distributed
77  {
225  template <typename Number, typename MemorySpace = MemorySpace::Host>
227  public Subscriptor
228  {
229  public:
230  using memory_space = MemorySpace;
231  using value_type = Number;
232  using pointer = value_type *;
233  using const_pointer = const value_type *;
234  using iterator = value_type *;
235  using const_iterator = const value_type *;
236  using reference = value_type &;
237  using const_reference = const value_type &;
238  using size_type = types::global_dof_index;
239  using real_type = typename numbers::NumberTraits<Number>::real_type;
240 
241  static_assert(
242  std::is_same<MemorySpace, ::MemorySpace::Host>::value ||
243  std::is_same<MemorySpace, ::MemorySpace::CUDA>::value,
244  "MemorySpace should be Host or CUDA");
245 
253  Vector();
254 
261  Vector(const Vector<Number, MemorySpace> &in_vector);
262 
267  Vector(const size_type size);
268 
285  Vector(const IndexSet &local_range,
286  const IndexSet &ghost_indices,
287  const MPI_Comm communicator);
288 
292  Vector(const IndexSet &local_range, const MPI_Comm communicator);
293 
300  Vector(
301  const std::shared_ptr<const Utilities::MPI::Partitioner> &partitioner);
302 
306  virtual ~Vector() override;
307 
312  void
313  reinit(const size_type size, const bool omit_zeroing_entries = false);
314 
325  template <typename Number2>
326  void
327  reinit(const Vector<Number2, MemorySpace> &in_vector,
328  const bool omit_zeroing_entries = false);
329 
346  void
347  reinit(const IndexSet &local_range,
348  const IndexSet &ghost_indices,
349  const MPI_Comm communicator);
350 
354  void
355  reinit(const IndexSet &local_range, const MPI_Comm communicator);
356 
363  void
364  reinit(
365  const std::shared_ptr<const Utilities::MPI::Partitioner> &partitioner);
366 
382  void
384 
397  operator=(const Vector<Number, MemorySpace> &in_vector);
398 
410  template <typename Number2>
412  operator=(const Vector<Number2, MemorySpace> &in_vector);
413 
414 #ifdef DEAL_II_WITH_PETSC
415 
425  DEAL_II_DEPRECATED
427  operator=(const PETScWrappers::MPI::Vector &petsc_vec);
428 #endif
429 
430 #ifdef DEAL_II_WITH_TRILINOS
431 
442  DEAL_II_DEPRECATED
444  operator=(const TrilinosWrappers::MPI::Vector &trilinos_vec);
445 #endif
446 
447 
487  virtual void
488  compress(::VectorOperation::values operation) override;
489 
511  void
512  update_ghost_values() const;
513 
529  void
530  compress_start(
531  const unsigned int communication_channel = 0,
533 
549  void
550  compress_finish(::VectorOperation::values operation);
551 
567  void
568  update_ghost_values_start(
569  const unsigned int communication_channel = 0) const;
570 
571 
579  void
580  update_ghost_values_finish() const;
581 
590  void
591  zero_out_ghosts() const;
592 
604  bool
605  has_ghost_elements() const;
606 
621  template <typename Number2>
622  void
623  copy_locally_owned_data_from(const Vector<Number2, MemorySpace> &src);
624 
635  template <typename MemorySpace2>
636  void
637  import(const Vector<Number, MemorySpace2> &src,
638  VectorOperation::values operation);
639 
641 
646 
651  virtual void
652  reinit(const VectorSpaceVector<Number> &V,
653  const bool omit_zeroing_entries = false) override;
654 
659  operator*=(const Number factor) override;
660 
665  operator/=(const Number factor) override;
666 
671  operator+=(const VectorSpaceVector<Number> &V) override;
672 
677  operator-=(const VectorSpaceVector<Number> &V) override;
678 
690  virtual void
691  import(
693  VectorOperation::values operation,
694  std::shared_ptr<const CommunicationPatternBase> communication_pattern =
695  std::shared_ptr<const CommunicationPatternBase>()) override;
696 
700  virtual Number
701  operator*(const VectorSpaceVector<Number> &V) const override;
702 
706  virtual void
707  add(const Number a) override;
708 
712  virtual void
713  add(const Number a, const VectorSpaceVector<Number> &V) override;
714 
718  virtual void
719  add(const Number a,
720  const VectorSpaceVector<Number> &V,
721  const Number b,
722  const VectorSpaceVector<Number> &W) override;
723 
728  virtual void
729  add(const std::vector<size_type> &indices,
730  const std::vector<Number> & values);
731 
736  virtual void
737  sadd(const Number s,
738  const Number a,
739  const VectorSpaceVector<Number> &V) override;
740 
746  virtual void
747  scale(const VectorSpaceVector<Number> &scaling_factors) override;
748 
752  virtual void
753  equ(const Number a, const VectorSpaceVector<Number> &V) override;
754 
759  virtual real_type
760  l1_norm() const override;
761 
766  virtual real_type
767  l2_norm() const override;
768 
772  real_type
773  norm_sqr() const;
774 
779  virtual real_type
780  linfty_norm() const override;
781 
802  virtual Number
803  add_and_dot(const Number a,
804  const VectorSpaceVector<Number> &V,
805  const VectorSpaceVector<Number> &W) override;
806 
811  virtual size_type
812  size() const override;
813 
825  virtual ::IndexSet
826  locally_owned_elements() const override;
827 
831  virtual void
832  print(std::ostream & out,
833  const unsigned int precision = 3,
834  const bool scientific = true,
835  const bool across = true) const override;
836 
840  virtual std::size_t
841  memory_consumption() const override;
843 
848 
855  operator=(const Number s) override;
856 
861  template <typename OtherNumber>
862  void
863  add(const std::vector<size_type> & indices,
864  const ::Vector<OtherNumber> &values);
865 
870  template <typename OtherNumber>
871  void
872  add(const size_type n_elements,
873  const size_type * indices,
874  const OtherNumber *values);
875 
880  void
881  sadd(const Number s, const Vector<Number, MemorySpace> &V);
882 
888  DEAL_II_DEPRECATED
889  void
890  sadd(const Number s,
891  const Number a,
893  const Number b,
894  const Vector<Number, MemorySpace> &W);
895 
901  DEAL_II_DEPRECATED
902  void
903  equ(const Number a,
905  const Number b,
906  const Vector<Number, MemorySpace> &v);
907 
909 
910 
915 
920  size_type
921  local_size() const;
922 
930  DEAL_II_DEPRECATED
931  std::pair<size_type, size_type>
932  local_range() const;
933 
940  DEAL_II_DEPRECATED
941  bool
942  in_local_range(const size_type global_index) const;
943 
949  DEAL_II_DEPRECATED
950  size_type
951  n_ghost_entries() const;
952 
960  DEAL_II_DEPRECATED
961  const IndexSet &
962  ghost_elements() const;
963 
971  DEAL_II_DEPRECATED
972  bool
973  is_ghost_entry(const types::global_dof_index global_index) const;
974 
985  iterator
986  begin();
987 
995  const_iterator
996  begin() const;
997 
1005  iterator
1006  end();
1007 
1015  const_iterator
1016  end() const;
1017 
1027  Number
1028  operator()(const size_type global_index) const;
1029 
1039  Number &
1040  operator()(const size_type global_index);
1041 
1049  Number operator[](const size_type global_index) const;
1057  Number &operator[](const size_type global_index);
1058 
1067  Number
1068  local_element(const size_type local_index) const;
1069 
1078  Number &
1079  local_element(const size_type local_index);
1080 
1087  Number *
1088  get_values() const;
1089 
1107  template <typename OtherNumber>
1108  void
1109  extract_subvector_to(const std::vector<size_type> &indices,
1110  std::vector<OtherNumber> & values) const;
1111 
1139  template <typename ForwardIterator, typename OutputIterator>
1140  void
1141  extract_subvector_to(ForwardIterator indices_begin,
1142  const ForwardIterator indices_end,
1143  OutputIterator values_begin) const;
1149  virtual bool
1150  all_zero() const override;
1151 
1155  virtual Number
1156  mean_value() const override;
1157 
1162  real_type
1163  lp_norm(const real_type p) const;
1165 
1170 
1175  const MPI_Comm &
1176  get_mpi_communicator() const;
1177 
1184  const std::shared_ptr<const Utilities::MPI::Partitioner> &
1185  get_partitioner() const;
1186 
1196  bool
1197  partitioners_are_compatible(
1198  const Utilities::MPI::Partitioner &part) const;
1199 
1213  bool
1214  partitioners_are_globally_compatible(
1215  const Utilities::MPI::Partitioner &part) const;
1216 
1220  void
1221  set_ghost_state(const bool ghosted) const;
1222 
1224 
1230  DeclException0(ExcVectorTypeNotCompatible);
1231 
1237  DeclException0(ExcNotAllowedForCuda);
1238 
1242  DeclException3(ExcNonMatchingElements,
1243  Number,
1244  Number,
1245  unsigned int,
1246  << "Called compress(VectorOperation::insert), but"
1247  << " the element received from a remote processor, value "
1248  << std::setprecision(16) << arg1
1249  << ", does not match with the value "
1250  << std::setprecision(16) << arg2
1251  << " on the owner processor " << arg3);
1252 
1256  DeclException4(ExcAccessToNonLocalElement,
1257  size_type,
1258  size_type,
1259  size_type,
1260  size_type,
1261  << "You tried to access element " << arg1
1262  << " of a distributed vector, but this element is not "
1263  << "stored on the current processor. Note: The range of "
1264  << "locally owned elements is " << arg2 << " to " << arg3
1265  << ", and there are " << arg4 << " ghost elements "
1266  << "that this vector can access.");
1267 
1268  private:
1273  void
1274  add_local(const Number a, const VectorSpaceVector<Number> &V);
1275 
1280  void
1281  sadd_local(const Number s,
1282  const Number a,
1283  const VectorSpaceVector<Number> &V);
1284 
1288  template <typename Number2>
1289  Number
1290  inner_product_local(const Vector<Number2, MemorySpace> &V) const;
1291 
1295  real_type
1296  norm_sqr_local() const;
1297 
1301  Number
1302  mean_value_local() const;
1303 
1307  real_type
1308  l1_norm_local() const;
1309 
1313  real_type
1314  lp_norm_local(const real_type p) const;
1315 
1319  real_type
1320  linfty_norm_local() const;
1321 
1327  Number
1328  add_and_dot_local(const Number a,
1329  const Vector<Number, MemorySpace> &V,
1330  const Vector<Number, MemorySpace> &W);
1331 
1337  std::shared_ptr<const Utilities::MPI::Partitioner> partitioner;
1338 
1342  size_type allocated_size;
1343 
1347  mutable ::MemorySpace::MemorySpaceData<Number, MemorySpace> data;
1348 
1353  mutable std::shared_ptr<::parallel::internal::TBBPartitioner>
1355 
1361  mutable ::MemorySpace::MemorySpaceData<Number, MemorySpace>
1363 
1371  mutable bool vector_is_ghosted;
1372 
1373 #ifdef DEAL_II_WITH_MPI
1374 
1382  std::vector<MPI_Request> compress_requests;
1383 
1388  mutable std::vector<MPI_Request> update_ghost_values_requests;
1389 #endif
1390 
1397 
1402  void
1403  clear_mpi_requests();
1404 
1408  void
1409  resize_val(const size_type new_allocated_size);
1410 
1411  // Make all other vector types friends.
1412  template <typename Number2, typename MemorySpace2>
1413  friend class Vector;
1414 
1415  // Make BlockVector type friends.
1416  template <typename Number2>
1417  friend class BlockVector;
1418  };
1422  /*-------------------- Inline functions ---------------------------------*/
1423 
1424 #ifndef DOXYGEN
1425 
1426  namespace internal
1427  {
1428  template <typename Number, typename MemorySpace>
1429  struct Policy
1430  {
1431  static inline typename Vector<Number, MemorySpace>::iterator
1433  {
1434  return nullptr;
1435  }
1436 
1437  static inline typename Vector<Number, MemorySpace>::const_iterator
1438  begin(
1439  const ::MemorySpace::MemorySpaceData<Number, MemorySpace> &)
1440  {
1441  return nullptr;
1442  }
1443 
1444  static inline Number *
1445  get_values(
1447  {
1448  return nullptr;
1449  }
1450  };
1451 
1452 
1453 
1454  template <typename Number>
1455  struct Policy<Number, ::MemorySpace::Host>
1456  {
1457  static inline
1458  typename Vector<Number, ::MemorySpace::Host>::iterator
1459  begin(::MemorySpace::
1460  MemorySpaceData<Number, ::MemorySpace::Host> &data)
1461  {
1462  return data.values.get();
1463  }
1464 
1465  static inline
1466  typename Vector<Number, ::MemorySpace::Host>::const_iterator
1467  begin(const ::MemorySpace::
1468  MemorySpaceData<Number, ::MemorySpace::Host> &data)
1469  {
1470  return data.values.get();
1471  }
1472 
1473  static inline Number *
1474  get_values(::MemorySpace::
1475  MemorySpaceData<Number, ::MemorySpace::Host> &data)
1476  {
1477  return data.values.get();
1478  }
1479  };
1480 
1481 
1482 
1483  template <typename Number>
1484  struct Policy<Number, ::MemorySpace::CUDA>
1485  {
1486  static inline
1487  typename Vector<Number, ::MemorySpace::CUDA>::iterator
1488  begin(::MemorySpace::
1489  MemorySpaceData<Number, ::MemorySpace::CUDA> &data)
1490  {
1491  return data.values_dev.get();
1492  }
1493 
1494  static inline
1495  typename Vector<Number, ::MemorySpace::CUDA>::const_iterator
1496  begin(const ::MemorySpace::
1497  MemorySpaceData<Number, ::MemorySpace::CUDA> &data)
1498  {
1499  return data.values_dev.get();
1500  }
1501 
1502  static inline Number *
1503  get_values(::MemorySpace::
1504  MemorySpaceData<Number, ::MemorySpace::CUDA> &data)
1505  {
1506  return data.values_dev.get();
1507  }
1508  };
1509  } // namespace internal
1510 
1511 
1512  template <typename Number, typename MemorySpace>
1513  inline bool
1515  {
1516  return vector_is_ghosted;
1517  }
1518 
1519 
1520 
1521  template <typename Number, typename MemorySpace>
1522  inline typename Vector<Number, MemorySpace>::size_type
1524  {
1525  return partitioner->size();
1526  }
1527 
1528 
1529 
1530  template <typename Number, typename MemorySpace>
1531  inline typename Vector<Number, MemorySpace>::size_type
1533  {
1534  return partitioner->local_size();
1535  }
1536 
1537 
1538 
1539  template <typename Number, typename MemorySpace>
1540  inline std::pair<typename Vector<Number, MemorySpace>::size_type,
1541  typename Vector<Number, MemorySpace>::size_type>
1543  {
1544  return partitioner->local_range();
1545  }
1546 
1547 
1548 
1549  template <typename Number, typename MemorySpace>
1550  inline bool
1552  const size_type global_index) const
1553  {
1554  return partitioner->in_local_range(global_index);
1555  }
1556 
1557 
1558 
1559  template <typename Number, typename MemorySpace>
1560  inline IndexSet
1562  {
1563  IndexSet is(size());
1564 
1565  is.add_range(partitioner->local_range().first,
1566  partitioner->local_range().second);
1567 
1568  return is;
1569  }
1570 
1571 
1572 
1573  template <typename Number, typename MemorySpace>
1574  inline typename Vector<Number, MemorySpace>::size_type
1576  {
1577  return partitioner->n_ghost_indices();
1578  }
1579 
1580 
1581 
1582  template <typename Number, typename MemorySpace>
1583  inline const IndexSet &
1585  {
1586  return partitioner->ghost_indices();
1587  }
1588 
1589 
1590 
1591  template <typename Number, typename MemorySpace>
1592  inline bool
1594  const size_type global_index) const
1595  {
1596  return partitioner->is_ghost_entry(global_index);
1597  }
1598 
1599 
1600 
1601  template <typename Number, typename MemorySpace>
1602  inline typename Vector<Number, MemorySpace>::iterator
1604  {
1605  return internal::Policy<Number, MemorySpace>::begin(data);
1606  }
1607 
1608 
1609 
1610  template <typename Number, typename MemorySpace>
1611  inline typename Vector<Number, MemorySpace>::const_iterator
1613  {
1614  return internal::Policy<Number, MemorySpace>::begin(data);
1615  }
1616 
1617 
1618 
1619  template <typename Number, typename MemorySpace>
1620  inline typename Vector<Number, MemorySpace>::iterator
1622  {
1623  return internal::Policy<Number, MemorySpace>::begin(data) +
1624  partitioner->local_size();
1625  }
1626 
1627 
1628 
1629  template <typename Number, typename MemorySpace>
1630  inline typename Vector<Number, MemorySpace>::const_iterator
1632  {
1633  return internal::Policy<Number, MemorySpace>::begin(data) +
1634  partitioner->local_size();
1635  }
1636 
1637 
1638 
1639  template <typename Number, typename MemorySpace>
1640  inline Number
1641  Vector<Number, MemorySpace>::operator()(const size_type global_index) const
1642  {
1643  Assert((std::is_same<MemorySpace, ::MemorySpace::Host>::value),
1644  ExcMessage(
1645  "This function is only implemented for the Host memory space"));
1646  Assert(
1647  partitioner->in_local_range(global_index) ||
1648  partitioner->ghost_indices().is_element(global_index),
1649  ExcAccessToNonLocalElement(global_index,
1650  partitioner->local_range().first,
1651  partitioner->local_range().second,
1652  partitioner->ghost_indices().n_elements()));
1653  // do not allow reading a vector which is not in ghost mode
1654  Assert(partitioner->in_local_range(global_index) ||
1655  vector_is_ghosted == true,
1656  ExcMessage("You tried to read a ghost element of this vector, "
1657  "but it has not imported its ghost values."));
1658  return data.values[partitioner->global_to_local(global_index)];
1659  }
1660 
1661 
1662 
1663  template <typename Number, typename MemorySpace>
1664  inline Number &
1665  Vector<Number, MemorySpace>::operator()(const size_type global_index)
1666  {
1667  Assert((std::is_same<MemorySpace, ::MemorySpace::Host>::value),
1668  ExcMessage(
1669  "This function is only implemented for the Host memory space"));
1670  Assert(
1671  partitioner->in_local_range(global_index) ||
1672  partitioner->ghost_indices().is_element(global_index),
1673  ExcAccessToNonLocalElement(global_index,
1674  partitioner->local_range().first,
1675  partitioner->local_range().second,
1676  partitioner->ghost_indices().n_elements()));
1677  // we would like to prevent reading ghosts from a vector that does not
1678  // have them imported, but this is not possible because we might be in a
1679  // part of the code where the vector has enabled ghosts but is non-const
1680  // (then, the compiler picks this method according to the C++ rule book
1681  // even if a human would pick the const method when this subsequent use
1682  // is just a read)
1683  return data.values[partitioner->global_to_local(global_index)];
1684  }
1685 
1686 
1687 
1688  template <typename Number, typename MemorySpace>
1689  inline Number Vector<Number, MemorySpace>::
1690  operator[](const size_type global_index) const
1691  {
1692  return operator()(global_index);
1693  }
1694 
1695 
1696 
1697  template <typename Number, typename MemorySpace>
1698  inline Number &Vector<Number, MemorySpace>::
1699  operator[](const size_type global_index)
1700  {
1701  return operator()(global_index);
1702  }
1703 
1704 
1705 
1706  template <typename Number, typename MemorySpace>
1707  inline Number
1709  const size_type local_index) const
1710  {
1711  Assert((std::is_same<MemorySpace, ::MemorySpace::Host>::value),
1712  ExcMessage(
1713  "This function is only implemented for the Host memory space"));
1714  AssertIndexRange(local_index,
1715  partitioner->local_size() +
1716  partitioner->n_ghost_indices());
1717  // do not allow reading a vector which is not in ghost mode
1718  Assert(local_index < local_size() || vector_is_ghosted == true,
1719  ExcMessage("You tried to read a ghost element of this vector, "
1720  "but it has not imported its ghost values."));
1721 
1722  return data.values[local_index];
1723  }
1724 
1725 
1726 
1727  template <typename Number, typename MemorySpace>
1728  inline Number &
1729  Vector<Number, MemorySpace>::local_element(const size_type local_index)
1730  {
1731  Assert((std::is_same<MemorySpace, ::MemorySpace::Host>::value),
1732  ExcMessage(
1733  "This function is only implemented for the Host memory space"));
1734 
1735  AssertIndexRange(local_index,
1736  partitioner->local_size() +
1737  partitioner->n_ghost_indices());
1738 
1739  return data.values[local_index];
1740  }
1741 
1742 
1743 
1744  template <typename Number, typename MemorySpace>
1745  inline Number *
1747  {
1748  return internal::Policy<Number, MemorySpace>::get_values(data);
1749  }
1750 
1751 
1752 
1753  template <typename Number, typename MemorySpace>
1754  template <typename OtherNumber>
1755  inline void
1757  const std::vector<size_type> &indices,
1758  std::vector<OtherNumber> & values) const
1759  {
1760  for (size_type i = 0; i < indices.size(); ++i)
1761  values[i] = operator()(indices[i]);
1762  }
1763 
1764 
1765 
1766  template <typename Number, typename MemorySpace>
1767  template <typename ForwardIterator, typename OutputIterator>
1768  inline void
1770  ForwardIterator indices_begin,
1771  const ForwardIterator indices_end,
1772  OutputIterator values_begin) const
1773  {
1774  while (indices_begin != indices_end)
1775  {
1776  *values_begin = operator()(*indices_begin);
1777  indices_begin++;
1778  values_begin++;
1779  }
1780  }
1781 
1782 
1783 
1784  template <typename Number, typename MemorySpace>
1785  template <typename OtherNumber>
1786  inline void
1788  const std::vector<size_type> & indices,
1789  const ::Vector<OtherNumber> &values)
1790  {
1791  AssertDimension(indices.size(), values.size());
1792  for (size_type i = 0; i < indices.size(); ++i)
1793  {
1794  Assert(
1795  numbers::is_finite(values[i]),
1796  ExcMessage(
1797  "The given value is not finite but either infinite or Not A Number (NaN)"));
1798  this->operator()(indices[i]) += values(i);
1799  }
1800  }
1801 
1802 
1803 
1804  template <typename Number, typename MemorySpace>
1805  template <typename OtherNumber>
1806  inline void
1807  Vector<Number, MemorySpace>::add(const size_type n_elements,
1808  const size_type * indices,
1809  const OtherNumber *values)
1810  {
1811  for (size_type i = 0; i < n_elements; ++i, ++indices, ++values)
1812  {
1813  Assert(
1814  numbers::is_finite(*values),
1815  ExcMessage(
1816  "The given value is not finite but either infinite or Not A Number (NaN)"));
1817  this->operator()(*indices) += *values;
1818  }
1819  }
1820 
1821 
1822 
1823  template <typename Number, typename MemorySpace>
1824  inline const MPI_Comm &
1826  {
1827  return partitioner->get_mpi_communicator();
1828  }
1829 
1830 
1831 
1832  template <typename Number, typename MemorySpace>
1833  inline const std::shared_ptr<const Utilities::MPI::Partitioner> &
1835  {
1836  return partitioner;
1837  }
1838 
1839 
1840 
1841  template <typename Number, typename MemorySpace>
1842  inline void
1843  Vector<Number, MemorySpace>::set_ghost_state(const bool ghosted) const
1844  {
1845  vector_is_ghosted = ghosted;
1846  }
1847 
1848 #endif
1849 
1850  } // namespace distributed
1851 } // namespace LinearAlgebra
1852 
1853 
1862 template <typename Number, typename MemorySpace>
1863 inline void
1866 {
1867  u.swap(v);
1868 }
1869 
1870 
1876 template <typename Number, typename MemorySpace>
1878  : std::false_type
1879 {};
1880 
1881 
1882 
1883 namespace internal
1884 {
1885  namespace LinearOperatorImplementation
1886  {
1887  template <typename>
1888  class ReinitHelper;
1889 
1894  template <typename Number>
1895  class ReinitHelper<LinearAlgebra::distributed::Vector<Number>>
1896  {
1897  public:
1898  template <typename Matrix>
1899  static void
1900  reinit_range_vector(const Matrix & matrix,
1902  bool omit_zeroing_entries)
1903  {
1904  matrix.initialize_dof_vector(v);
1905  if (!omit_zeroing_entries)
1906  v = Number();
1907  }
1908 
1909  template <typename Matrix>
1910  static void
1911  reinit_domain_vector(const Matrix & matrix,
1913  bool omit_zeroing_entries)
1914  {
1915  matrix.initialize_dof_vector(v);
1916  if (!omit_zeroing_entries)
1917  v = Number();
1918  }
1919  };
1920 
1921  } // namespace LinearOperatorImplementation
1922 } /* namespace internal */
1923 
1924 
1925 DEAL_II_NAMESPACE_CLOSE
1926 
1927 #endif
bool in_local_range(const size_type global_index) const
#define AssertDimension(dim1, dim2)
Definition: exceptions.h:1571
DEAL_II_CONSTEXPR SymmetricTensor< rank_, dim, Number > operator*(const SymmetricTensor< rank_, dim, Number > &t, const Number &factor)
std::vector< MPI_Request > update_ghost_values_requests
std::shared_ptr< const Utilities::MPI::Partitioner > partitioner
#define AssertIndexRange(index, range)
Definition: exceptions.h:1641
__global__ void add_and_dot(Number *res, Number *v1, const Number *v2, const Number *v3, const Number a, const size_type N)
LinearAlgebra::distributed::Vector< Number > Vector
bool is_finite(const double x)
Definition: numbers.h:555
bool is_ghost_entry(const types::global_dof_index global_index) const
__global__ void scale(Number *val, const Number *V_val, const size_type N)
Number local_element(const size_type local_index) const
void set_ghost_state(const bool ghosted) const
static ::ExceptionBase & ExcMessage(std::string arg1)
#define Assert(cond, exc)
Definition: exceptions.h:1411
#define DeclException0(Exception0)
Definition: exceptions.h:473
std::shared_ptr<::parallel::internal::TBBPartitioner > thread_loop_partitioner
mutable ::MemorySpace::MemorySpaceData< Number, MemorySpace > import_data
__global__ void equ(Number *val, const Number a, const Number *V_val, const size_type N)
mutable ::MemorySpace::MemorySpaceData< Number, MemorySpace > data
__global__ void sadd(const Number s, Number *val, const Number a, const Number *V_val, const size_type N)
void swap(Vector< Number > &u, Vector< Number > &v)
Definition: vector.h:1376
unsigned int global_dof_index
Definition: types.h:89
virtual ::IndexSet locally_owned_elements() const override
virtual size_type size() const override
std::pair< size_type, size_type > local_range() const
void swap(Vector< Number, MemorySpace > &v)
const std::shared_ptr< const Utilities::MPI::Partitioner > & get_partitioner() const
#define DeclException4(Exception4, type1, type2, type3, type4, outsequence)
Definition: exceptions.h:587
Number operator()(const size_type global_index) const
virtual void add(const Number a) override
#define DeclException3(Exception3, type1, type2, type3, outsequence)
Definition: exceptions.h:564
void swap(LinearAlgebra::distributed::Vector< Number, MemorySpace > &u, LinearAlgebra::distributed::Vector< Number, MemorySpace > &v)
const MPI_Comm & get_mpi_communicator() const
std::vector< MPI_Request > compress_requests
const IndexSet & ghost_elements() const
void extract_subvector_to(const std::vector< size_type > &indices, std::vector< OtherNumber > &values) const
Number operator[](const size_type global_index) const