Reference documentation for deal.II version GIT 29f9da0a34 2023-12-07 10:00:01+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\}}\)
mg_transfer_global_coarsening.h
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2020 - 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_mg_transfer_global_coarsening_h
17 #define dealii_mg_transfer_global_coarsening_h
18 
22 
24 
27 
30 
33 
35 
36 
37 
39 
40 // Forward declarations
41 #ifndef DOXYGEN
42 namespace internal
43 {
44  class MGTwoLevelTransferImplementation;
45 }
46 
48 {
49  template <int dim, int spacedim>
50  class Base;
51 }
52 
53 template <int dim, typename Number>
54 class MGTransferMF;
55 #endif
56 
57 
58 namespace mg
59 {
71  {
77  boost::signals2::signal<void(const bool before)> prolongation_cell_loop;
78 
84  boost::signals2::signal<void(const bool before)> restriction_cell_loop;
85 
93  boost::signals2::signal<void(const bool before)> prolongation;
94 
102  boost::signals2::signal<void(const bool before)> restriction;
103  };
104 } // namespace mg
105 
110 {
119  {
124  bisect,
134  go_to_one
135  };
136 
141  unsigned int
143  const unsigned int degree,
144  const PolynomialCoarseningSequenceType &p_sequence);
145 
151  std::vector<unsigned int>
153  const unsigned int max_degree,
154  const PolynomialCoarseningSequenceType &p_sequence);
155 
166  template <int dim, int spacedim>
167  std::vector<std::shared_ptr<const Triangulation<dim, spacedim>>>
170 
187  template <int dim, int spacedim>
188  std::vector<std::shared_ptr<const Triangulation<dim, spacedim>>>
192  const bool preserve_fine_triangulation,
193  const bool repartition_fine_triangulation);
194 
200  template <int dim, int spacedim>
201  std::vector<std::shared_ptr<const Triangulation<dim, spacedim>>>
205  const bool repartition_fine_triangulation = false);
206 
207 } // namespace MGTransferGlobalCoarseningTools
208 
209 
213 template <typename VectorType>
215 {
216 public:
220  virtual void
221  prolongate_and_add(VectorType &dst, const VectorType &src) const = 0;
222 
226  virtual void
227  restrict_and_add(VectorType &dst, const VectorType &src) const = 0;
228 
235  virtual void
236  interpolate(VectorType &dst, const VectorType &src) const = 0;
237 
242  virtual void
244  const std::shared_ptr<const Utilities::MPI::Partitioner>
245  &partitioner_coarse,
246  const std::shared_ptr<const Utilities::MPI::Partitioner>
247  &partitioner_fine) = 0;
248 
252  virtual std::size_t
253  memory_consumption() const = 0;
254 };
255 
256 
264 template <typename Number>
266  : public Subscriptor
267 {
268 public:
270 
275 
279  void
280  prolongate_and_add(VectorType &dst, const VectorType &src) const;
281 
285  void
286  restrict_and_add(VectorType &dst, const VectorType &src) const;
287 
292  virtual void
293  interpolate(VectorType &dst, const VectorType &src) const = 0;
294 
299  virtual void
301  const std::shared_ptr<const Utilities::MPI::Partitioner>
302  &partitioner_coarse,
303  const std::shared_ptr<const Utilities::MPI::Partitioner>
304  &partitioner_fine) = 0;
305 
309  virtual std::size_t
310  memory_consumption() const = 0;
311 
312 protected:
316  virtual void
319  const LinearAlgebra::distributed::Vector<Number> &src) const = 0;
320 
324  virtual void
327  const LinearAlgebra::distributed::Vector<Number> &src) const = 0;
328 
334  void
337 
343  void
345  const VectorOperation::values op) const;
346 
352  void
355 
360  template <int dim, std::size_t width>
361  void
363  const std::shared_ptr<const Utilities::MPI::Partitioner>
364  &partitioner_coarse,
365  const std::shared_ptr<const Utilities::MPI::Partitioner> &partitioner_fine,
366  bool &vec_fine_needs_ghost_update,
368  dim,
369  VectorizedArray<Number, width>> &constraint_info_coarse,
370  std::vector<unsigned int> &dof_indices_fine);
371 
378 
379 public:
383  std::shared_ptr<const Utilities::MPI::Partitioner> partitioner_coarse;
384 
388  std::shared_ptr<const Utilities::MPI::Partitioner> partitioner_fine;
389 
390 protected:
395 
404 
409 
414  std::shared_ptr<const Utilities::MPI::Partitioner>
416 
421  std::shared_ptr<const Utilities::MPI::Partitioner> partitioner_fine_embedded;
422 
428 
434 };
435 
436 
437 
443 template <int dim, typename VectorType>
444 class MGTwoLevelTransfer : public MGTwoLevelTransferBase<VectorType>
445 {
446 public:
450  void
451  prolongate_and_add(VectorType &dst, const VectorType &src) const override;
452 
456  void
457  restrict_and_add(VectorType &dst, const VectorType &src) const override;
458 
463  void
464  interpolate(VectorType &dst, const VectorType &src) const override;
465 
470  void
472  const std::shared_ptr<const Utilities::MPI::Partitioner>
473  &partitioner_coarse,
474  const std::shared_ptr<const Utilities::MPI::Partitioner> &partitioner_fine)
475  override;
476 
480  std::size_t
481  memory_consumption() const override;
482 };
483 
484 
485 
492 template <int dim, typename Number>
494  : public MGTwoLevelTransferBase<LinearAlgebra::distributed::Vector<Number>>
495 {
497 
498 public:
504  void
506  const DoFHandler<dim> &dof_handler_fine,
507  const DoFHandler<dim> &dof_handler_coarse,
508  const AffineConstraints<Number> &constraint_fine =
510  const AffineConstraints<Number> &constraint_coarse =
512  const unsigned int mg_level_fine = numbers::invalid_unsigned_int,
513  const unsigned int mg_level_coarse = numbers::invalid_unsigned_int);
514 
524  void
526  const DoFHandler<dim> &dof_handler_fine,
527  const DoFHandler<dim> &dof_handler_coarse,
528  const AffineConstraints<Number> &constraint_fine =
530  const AffineConstraints<Number> &constraint_coarse =
532  const unsigned int mg_level_fine = numbers::invalid_unsigned_int,
533  const unsigned int mg_level_coarse = numbers::invalid_unsigned_int);
534 
548  void
549  reinit(const DoFHandler<dim> &dof_handler_fine,
550  const DoFHandler<dim> &dof_handler_coarse,
551  const AffineConstraints<Number> &constraint_fine =
553  const AffineConstraints<Number> &constraint_coarse =
555  const unsigned int mg_level_fine = numbers::invalid_unsigned_int,
556  const unsigned int mg_level_coarse = numbers::invalid_unsigned_int);
557 
566  static bool
567  fast_polynomial_transfer_supported(const unsigned int fe_degree_fine,
568  const unsigned int fe_degree_coarse);
569 
574  void
577  const LinearAlgebra::distributed::Vector<Number> &src) const override;
578 
583  void
585  const std::shared_ptr<const Utilities::MPI::Partitioner>
586  &partitioner_coarse,
587  const std::shared_ptr<const Utilities::MPI::Partitioner> &partitioner_fine)
588  override;
589 
593  std::size_t
594  memory_consumption() const override;
595 
596 protected:
597  void
600  const LinearAlgebra::distributed::Vector<Number> &src) const override;
601 
602  void
605  const LinearAlgebra::distributed::Vector<Number> &src) const override;
606 
607 private:
615  struct MGTransferScheme
616  {
620  unsigned int n_coarse_cells;
621 
629 
636  unsigned int n_dofs_per_cell_fine;
637 
641  unsigned int degree_coarse;
642 
648  unsigned int degree_fine;
649 
654 
659 
664 
669 
676  };
677 
681  std::vector<MGTransferScheme> schemes;
682 
689 
695 
699  std::vector<Number> weights; // TODO: vectorize
700 
706 
710  unsigned int n_components;
711 
716 
720  unsigned int mg_level_fine;
721 
722  friend class internal::MGTwoLevelTransferImplementation;
723 
724  friend class MGTransferMF<dim, Number>;
725 };
726 
727 
728 
733 template <int dim, typename VectorType>
735 {
736 public:
740  void
741  prolongate_and_add(VectorType &dst, const VectorType &src) const override;
742 
746  void
747  restrict_and_add(VectorType &dst, const VectorType &src) const override;
748 
755  void
756  interpolate(VectorType &dst, const VectorType &src) const override;
757 
761  std::size_t
762  memory_consumption() const override;
763 };
764 
765 
766 
773 template <int dim, typename Number>
776  : public MGTwoLevelTransferBase<LinearAlgebra::distributed::Vector<Number>>
777 {
778 private:
780 
782 
783 public:
790  struct AdditionalData
791  {
801  AdditionalData(const double tolerance = 1e-6,
802  const unsigned int rtree_level = 0,
803  const bool enforce_all_points_found = true)
804  : tolerance(tolerance)
805  , rtree_level(rtree_level)
806  , enforce_all_points_found(enforce_all_points_found)
807  {}
808 
813  double tolerance;
814 
820  unsigned int rtree_level;
821 
830  };
831 
832  MGTwoLevelTransferNonNested(const AdditionalData &data = AdditionalData());
833 
838  void
839  reinit(const DoFHandler<dim> &dof_handler_fine,
840  const DoFHandler<dim> &dof_handler_coarse,
841  const Mapping<dim> &mapping_fine,
842  const Mapping<dim> &mapping_coarse,
843  const AffineConstraints<Number> &constraint_fine =
845  const AffineConstraints<Number> &constraint_coarse =
847 
854  void
857  const LinearAlgebra::distributed::Vector<Number> &src) const override;
858 
863  void
865  const std::shared_ptr<const Utilities::MPI::Partitioner>
866  &partitioner_coarse,
867  const std::shared_ptr<const Utilities::MPI::Partitioner> &partitioner_fine)
868  override;
869 
873  std::size_t
874  memory_consumption() const override;
875 
879  boost::signals2::connection
880  connect_prolongation_cell_loop(const std::function<void(const bool)> &slot);
881 
885  boost::signals2::connection
886  connect_restriction_cell_loop(const std::function<void(const bool)> &slot);
887 
891  boost::signals2::connection
892  connect_prolongation(const std::function<void(const bool)> &slot);
893 
897  boost::signals2::connection
898  connect_restriction(const std::function<void(const bool)> &slot);
899 
900 protected:
901  AdditionalData additional_data;
905  void
908  const LinearAlgebra::distributed::Vector<Number> &src) const override;
909 
913  void
916  const LinearAlgebra::distributed::Vector<Number> &src) const override;
917 
918 private:
922  template <int n_components>
923  void
927 
931  template <int n_components>
932  void
936 
941 
945  unsigned int mg_level_fine;
946 
952 
956  std::shared_ptr<NonMatching::MappingInfo<dim, dim, Number>> mapping_info;
957 
964 
968  std::unique_ptr<FiniteElement<dim>> fe_coarse;
969 
974  std::vector<unsigned int> level_dof_indices_fine;
975 
981  std::vector<unsigned int> level_dof_indices_fine_ptrs;
982 
983  friend class MGTransferMF<dim, Number>;
984 };
985 
986 
987 
1016 template <int dim, typename Number>
1018  LinearAlgebra::distributed::Vector<Number>>
1019 {
1020 public:
1025 
1032 
1047  template <typename MGTwoLevelTransferObject>
1049  const std::function<void(const unsigned int, VectorType &)>
1050  &initialize_dof_vector = {});
1051 
1055  template <typename MGTwoLevelTransferObject>
1056  void
1059 
1068  void
1069  build(const std::vector<std::shared_ptr<const Utilities::MPI::Partitioner>>
1070  &external_partitioners = {});
1071 
1076  void
1077  build(const std::function<void(const unsigned int, VectorType &)>
1079 
1094 
1100  void
1102 
1119  void
1120  build(const DoFHandler<dim> &dof_handler,
1121  const std::vector<std::shared_ptr<const Utilities::MPI::Partitioner>>
1122  &external_partitioners = {});
1123 
1133  void
1134  build(const DoFHandler<dim> &dof_handler,
1135  const std::function<void(const unsigned int, VectorType &)>
1137 
1148  void
1149  prolongate(const unsigned int to_level,
1150  VectorType &dst,
1151  const VectorType &src) const override;
1152 
1156  void
1157  prolongate_and_add(const unsigned int to_level,
1158  VectorType &dst,
1159  const VectorType &src) const override;
1160 
1164  virtual void
1165  restrict_and_add(const unsigned int from_level,
1166  VectorType &dst,
1167  const VectorType &src) const override;
1168 
1178  template <class InVector>
1179  void
1180  copy_to_mg(const DoFHandler<dim> &dof_handler,
1182  const InVector &src) const;
1183 
1193  template <class OutVector>
1194  void
1195  copy_from_mg(const DoFHandler<dim> &dof_handler,
1196  OutVector &dst,
1197  const MGLevelObject<VectorType> &src) const;
1198 
1217  template <class InVector>
1218  void
1221  const InVector &src) const;
1222 
1231  template <class InVector>
1232  void
1233  interpolate_to_mg(MGLevelObject<VectorType> &dst, const InVector &src) const;
1234 
1248  std::size_t
1250 
1254  unsigned int
1255  min_level() const;
1256 
1260  unsigned int
1261  max_level() const;
1262 
1267  void
1269 
1272 private:
1278  void
1280  const DoFHandler<dim> &dof_handler,
1282 
1286  std::pair<const DoFHandler<dim> *, unsigned int>
1288 
1294  void
1296  const DoFHandler<dim> &dof_handler);
1297 
1301  template <typename MGTwoLevelTransferObject>
1302  void
1305 
1309  template <class InVector>
1310  void
1311  initialize_dof_vector(const unsigned int level,
1312  VectorType &vector,
1313  const InVector &vector_reference,
1314  const bool omit_zeroing_entries) const;
1315 
1321  void
1322  assert_dof_handler(const DoFHandler<dim> &dof_handler_out) const;
1323 
1330 
1335 
1339  std::vector<std::shared_ptr<const Utilities::MPI::Partitioner>>
1341 };
1342 
1343 
1344 
1350 template <int dim, typename Number>
1352  : public MGTransferBlockMatrixFreeBase<dim, Number, MGTransferMF<dim, Number>>
1353 {
1354 public:
1359 
1365  MGTransferBlockMF() = default;
1366 
1372  MGTransferBlockMF(const MGConstrainedDoFs &mg_constrained_dofs);
1373 
1379  MGTransferBlockMF(const std::vector<MGConstrainedDoFs> &mg_constrained_dofs);
1380 
1386  void
1387  initialize_constraints(const MGConstrainedDoFs &mg_constrained_dofs);
1388 
1394  void
1396  const std::vector<MGConstrainedDoFs> &mg_constrained_dofs);
1397 
1403  void
1404  build(const DoFHandler<dim> &dof_handler);
1405 
1411  void
1412  build(const std::vector<const DoFHandler<dim> *> &dof_handler);
1413 
1414 protected:
1416  get_matrix_free_transfer(const unsigned int b) const override;
1417 
1418 private:
1422  std::vector<MGTransferMF<dim, Number>> transfer_operators_internal;
1423 
1427  std::vector<SmartPointer<const MGTransferMF<dim, Number>>> transfer_operators;
1428 };
1429 
1430 
1431 
1432 template <int dim, typename VectorType>
1435 
1436 template <int dim, typename VectorType>
1439 
1440 
1441 
1442 #ifndef DOXYGEN
1443 
1444 /* ----------------------- Inline functions --------------------------------- */
1445 
1446 
1447 
1448 template <int dim, typename Number>
1449 template <typename MGTwoLevelTransferObject>
1452  const std::function<void(const unsigned int, VectorType &)>
1453  &initialize_dof_vector)
1454 {
1455  this->transfer.clear();
1456  this->internal_transfer.clear();
1457 
1458  this->initialize_transfer_references(transfer);
1459  this->build(initialize_dof_vector);
1460 }
1461 
1462 
1463 
1464 template <int dim, typename Number>
1465 template <typename MGTwoLevelTransferObject>
1466 void
1469 {
1470  this->initialize_transfer_references(transfer);
1471 }
1472 
1473 
1474 
1475 template <int dim, typename Number>
1476 template <typename MGTwoLevelTransferObject>
1477 void
1480 {
1481  const unsigned int min_level = transfer.min_level();
1482  const unsigned int max_level = transfer.max_level();
1483 
1484  this->transfer.resize(min_level, max_level);
1485 
1486  for (unsigned int l = min_level; l <= max_level; ++l)
1487  this->transfer[l] = &const_cast<MGTwoLevelTransferBase<VectorType> &>(
1488  static_cast<const MGTwoLevelTransferBase<VectorType> &>(
1489  Utilities::get_underlying_value(transfer[l])));
1490 }
1491 
1492 
1493 
1494 template <int dim, typename Number>
1495 template <class InVector>
1496 void
1498  const unsigned int level,
1499  VectorType &vec,
1500  const InVector &vec_reference,
1501  const bool omit_zeroing_entries) const
1502 {
1503  std::shared_ptr<const Utilities::MPI::Partitioner> partitioner;
1504 
1505  if (external_partitioners.empty())
1506  {
1507  partitioner = vec_reference.get_partitioner();
1508  }
1509  else
1510  {
1511  Assert(transfer.min_level() <= level && level <= transfer.max_level(),
1512  ExcInternalError());
1513 
1514  partitioner = external_partitioners[level - transfer.min_level()];
1515  }
1516 
1517  // check if vectors are already correctly initialized
1518 
1519  // yes: same partitioners are used
1520  if (vec.get_partitioner().get() == partitioner.get())
1521  {
1522  if (omit_zeroing_entries == false)
1523  vec = 0;
1524  return; // nothing to do
1525  }
1526 
1527  // yes: vectors are compatible
1528  if (vec.size() == partitioner->size() &&
1529  vec.locally_owned_size() == partitioner->locally_owned_size())
1530  {
1531  if (omit_zeroing_entries == false)
1532  vec = 0;
1533  return; // nothing to do
1534  }
1535 
1536  // no
1537  vec.reinit(partitioner, omit_zeroing_entries);
1538 }
1539 
1540 
1541 
1542 template <int dim, typename Number>
1543 template <class InVector>
1544 void
1547  const InVector &src) const
1548 {
1549  assert_dof_handler(dof_handler);
1550 
1551  for (unsigned int level = dst.min_level(); level <= dst.max_level(); ++level)
1552  {
1553  const bool zero_out_values =
1554  (this->perform_plain_copy == false &&
1555  this->perform_renumbered_plain_copy == false) ||
1556  level != dst.max_level();
1557 
1558  this->initialize_dof_vector(level, dst[level], src, !zero_out_values);
1559  }
1560 
1561  if (this->perform_plain_copy)
1562  {
1563  dst[dst.max_level()].copy_locally_owned_data_from(src);
1564  }
1565  else if (this->perform_renumbered_plain_copy)
1566  {
1567  auto &dst_level = dst[dst.max_level()];
1568 
1569  for (unsigned int i = 0; i < this->copy_indices.back().n_cols(); ++i)
1570  dst_level.local_element(this->copy_indices.back()(1, i)) =
1571  src.local_element(i);
1572  }
1573  else
1574  {
1575  this->ghosted_global_vector = src;
1576  this->ghosted_global_vector.update_ghost_values();
1577 
1578  for (unsigned int l = dst.max_level() + 1; l != dst.min_level();)
1579  {
1580  --l;
1581 
1582  auto &dst_level = dst[l];
1583 
1584  const auto copy_unknowns = [&](const auto &indices) {
1585  for (unsigned int i = 0; i < indices.n_cols(); ++i)
1586  dst_level.local_element(indices(1, i)) =
1587  this->ghosted_global_vector.local_element(indices(0, i));
1588  };
1589 
1590  copy_unknowns(this->copy_indices[l]);
1591  copy_unknowns(this->copy_indices_level_mine[l]);
1592 
1593  dst_level.compress(VectorOperation::insert);
1594  }
1595  }
1596 }
1597 
1598 
1599 
1600 template <int dim, typename Number>
1601 template <class OutVector>
1602 void
1604  const DoFHandler<dim> &dof_handler,
1605  OutVector &dst,
1606  const MGLevelObject<VectorType> &src) const
1607 {
1608  assert_dof_handler(dof_handler);
1609 
1610  if (this->perform_plain_copy)
1611  {
1612  dst.zero_out_ghost_values();
1613  dst.copy_locally_owned_data_from(src[src.max_level()]);
1614  }
1615  else if (this->perform_renumbered_plain_copy)
1616  {
1617  const auto &src_level = src[src.max_level()];
1618  dst.zero_out_ghost_values();
1619  for (unsigned int i = 0; i < this->copy_indices.back().n_cols(); ++i)
1620  dst.local_element(i) =
1621  src_level.local_element(this->copy_indices.back()(1, i));
1622  }
1623  else
1624  {
1625  dst = 0;
1626  for (unsigned int l = src.min_level(); l <= src.max_level(); ++l)
1627  {
1628  auto &ghosted_vector = this->ghosted_level_vector[l];
1629 
1630  if (this->ghosted_level_vector[l].size() > 0)
1631  ghosted_vector = src[l];
1632 
1633  const auto *const ghosted_vector_ptr =
1634  (this->ghosted_level_vector[l].size() > 0) ? &ghosted_vector :
1635  &src[l];
1636 
1637  ghosted_vector_ptr->update_ghost_values();
1638 
1639  const auto copy_unknowns = [&](const auto &indices) {
1640  for (unsigned int i = 0; i < indices.n_cols(); ++i)
1641  dst.local_element(indices(0, i)) =
1642  ghosted_vector_ptr->local_element(indices(1, i));
1643  };
1644 
1645  copy_unknowns(this->copy_indices[l]);
1646  copy_unknowns(this->copy_indices_global_mine[l]);
1647  }
1648  dst.compress(VectorOperation::insert);
1649  }
1650 }
1651 
1652 
1653 
1654 template <int dim, typename Number>
1655 template <class InVector>
1656 void
1658  const InVector &src) const
1659 {
1660  DoFHandler<dim> dof_handler_dummy;
1661 
1662  this->interpolate_to_mg(dof_handler_dummy, dst, src);
1663 }
1664 
1665 
1666 
1667 template <int dim, typename Number>
1668 template <class InVector>
1669 void
1672  const InVector &src) const
1673 {
1674  assert_dof_handler(dof_handler);
1675 
1676  const unsigned int min_level = transfer.min_level();
1677  const unsigned int max_level = transfer.max_level();
1678 
1679  AssertDimension(min_level, dst.min_level());
1680  AssertDimension(max_level, dst.max_level());
1681 
1682  for (unsigned int level = min_level; level <= max_level; ++level)
1683  {
1684  const bool zero_out_values = false;
1685  this->initialize_dof_vector(level, dst[level], src, !zero_out_values);
1686  }
1687 
1688  if (this->perform_plain_copy)
1689  {
1690  dst[max_level].copy_locally_owned_data_from(src);
1691 
1692  for (unsigned int l = max_level; l > min_level; --l)
1693  this->transfer[l]->interpolate(dst[l - 1], dst[l]);
1694  }
1695  else if (this->perform_renumbered_plain_copy)
1696  {
1697  auto &dst_level = dst[max_level];
1698 
1699  for (unsigned int i = 0; i < this->solution_copy_indices.back().n_cols();
1700  ++i)
1701  dst_level.local_element(this->solution_copy_indices.back()(1, i)) =
1702  src.local_element(i);
1703 
1704  for (unsigned int l = max_level; l > min_level; --l)
1705  this->transfer[l]->interpolate(dst[l - 1], dst[l]);
1706  }
1707  else
1708  {
1709  this->solution_ghosted_global_vector = src;
1710  this->solution_ghosted_global_vector.update_ghost_values();
1711 
1712  for (unsigned int l = max_level + 1; l != min_level;)
1713  {
1714  --l;
1715 
1716  auto &dst_level = dst[l];
1717 
1718  const auto copy_unknowns = [&](const auto &indices) {
1719  for (unsigned int i = 0; i < indices.n_cols(); ++i)
1720  dst_level.local_element(indices(1, i)) =
1721  this->solution_ghosted_global_vector.local_element(
1722  indices(0, i));
1723  };
1724 
1725  copy_unknowns(this->solution_copy_indices[l]);
1726  copy_unknowns(this->solution_copy_indices_level_mine[l]);
1727 
1728  dst_level.compress(VectorOperation::insert);
1729 
1730  if (l != min_level)
1731  this->transfer[l]->interpolate(dst[l - 1], dst[l]);
1732  }
1733  }
1734 }
1735 
1736 #endif
1737 
1739 
1740 #endif
std::function< void(const unsigned int, LinearAlgebra::distributed::Vector< Number > &)> initialize_dof_vector
Definition: mg_transfer.h:604
void resize(const unsigned int new_minlevel, const unsigned int new_maxlevel, Args &&...args)
unsigned int max_level() const
unsigned int min_level() const
void initialize_constraints(const MGConstrainedDoFs &mg_constrained_dofs)
MGTransferBlockMF(const std::vector< MGConstrainedDoFs > &mg_constrained_dofs)
MGTransferBlockMF(const MGConstrainedDoFs &mg_constrained_dofs)
void build(const std::vector< const DoFHandler< dim > * > &dof_handler)
std::vector< MGTransferMF< dim, Number > > transfer_operators_internal
MGTransferBlockMF(const MGTransferMF< dim, Number > &transfer_operator)
const MGTransferMF< dim, Number > & get_matrix_free_transfer(const unsigned int b) const override
MGTransferBlockMF()=default
void build(const DoFHandler< dim > &dof_handler)
std::vector< SmartPointer< const MGTransferMF< dim, Number > > > transfer_operators
void initialize_constraints(const std::vector< MGConstrainedDoFs > &mg_constrained_dofs)
void copy_to_mg(const DoFHandler< dim > &dof_handler, MGLevelObject< VectorType > &dst, const InVector &src) const
unsigned int min_level() const
void build(const std::function< void(const unsigned int, VectorType &)> &initialize_dof_vector)
void build(const DoFHandler< dim > &dof_handler, const std::vector< std::shared_ptr< const Utilities::MPI::Partitioner >> &external_partitioners={})
void assert_dof_handler(const DoFHandler< dim > &dof_handler_out) const
void interpolate_to_mg(const DoFHandler< dim > &dof_handler, MGLevelObject< VectorType > &dst, const InVector &src) const
std::vector< std::shared_ptr< const Utilities::MPI::Partitioner > > external_partitioners
void prolongate_and_add(const unsigned int to_level, VectorType &dst, const VectorType &src) const override
unsigned int max_level() const
std::pair< const DoFHandler< dim > *, unsigned int > get_dof_handler_fine() const
MGTransferMF(const MGLevelObject< MGTwoLevelTransferObject > &transfer, const std::function< void(const unsigned int, VectorType &)> &initialize_dof_vector={})
void build(const DoFHandler< dim > &dof_handler, const std::function< void(const unsigned int, VectorType &)> &initialize_dof_vector)
void build(const std::vector< std::shared_ptr< const Utilities::MPI::Partitioner >> &external_partitioners={})
void initialize_dof_vector(const unsigned int level, VectorType &vector, const InVector &vector_reference, const bool omit_zeroing_entries) const
void initialize_constraints(const MGConstrainedDoFs &mg_constrained_dofs)
void initialize_internal_transfer(const DoFHandler< dim > &dof_handler, const SmartPointer< const MGConstrainedDoFs > &mg_constrained_dofs)
void initialize_two_level_transfers(const MGLevelObject< MGTwoLevelTransferObject > &transfer)
MGTransferMF(const MGConstrainedDoFs &mg_constrained_dofs)
MGLevelObject< MGTwoLevelTransfer< dim, VectorType > > internal_transfer
void fill_and_communicate_copy_indices_global_coarsening(const DoFHandler< dim > &dof_handler)
MGLevelObject< SmartPointer< MGTwoLevelTransferBase< VectorType > > > transfer
std::size_t memory_consumption() const
virtual void restrict_and_add(const unsigned int from_level, VectorType &dst, const VectorType &src) const override
void initialize_transfer_references(const MGLevelObject< MGTwoLevelTransferObject > &transfer)
void prolongate(const unsigned int to_level, VectorType &dst, const VectorType &src) const override
void copy_from_mg(const DoFHandler< dim > &dof_handler, OutVector &dst, const MGLevelObject< VectorType > &src) const
void interpolate_to_mg(MGLevelObject< VectorType > &dst, const InVector &src) const
void prolongate_and_add(VectorType &dst, const VectorType &src) const
std::shared_ptr< const Utilities::MPI::Partitioner > partitioner_fine_embedded
virtual void enable_inplace_operations_if_possible(const std::shared_ptr< const Utilities::MPI::Partitioner > &partitioner_coarse, const std::shared_ptr< const Utilities::MPI::Partitioner > &partitioner_fine)=0
void compress(LinearAlgebra::distributed::Vector< Number > &vec, const VectorOperation::values op) const
void zero_out_ghost_values(const LinearAlgebra::distributed::Vector< Number > &vec) const
virtual void restrict_and_add_internal(LinearAlgebra::distributed::Vector< Number > &dst, const LinearAlgebra::distributed::Vector< Number > &src) const =0
virtual void interpolate(VectorType &dst, const VectorType &src) const =0
void update_ghost_values(const LinearAlgebra::distributed::Vector< Number > &vec) const
virtual void prolongate_and_add_internal(LinearAlgebra::distributed::Vector< Number > &dst, const LinearAlgebra::distributed::Vector< Number > &src) const =0
void internal_enable_inplace_operations_if_possible(const std::shared_ptr< const Utilities::MPI::Partitioner > &partitioner_coarse, const std::shared_ptr< const Utilities::MPI::Partitioner > &partitioner_fine, bool &vec_fine_needs_ghost_update, internal::MatrixFreeFunctions::ConstraintInfo< dim, VectorizedArray< Number, width >> &constraint_info_coarse, std::vector< unsigned int > &dof_indices_fine)
std::shared_ptr< const Utilities::MPI::Partitioner > partitioner_coarse_embedded
void restrict_and_add(VectorType &dst, const VectorType &src) const
virtual void enable_inplace_operations_if_possible(const std::shared_ptr< const Utilities::MPI::Partitioner > &partitioner_coarse, const std::shared_ptr< const Utilities::MPI::Partitioner > &partitioner_fine)=0
virtual std::size_t memory_consumption() const =0
virtual void restrict_and_add(VectorType &dst, const VectorType &src) const =0
virtual void interpolate(VectorType &dst, const VectorType &src) const =0
virtual void prolongate_and_add(VectorType &dst, const VectorType &src) const =0
boost::signals2::connection connect_restriction_cell_loop(const std::function< void(const bool)> &slot)
void enable_inplace_operations_if_possible(const std::shared_ptr< const Utilities::MPI::Partitioner > &partitioner_coarse, const std::shared_ptr< const Utilities::MPI::Partitioner > &partitioner_fine) override
std::shared_ptr< NonMatching::MappingInfo< dim, dim, Number > > mapping_info
internal::MatrixFreeFunctions::ConstraintInfo< dim, VectorizedArrayType > constraint_info
void prolongate_and_add_internal_comp(LinearAlgebra::distributed::Vector< Number > &dst, const LinearAlgebra::distributed::Vector< Number > &src) const
boost::signals2::connection connect_prolongation(const std::function< void(const bool)> &slot)
boost::signals2::connection connect_prolongation_cell_loop(const std::function< void(const bool)> &slot)
boost::signals2::connection connect_restriction(const std::function< void(const bool)> &slot)
void prolongate_and_add_internal(LinearAlgebra::distributed::Vector< Number > &dst, const LinearAlgebra::distributed::Vector< Number > &src) const override
void interpolate(LinearAlgebra::distributed::Vector< Number > &dst, const LinearAlgebra::distributed::Vector< Number > &src) const override
void restrict_and_add_internal(LinearAlgebra::distributed::Vector< Number > &dst, const LinearAlgebra::distributed::Vector< Number > &src) const override
void reinit(const DoFHandler< dim > &dof_handler_fine, const DoFHandler< dim > &dof_handler_coarse, const Mapping< dim > &mapping_fine, const Mapping< dim > &mapping_coarse, const AffineConstraints< Number > &constraint_fine=AffineConstraints< Number >(), const AffineConstraints< Number > &constraint_coarse=AffineConstraints< Number >())
void restrict_and_add_internal_comp(LinearAlgebra::distributed::Vector< Number > &dst, const LinearAlgebra::distributed::Vector< Number > &src) const
void prolongate_and_add(VectorType &dst, const VectorType &src) const override
std::size_t memory_consumption() const override
void restrict_and_add(VectorType &dst, const VectorType &src) const override
void interpolate(VectorType &dst, const VectorType &src) const override
internal::MatrixFreeFunctions::ConstraintInfo< dim, VectorizedArrayType > constraint_info_fine
void enable_inplace_operations_if_possible(const std::shared_ptr< const Utilities::MPI::Partitioner > &partitioner_coarse, const std::shared_ptr< const Utilities::MPI::Partitioner > &partitioner_fine) override
void reinit_polynomial_transfer(const DoFHandler< dim > &dof_handler_fine, const DoFHandler< dim > &dof_handler_coarse, const AffineConstraints< Number > &constraint_fine=AffineConstraints< Number >(), const AffineConstraints< Number > &constraint_coarse=AffineConstraints< Number >(), const unsigned int mg_level_fine=numbers::invalid_unsigned_int, const unsigned int mg_level_coarse=numbers::invalid_unsigned_int)
void interpolate(LinearAlgebra::distributed::Vector< Number > &dst, const LinearAlgebra::distributed::Vector< Number > &src) const override
static bool fast_polynomial_transfer_supported(const unsigned int fe_degree_fine, const unsigned int fe_degree_coarse)
void prolongate_and_add_internal(LinearAlgebra::distributed::Vector< Number > &dst, const LinearAlgebra::distributed::Vector< Number > &src) const override
internal::MatrixFreeFunctions::ConstraintInfo< dim, VectorizedArrayType > constraint_info_coarse
void reinit(const DoFHandler< dim > &dof_handler_fine, const DoFHandler< dim > &dof_handler_coarse, const AffineConstraints< Number > &constraint_fine=AffineConstraints< Number >(), const AffineConstraints< Number > &constraint_coarse=AffineConstraints< Number >(), const unsigned int mg_level_fine=numbers::invalid_unsigned_int, const unsigned int mg_level_coarse=numbers::invalid_unsigned_int)
void restrict_and_add_internal(LinearAlgebra::distributed::Vector< Number > &dst, const LinearAlgebra::distributed::Vector< Number > &src) const override
void reinit_geometric_transfer(const DoFHandler< dim > &dof_handler_fine, const DoFHandler< dim > &dof_handler_coarse, const AffineConstraints< Number > &constraint_fine=AffineConstraints< Number >(), const AffineConstraints< Number > &constraint_coarse=AffineConstraints< Number >(), const unsigned int mg_level_fine=numbers::invalid_unsigned_int, const unsigned int mg_level_coarse=numbers::invalid_unsigned_int)
void enable_inplace_operations_if_possible(const std::shared_ptr< const Utilities::MPI::Partitioner > &partitioner_coarse, const std::shared_ptr< const Utilities::MPI::Partitioner > &partitioner_fine) override
void interpolate(VectorType &dst, const VectorType &src) const override
void restrict_and_add(VectorType &dst, const VectorType &src) const override
void prolongate_and_add(VectorType &dst, const VectorType &src) const override
std::size_t memory_consumption() const override
Abstract base class for mapping classes.
Definition: mapping.h:317
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:477
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:478
unsigned int level
Definition: grid_out.cc:4617
static ::ExceptionBase & ExcInternalError()
#define Assert(cond, exc)
Definition: exceptions.h:1631
#define AssertDimension(dim1, dim2)
Definition: exceptions.h:1820
void interpolate(const DoFHandler< dim, spacedim > &dof1, const InVector &u1, const DoFHandler< dim, spacedim > &dof2, OutVector &u2)
std::vector< std::shared_ptr< const Triangulation< dim, spacedim > > > create_geometric_coarsening_sequence(const Triangulation< dim, spacedim > &tria)
unsigned int create_next_polynomial_coarsening_degree(const unsigned int degree, const PolynomialCoarseningSequenceType &p_sequence)
std::vector< unsigned int > create_polynomial_coarsening_sequence(const unsigned int max_degree, const PolynomialCoarseningSequenceType &p_sequence)
SymmetricTensor< 2, dim, Number > e(const Tensor< 2, dim, Number > &F)
Tensor< 2, dim, Number > l(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
SymmetricTensor< 2, dim, Number > b(const Tensor< 2, dim, Number > &F)
T & get_underlying_value(T &p)
Definition: utilities.h:1601
Definition: mg.h:82
static const unsigned int invalid_unsigned_int
Definition: types.h:221
AdditionalData(const double tolerance=1e-6, const unsigned int rtree_level=0, const bool enforce_all_points_found=true)
boost::signals2::signal< void(const bool before)> prolongation_cell_loop
boost::signals2::signal< void(const bool before)> restriction
boost::signals2::signal< void(const bool before)> restriction_cell_loop
boost::signals2::signal< void(const bool before)> prolongation
const ::Triangulation< dim, spacedim > & tria