Reference documentation for deal.II version 9.1.1
\(\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 namespace LinearAlgebra
37 {
41  namespace distributed
42  {
43  template <typename>
44  class BlockVector;
45  }
46 
47  template <typename>
49 } // namespace LinearAlgebra
50 
51 #ifdef DEAL_II_WITH_PETSC
52 namespace PETScWrappers
53 {
54  namespace MPI
55  {
56  class Vector;
57  }
58 } // namespace PETScWrappers
59 #endif
60 
61 #ifdef DEAL_II_WITH_TRILINOS
62 namespace TrilinosWrappers
63 {
64  namespace MPI
65  {
66  class Vector;
67  }
68 } // namespace TrilinosWrappers
69 #endif
70 
71 namespace LinearAlgebra
72 {
73  namespace distributed
74  {
222  template <typename Number, typename MemorySpace = MemorySpace::Host>
224  public Subscriptor
225  {
226  public:
227  using memory_space = MemorySpace;
228  using value_type = Number;
229  using pointer = value_type *;
230  using const_pointer = const value_type *;
231  using iterator = value_type *;
232  using const_iterator = const value_type *;
233  using reference = value_type &;
234  using const_reference = const value_type &;
235  using size_type = types::global_dof_index;
236  using real_type = typename numbers::NumberTraits<Number>::real_type;
237 
238  static_assert(
239  std::is_same<MemorySpace, ::MemorySpace::Host>::value ||
240  std::is_same<MemorySpace, ::MemorySpace::CUDA>::value,
241  "MemorySpace should be Host or CUDA");
242 
250  Vector();
251 
255  Vector(const Vector<Number, MemorySpace> &in_vector);
256 
261  Vector(const size_type size);
262 
279  Vector(const IndexSet &local_range,
280  const IndexSet &ghost_indices,
281  const MPI_Comm communicator);
282 
286  Vector(const IndexSet &local_range, const MPI_Comm communicator);
287 
294  Vector(
295  const std::shared_ptr<const Utilities::MPI::Partitioner> &partitioner);
296 
300  virtual ~Vector() override;
301 
306  void
307  reinit(const size_type size, const bool omit_zeroing_entries = false);
308 
319  template <typename Number2>
320  void
321  reinit(const Vector<Number2, MemorySpace> &in_vector,
322  const bool omit_zeroing_entries = false);
323 
340  void
341  reinit(const IndexSet &local_range,
342  const IndexSet &ghost_indices,
343  const MPI_Comm communicator);
344 
348  void
349  reinit(const IndexSet &local_range, const MPI_Comm communicator);
350 
357  void
358  reinit(
359  const std::shared_ptr<const Utilities::MPI::Partitioner> &partitioner);
360 
376  void
378 
391  operator=(const Vector<Number, MemorySpace> &in_vector);
392 
404  template <typename Number2>
406  operator=(const Vector<Number2, MemorySpace> &in_vector);
407 
408 #ifdef DEAL_II_WITH_PETSC
409 
419  DEAL_II_DEPRECATED
421  operator=(const PETScWrappers::MPI::Vector &petsc_vec);
422 #endif
423 
424 #ifdef DEAL_II_WITH_TRILINOS
425 
436  DEAL_II_DEPRECATED
438  operator=(const TrilinosWrappers::MPI::Vector &trilinos_vec);
439 #endif
440 
441 
481  virtual void
482  compress(::VectorOperation::values operation) override;
483 
505  void
506  update_ghost_values() const;
507 
522  void
524  const unsigned int communication_channel = 0,
526 
542  void
544 
559  void
561  const unsigned int communication_channel = 0) const;
562 
563 
571  void
573 
582  void
583  zero_out_ghosts() const;
584 
596  bool
597  has_ghost_elements() const;
598 
613  template <typename Number2>
614  void
616 
618 
623 
628  virtual void
630  const bool omit_zeroing_entries = false) override;
631 
636  operator*=(const Number factor) override;
637 
642  operator/=(const Number factor) override;
643 
648  operator+=(const VectorSpaceVector<Number> &V) override;
649 
654  operator-=(const VectorSpaceVector<Number> &V) override;
655 
667  virtual void
668  import(
670  VectorOperation::values operation,
671  std::shared_ptr<const CommunicationPatternBase> communication_pattern =
672  std::shared_ptr<const CommunicationPatternBase>()) override;
673 
677  virtual Number
678  operator*(const VectorSpaceVector<Number> &V) const override;
679 
683  virtual void
684  add(const Number a) override;
685 
689  virtual void
690  add(const Number a, const VectorSpaceVector<Number> &V) override;
691 
695  virtual void
696  add(const Number a,
697  const VectorSpaceVector<Number> &V,
698  const Number b,
699  const VectorSpaceVector<Number> &W) override;
700 
705  virtual void
706  add(const std::vector<size_type> &indices,
707  const std::vector<Number> & values);
708 
713  virtual void
714  sadd(const Number s,
715  const Number a,
716  const VectorSpaceVector<Number> &V) override;
717 
723  virtual void
724  scale(const VectorSpaceVector<Number> &scaling_factors) override;
725 
729  virtual void
730  equ(const Number a, const VectorSpaceVector<Number> &V) override;
731 
736  virtual real_type
737  l1_norm() const override;
738 
743  virtual real_type
744  l2_norm() const override;
745 
749  real_type
750  norm_sqr() const;
751 
756  virtual real_type
757  linfty_norm() const override;
758 
779  virtual Number
780  add_and_dot(const Number a,
781  const VectorSpaceVector<Number> &V,
782  const VectorSpaceVector<Number> &W) override;
783 
788  virtual size_type
789  size() const override;
790 
802  virtual ::IndexSet
803  locally_owned_elements() const override;
804 
808  virtual void
809  print(std::ostream & out,
810  const unsigned int precision = 3,
811  const bool scientific = true,
812  const bool across = true) const override;
813 
817  virtual std::size_t
818  memory_consumption() const override;
820 
825 
832  operator=(const Number s) override;
833 
838  template <typename OtherNumber>
839  void
840  add(const std::vector<size_type> & indices,
841  const ::Vector<OtherNumber> &values);
842 
847  template <typename OtherNumber>
848  void
849  add(const size_type n_elements,
850  const size_type * indices,
851  const OtherNumber *values);
852 
857  void
858  sadd(const Number s, const Vector<Number, MemorySpace> &V);
859 
865  DEAL_II_DEPRECATED
866  void
867  sadd(const Number s,
868  const Number a,
870  const Number b,
871  const Vector<Number, MemorySpace> &W);
872 
878  DEAL_II_DEPRECATED
879  void
880  equ(const Number a,
882  const Number b,
883  const Vector<Number, MemorySpace> &v);
884 
886 
887 
892 
897  size_type
898  local_size() const;
899 
907  DEAL_II_DEPRECATED
908  std::pair<size_type, size_type>
909  local_range() const;
910 
917  DEAL_II_DEPRECATED
918  bool
919  in_local_range(const size_type global_index) const;
920 
926  DEAL_II_DEPRECATED
927  size_type
928  n_ghost_entries() const;
929 
937  DEAL_II_DEPRECATED
938  const IndexSet &
939  ghost_elements() const;
940 
948  DEAL_II_DEPRECATED
949  bool
950  is_ghost_entry(const types::global_dof_index global_index) const;
951 
962  iterator
963  begin();
964 
972  const_iterator
973  begin() const;
974 
982  iterator
983  end();
984 
992  const_iterator
993  end() const;
994 
1004  Number
1005  operator()(const size_type global_index) const;
1006 
1016  Number &
1017  operator()(const size_type global_index);
1018 
1026  Number operator[](const size_type global_index) const;
1034  Number &operator[](const size_type global_index);
1035 
1044  Number
1045  local_element(const size_type local_index) const;
1046 
1055  Number &
1056  local_element(const size_type local_index);
1057 
1064  Number *
1065  get_values() const;
1066 
1084  template <typename OtherNumber>
1085  void
1086  extract_subvector_to(const std::vector<size_type> &indices,
1087  std::vector<OtherNumber> & values) const;
1088 
1116  template <typename ForwardIterator, typename OutputIterator>
1117  void
1118  extract_subvector_to(ForwardIterator indices_begin,
1119  const ForwardIterator indices_end,
1120  OutputIterator values_begin) const;
1126  virtual bool
1127  all_zero() const override;
1128 
1132  virtual Number
1133  mean_value() const override;
1134 
1139  real_type
1140  lp_norm(const real_type p) const;
1142 
1147 
1152  const MPI_Comm &
1153  get_mpi_communicator() const;
1154 
1161  const std::shared_ptr<const Utilities::MPI::Partitioner> &
1162  get_partitioner() const;
1163 
1173  bool
1175  const Utilities::MPI::Partitioner &part) const;
1176 
1190  bool
1192  const Utilities::MPI::Partitioner &part) const;
1193 
1197  void
1198  set_ghost_state(const bool ghosted) const;
1199 
1201 
1208 
1215 
1220  Number,
1221  Number,
1222  unsigned int,
1223  << "Called compress(VectorOperation::insert), but"
1224  << " the element received from a remote processor, value "
1225  << std::setprecision(16) << arg1
1226  << ", does not match with the value "
1227  << std::setprecision(16) << arg2
1228  << " on the owner processor " << arg3);
1229 
1234  size_type,
1235  size_type,
1236  size_type,
1237  size_type,
1238  << "You tried to access element " << arg1
1239  << " of a distributed vector, but this element is not "
1240  << "stored on the current processor. Note: The range of "
1241  << "locally owned elements is " << arg2 << " to " << arg3
1242  << ", and there are " << arg4 << " ghost elements "
1243  << "that this vector can access.");
1244 
1245  private:
1250  void
1251  add_local(const Number a, const VectorSpaceVector<Number> &V);
1252 
1257  void
1258  sadd_local(const Number s,
1259  const Number a,
1260  const VectorSpaceVector<Number> &V);
1261 
1265  template <typename Number2>
1266  Number
1268 
1272  real_type
1273  norm_sqr_local() const;
1274 
1278  Number
1279  mean_value_local() const;
1280 
1284  real_type
1285  l1_norm_local() const;
1286 
1290  real_type
1291  lp_norm_local(const real_type p) const;
1292 
1296  real_type
1297  linfty_norm_local() const;
1298 
1304  Number
1305  add_and_dot_local(const Number a,
1306  const Vector<Number, MemorySpace> &V,
1307  const Vector<Number, MemorySpace> &W);
1308 
1314  std::shared_ptr<const Utilities::MPI::Partitioner> partitioner;
1315 
1319  size_type allocated_size;
1320 
1324  mutable ::MemorySpace::MemorySpaceData<Number, MemorySpace> data;
1325 
1330  mutable std::shared_ptr<::parallel::internal::TBBPartitioner>
1332 
1338  mutable ::MemorySpace::MemorySpaceData<Number, MemorySpace>
1340 
1348  mutable bool vector_is_ghosted;
1349 
1350 #ifdef DEAL_II_WITH_MPI
1351 
1359  std::vector<MPI_Request> compress_requests;
1360 
1365  mutable std::vector<MPI_Request> update_ghost_values_requests;
1366 #endif
1367 
1374 
1379  void
1381 
1385  void
1386  resize_val(const size_type new_allocated_size);
1387 
1388  /*
1389  * Make all other vector types friends.
1390  */
1391  template <typename Number2, typename MemorySpace2>
1392  friend class Vector;
1393 
1397  template <typename Number2>
1398  friend class BlockVector;
1399  };
1403  /*-------------------- Inline functions ---------------------------------*/
1404 
1405 #ifndef DOXYGEN
1406 
1407  namespace internal
1408  {
1409  template <typename Number, typename MemorySpace>
1410  struct Policy
1411  {
1412  static inline typename Vector<Number, MemorySpace>::iterator
1414  {
1415  return nullptr;
1416  }
1417 
1418  static inline typename Vector<Number, MemorySpace>::const_iterator
1419  begin(
1420  const ::MemorySpace::MemorySpaceData<Number, MemorySpace> &)
1421  {
1422  return nullptr;
1423  }
1424 
1425  static inline Number *
1426  get_values(
1428  {
1429  return nullptr;
1430  }
1431  };
1432 
1433 
1434 
1435  template <typename Number>
1436  struct Policy<Number, ::MemorySpace::Host>
1437  {
1438  static inline
1439  typename Vector<Number, ::MemorySpace::Host>::iterator
1440  begin(::MemorySpace::
1441  MemorySpaceData<Number, ::MemorySpace::Host> &data)
1442  {
1443  return data.values.get();
1444  }
1445 
1446  static inline
1447  typename Vector<Number, ::MemorySpace::Host>::const_iterator
1448  begin(const ::MemorySpace::
1449  MemorySpaceData<Number, ::MemorySpace::Host> &data)
1450  {
1451  return data.values.get();
1452  }
1453 
1454  static inline Number *
1455  get_values(::MemorySpace::
1456  MemorySpaceData<Number, ::MemorySpace::Host> &data)
1457  {
1458  return data.values.get();
1459  }
1460  };
1461 
1462 
1463 
1464  template <typename Number>
1465  struct Policy<Number, ::MemorySpace::CUDA>
1466  {
1467  static inline
1468  typename Vector<Number, ::MemorySpace::CUDA>::iterator
1469  begin(::MemorySpace::
1470  MemorySpaceData<Number, ::MemorySpace::CUDA> &data)
1471  {
1472  return data.values_dev.get();
1473  }
1474 
1475  static inline
1476  typename Vector<Number, ::MemorySpace::CUDA>::const_iterator
1477  begin(const ::MemorySpace::
1478  MemorySpaceData<Number, ::MemorySpace::CUDA> &data)
1479  {
1480  return data.values_dev.get();
1481  }
1482 
1483  static inline Number *
1484  get_values(::MemorySpace::
1485  MemorySpaceData<Number, ::MemorySpace::CUDA> &data)
1486  {
1487  return data.values_dev.get();
1488  }
1489  };
1490  } // namespace internal
1491 
1492 
1493  template <typename Number, typename MemorySpace>
1494  inline bool
1496  {
1497  return vector_is_ghosted;
1498  }
1499 
1500 
1501 
1502  template <typename Number, typename MemorySpace>
1503  inline typename Vector<Number, MemorySpace>::size_type
1505  {
1506  return partitioner->size();
1507  }
1508 
1509 
1510 
1511  template <typename Number, typename MemorySpace>
1512  inline typename Vector<Number, MemorySpace>::size_type
1514  {
1515  return partitioner->local_size();
1516  }
1517 
1518 
1519 
1520  template <typename Number, typename MemorySpace>
1521  inline std::pair<typename Vector<Number, MemorySpace>::size_type,
1522  typename Vector<Number, MemorySpace>::size_type>
1524  {
1525  return partitioner->local_range();
1526  }
1527 
1528 
1529 
1530  template <typename Number, typename MemorySpace>
1531  inline bool
1533  const size_type global_index) const
1534  {
1535  return partitioner->in_local_range(global_index);
1536  }
1537 
1538 
1539 
1540  template <typename Number, typename MemorySpace>
1541  inline IndexSet
1543  {
1544  IndexSet is(size());
1545 
1546  is.add_range(partitioner->local_range().first,
1547  partitioner->local_range().second);
1548 
1549  return is;
1550  }
1551 
1552 
1553 
1554  template <typename Number, typename MemorySpace>
1555  inline typename Vector<Number, MemorySpace>::size_type
1557  {
1558  return partitioner->n_ghost_indices();
1559  }
1560 
1561 
1562 
1563  template <typename Number, typename MemorySpace>
1564  inline const IndexSet &
1566  {
1567  return partitioner->ghost_indices();
1568  }
1569 
1570 
1571 
1572  template <typename Number, typename MemorySpace>
1573  inline bool
1575  const size_type global_index) const
1576  {
1577  return partitioner->is_ghost_entry(global_index);
1578  }
1579 
1580 
1581 
1582  template <typename Number, typename MemorySpace>
1583  inline typename Vector<Number, MemorySpace>::iterator
1585  {
1586  return internal::Policy<Number, MemorySpace>::begin(data);
1587  }
1588 
1589 
1590 
1591  template <typename Number, typename MemorySpace>
1592  inline typename Vector<Number, MemorySpace>::const_iterator
1594  {
1595  return internal::Policy<Number, MemorySpace>::begin(data);
1596  }
1597 
1598 
1599 
1600  template <typename Number, typename MemorySpace>
1601  inline typename Vector<Number, MemorySpace>::iterator
1603  {
1604  return internal::Policy<Number, MemorySpace>::begin(data) +
1605  partitioner->local_size();
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  partitioner->local_size();
1616  }
1617 
1618 
1619 
1620  template <typename Number, typename MemorySpace>
1621  inline Number
1622  Vector<Number, MemorySpace>::operator()(const size_type global_index) const
1623  {
1624  Assert((std::is_same<MemorySpace, ::MemorySpace::Host>::value),
1625  ExcMessage(
1626  "This function is only implemented for the Host memory space"));
1627  Assert(
1628  partitioner->in_local_range(global_index) ||
1629  partitioner->ghost_indices().is_element(global_index),
1630  ExcAccessToNonLocalElement(global_index,
1631  partitioner->local_range().first,
1632  partitioner->local_range().second,
1633  partitioner->ghost_indices().n_elements()));
1634  // do not allow reading a vector which is not in ghost mode
1635  Assert(partitioner->in_local_range(global_index) ||
1636  vector_is_ghosted == true,
1637  ExcMessage("You tried to read a ghost element of this vector, "
1638  "but it has not imported its ghost values."));
1639  return data.values[partitioner->global_to_local(global_index)];
1640  }
1641 
1642 
1643 
1644  template <typename Number, typename MemorySpace>
1645  inline Number &
1646  Vector<Number, MemorySpace>::operator()(const size_type global_index)
1647  {
1648  Assert((std::is_same<MemorySpace, ::MemorySpace::Host>::value),
1649  ExcMessage(
1650  "This function is only implemented for the Host memory space"));
1651  Assert(
1652  partitioner->in_local_range(global_index) ||
1653  partitioner->ghost_indices().is_element(global_index),
1654  ExcAccessToNonLocalElement(global_index,
1655  partitioner->local_range().first,
1656  partitioner->local_range().second,
1657  partitioner->ghost_indices().n_elements()));
1658  // we would like to prevent reading ghosts from a vector that does not
1659  // have them imported, but this is not possible because we might be in a
1660  // part of the code where the vector has enabled ghosts but is non-const
1661  // (then, the compiler picks this method according to the C++ rule book
1662  // even if a human would pick the const method when this subsequent use
1663  // is just a read)
1664  return data.values[partitioner->global_to_local(global_index)];
1665  }
1666 
1667 
1668 
1669  template <typename Number, typename MemorySpace>
1670  inline Number Vector<Number, MemorySpace>::
1671  operator[](const size_type global_index) const
1672  {
1673  return operator()(global_index);
1674  }
1675 
1676 
1677 
1678  template <typename Number, typename MemorySpace>
1679  inline Number &Vector<Number, MemorySpace>::
1680  operator[](const size_type global_index)
1681  {
1682  return operator()(global_index);
1683  }
1684 
1685 
1686 
1687  template <typename Number, typename MemorySpace>
1688  inline Number
1690  const size_type local_index) const
1691  {
1692  Assert((std::is_same<MemorySpace, ::MemorySpace::Host>::value),
1693  ExcMessage(
1694  "This function is only implemented for the Host memory space"));
1695  AssertIndexRange(local_index,
1696  partitioner->local_size() +
1697  partitioner->n_ghost_indices());
1698  // do not allow reading a vector which is not in ghost mode
1699  Assert(local_index < local_size() || vector_is_ghosted == true,
1700  ExcMessage("You tried to read a ghost element of this vector, "
1701  "but it has not imported its ghost values."));
1702 
1703  return data.values[local_index];
1704  }
1705 
1706 
1707 
1708  template <typename Number, typename MemorySpace>
1709  inline Number &
1710  Vector<Number, MemorySpace>::local_element(const size_type local_index)
1711  {
1712  Assert((std::is_same<MemorySpace, ::MemorySpace::Host>::value),
1713  ExcMessage(
1714  "This function is only implemented for the Host memory space"));
1715 
1716  AssertIndexRange(local_index,
1717  partitioner->local_size() +
1718  partitioner->n_ghost_indices());
1719 
1720  return data.values[local_index];
1721  }
1722 
1723 
1724 
1725  template <typename Number, typename MemorySpace>
1726  inline Number *
1728  {
1729  return internal::Policy<Number, MemorySpace>::get_values(data);
1730  }
1731 
1732 
1733 
1734  template <typename Number, typename MemorySpace>
1735  template <typename OtherNumber>
1736  inline void
1738  const std::vector<size_type> &indices,
1739  std::vector<OtherNumber> & values) const
1740  {
1741  for (size_type i = 0; i < indices.size(); ++i)
1742  values[i] = operator()(indices[i]);
1743  }
1744 
1745 
1746 
1747  template <typename Number, typename MemorySpace>
1748  template <typename ForwardIterator, typename OutputIterator>
1749  inline void
1751  ForwardIterator indices_begin,
1752  const ForwardIterator indices_end,
1753  OutputIterator values_begin) const
1754  {
1755  while (indices_begin != indices_end)
1756  {
1757  *values_begin = operator()(*indices_begin);
1758  indices_begin++;
1759  values_begin++;
1760  }
1761  }
1762 
1763 
1764 
1765  template <typename Number, typename MemorySpace>
1766  template <typename OtherNumber>
1767  inline void
1769  const std::vector<size_type> & indices,
1770  const ::Vector<OtherNumber> &values)
1771  {
1772  AssertDimension(indices.size(), values.size());
1773  for (size_type i = 0; i < indices.size(); ++i)
1774  {
1775  Assert(
1776  numbers::is_finite(values[i]),
1777  ExcMessage(
1778  "The given value is not finite but either infinite or Not A Number (NaN)"));
1779  this->operator()(indices[i]) += values(i);
1780  }
1781  }
1782 
1783 
1784 
1785  template <typename Number, typename MemorySpace>
1786  template <typename OtherNumber>
1787  inline void
1788  Vector<Number, MemorySpace>::add(const size_type n_elements,
1789  const size_type * indices,
1790  const OtherNumber *values)
1791  {
1792  for (size_type i = 0; i < n_elements; ++i, ++indices, ++values)
1793  {
1794  Assert(
1795  numbers::is_finite(*values),
1796  ExcMessage(
1797  "The given value is not finite but either infinite or Not A Number (NaN)"));
1798  this->operator()(*indices) += *values;
1799  }
1800  }
1801 
1802 
1803 
1804  template <typename Number, typename MemorySpace>
1805  inline const MPI_Comm &
1807  {
1808  return partitioner->get_mpi_communicator();
1809  }
1810 
1811 
1812 
1813  template <typename Number, typename MemorySpace>
1814  inline const std::shared_ptr<const Utilities::MPI::Partitioner> &
1816  {
1817  return partitioner;
1818  }
1819 
1820 
1821 
1822  template <typename Number, typename MemorySpace>
1823  inline void
1824  Vector<Number, MemorySpace>::set_ghost_state(const bool ghosted) const
1825  {
1826  vector_is_ghosted = ghosted;
1827  }
1828 
1829 #endif
1830 
1831  } // namespace distributed
1832 } // namespace LinearAlgebra
1833 
1834 
1843 template <typename Number, typename MemorySpace>
1844 inline void
1847 {
1848  u.swap(v);
1849 }
1850 
1851 
1857 template <typename Number, typename MemorySpace>
1859  : std::false_type
1860 {};
1861 
1862 
1863 
1864 namespace internal
1865 {
1866  namespace LinearOperatorImplementation
1867  {
1868  template <typename>
1869  class ReinitHelper;
1870 
1875  template <typename Number>
1877  {
1878  public:
1879  template <typename Matrix>
1880  static void
1881  reinit_range_vector(const Matrix & matrix,
1883  bool omit_zeroing_entries)
1884  {
1885  matrix.initialize_dof_vector(v);
1886  if (!omit_zeroing_entries)
1887  v = Number();
1888  }
1889 
1890  template <typename Matrix>
1891  static void
1892  reinit_domain_vector(const Matrix & matrix,
1894  bool omit_zeroing_entries)
1895  {
1896  matrix.initialize_dof_vector(v);
1897  if (!omit_zeroing_entries)
1898  v = Number();
1899  }
1900  };
1901 
1902  } // namespace LinearOperatorImplementation
1903 } /* namespace internal */
1904 
1905 
1906 DEAL_II_NAMESPACE_CLOSE
1907 
1908 #endif
virtual std::size_t memory_consumption() const override
void copy_locally_owned_data_from(const Vector< Number2, MemorySpace > &src)
bool in_local_range(const size_type global_index) const
void resize_val(const size_type new_allocated_size)
#define AssertDimension(dim1, dim2)
Definition: exceptions.h:1567
virtual real_type l1_norm() const override
static ::ExceptionBase & ExcNotAllowedForCuda()
std::vector< MPI_Request > update_ghost_values_requests
void sadd_local(const Number s, const Number a, const VectorSpaceVector< Number > &V)
static ::ExceptionBase & ExcVectorTypeNotCompatible()
real_type lp_norm_local(const real_type p) const
virtual Vector< Number, MemorySpace > & operator+=(const VectorSpaceVector< Number > &V) override
virtual Vector< Number, MemorySpace > & operator-=(const VectorSpaceVector< Number > &V) override
void add_local(const Number a, const VectorSpaceVector< Number > &V)
std::shared_ptr< const Utilities::MPI::Partitioner > partitioner
#define AssertIndexRange(index, range)
Definition: exceptions.h:1637
virtual void print(std::ostream &out, const unsigned int precision=3, const bool scientific=true, const bool across=true) const override
virtual void scale(const VectorSpaceVector< Number > &scaling_factors) override
void reinit(const size_type size, const bool omit_zeroing_entries=false)
bool partitioners_are_compatible(const Utilities::MPI::Partitioner &part) const
real_type lp_norm(const real_type p) const
LinearAlgebra::distributed::Vector< Number > Vector
static void reinit_range_vector(const Matrix &matrix, Vector &v, bool omit_zeroing_entries)
bool is_finite(const double x)
Definition: numbers.h:463
bool is_ghost_entry(const types::global_dof_index global_index) const
bool partitioners_are_globally_compatible(const Utilities::MPI::Partitioner &part) const
Number add_and_dot_local(const Number a, const Vector< Number, MemorySpace > &V, const Vector< Number, MemorySpace > &W)
static void reinit_domain_vector(const Matrix &matrix, Vector &v, bool omit_zeroing_entries)
Number local_element(const size_type local_index) const
void set_ghost_state(const bool ghosted) const
static ::ExceptionBase & ExcMessage(std::string arg1)
virtual void compress(::VectorOperation::values operation) override
Number inner_product_local(const Vector< Number2, MemorySpace > &V) const
#define Assert(cond, exc)
Definition: exceptions.h:1407
#define DeclException0(Exception0)
Definition: exceptions.h:473
std::shared_ptr<::parallel::internal::TBBPartitioner > thread_loop_partitioner
virtual bool all_zero() const override
mutable ::MemorySpace::MemorySpaceData< Number, MemorySpace > import_data
mutable ::MemorySpace::MemorySpaceData< Number, MemorySpace > data
virtual Number operator*(const VectorSpaceVector< Number > &V) const override
void compress_finish(::VectorOperation::values operation)
void update_ghost_values_start(const unsigned int communication_channel=0) const
static ::ExceptionBase & ExcAccessToNonLocalElement(size_type arg1, size_type arg2, size_type arg3, size_type arg4)
static ::ExceptionBase & ExcNonMatchingElements(Number arg1, Number arg2, unsigned int arg3)
unsigned int global_dof_index
Definition: types.h:89
Vector< Number, MemorySpace > & operator=(const Vector< Number, MemorySpace > &in_vector)
virtual ::IndexSet locally_owned_elements() const override
virtual size_type size() const override
virtual void equ(const Number a, const VectorSpaceVector< Number > &V) override
void compress_start(const unsigned int communication_channel=0, ::VectorOperation::values operation=VectorOperation::add)
std::pair< size_type, size_type > local_range() const
virtual real_type l2_norm() const override
void swap(Vector< Number, MemorySpace > &v)
virtual real_type linfty_norm() const override
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
virtual Vector< Number, MemorySpace > & operator*=(const Number factor) override
std::vector< MPI_Request > compress_requests
virtual Number mean_value() const override
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
virtual Vector< Number, MemorySpace > & operator/=(const Number factor) override
virtual Number add_and_dot(const Number a, const VectorSpaceVector< Number > &V, const VectorSpaceVector< Number > &W) override
virtual void sadd(const Number s, const Number a, const VectorSpaceVector< Number > &V) override