Reference documentation for deal.II version GIT 35969cdc9b 2023-12-09 01:10:02+00:00
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
la_parallel_vector.h
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2011 - 2023 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 
24 #include <deal.II/base/mpi_stub.h>
25 #include <deal.II/base/numbers.h>
26 #include <deal.II/base/parallel.h>
29 
33 
34 #include <iomanip>
35 #include <memory>
36 
38 
39 // Forward declarations
40 #ifndef DOXYGEN
41 namespace LinearAlgebra
42 {
46  namespace distributed
47  {
48  template <typename>
49  class BlockVector;
50  }
51 
52  template <typename>
53  class ReadWriteVector;
54 } // namespace LinearAlgebra
55 
56 # ifdef DEAL_II_WITH_PETSC
57 namespace PETScWrappers
58 {
59  namespace MPI
60  {
61  class Vector;
62  }
63 } // namespace PETScWrappers
64 # endif
65 
66 # ifdef DEAL_II_WITH_TRILINOS
67 namespace TrilinosWrappers
68 {
69  namespace MPI
70  {
71  class Vector;
72  }
73 } // namespace TrilinosWrappers
74 # endif
75 #endif
76 
77 namespace LinearAlgebra
78 {
79  namespace distributed
80  {
249  template <typename Number, typename MemorySpace = MemorySpace::Host>
250  class Vector : public ::ReadVector<Number>, public Subscriptor
251  {
252  public:
254  using value_type = Number;
255  using pointer = value_type *;
256  using const_pointer = const value_type *;
257  using iterator = value_type *;
258  using const_iterator = const value_type *;
260  using const_reference = const value_type &;
263 
264  static_assert(
265  std::is_same_v<MemorySpace, ::MemorySpace::Host> ||
266  std::is_same_v<MemorySpace, ::MemorySpace::Default>,
267  "MemorySpace should be Host or Default");
268 
277 
285 
293  Vector(Vector<Number, MemorySpace> &&in_vector); // NOLINT
294 
300 
317  Vector(const IndexSet &local_range,
318  const IndexSet &ghost_indices,
319  const MPI_Comm communicator);
320 
324  Vector(const IndexSet &local_range, const MPI_Comm communicator);
325 
333  const std::shared_ptr<const Utilities::MPI::Partitioner> &partitioner);
334 
339 
344  void
345  reinit(const size_type size, const bool omit_zeroing_entries = false);
346 
357  template <typename Number2>
358  void
360  const bool omit_zeroing_entries = false);
361 
378  void
379  reinit(const IndexSet &local_range,
380  const IndexSet &ghost_indices,
381  const MPI_Comm communicator);
382 
386  void
387  reinit(const IndexSet &local_range, const MPI_Comm communicator);
388 
401  void
403  const std::shared_ptr<const Utilities::MPI::Partitioner> &partitioner,
404  const MPI_Comm comm_sm = MPI_COMM_SELF);
405 
412  void
414  const std::shared_ptr<const Utilities::MPI::Partitioner> &partitioner,
415  const bool make_ghosted,
416  const MPI_Comm &comm_sm = MPI_COMM_SELF);
417 
437  void
438  reinit(const types::global_dof_index local_size,
439  const types::global_dof_index ghost_size,
440  const MPI_Comm comm,
441  const MPI_Comm comm_sm = MPI_COMM_SELF);
442 
455  void
457 
465  operator=(Vector<Number, MemorySpace> &&in_vector); // NOLINT
466 
480 
492  template <typename Number2>
495 
537  void
539 
561  void
563 
581  void
582  compress_start(const unsigned int communication_channel = 0,
584 
603  void
605 
623  void
625  const unsigned int communication_channel = 0) const;
626 
627 
635  void
637 
646  void
648 
660  bool
662 
677  template <typename Number2>
678  void
680 
691  template <typename MemorySpace2>
692  void
694  VectorOperation::values operation);
695 
699  template <typename MemorySpace2>
700  DEAL_II_DEPRECATED void
701  import(const Vector<Number, MemorySpace2> &src,
702  VectorOperation::values operation)
703  {
704  import_elements(src, operation);
705  }
706 
718  operator*=(const Number factor);
719 
724  operator/=(const Number factor);
725 
731 
737 
749  void
752  const VectorOperation::values operation,
753  const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
754  &communication_pattern = {});
755 
759  DEAL_II_DEPRECATED void
761  VectorOperation::values operation,
762  std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
763  communication_pattern = {})
764  {
765  import_elements(V, operation, communication_pattern);
766  }
767 
771  Number
773 
777  void
778  add(const Number a);
779 
783  void
784  add(const Number a, const Vector<Number, MemorySpace> &V);
785 
789  void
790  add(const Number a,
792  const Number b,
793  const Vector<Number, MemorySpace> &W);
794 
799  void
800  add(const std::vector<size_type> &indices,
801  const std::vector<Number> &values);
802 
807  void
808  sadd(const Number s,
809  const Number a,
811 
817  void
818  scale(const Vector<Number, MemorySpace> &scaling_factors);
819 
823  void
824  equ(const Number a, const Vector<Number, MemorySpace> &V);
825 
830  real_type
831  l1_norm() const;
832 
837  real_type
838  l2_norm() const;
839 
843  real_type
844  norm_sqr() const;
845 
850  real_type
851  linfty_norm() const;
852 
873  Number
874  add_and_dot(const Number a,
876  const Vector<Number, MemorySpace> &W);
877 
882  virtual size_type
883  size() const override;
884 
896  ::IndexSet
898 
902  void
903  print(std::ostream &out,
904  const unsigned int precision = 3,
905  const bool scientific = true,
906  const bool across = true) const;
907 
911  std::size_t
926  operator=(const Number s);
927 
932  template <typename OtherNumber>
933  void
934  add(const std::vector<size_type> &indices,
935  const ::Vector<OtherNumber> &values);
936 
941  template <typename OtherNumber>
942  void
943  add(const size_type n_elements,
944  const size_type *indices,
945  const OtherNumber *values);
946 
951  void
952  sadd(const Number s, const Vector<Number, MemorySpace> &V);
953 
966  size_type
968 
973  bool
975 
986  iterator
987  begin();
988 
997  begin() const;
998 
1006  iterator
1007  end();
1008 
1017  end() const;
1018 
1028  Number
1030 
1040  Number &
1042 
1050  Number
1059  Number &
1061 
1070  Number
1071  local_element(const size_type local_index) const;
1072 
1081  Number &
1082  local_element(const size_type local_index);
1083 
1090  Number *
1091  get_values() const;
1092 
1110  template <typename OtherNumber>
1111  void
1112  extract_subvector_to(const std::vector<size_type> &indices,
1113  std::vector<OtherNumber> &values) const;
1114 
1118  virtual void
1121  ArrayView<Number> &elements) const override;
1122 
1150  template <typename ForwardIterator, typename OutputIterator>
1151  void
1152  extract_subvector_to(ForwardIterator indices_begin,
1153  const ForwardIterator indices_end,
1154  OutputIterator values_begin) const;
1160  bool
1161  all_zero() const;
1162 
1166  Number
1167  mean_value() const;
1168 
1173  real_type
1174  lp_norm(const real_type p) const;
1185  MPI_Comm
1187 
1194  const std::shared_ptr<const Utilities::MPI::Partitioner> &
1196 
1206  bool
1208  const Utilities::MPI::Partitioner &part) const;
1209 
1223  bool
1225  const Utilities::MPI::Partitioner &part) const;
1226 
1230  void
1231  set_ghost_state(const bool ghosted) const;
1232 
1237  const std::vector<ArrayView<const Number>> &
1239 
1248 
1253  Number,
1254  Number,
1255  unsigned int,
1256  << "Called compress(VectorOperation::insert), but"
1257  << " the element received from a remote processor, value "
1258  << std::setprecision(16) << arg1
1259  << ", does not match with the value "
1260  << std::setprecision(16) << arg2
1261  << " on the owner processor " << arg3);
1262 
1268  size_type,
1269  size_type,
1270  size_type,
1271  size_type,
1272  << "You tried to access element " << arg1
1273  << " of a distributed vector, but this element is not "
1274  << "stored on the current processor. Note: The range of "
1275  << "locally owned elements is [" << arg2 << ',' << arg3
1276  << "], and there are " << arg4 << " ghost elements "
1277  << "that this vector can access."
1278  << "\n\n"
1279  << "A common source for this kind of problem is that you "
1280  << "are passing a 'fully distributed' vector into a function "
1281  << "that needs read access to vector elements that correspond "
1282  << "to degrees of freedom on ghost cells (or at least to "
1283  << "'locally active' degrees of freedom that are not also "
1284  << "'locally owned'). You need to pass a vector that has these "
1285  << "elements as ghost entries.");
1286 
1287  private:
1292  void
1293  add_local(const Number a, const Vector<Number, MemorySpace> &V);
1294 
1299  void
1300  sadd_local(const Number s,
1301  const Number a,
1303 
1307  template <typename Number2>
1308  Number
1310 
1314  real_type
1316 
1320  Number
1322 
1326  real_type
1327  l1_norm_local() const;
1328 
1332  real_type
1333  lp_norm_local(const real_type p) const;
1334 
1338  real_type
1340 
1346  Number
1347  add_and_dot_local(const Number a,
1349  const Vector<Number, MemorySpace> &W);
1350 
1356  std::shared_ptr<const Utilities::MPI::Partitioner> partitioner;
1357 
1362 
1366  mutable ::MemorySpace::MemorySpaceData<Number, MemorySpace> data;
1367 
1372  mutable std::shared_ptr<::parallel::internal::TBBPartitioner>
1374 
1379  mutable ::MemorySpace::MemorySpaceData<Number, MemorySpace>
1381 
1389  mutable bool vector_is_ghosted;
1390 
1391 #ifdef DEAL_II_WITH_MPI
1400  std::vector<MPI_Request> compress_requests;
1401 
1406  mutable std::vector<MPI_Request> update_ghost_values_requests;
1407 #endif
1408 
1414  mutable std::mutex mutex;
1415 
1421  MPI_Comm comm_sm;
1422 
1427  void
1429 
1433  void
1434  resize_val(const size_type new_allocated_size,
1435  const MPI_Comm comm_sm = MPI_COMM_SELF);
1436 
1437  // Make all other vector types friends.
1438  template <typename Number2, typename MemorySpace2>
1439  friend class Vector;
1440 
1441  // Make BlockVector type friends.
1442  template <typename Number2>
1443  friend class BlockVector;
1444  };
1448  /*-------------------- Inline functions ---------------------------------*/
1449 
1450 #ifndef DOXYGEN
1451 
1452  template <typename Number, typename MemorySpace>
1453  inline bool
1455  {
1456  return vector_is_ghosted;
1457  }
1458 
1459 
1460 
1461  template <typename Number, typename MemorySpace>
1464  {
1465  return partitioner->size();
1466  }
1467 
1468 
1469 
1470  template <typename Number, typename MemorySpace>
1473  {
1474  return partitioner->locally_owned_size();
1475  }
1476 
1477 
1478 
1479  template <typename Number, typename MemorySpace>
1480  inline bool
1482  const size_type global_index) const
1483  {
1484  return partitioner->in_local_range(global_index);
1485  }
1486 
1487 
1488 
1489  template <typename Number, typename MemorySpace>
1490  inline IndexSet
1492  {
1493  IndexSet is(size());
1494 
1495  is.add_range(partitioner->local_range().first,
1496  partitioner->local_range().second);
1497 
1498  return is;
1499  }
1500 
1501 
1502 
1503  template <typename Number, typename MemorySpace>
1506  {
1507  return data.values.data();
1508  }
1509 
1510 
1511 
1512  template <typename Number, typename MemorySpace>
1515  {
1516  return data.values.data();
1517  }
1518 
1519 
1520 
1521  template <typename Number, typename MemorySpace>
1524  {
1525  return data.values.data() + partitioner->locally_owned_size();
1526  }
1527 
1528 
1529 
1530  template <typename Number, typename MemorySpace>
1533  {
1534  return data.values.data() + partitioner->locally_owned_size();
1535  }
1536 
1537 
1538 
1539  template <typename Number, typename MemorySpace>
1540  const std::vector<ArrayView<const Number>> &
1542  {
1543  return data.values_sm;
1544  }
1545 
1546 
1547 
1548  template <typename Number, typename MemorySpace>
1549  inline Number
1551  {
1552  Assert((std::is_same_v<MemorySpace, ::MemorySpace::Host>),
1553  ExcMessage(
1554  "This function is only implemented for the Host memory space"));
1555  Assert(
1556  partitioner->in_local_range(global_index) ||
1557  partitioner->ghost_indices().is_element(global_index),
1558  ExcAccessToNonLocalElement(global_index,
1559  partitioner->local_range().first,
1560  partitioner->local_range().second == 0 ?
1561  0 :
1562  (partitioner->local_range().second - 1),
1563  partitioner->ghost_indices().n_elements()));
1564  // do not allow reading a vector which is not in ghost mode
1565  Assert(partitioner->in_local_range(global_index) ||
1566  vector_is_ghosted == true,
1567  ExcMessage("You tried to read a ghost element of this vector, "
1568  "but it has not imported its ghost values."));
1569  return data.values[partitioner->global_to_local(global_index)];
1570  }
1571 
1572 
1573 
1574  template <typename Number, typename MemorySpace>
1575  inline Number &
1577  {
1578  Assert((std::is_same_v<MemorySpace, ::MemorySpace::Host>),
1579  ExcMessage(
1580  "This function is only implemented for the Host memory space"));
1581  Assert(
1582  partitioner->in_local_range(global_index) ||
1583  partitioner->ghost_indices().is_element(global_index),
1584  ExcAccessToNonLocalElement(global_index,
1585  partitioner->local_range().first,
1586  partitioner->local_range().second == 0 ?
1587  0 :
1588  (partitioner->local_range().second - 1),
1589  partitioner->ghost_indices().n_elements()));
1590  // we would like to prevent reading ghosts from a vector that does not
1591  // have them imported, but this is not possible because we might be in a
1592  // part of the code where the vector has enabled ghosts but is non-const
1593  // (then, the compiler picks this method according to the C++ rule book
1594  // even if a human would pick the const method when this subsequent use
1595  // is just a read)
1596  return data.values[partitioner->global_to_local(global_index)];
1597  }
1598 
1599 
1600 
1601  template <typename Number, typename MemorySpace>
1602  inline Number
1604  {
1605  return operator()(global_index);
1606  }
1607 
1608 
1609 
1610  template <typename Number, typename MemorySpace>
1611  inline Number &
1613  {
1614  return operator()(global_index);
1615  }
1616 
1617 
1618 
1619  template <typename Number, typename MemorySpace>
1620  inline Number
1622  const size_type local_index) const
1623  {
1624  Assert((std::is_same_v<MemorySpace, ::MemorySpace::Host>),
1625  ExcMessage(
1626  "This function is only implemented for the Host memory space"));
1627  AssertIndexRange(local_index,
1628  partitioner->locally_owned_size() +
1629  partitioner->n_ghost_indices());
1630  // do not allow reading a vector which is not in ghost mode
1631  Assert(local_index < locally_owned_size() || vector_is_ghosted == true,
1632  ExcMessage("You tried to read a ghost element of this vector, "
1633  "but it has not imported its ghost values."));
1634 
1635  return data.values[local_index];
1636  }
1637 
1638 
1639 
1640  template <typename Number, typename MemorySpace>
1641  inline Number &
1643  {
1644  Assert((std::is_same_v<MemorySpace, ::MemorySpace::Host>),
1645  ExcMessage(
1646  "This function is only implemented for the Host memory space"));
1647 
1648  AssertIndexRange(local_index,
1649  partitioner->locally_owned_size() +
1650  partitioner->n_ghost_indices());
1651 
1652  return data.values[local_index];
1653  }
1654 
1655 
1656 
1657  template <typename Number, typename MemorySpace>
1658  inline Number *
1660  {
1661  return data.values.data();
1662  }
1663 
1664 
1665 
1666  template <typename Number, typename MemorySpace>
1667  template <typename OtherNumber>
1668  inline void
1670  const std::vector<size_type> &indices,
1671  std::vector<OtherNumber> &values) const
1672  {
1673  for (size_type i = 0; i < indices.size(); ++i)
1674  values[i] = operator()(indices[i]);
1675  }
1676 
1677 
1678 
1679  template <typename Number, typename MemorySpace>
1680  template <typename ForwardIterator, typename OutputIterator>
1681  inline void
1683  ForwardIterator indices_begin,
1684  const ForwardIterator indices_end,
1685  OutputIterator values_begin) const
1686  {
1687  while (indices_begin != indices_end)
1688  {
1689  *values_begin = operator()(*indices_begin);
1690  indices_begin++;
1691  values_begin++;
1692  }
1693  }
1694 
1695 
1696 
1697  template <typename Number, typename MemorySpace>
1698  template <typename OtherNumber>
1699  inline void
1701  const std::vector<size_type> &indices,
1702  const ::Vector<OtherNumber> &values)
1703  {
1704  AssertDimension(indices.size(), values.size());
1705  for (size_type i = 0; i < indices.size(); ++i)
1706  {
1707  Assert(
1709  ExcMessage(
1710  "The given value is not finite but either infinite or Not A Number (NaN)"));
1711  this->operator()(indices[i]) += values(i);
1712  }
1713  }
1714 
1715 
1716 
1717  template <typename Number, typename MemorySpace>
1718  template <typename OtherNumber>
1719  inline void
1721  const size_type *indices,
1722  const OtherNumber *values)
1723  {
1724  for (size_type i = 0; i < n_elements; ++i, ++indices, ++values)
1725  {
1726  Assert(
1728  ExcMessage(
1729  "The given value is not finite but either infinite or Not A Number (NaN)"));
1730  this->operator()(*indices) += *values;
1731  }
1732  }
1733 
1734 
1735 
1736  template <typename Number, typename MemorySpace>
1737  inline MPI_Comm
1739  {
1740  return partitioner->get_mpi_communicator();
1741  }
1742 
1743 
1744 
1745  template <typename Number, typename MemorySpace>
1746  inline const std::shared_ptr<const Utilities::MPI::Partitioner> &
1748  {
1749  return partitioner;
1750  }
1751 
1752 
1753 
1754  template <typename Number, typename MemorySpace>
1755  inline void
1756  Vector<Number, MemorySpace>::set_ghost_state(const bool ghosted) const
1757  {
1758  vector_is_ghosted = ghosted;
1759  }
1760 
1761 #endif
1762 
1763  } // namespace distributed
1764 } // namespace LinearAlgebra
1765 
1766 
1774 template <typename Number, typename MemorySpace>
1775 inline void
1778 {
1779  u.swap(v);
1780 }
1781 
1782 
1786 template <typename Number, typename MemorySpace>
1788  : std::false_type
1789 {};
1790 
1791 
1792 
1793 namespace internal
1794 {
1795  namespace LinearOperatorImplementation
1796  {
1797  template <typename>
1798  class ReinitHelper;
1799 
1804  template <typename Number>
1806  {
1807  public:
1808  // A helper type-trait that leverage SFINAE to figure out if type T has
1809  // void T::get_mpi_communicator()
1810  template <typename T>
1812  decltype(std::declval<T>().get_mpi_communicator());
1813 
1814  template <typename T>
1815  static constexpr bool has_get_mpi_communicator =
1816  is_supported_operation<get_mpi_communicator_t, T>;
1817 
1818  // A helper type-trait that leverage SFINAE to figure out if type T has
1819  // void T::locally_owned_domain_indices()
1820  template <typename T>
1822  decltype(std::declval<T>().locally_owned_domain_indices());
1823 
1824  template <typename T>
1825  static constexpr bool has_locally_owned_domain_indices =
1826  is_supported_operation<locally_owned_domain_indices_t, T>;
1827 
1828  // A helper type-trait that leverage SFINAE to figure out if type T has
1829  // void T::locally_owned_range_indices()
1830  template <typename T>
1832  decltype(std::declval<T>().locally_owned_range_indices());
1833 
1834  template <typename T>
1835  static constexpr bool has_locally_owned_range_indices =
1836  is_supported_operation<locally_owned_range_indices_t, T>;
1837 
1838  // A helper type-trait that leverage SFINAE to figure out if type T has
1839  // void T::initialize_dof_vector(VectorType v)
1840  template <typename T>
1842  decltype(std::declval<T>().initialize_dof_vector(
1843  std::declval<LinearAlgebra::distributed::Vector<Number> &>()));
1844 
1845  template <typename T>
1846  static constexpr bool has_initialize_dof_vector =
1847  is_supported_operation<initialize_dof_vector_t, T>;
1848 
1849  // Used for (Trilinos/PETSc)Wrappers::SparseMatrix
1850  template <typename MatrixType,
1851 #if !defined(__INTEL_COMPILER) || __INTEL_COMPILER >= 1900
1852  std::enable_if_t<has_get_mpi_communicator<MatrixType> &&
1853  has_locally_owned_domain_indices<MatrixType>,
1854 #else
1855  // workaround for Intel 18
1856  std::enable_if_t<
1857  is_supported_operation<get_mpi_communicator_t, MatrixType> &&
1859  MatrixType>,
1860 #endif
1861  MatrixType> * = nullptr>
1862  static void
1863  reinit_domain_vector(MatrixType &mat,
1865  bool /*omit_zeroing_entries*/)
1866  {
1867  vec.reinit(mat.locally_owned_domain_indices(),
1868  mat.get_mpi_communicator());
1869  }
1870 
1871  // Used for MatrixFree and DiagonalMatrix
1872  template <typename MatrixType,
1873 #if !defined(__INTEL_COMPILER) || __INTEL_COMPILER >= 1900
1874  std::enable_if_t<has_initialize_dof_vector<MatrixType>,
1875 #else
1876  // workaround for Intel 18
1877  std::enable_if_t<
1878  is_supported_operation<initialize_dof_vector_t, MatrixType>,
1879 #endif
1880  MatrixType> * = nullptr>
1881  static void
1882  reinit_domain_vector(MatrixType &mat,
1884  bool omit_zeroing_entries)
1885  {
1886  mat.initialize_dof_vector(vec);
1887  if (!omit_zeroing_entries)
1888  vec = Number();
1889  }
1890 
1891  // Used for (Trilinos/PETSc)Wrappers::SparseMatrix
1892  template <typename MatrixType,
1893 #if !defined(__INTEL_COMPILER) || __INTEL_COMPILER >= 1900
1894  std::enable_if_t<has_get_mpi_communicator<MatrixType> &&
1895  has_locally_owned_range_indices<MatrixType>,
1896 #else
1897  // workaround for Intel 18
1898  std::enable_if_t<
1899  is_supported_operation<get_mpi_communicator_t, MatrixType> &&
1900  is_supported_operation<locally_owned_range_indices_t,
1901  MatrixType>,
1902 #endif
1903  MatrixType> * = nullptr>
1904  static void
1905  reinit_range_vector(MatrixType &mat,
1907  bool /*omit_zeroing_entries*/)
1908  {
1909  vec.reinit(mat.locally_owned_range_indices(),
1910  mat.get_mpi_communicator());
1911  }
1912 
1913  // Used for MatrixFree and DiagonalMatrix
1914  template <typename MatrixType,
1915 #if !defined(__INTEL_COMPILER) || __INTEL_COMPILER >= 1900
1916  std::enable_if_t<has_initialize_dof_vector<MatrixType>,
1917 #else
1918  // workaround for Intel 18
1919  std::enable_if_t<
1920  is_supported_operation<initialize_dof_vector_t, MatrixType>,
1921 #endif
1922  MatrixType> * = nullptr>
1923  static void
1924  reinit_range_vector(MatrixType &mat,
1926  bool omit_zeroing_entries)
1927  {
1928  mat.initialize_dof_vector(vec);
1929  if (!omit_zeroing_entries)
1930  vec = Number();
1931  }
1932  };
1933 
1934  } // namespace LinearOperatorImplementation
1935 } /* namespace internal */
1936 
1937 
1939 
1940 #endif
virtual size_type size() const override
value_type operator()(const size_type i) const
std::size_t locally_owned_size() const
bool partitioners_are_compatible(const Utilities::MPI::Partitioner &part) const
void sadd(const Number s, const Number a, const Vector< Number, MemorySpace > &V)
Number & operator[](const size_type global_index)
Number local_element(const size_type local_index) const
void reinit(const IndexSet &local_range, const MPI_Comm communicator)
Number add_and_dot_local(const Number a, const Vector< Number, MemorySpace > &V, const Vector< Number, MemorySpace > &W)
void compress_finish(VectorOperation::values operation)
mutable ::MemorySpace::MemorySpaceData< Number, MemorySpace > import_data
void swap(Vector< Number, MemorySpace > &v)
mutable ::MemorySpace::MemorySpaceData< Number, MemorySpace > data
void equ(const Number a, const Vector< Number, MemorySpace > &V)
void sadd_local(const Number s, const Number a, const Vector< Number, MemorySpace > &V)
typename numbers::NumberTraits< Number >::real_type real_type
const_iterator end() const
Number & local_element(const size_type local_index)
Vector(const IndexSet &local_range, const MPI_Comm communicator)
Vector(const size_type size)
Vector(Vector< Number, MemorySpace > &&in_vector)
size_type locally_owned_size() const
void reinit(const std::shared_ptr< const Utilities::MPI::Partitioner > &partitioner, const MPI_Comm comm_sm=MPI_COMM_SELF)
std::shared_ptr< const Utilities::MPI::Partitioner > partitioner
void add(const size_type n_elements, const size_type *indices, const OtherNumber *values)
void sadd(const Number s, const Vector< Number, MemorySpace > &V)
void reinit(const IndexSet &local_range, const IndexSet &ghost_indices, const MPI_Comm communicator)
const std::shared_ptr< const Utilities::MPI::Partitioner > & get_partitioner() const
Number & operator()(const size_type global_index)
Number operator[](const size_type global_index) const
Vector(const Vector< Number, MemorySpace > &in_vector)
void add(const Number a, const Vector< Number, MemorySpace > &V)
void set_ghost_state(const bool ghosted) const
void add(const std::vector< size_type > &indices, const std::vector< Number > &values)
::IndexSet locally_owned_elements() const
virtual void extract_subvector_to(const ArrayView< const types::global_dof_index > &indices, ArrayView< Number > &elements) const override
void compress(VectorOperation::values operation)
Vector(const IndexSet &local_range, const IndexSet &ghost_indices, const MPI_Comm communicator)
void add(const std::vector< size_type > &indices, const ::Vector< OtherNumber > &values)
void import_elements(const Vector< Number, MemorySpace2 > &src, VectorOperation::values operation)
Vector< Number, MemorySpace > & operator-=(const Vector< Number, MemorySpace > &V)
void add(const Number a, const Vector< Number, MemorySpace > &V, const Number b, const Vector< Number, MemorySpace > &W)
Vector< Number, MemorySpace > & operator=(const Number s)
void reinit(const Vector< Number2, MemorySpace > &in_vector, const bool omit_zeroing_entries=false)
real_type lp_norm(const real_type p) const
bool partitioners_are_globally_compatible(const Utilities::MPI::Partitioner &part) const
Vector< Number, MemorySpace > & operator/=(const Number factor)
virtual size_type size() const override
std::shared_ptr<::parallel::internal::TBBPartitioner > thread_loop_partitioner
Number add_and_dot(const Number a, const Vector< Number, MemorySpace > &V, const Vector< Number, MemorySpace > &W)
std::size_t memory_consumption() const
void update_ghost_values_start(const unsigned int communication_channel=0) const
void import_elements(const LinearAlgebra::ReadWriteVector< Number > &V, const VectorOperation::values operation, const std::shared_ptr< const Utilities::MPI::CommunicationPatternBase > &communication_pattern={})
void copy_locally_owned_data_from(const Vector< Number2, MemorySpace > &src)
Vector< Number, MemorySpace > & operator=(const Vector< Number, MemorySpace > &in_vector)
Number operator()(const size_type global_index) const
real_type lp_norm_local(const real_type p) const
void print(std::ostream &out, const unsigned int precision=3, const bool scientific=true, const bool across=true) const
void reinit(const size_type size, const bool omit_zeroing_entries=false)
const std::vector< ArrayView< const Number > > & shared_vector_data() const
Vector< Number, MemorySpace > & operator=(const Vector< Number2, MemorySpace > &in_vector)
void extract_subvector_to(const std::vector< size_type > &indices, std::vector< OtherNumber > &values) const
void compress_start(const unsigned int communication_channel=0, VectorOperation::values operation=VectorOperation::add)
std::vector< MPI_Request > update_ghost_values_requests
void scale(const Vector< Number, MemorySpace > &scaling_factors)
const_iterator begin() const
std::vector< MPI_Request > compress_requests
void add_local(const Number a, const Vector< Number, MemorySpace > &V)
Number operator*(const Vector< Number, MemorySpace > &V) const
bool in_local_range(const size_type global_index) const
void extract_subvector_to(ForwardIterator indices_begin, const ForwardIterator indices_end, OutputIterator values_begin) const
Vector< Number, MemorySpace > & operator=(Vector< Number, MemorySpace > &&in_vector)
Number inner_product_local(const Vector< Number2, MemorySpace > &V) const
void reinit(const std::shared_ptr< const Utilities::MPI::Partitioner > &partitioner, const bool make_ghosted, const MPI_Comm &comm_sm=MPI_COMM_SELF)
Vector< Number, MemorySpace > & operator+=(const Vector< Number, MemorySpace > &V)
void resize_val(const size_type new_allocated_size, const MPI_Comm comm_sm=MPI_COMM_SELF)
void reinit(const types::global_dof_index local_size, const types::global_dof_index ghost_size, const MPI_Comm comm, const MPI_Comm comm_sm=MPI_COMM_SELF)
Vector< Number, MemorySpace > & operator*=(const Number factor)
Vector(const std::shared_ptr< const Utilities::MPI::Partitioner > &partitioner)
Definition: vector.h:110
void swap(LinearAlgebra::distributed::Vector< Number, MemorySpace > &u, LinearAlgebra::distributed::Vector< Number, MemorySpace > &v)
const value_type * const_iterator
Definition: vector.h:133
types::global_dof_index size_type
Definition: vector.h:136
value_type * iterator
Definition: vector.h:132
decltype(std::declval< T >().initialize_dof_vector(std::declval< LinearAlgebra::distributed::Vector< Number > & >())) initialize_dof_vector_t
static void reinit_range_vector(MatrixType &mat, LinearAlgebra::distributed::Vector< Number > &vec, bool)
static void reinit_range_vector(MatrixType &mat, LinearAlgebra::distributed::Vector< Number > &vec, bool omit_zeroing_entries)
static void reinit_domain_vector(MatrixType &mat, LinearAlgebra::distributed::Vector< Number > &vec, bool omit_zeroing_entries)
static void reinit_domain_vector(MatrixType &mat, LinearAlgebra::distributed::Vector< Number > &vec, bool)
#define DEAL_II_DEPRECATED
Definition: config.h:178
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:477
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:478
#define DeclException0(Exception0)
Definition: exceptions.h:472
#define DeclException4(Exception4, type1, type2, type3, type4, outsequence)
Definition: exceptions.h:586
static ::ExceptionBase & ExcVectorTypeNotCompatible()
static ::ExceptionBase & ExcNonMatchingElements(Number arg1, Number arg2, unsigned int arg3)
static ::ExceptionBase & ExcAccessToNonLocalElement(size_type arg1, size_type arg2, size_type arg3, size_type arg4)
#define Assert(cond, exc)
Definition: exceptions.h:1631
#define AssertDimension(dim1, dim2)
Definition: exceptions.h:1820
#define AssertIndexRange(index, range)
Definition: exceptions.h:1888
#define DeclException3(Exception3, type1, type2, type3, outsequence)
Definition: exceptions.h:563
static ::ExceptionBase & ExcMessage(std::string arg1)
static const char V
types::global_dof_index size_type
Definition: cuda_kernels.h:45
SymmetricTensor< 2, dim, Number > b(const Tensor< 2, dim, Number > &F)
TrilinosWrappers::types::int_type global_index(const Epetra_BlockMap &map, const ::types::global_dof_index i)
constexpr bool is_supported_operation
bool is_finite(const double x)
Definition: numbers.h:539
unsigned int global_dof_index
Definition: types.h:82
const MPI_Comm comm