deal.II version 9.8.0
\(\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\}}\)
Loading...
Searching...
No Matches
mg_transfer_matrix_free.h
Go to the documentation of this file.
1// -----------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
4// Copyright (C) 2016 - 2026 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Detailed license information governing the source code and contributions
9// can be found in LICENSE.md and CONTRIBUTING.md at the top level directory.
10//
11// -----------------------------------------------------------------------------
12
13#ifndef dealii_mg_transfer_matrix_free_h
14#define dealii_mg_transfer_matrix_free_h
15
20
22
26
30
35
37
38
40
41// Forward declarations
42#ifndef DOXYGEN
43namespace internal
44{
45 class MGTwoLevelTransferImplementation;
46} // namespace internal
47
48namespace Portable
49{
50 template <int dim, typename VectorType>
52
53 namespace internal
54 {
55 class MGTwoLevelTransferImplementation;
56 } // namespace internal
57} // namespace Portable
58
59template <int dim,
60 typename Number,
63#endif
64
69
70namespace mg
71{
83 {
89 boost::signals2::signal<void(const bool before)> prolongation_cell_loop;
90
96 boost::signals2::signal<void(const bool before)> restriction_cell_loop;
97
105 boost::signals2::signal<void(const bool before)> prolongation;
106
114 boost::signals2::signal<void(const bool before)> restriction;
115 };
116} // namespace mg
117
118
119
123template <int dim, typename VectorType>
125{
126public:
127 static_assert(
128 std::is_same_v<
129 VectorType,
130 LinearAlgebra::distributed::Vector<typename VectorType::value_type,
132 std::is_same_v<
133 VectorType,
134 LinearAlgebra::distributed::Vector<typename VectorType::value_type,
136 "This class is currently only implemented for vectors of "
137 "type LinearAlgebra::distributed::Vector.");
138
142 std::shared_ptr<const Utilities::MPI::Partitioner> partitioner_coarse;
143
147 std::shared_ptr<const Utilities::MPI::Partitioner> partitioner_fine;
148
152 virtual void
153 prolongate_and_add(VectorType &dst, const VectorType &src) const = 0;
154
158 virtual void
159 restrict_and_add(VectorType &dst, const VectorType &src) const = 0;
160
168 virtual void
169 interpolate(VectorType &dst, const VectorType &src) const = 0;
170
176 virtual std::pair<bool, bool>
178 const std::shared_ptr<const Utilities::MPI::Partitioner>
180 const std::shared_ptr<const Utilities::MPI::Partitioner>
181 &partitioner_fine) = 0;
182
186 virtual std::size_t
188
189
193 virtual std::pair<const DoFHandler<dim> *, unsigned int>
195};
196
197
198
199namespace internal
200{
204 template <int dim, typename VectorType>
205 class MGTwoLevelTransferCore : public MGTwoLevelTransferBase<dim, VectorType>
206 {
207 public:
211 using Number = typename VectorType::value_type;
212
217
221 void
222 prolongate_and_add(VectorType &dst, const VectorType &src) const override;
223
227 void
228 restrict_and_add(VectorType &dst, const VectorType &src) const override;
229
230 protected:
234 virtual void
236 const VectorType &src) const = 0;
237
241 virtual void
242 restrict_and_add_internal(VectorType &dst, const VectorType &src) const = 0;
243
249 void
250 update_ghost_values(const VectorType &vec) const;
251
257 void
258 compress(VectorType &vec, const VectorOperation::values op) const;
259
265 void
266 zero_out_ghost_values(const VectorType &vec) const;
267
272 template <std::size_t width, typename IndexType>
273 std::pair<bool, bool>
275 const std::shared_ptr<const Utilities::MPI::Partitioner>
277 const std::shared_ptr<const Utilities::MPI::Partitioner>
281 ConstraintInfo<dim, VectorizedArray<Number, width>, IndexType>
282 &constraint_info_coarse,
283 std::vector<unsigned int> &dof_indices_fine);
284
291
292 protected:
297 mutable VectorType vec_coarse;
298
306 mutable VectorType vec_fine;
307
312
317 std::shared_ptr<const Utilities::MPI::Partitioner>
319
324 std::shared_ptr<const Utilities::MPI::Partitioner>
326
332
338 };
339} // namespace internal
340
341
342
368template <int dim, typename VectorType>
370 : public internal::MGTwoLevelTransferCore<dim, VectorType>
371{
372public:
373 static_assert(
374 std::is_same_v<
375 VectorType,
376 LinearAlgebra::distributed::Vector<typename VectorType::value_type,
378 std::is_same_v<
379 VectorType,
380 LinearAlgebra::distributed::Vector<typename VectorType::value_type,
382 "This class is currently only implemented for vectors of "
383 "type LinearAlgebra::distributed::Vector.");
384
388 using Number = typename VectorType::value_type;
389
395
401 void
404 const DoFHandler<dim> &dof_handler_coarse,
405 const AffineConstraints<Number> &constraint_fine =
407 const AffineConstraints<Number> &constraint_coarse =
409 const unsigned int mg_level_fine = numbers::invalid_unsigned_int,
410 const unsigned int mg_level_coarse = numbers::invalid_unsigned_int);
411
421 void
424 const DoFHandler<dim> &dof_handler_coarse,
425 const AffineConstraints<Number> &constraint_fine =
427 const AffineConstraints<Number> &constraint_coarse =
429 const unsigned int mg_level_fine = numbers::invalid_unsigned_int,
430 const unsigned int mg_level_coarse = numbers::invalid_unsigned_int);
431
445 void
447 const DoFHandler<dim> &dof_handler_coarse,
448 const AffineConstraints<Number> &constraint_fine =
450 const AffineConstraints<Number> &constraint_coarse =
452 const unsigned int mg_level_fine = numbers::invalid_unsigned_int,
453 const unsigned int mg_level_coarse = numbers::invalid_unsigned_int);
454
464 void
465 reinit(const MatrixFree<dim, Number> &matrix_free_fine,
466 const unsigned int dof_handler_index_fine,
467 const MatrixFree<dim, Number> &matrix_free_coarse,
468 const unsigned int dof_handler_index_coarse);
469
478 static bool
479 fast_polynomial_transfer_supported(const unsigned int fe_degree_fine,
480 const unsigned int fe_degree_coarse);
481
485 void
486 interpolate(VectorType &dst, const VectorType &src) const override;
487
492 std::pair<bool, bool>
494 const std::shared_ptr<const Utilities::MPI::Partitioner>
496 const std::shared_ptr<const Utilities::MPI::Partitioner> &partitioner_fine)
497 override;
498
502 std::size_t
503 memory_consumption() const override;
504
508 std::pair<const DoFHandler<dim> *, unsigned int>
509 get_dof_handler_fine() const override;
510
511protected:
512 void
514 const VectorType &src) const override;
515
516 void
518 const VectorType &src) const override;
519
520private:
580
584 std::vector<MGTransferScheme> schemes;
585
590 internal::MatrixFreeFunctions::
591 ConstraintInfo<dim, VectorizedArrayType, types::global_dof_index>
593
597 internal::MatrixFreeFunctions::
598 ConstraintInfo<dim, VectorizedArrayType, types::global_dof_index>
600
633
639 std::unique_ptr<MatrixFreeRelatedData> matrix_free_data;
640
645 std::vector<unsigned int> weights_start;
646
652
657 std::vector<unsigned char> weights_are_compressed;
658
662 unsigned int n_components;
663
668
672 unsigned int mg_level_fine;
673
675
676 friend class MGTransferMatrixFree<dim, Number, MemorySpace::Host>;
677
678 friend class MGTransferMatrixFree<dim, Number, MemorySpace::Default>;
679
680 friend class Portable::MGTwoLevelTransfer<
681 dim,
682 LinearAlgebra::distributed::Vector<Number, MemorySpace::Default>>;
683
685};
686
687
693template <int dim, typename VectorType>
695 : public MGTwoLevelTransferBase<dim, VectorType>
696{
697public:
698 static_assert(
699 std::is_same_v<
700 VectorType,
701 LinearAlgebra::distributed::Vector<typename VectorType::value_type,
703 "type LinearAlgebra::distributed::Vector. This class should not be used for host vectors since it would perform redundant transfers. Use MGTwoLevelTransfer instead.");
704
705
709 using Number = typename VectorType::value_type;
710
711 /*
712 * The vector type used by vectors defined on the host.
713 */
716
721
725 void
726 reinit(const DoFHandler<dim> &dof_handler_fine,
727 const DoFHandler<dim> &dof_handler_coarse,
728 const AffineConstraints<Number> &constraint_fine =
730 const AffineConstraints<Number> &constraint_coarse =
732 const unsigned int mg_level_fine = numbers::invalid_unsigned_int,
733 const unsigned int mg_level_coarse = numbers::invalid_unsigned_int);
734
738 void
739 reinit(const MatrixFree<dim, Number> &matrix_free_fine,
740 const unsigned int dof_handler_index_fine,
741 const MatrixFree<dim, Number> &matrix_free_coarse,
742 const unsigned int dof_handler_index_coarse);
743
747 bool
748 fast_polynomial_transfer_supported(const unsigned int fe_degree_fine,
749 const unsigned int fe_degree_coarse);
750
754 void
755 prolongate_and_add(VectorType &dst, const VectorType &src) const override;
756
760 void
761 restrict_and_add(VectorType &dst, const VectorType &src) const override;
762
766 void
767 interpolate(VectorType &dst, const VectorType &src) const override;
768
772 std::pair<bool, bool>
774 const std::shared_ptr<const Utilities::MPI::Partitioner>
776 const std::shared_ptr<const Utilities::MPI::Partitioner> &partitioner_fine)
777 override;
778
782 std::size_t
783 memory_consumption() const override;
784
788 std::pair<const DoFHandler<dim> *, unsigned int>
789 get_dof_handler_fine() const override;
790
791private:
796
801
806
810 void
811 copy_to_host(VectorTypeHost &dst, const VectorType &src) const;
812
816 void
817 copy_from_host(VectorType &dst, const VectorTypeHost &src) const;
818
819 friend class internal::MGTwoLevelTransferImplementation;
820
821 friend class MGTransferMatrixFree<dim,
822 Number,
823 typename VectorType::memory_space>;
824};
825
826
827
831template <int dim, typename VectorType>
833 : public internal::MGTwoLevelTransferCore<dim, VectorType>
834{
835private:
836 static_assert(
837 std::is_same_v<
838 VectorType,
840 "This class is currently only implemented for vectors of "
841 "type LinearAlgebra::distributed::Vector.");
842
843 using Number = typename VectorType::value_type;
845
847
848public:
856 {
866 AdditionalData(const double tolerance = 1e-6,
867 const unsigned int rtree_level = 0,
868 const bool enforce_all_points_found = true)
872 {}
873
878 double tolerance;
879
885 unsigned int rtree_level;
886
895 };
896
901
906 void
908 const DoFHandler<dim> &dof_handler_coarse,
909 const Mapping<dim> &mapping_fine,
910 const Mapping<dim> &mapping_coarse,
911 const AffineConstraints<Number> &constraint_fine =
913 const AffineConstraints<Number> &constraint_coarse =
915
922 void
923 interpolate(VectorType &dst, const VectorType &src) const override;
924
929 std::pair<bool, bool>
931 const std::shared_ptr<const Utilities::MPI::Partitioner>
933 const std::shared_ptr<const Utilities::MPI::Partitioner> &partitioner_fine)
934 override;
935
939 std::size_t
940 memory_consumption() const override;
941
945 std::pair<const DoFHandler<dim> *, unsigned int>
946 get_dof_handler_fine() const override;
947
951 boost::signals2::connection
952 connect_prolongation_cell_loop(const std::function<void(const bool)> &slot);
953
957 boost::signals2::connection
958 connect_restriction_cell_loop(const std::function<void(const bool)> &slot);
959
963 boost::signals2::connection
964 connect_prolongation(const std::function<void(const bool)> &slot);
965
969 boost::signals2::connection
970 connect_restriction(const std::function<void(const bool)> &slot);
971
972protected:
977 void
979 const VectorType &src) const override;
980
984 void
986 const VectorType &src) const override;
987
988private:
992 template <int n_components>
993 void
995 const VectorType &src) const;
996
1000 template <int n_components>
1001 void
1002 restrict_and_add_internal_comp(VectorType &dst, const VectorType &src) const;
1003
1008
1012 unsigned int mg_level_fine;
1013
1019
1023 mutable std::vector<Number> rpe_input_output;
1024
1028 mutable std::vector<Number> rpe_buffer;
1029
1033 std::shared_ptr<NonMatching::MappingInfo<dim, dim, Number>> mapping_info;
1034
1039 internal::MatrixFreeFunctions::
1040 ConstraintInfo<dim, VectorizedArrayType, unsigned int>
1042
1046 std::unique_ptr<FiniteElement<dim>> fe_coarse;
1047
1052 std::vector<unsigned int> level_dof_indices_fine;
1053
1059 std::vector<unsigned int> level_dof_indices_fine_ptrs;
1060
1061 friend class MGTransferMatrixFree<dim,
1062 Number,
1063 typename VectorType::memory_space>;
1064};
1065
1066
1067
1100template <int dim, typename Number, typename MemorySpace>
1102 : public ::MGLevelGlobalTransfer<
1103 LinearAlgebra::distributed::Vector<Number, MemorySpace>>
1104{
1105public:
1110
1117
1122
1132 template <typename MGTwoLevelTransferObject>
1135 const std::function<void(const unsigned int, VectorType &)>
1136 &initialize_dof_vector = {});
1137
1141 template <typename MGTwoLevelTransferObject>
1142 void
1145
1154 void
1155 build(const std::vector<std::shared_ptr<const Utilities::MPI::Partitioner>>
1156 &external_partitioners = {});
1157
1162 void
1163 build(const std::function<void(const unsigned int, VectorType &)>
1165
1167
1172
1178
1182 void
1184
1186
1191
1201 void
1202 build(const DoFHandler<dim> &dof_handler,
1203 const std::vector<std::shared_ptr<const Utilities::MPI::Partitioner>>
1204 &external_partitioners = {});
1205
1215 void
1216 build(const DoFHandler<dim> &dof_handler,
1217 const std::function<void(const unsigned int, VectorType &)>
1219
1221
1226
1230 void
1231 prolongate(const unsigned int to_level,
1232 VectorType &dst,
1233 const VectorType &src) const override;
1234
1238 void
1239 prolongate_and_add(const unsigned int to_level,
1240 VectorType &dst,
1241 const VectorType &src) const override;
1242
1246 virtual void
1247 restrict_and_add(const unsigned int from_level,
1248 VectorType &dst,
1249 const VectorType &src) const override;
1250
1260 template <class InVector>
1261 void
1262 copy_to_mg(const DoFHandler<dim> &dof_handler,
1264 const InVector &src) const;
1265
1275 template <class OutVector>
1276 void
1277 copy_from_mg(const DoFHandler<dim> &dof_handler,
1278 OutVector &dst,
1279 const MGLevelObject<VectorType> &src) const;
1280
1299 template <class InVector>
1300 void
1303 const InVector &src) const;
1304
1313 template <class InVector>
1314 void
1315 interpolate_to_mg(MGLevelObject<VectorType> &dst, const InVector &src) const;
1316
1318
1323
1330 std::size_t
1332
1336 unsigned int
1337 min_level() const;
1338
1342 unsigned int
1343 max_level() const;
1344
1349 void
1351
1353
1354private:
1358 void
1360 const DoFHandler<dim> &dof_handler,
1362
1366 std::pair<const DoFHandler<dim> *, unsigned int>
1368
1374 void
1376 const DoFHandler<dim> &dof_handler);
1377
1381 template <typename MGTwoLevelTransferObject>
1382 void
1385
1394 template <class InVector>
1395 void
1396 initialize_dof_vector(const unsigned int level,
1397 VectorType &vector,
1398 const InVector &vector_reference,
1399 const bool omit_zeroing_entries,
1400 const bool force_same_partitioner = false) const;
1401
1407 void
1408 assert_dof_handler(const DoFHandler<dim> &dof_handler_out) const;
1409
1414 dim,
1417
1423
1427 std::vector<std::shared_ptr<const Utilities::MPI::Partitioner>>
1429};
1430
1436template <int dim, typename Number, typename TransferType>
1438 : public MGTransferBase<LinearAlgebra::distributed::BlockVector<Number>>
1439{
1440public:
1444
1459 virtual void
1461 const unsigned int to_level,
1463 const LinearAlgebra::distributed::BlockVector<Number> &src) const override;
1464
1465 virtual void
1467 const unsigned int to_level,
1469 const LinearAlgebra::distributed::BlockVector<Number> &src) const override;
1470
1489 virtual void
1491 const unsigned int from_level,
1493 const LinearAlgebra::distributed::BlockVector<Number> &src) const override;
1494
1505 template <typename BlockVectorType2>
1506 void
1508 const DoFHandler<dim> &dof_handler,
1510 const BlockVectorType2 &src) const;
1511
1515 template <typename BlockVectorType2>
1516 void
1518 const std::vector<const DoFHandler<dim> *> &dof_handler,
1520 const BlockVectorType2 &src) const;
1521
1525 template <typename BlockVectorType2>
1526 void
1528 const DoFHandler<dim> &dof_handler,
1529 BlockVectorType2 &dst,
1531 const;
1532
1536 template <typename BlockVectorType2>
1537 void
1539 const std::vector<const DoFHandler<dim> *> &dof_handler,
1540 BlockVectorType2 &dst,
1542 const;
1543
1544protected:
1549 virtual const TransferType &
1550 get_matrix_free_transfer(const unsigned int b) const = 0;
1551
1556 const bool same_for_all;
1557};
1558
1572template <int dim, typename Number>
1575 dim,
1576 Number,
1577 MGTransferMatrixFree<dim, Number, ::MemorySpace::Host>>
1578{
1579public:
1585 &transfer_operator);
1586
1592
1598
1603 const std::vector<MGConstrainedDoFs> &mg_constrained_dofs);
1604
1608 void
1609 initialize_constraints(const MGConstrainedDoFs &mg_constrained_dofs);
1610
1614 void
1616 const std::vector<MGConstrainedDoFs> &mg_constrained_dofs);
1617
1621 void
1622 build(const DoFHandler<dim> &dof_handler);
1623
1627 void
1628 build(const std::vector<const DoFHandler<dim> *> &dof_handler);
1629
1630protected:
1632 get_matrix_free_transfer(const unsigned int b) const override;
1633
1634private:
1638 std::vector<MGTransferMatrixFree<dim, Number, ::MemorySpace::Host>>
1640
1644 std::vector<ObserverPointer<
1647};
1648
1649
1651
1652#ifndef DOXYGEN
1653
1654/* ----------------------- Inline functions --------------------------------- */
1655
1656template <int dim, typename VectorType>
1657void
1659 const DoFHandler<dim> &dof_handler_fine,
1660 const DoFHandler<dim> &dof_handler_coarse,
1661 const AffineConstraints<Number> &constraint_fine,
1662 const AffineConstraints<Number> &constraint_coarse,
1663 const unsigned int mg_level_fine,
1664 const unsigned int mg_level_coarse)
1665{
1666 host_transfer.reinit(dof_handler_fine,
1667 dof_handler_coarse,
1668 constraint_fine,
1669 constraint_coarse,
1670 mg_level_fine,
1671 mg_level_coarse);
1672}
1673
1674template <int dim, typename VectorType>
1675void
1677 const MatrixFree<dim, Number> &matrix_free_fine,
1678 const unsigned int dof_handler_index_fine,
1679 const MatrixFree<dim, Number> &matrix_free_coarse,
1680 const unsigned int dof_handler_index_coarse)
1681{
1682 host_transfer.reinit(matrix_free_fine,
1683 dof_handler_index_fine,
1684 matrix_free_coarse,
1685 dof_handler_index_coarse);
1686}
1687
1688
1689template <int dim, typename VectorType>
1690bool
1692 fast_polynomial_transfer_supported(const unsigned int fe_degree_fine,
1693 const unsigned int fe_degree_coarse)
1694{
1695 return host_transfer.fast_polynomial_transfer_supported(fe_degree_fine,
1696 fe_degree_coarse);
1697}
1698
1699template <int dim, typename VectorType>
1700void
1702 VectorType &dst,
1703 const VectorType &src) const
1704{
1705 if (host_vector_coarse.size() == 0)
1706 host_vector_coarse.reinit(src.get_partitioner());
1707 if (host_vector_fine.size() == 0)
1708 host_vector_fine.reinit(dst.get_partitioner());
1709
1710 copy_to_host(host_vector_fine, dst);
1711 copy_to_host(host_vector_coarse, src);
1712
1713 host_transfer.prolongate_and_add(host_vector_fine, host_vector_coarse);
1714
1715 copy_from_host(dst, host_vector_fine);
1716}
1717
1718template <int dim, typename VectorType>
1719void
1721 VectorType &dst,
1722 const VectorType &src) const
1723{
1724 if (host_vector_coarse.size() == 0)
1725 host_vector_coarse.reinit(dst.get_partitioner());
1726 if (host_vector_fine.size() == 0)
1727 host_vector_fine.reinit(src.get_partitioner());
1728
1729 copy_to_host(host_vector_coarse, dst);
1730 copy_to_host(host_vector_fine, src);
1731
1732 host_transfer.restrict_and_add(host_vector_coarse, host_vector_fine);
1733
1734 copy_from_host(dst, host_vector_coarse);
1735}
1736
1737template <int dim, typename VectorType>
1738void
1740 VectorType &dst,
1741 const VectorType &src) const
1742{
1743 if (host_vector_coarse.size() == 0)
1744 host_vector_coarse.reinit(dst.get_partitioner());
1745 if (host_vector_fine.size() == 0)
1746 host_vector_fine.reinit(src.get_partitioner());
1747
1748 copy_to_host(host_vector_fine, src);
1749
1750 host_transfer.interpolate(host_vector_coarse, host_vector_fine);
1751
1752 copy_from_host(dst, host_vector_coarse);
1753}
1754
1755template <int dim, typename VectorType>
1756std::pair<bool, bool>
1759 const std::shared_ptr<const Utilities::MPI::Partitioner>
1760 &partitioner_coarse,
1761 const std::shared_ptr<const Utilities::MPI::Partitioner> &partitioner_fine)
1762{
1763 return host_transfer.enable_inplace_operations_if_possible(partitioner_coarse,
1764 partitioner_fine);
1765}
1766
1767template <int dim, typename VectorType>
1768std::size_t
1770{
1771 return host_transfer.memory_consumption();
1772}
1773
1774template <int dim, typename VectorType>
1775std::pair<const DoFHandler<dim> *, unsigned int>
1777{
1778 return host_transfer.get_dof_handler_fine();
1779}
1780
1781
1782template <int dim, typename VectorType>
1783void
1785 VectorTypeHost &dst,
1786 const VectorType &src) const
1787{
1788 LinearAlgebra::ReadWriteVector<Number> rw_vector(
1789 src.get_partitioner()->locally_owned_range());
1790 rw_vector.import_elements(src, VectorOperation::insert);
1791
1792 dst.import_elements(rw_vector, VectorOperation::insert);
1793}
1794
1795template <int dim, typename VectorType>
1796void
1798 VectorType &dst,
1799 const VectorTypeHost &src) const
1800{
1801 LinearAlgebra::ReadWriteVector<Number> rw_vector(
1802 src.get_partitioner()->locally_owned_range());
1803 rw_vector.import_elements(src, VectorOperation::insert);
1804
1805 dst.import_elements(rw_vector, VectorOperation::insert);
1806}
1807
1808
1809
1810template <int dim, typename Number, typename MemorySpace>
1811template <typename MGTwoLevelTransferObject>
1813 const MGLevelObject<MGTwoLevelTransferObject> &transfer,
1814 const std::function<void(const unsigned int, VectorType &)>
1815 &initialize_dof_vector)
1816{
1817 this->transfer.clear();
1818 this->internal_transfer.clear();
1819
1820 this->initialize_transfer_references(transfer);
1821 this->build(initialize_dof_vector);
1822}
1823
1824
1825
1826template <int dim, typename Number, typename MemorySpace>
1827template <typename MGTwoLevelTransferObject>
1828void
1830 const MGLevelObject<MGTwoLevelTransferObject> &transfer)
1831{
1832 this->initialize_transfer_references(transfer);
1833}
1834
1835
1836
1837template <int dim, typename Number, typename MemorySpace>
1838template <typename MGTwoLevelTransferObject>
1839void
1841 const MGLevelObject<MGTwoLevelTransferObject> &transfer)
1842{
1843 const unsigned int min_level = transfer.min_level();
1844 const unsigned int max_level = transfer.max_level();
1845
1846 this->transfer.resize(min_level, max_level);
1847
1848 // Note that transfer[min_level] is empty and never used:
1849 for (unsigned int l = min_level + 1; l <= max_level; ++l)
1850 this->transfer[l] = &const_cast<MGTwoLevelTransferBase<dim, VectorType> &>(
1851 static_cast<const MGTwoLevelTransferBase<dim, VectorType> &>(
1852 Utilities::get_underlying_value(transfer[l])));
1853}
1854
1855
1856
1857template <int dim, typename Number, typename MemorySpace>
1858template <class InVector>
1859void
1861 const unsigned int level,
1862 VectorType &vec,
1863 const InVector &vec_reference,
1864 const bool omit_zeroing_entries,
1865 const bool force_same_partitioner) const
1866{
1867 std::shared_ptr<const Utilities::MPI::Partitioner> partitioner;
1868
1869 if (external_partitioners.empty())
1870 {
1871 partitioner = vec_reference.get_partitioner();
1872 }
1873 else
1874 {
1875 Assert(transfer.min_level() <= level && level <= transfer.max_level(),
1877
1878 partitioner = external_partitioners[level - transfer.min_level()];
1879 }
1880
1881 // check if vectors are already correctly initialized
1882
1883 // yes: same partitioners are used
1884 if (vec.get_partitioner().get() == partitioner.get())
1885 {
1886 if (omit_zeroing_entries == false)
1887 vec = 0;
1888 return; // nothing to do
1889 }
1890
1891 // yes: vectors are compatible
1892 if (!force_same_partitioner && vec.size() == partitioner->size() &&
1893 vec.locally_owned_size() == partitioner->locally_owned_size())
1894 {
1895 if (omit_zeroing_entries == false)
1896 vec = 0;
1897 return; // nothing to do
1898 }
1899
1900 // no
1901 vec.reinit(partitioner, omit_zeroing_entries);
1902}
1903
1904
1905
1906template <int dim, typename Number, typename MemorySpace>
1907template <class InVector>
1908void
1910 const DoFHandler<dim> &dof_handler,
1911 MGLevelObject<VectorType> &dst,
1912 const InVector &src) const
1913{
1914 assert_dof_handler(dof_handler);
1915
1916 for (unsigned int level = dst.min_level(); level <= dst.max_level(); ++level)
1917 {
1918 const bool zero_out_values =
1919 (this->perform_plain_copy == false &&
1920 this->perform_renumbered_plain_copy == false) ||
1921 level != dst.max_level();
1922
1923 this->initialize_dof_vector(level,
1924 dst[level],
1925 src,
1926 !zero_out_values,
1927 /* force_same_partitioner = */ true);
1928 }
1929
1930 if (this->perform_plain_copy)
1931 {
1932 dst[dst.max_level()].copy_locally_owned_data_from(src);
1933 }
1934 else if (this->perform_renumbered_plain_copy)
1935 {
1936 auto &dst_level = dst[dst.max_level()];
1937
1938 for (unsigned int i = 0; i < this->copy_indices.back().n_cols(); ++i)
1939 dst_level.local_element(this->copy_indices.back()(1, i)) =
1940 src.local_element(i);
1941 }
1942 else
1943 {
1944 this->ghosted_global_vector = src;
1945 this->ghosted_global_vector.update_ghost_values();
1946
1947 for (unsigned int l = dst.max_level() + 1; l != dst.min_level();)
1948 {
1949 --l;
1950
1951 auto &dst_level = dst[l];
1952
1953 const auto copy_unknowns = [&](const auto &indices) {
1954 for (unsigned int i = 0; i < indices.n_cols(); ++i)
1955 dst_level.local_element(indices(1, i)) =
1956 this->ghosted_global_vector.local_element(indices(0, i));
1957 };
1958
1959 copy_unknowns(this->copy_indices[l]);
1960 copy_unknowns(this->copy_indices_level_mine[l]);
1961
1962 dst_level.compress(VectorOperation::insert);
1963 }
1964 }
1965}
1966
1967
1968
1969template <int dim, typename Number, typename MemorySpace>
1970template <class OutVector>
1971void
1973 const DoFHandler<dim> &dof_handler,
1974 OutVector &dst,
1975 const MGLevelObject<VectorType> &src) const
1976{
1977 assert_dof_handler(dof_handler);
1978
1979 if (this->perform_plain_copy)
1980 {
1981 dst.zero_out_ghost_values();
1982 dst.copy_locally_owned_data_from(src[src.max_level()]);
1983 }
1984 else if (this->perform_renumbered_plain_copy)
1985 {
1986 const auto &src_level = src[src.max_level()];
1987 dst.zero_out_ghost_values();
1988 for (unsigned int i = 0; i < this->copy_indices.back().n_cols(); ++i)
1989 dst.local_element(i) =
1990 src_level.local_element(this->copy_indices.back()(1, i));
1991 }
1992 else
1993 {
1994 dst = 0;
1995 for (unsigned int l = src.min_level(); l <= src.max_level(); ++l)
1996 {
1997 auto &ghosted_vector = this->ghosted_level_vector[l];
1998
1999 if (this->ghosted_level_vector[l].size() > 0)
2000 ghosted_vector = src[l];
2001
2002 const auto *const ghosted_vector_ptr =
2003 (this->ghosted_level_vector[l].size() > 0) ? &ghosted_vector :
2004 &src[l];
2005
2006 ghosted_vector_ptr->update_ghost_values();
2007
2008 const auto copy_unknowns = [&](const auto &indices) {
2009 for (unsigned int i = 0; i < indices.n_cols(); ++i)
2010 dst.local_element(indices(0, i)) =
2011 ghosted_vector_ptr->local_element(indices(1, i));
2012 };
2013
2014 copy_unknowns(this->copy_indices[l]);
2015 copy_unknowns(this->copy_indices_global_mine[l]);
2016 }
2017 dst.compress(VectorOperation::insert);
2018 }
2019}
2020
2021
2022
2023template <int dim, typename Number, typename MemorySpace>
2024template <class InVector>
2025void
2027 MGLevelObject<VectorType> &dst,
2028 const InVector &src) const
2029{
2030 DoFHandler<dim> dof_handler_dummy;
2031
2032 this->interpolate_to_mg(dof_handler_dummy, dst, src);
2033}
2034
2035
2036
2037template <int dim, typename Number, typename MemorySpace>
2038template <class InVector>
2039void
2041 const DoFHandler<dim> &dof_handler,
2042 MGLevelObject<VectorType> &dst,
2043 const InVector &src) const
2044{
2045 assert_dof_handler(dof_handler);
2046
2047 const unsigned int min_level = dst.min_level();
2048 const unsigned int max_level = transfer.max_level();
2049
2050 AssertDimension(max_level, dst.max_level());
2051
2052 for (unsigned int level = min_level; level <= max_level; ++level)
2053 {
2054 const bool zero_out_values = false;
2055 this->initialize_dof_vector(level, dst[level], src, !zero_out_values);
2056 }
2057
2058 if (this->perform_plain_copy)
2059 {
2060 dst[max_level].copy_locally_owned_data_from(src);
2061
2062 for (unsigned int l = max_level; l > min_level; --l)
2063 this->transfer[l]->interpolate(dst[l - 1], dst[l]);
2064 }
2065 else if (this->perform_renumbered_plain_copy)
2066 {
2067 auto &dst_level = dst[max_level];
2068
2069 for (unsigned int i = 0; i < this->solution_copy_indices.back().n_cols();
2070 ++i)
2071 dst_level.local_element(this->solution_copy_indices.back()(1, i)) =
2072 src.local_element(i);
2073
2074 for (unsigned int l = max_level; l > min_level; --l)
2075 this->transfer[l]->interpolate(dst[l - 1], dst[l]);
2076 }
2077 else
2078 {
2079 this->solution_ghosted_global_vector = src;
2080 this->solution_ghosted_global_vector.update_ghost_values();
2081
2082 for (unsigned int l = max_level + 1; l != min_level;)
2083 {
2084 --l;
2085
2086 auto &dst_level = dst[l];
2087
2088 const auto copy_unknowns = [&](const auto &indices) {
2089 for (unsigned int i = 0; i < indices.n_cols(); ++i)
2090 dst_level.local_element(indices(1, i)) =
2091 this->solution_ghosted_global_vector.local_element(
2092 indices(0, i));
2093 };
2094
2095 copy_unknowns(this->solution_copy_indices[l]);
2096 copy_unknowns(this->solution_copy_indices_level_mine[l]);
2097
2098 dst_level.compress(VectorOperation::insert);
2099
2100 if (l != min_level)
2101 this->transfer[l]->interpolate(dst[l - 1], dst[l]);
2102 }
2103 }
2104}
2105
2106
2107
2108template <int dim, typename Number, typename TransferType>
2109template <typename BlockVectorType2>
2110void
2112 const DoFHandler<dim> &dof_handler,
2113 MGLevelObject<LinearAlgebra::distributed::BlockVector<Number>> &dst,
2114 const BlockVectorType2 &src) const
2115{
2116 Assert(same_for_all,
2117 ExcMessage(
2118 "This object was initialized with support for usage with one "
2119 "DoFHandler for each block, but this method assumes that "
2120 "the same DoFHandler is used for all the blocks!"));
2121 const std::vector<const DoFHandler<dim> *> mg_dofs(src.n_blocks(),
2122 &dof_handler);
2123
2124 copy_to_mg(mg_dofs, dst, src);
2125}
2126
2127
2128
2129template <int dim, typename Number, typename TransferType>
2130template <typename BlockVectorType2>
2131void
2133 const std::vector<const DoFHandler<dim> *> &dof_handler,
2134 MGLevelObject<LinearAlgebra::distributed::BlockVector<Number>> &dst,
2135 const BlockVectorType2 &src) const
2136{
2137 const unsigned int n_blocks = src.n_blocks();
2138 AssertDimension(dof_handler.size(), n_blocks);
2139
2140 if (n_blocks == 0)
2141 return;
2142
2143 const unsigned int min_level = dst.min_level();
2144 const unsigned int max_level = dst.max_level();
2145
2146 for (unsigned int level = min_level; level <= max_level; ++level)
2147 if (dst[level].n_blocks() != n_blocks)
2148 dst[level].reinit(n_blocks);
2149
2150 // FIXME: this a quite ugly as we need a temporary object:
2151 MGLevelObject<LinearAlgebra::distributed::Vector<Number>> dst_non_block(
2152 min_level, max_level);
2153
2154 for (unsigned int b = 0; b < n_blocks; ++b)
2155 {
2156 const unsigned int data_block = same_for_all ? 0 : b;
2157 get_matrix_free_transfer(data_block)
2158 .copy_to_mg(*dof_handler[b], dst_non_block, src.block(b));
2159
2160 for (unsigned int l = min_level; l <= max_level; ++l)
2161 dst[l].block(b) = dst_non_block[l];
2162 }
2163
2164 for (unsigned int level = min_level; level <= max_level; ++level)
2165 dst[level].collect_sizes();
2166}
2167
2168template <int dim, typename Number, typename TransferType>
2169template <typename BlockVectorType2>
2170void
2172 const DoFHandler<dim> &dof_handler,
2173 BlockVectorType2 &dst,
2174 const MGLevelObject<LinearAlgebra::distributed::BlockVector<Number>> &src)
2175 const
2176{
2177 Assert(same_for_all,
2178 ExcMessage(
2179 "This object was initialized with support for usage with one "
2180 "DoFHandler for each block, but this method assumes that "
2181 "the same DoFHandler is used for all the blocks!"));
2182 const std::vector<const DoFHandler<dim> *> mg_dofs(dst.n_blocks(),
2183 &dof_handler);
2184
2185 copy_from_mg(mg_dofs, dst, src);
2186}
2187
2188template <int dim, typename Number, typename TransferType>
2189template <typename BlockVectorType2>
2190void
2192 const std::vector<const DoFHandler<dim> *> &dof_handler,
2193 BlockVectorType2 &dst,
2194 const MGLevelObject<LinearAlgebra::distributed::BlockVector<Number>> &src)
2195 const
2196{
2197 const unsigned int n_blocks = dst.n_blocks();
2198 AssertDimension(dof_handler.size(), n_blocks);
2199
2200 if (n_blocks == 0)
2201 return;
2202
2203 const unsigned int min_level = src.min_level();
2204 const unsigned int max_level = src.max_level();
2205
2206 for (unsigned int l = min_level; l <= max_level; ++l)
2207 AssertDimension(src[l].n_blocks(), dst.n_blocks());
2208
2209 // FIXME: this a quite ugly as we need a temporary object:
2210 MGLevelObject<LinearAlgebra::distributed::Vector<Number>> src_non_block(
2211 min_level, max_level);
2212
2213 for (unsigned int b = 0; b < n_blocks; ++b)
2214 {
2215 for (unsigned int l = min_level; l <= max_level; ++l)
2216 {
2217 src_non_block[l].reinit(src[l].block(b));
2218 src_non_block[l] = src[l].block(b);
2219 }
2220 const unsigned int data_block = same_for_all ? 0 : b;
2221 get_matrix_free_transfer(data_block)
2222 .copy_from_mg(*dof_handler[b], dst.block(b), src_non_block);
2223 }
2224}
2225
2226#endif
2227
2229
2230#endif
virtual size_type size() const override
void reinit(const size_type size, const bool omit_zeroing_entries=false)
ObserverPointer< const MGConstrainedDoFs > mg_constrained_dofs
std::function< void(const unsigned int, LinearAlgebra::distributed::Vector< Number, MemorySpace > &)> initialize_dof_vector
void resize(const unsigned int new_minlevel, const unsigned int new_maxlevel, Args &&...args)
unsigned int max_level() const
unsigned int min_level() const
virtual void prolongate(const unsigned int to_level, LinearAlgebra::distributed::BlockVector< Number > &dst, const LinearAlgebra::distributed::BlockVector< Number > &src) const override
virtual void prolongate_and_add(const unsigned int to_level, LinearAlgebra::distributed::BlockVector< Number > &dst, const LinearAlgebra::distributed::BlockVector< Number > &src) const override
virtual const TransferType & get_matrix_free_transfer(const unsigned int b) const =0
void copy_from_mg(const std::vector< const DoFHandler< dim > * > &dof_handler, BlockVectorType2 &dst, const MGLevelObject< LinearAlgebra::distributed::BlockVector< Number > > &src) const
void copy_to_mg(const DoFHandler< dim > &dof_handler, MGLevelObject< LinearAlgebra::distributed::BlockVector< Number > > &dst, const BlockVectorType2 &src) const
virtual void restrict_and_add(const unsigned int from_level, LinearAlgebra::distributed::BlockVector< Number > &dst, const LinearAlgebra::distributed::BlockVector< Number > &src) const override
MGTransferBlockMatrixFreeBase(const bool same_for_all)
void copy_from_mg(const DoFHandler< dim > &dof_handler, BlockVectorType2 &dst, const MGLevelObject< LinearAlgebra::distributed::BlockVector< Number > > &src) const
void copy_to_mg(const std::vector< const DoFHandler< dim > * > &dof_handler, MGLevelObject< LinearAlgebra::distributed::BlockVector< Number > > &dst, const BlockVectorType2 &src) const
const MGTransferMatrixFree< dim, Number, ::MemorySpace::Host > & get_matrix_free_transfer(const unsigned int b) const override
MGTransferBlockMatrixFree(const MGTransferMatrixFree< dim, Number, ::MemorySpace::Host > &transfer_operator)
MGTransferBlockMatrixFree(const MGConstrainedDoFs &mg_constrained_dofs)
std::vector< ObserverPointer< const MGTransferMatrixFree< dim, typename VectorType::value_type, ::MemorySpace::Host > > > transfer_operators
std::vector< MGTransferMatrixFree< dim, typename VectorType::value_type, ::MemorySpace::Host > > transfer_operators_internal
MGTransferBlockMatrixFree(const std::vector< MGConstrainedDoFs > &mg_constrained_dofs)
void build(const DoFHandler< dim > &dof_handler)
MGTransferBlockMatrixFree()=default
void build(const std::vector< const DoFHandler< dim > * > &dof_handler)
void initialize_constraints(const std::vector< MGConstrainedDoFs > &mg_constrained_dofs)
void initialize_constraints(const MGConstrainedDoFs &mg_constrained_dofs)
void initialize_two_level_transfers(const MGLevelObject< MGTwoLevelTransferObject > &transfer)
void interpolate_to_mg(MGLevelObject< VectorType > &dst, const InVector &src) const
std::vector< std::shared_ptr< const Utilities::MPI::Partitioner > > external_partitioners
void interpolate_to_mg(const DoFHandler< dim > &dof_handler, MGLevelObject< VectorType > &dst, const InVector &src) const
void initialize_transfer_references(const MGLevelObject< MGTwoLevelTransferObject > &transfer)
MGLevelObject< MGTwoLevelTransfer< dim, LinearAlgebra::distributed::Vector< Number, ::MemorySpace::Host > > > internal_transfer
void build(const std::vector< std::shared_ptr< const Utilities::MPI::Partitioner > > &external_partitioners={})
unsigned int max_level() const
void prolongate(const unsigned int to_level, VectorType &dst, const VectorType &src) const override
void initialize_dof_vector(const unsigned int level, VectorType &vector, const InVector &vector_reference, const bool omit_zeroing_entries, const bool force_same_partitioner=false) const
void copy_from_mg(const DoFHandler< dim > &dof_handler, OutVector &dst, const MGLevelObject< VectorType > &src) const
void build(const DoFHandler< dim > &dof_handler, const std::vector< std::shared_ptr< const Utilities::MPI::Partitioner > > &external_partitioners={})
MGTransferMatrixFree(const MGConstrainedDoFs &mg_constrained_dofs)
void fill_and_communicate_copy_indices_global_coarsening(const DoFHandler< dim > &dof_handler)
void build(const DoFHandler< dim > &dof_handler, const std::function< void(const unsigned int, VectorType &)> &initialize_dof_vector)
void initialize_internal_transfer(const DoFHandler< dim > &dof_handler, const ObserverPointer< const MGConstrainedDoFs > &mg_constrained_dofs)
virtual void restrict_and_add(const unsigned int from_level, VectorType &dst, const VectorType &src) const override
void prolongate_and_add(const unsigned int to_level, VectorType &dst, const VectorType &src) const override
MGLevelObject< ObserverPointer< MGTwoLevelTransferBase< dim, VectorType > > > transfer
void build(const std::function< void(const unsigned int, VectorType &)> &initialize_dof_vector)
MGTransferMatrixFree(const MGLevelObject< MGTwoLevelTransferObject > &transfer, const std::function< void(const unsigned int, VectorType &)> &initialize_dof_vector={})
void initialize_constraints(const MGConstrainedDoFs &mg_constrained_dofs)
unsigned int min_level() const
std::pair< const DoFHandler< dim > *, unsigned int > get_dof_handler_fine() const
LinearAlgebra::distributed::Vector< Number, MemorySpace > VectorType
void copy_to_mg(const DoFHandler< dim > &dof_handler, MGLevelObject< VectorType > &dst, const InVector &src) const
void assert_dof_handler(const DoFHandler< dim > &dof_handler_out) const
std::size_t memory_consumption() const
std::shared_ptr< const Utilities::MPI::Partitioner > partitioner_fine
virtual std::pair< const DoFHandler< dim > *, unsigned int > get_dof_handler_fine() const =0
virtual std::size_t memory_consumption() const =0
virtual void restrict_and_add(VectorType &dst, const VectorType &src) const =0
virtual std::pair< bool, bool > 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
std::shared_ptr< const Utilities::MPI::Partitioner > partitioner_coarse
virtual void prolongate_and_add(VectorType &dst, const VectorType &src) const =0
virtual void interpolate(VectorType &dst, const VectorType &src) const =0
typename VectorType::value_type Number
std::size_t memory_consumption() const override
MGTwoLevelTransfer< dim, VectorTypeHost > host_transfer
void interpolate(VectorType &dst, const VectorType &src) const override
void reinit(const MatrixFree< dim, Number > &matrix_free_fine, const unsigned int dof_handler_index_fine, const MatrixFree< dim, Number > &matrix_free_coarse, const unsigned int dof_handler_index_coarse)
void restrict_and_add(VectorType &dst, const VectorType &src) const override
LinearAlgebra::distributed::Vector< Number, MemorySpace::Host > VectorTypeHost
bool fast_polynomial_transfer_supported(const unsigned int fe_degree_fine, const unsigned int fe_degree_coarse)
void copy_to_host(VectorTypeHost &dst, const VectorType &src) const
std::pair< const DoFHandler< dim > *, unsigned int > get_dof_handler_fine() const override
std::pair< bool, bool > 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 copy_from_host(VectorType &dst, const VectorTypeHost &src) const
void prolongate_and_add(VectorType &dst, const VectorType &src) const override
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)
std::shared_ptr< NonMatching::MappingInfo< dim, dim, Number > > mapping_info
boost::signals2::connection connect_restriction(const std::function< void(const bool)> &slot)
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 >())
std::unique_ptr< FiniteElement< dim > > fe_coarse
ObserverPointer< const DoFHandler< dim > > dof_handler_fine
void restrict_and_add_internal_comp(VectorType &dst, const VectorType &src) const
boost::signals2::connection connect_prolongation_cell_loop(const std::function< void(const bool)> &slot)
std::size_t memory_consumption() const override
std::pair< bool, bool > 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
Utilities::MPI::RemotePointEvaluation< dim > rpe
void restrict_and_add_internal(VectorType &dst, const VectorType &src) const override
std::vector< unsigned int > level_dof_indices_fine_ptrs
internal::MatrixFreeFunctions::ConstraintInfo< dim, VectorizedArrayType, unsigned int > constraint_info
boost::signals2::connection connect_prolongation(const std::function< void(const bool)> &slot)
boost::signals2::connection connect_restriction_cell_loop(const std::function< void(const bool)> &slot)
VectorizedArray< Number, 1 > VectorizedArrayType
void prolongate_and_add_internal_comp(VectorType &dst, const VectorType &src) const
MGTwoLevelTransferNonNested(const AdditionalData &data=AdditionalData())
void interpolate(VectorType &dst, const VectorType &src) const override
std::vector< unsigned int > level_dof_indices_fine
typename VectorType::value_type Number
void prolongate_and_add_internal(VectorType &dst, const VectorType &src) const override
std::pair< const DoFHandler< dim > *, unsigned int > get_dof_handler_fine() 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)
internal::MatrixFreeFunctions::ConstraintInfo< dim, VectorizedArrayType, types::global_dof_index > constraint_info_fine
void reinit(const MatrixFree< dim, Number > &matrix_free_fine, const unsigned int dof_handler_index_fine, const MatrixFree< dim, Number > &matrix_free_coarse, const unsigned int dof_handler_index_coarse)
friend class internal::MGTwoLevelTransferImplementation
std::vector< MGTransferScheme > schemes
ObserverPointer< const DoFHandler< dim > > dof_handler_fine
VectorizedArray< Number > VectorizedArrayType
friend class Portable::internal::MGTwoLevelTransferImplementation
typename VectorType::value_type Number
std::vector< unsigned char > weights_are_compressed
std::pair< const DoFHandler< dim > *, unsigned int > get_dof_handler_fine() const override
void interpolate(VectorType &dst, const VectorType &src) const override
internal::MatrixFreeFunctions::ConstraintInfo< dim, VectorizedArrayType, types::global_dof_index > constraint_info_coarse
std::unique_ptr< MatrixFreeRelatedData > matrix_free_data
static bool fast_polynomial_transfer_supported(const unsigned int fe_degree_fine, const unsigned int fe_degree_coarse)
AlignedVector< VectorizedArrayType > weights
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)
std::pair< bool, bool > 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 restrict_and_add_internal(VectorType &dst, const VectorType &src) const override
std::vector< unsigned int > weights_start
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)
std::size_t memory_consumption() const override
void prolongate_and_add_internal(VectorType &dst, const VectorType &src) const override
Abstract base class for mapping classes.
Definition mapping.h:318
Communicate values between a mesh and arbitrary points.
static constexpr std::size_t size()
std::shared_ptr< const Utilities::MPI::Partitioner > partitioner_fine_embedded
void restrict_and_add(VectorType &dst, const VectorType &src) const override
virtual void restrict_and_add_internal(VectorType &dst, const VectorType &src) const =0
void zero_out_ghost_values(const VectorType &vec) const
AlignedVector< Number > buffer_coarse_embedded
std::pair< bool, bool > 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 >, IndexType > &constraint_info_coarse, std::vector< unsigned int > &dof_indices_fine)
void compress(VectorType &vec, const VectorOperation::values op) const
std::shared_ptr< const Utilities::MPI::Partitioner > partitioner_coarse_embedded
typename VectorType::value_type Number
virtual void prolongate_and_add_internal(VectorType &dst, const VectorType &src) const =0
void prolongate_and_add(VectorType &dst, const VectorType &src) const override
void update_ghost_values(const VectorType &vec) const
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:38
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:39
#define Assert(cond, exc)
#define AssertDimension(dim1, dim2)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcMessage(std::string arg1)
void interpolate(const DoFHandler< dim, spacedim > &dof1, const InVector &u1, const DoFHandler< dim, spacedim > &dof2, OutVector &u2)
std::enable_if_t< IsBlockVector< VectorType >::value, void > collect_sizes(VectorType &vector)
Definition operators.h:93
std::enable_if_t< IsBlockVector< VectorType >::value, unsigned int > n_blocks(const VectorType &vector)
Definition operators.h:47
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:1610
Definition mg.h:79
constexpr unsigned int invalid_unsigned_int
Definition types.h:236
AdditionalData(const double tolerance=1e-6, const unsigned int rtree_level=0, const bool enforce_all_points_found=true)
internal::MatrixFreeFunctions::ShapeInfo< double > shape_info_coarse
std::vector< std::array< unsigned int, VectorizedArrayType::size()> > cell_list_fine_to_coarse
ObserverPointer< const MatrixFree< dim, Number > > matrix_free_fine
ObserverPointer< const MatrixFree< dim, Number > > matrix_free_coarse
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