deal.II version GIT relicensing-3356-g4636aadadd 2025-05-22 18:40:00+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\}}\)
Loading...
Searching...
No Matches
grid_tools.h
Go to the documentation of this file.
1// ------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: LGPL-2.1-or-later
4// Copyright (C) 2001 - 2024 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Part of the source code is dual licensed under Apache-2.0 WITH
9// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
10// governing the source code and code contributions can be found in
11// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
12//
13// ------------------------------------------------------------------------
14
15#ifndef dealii_grid_tools_h
16#define dealii_grid_tools_h
17
18
19#include <deal.II/base/config.h>
20
23#include <deal.II/base/point.h>
24
26
28
30
32#include <deal.II/fe/mapping.h>
33
37#include <deal.II/grid/tria.h>
40
45
47
48#include <boost/archive/binary_iarchive.hpp>
49#include <boost/archive/binary_oarchive.hpp>
50#include <boost/random/mersenne_twister.hpp>
51#include <boost/serialization/array.hpp>
52#include <boost/serialization/vector.hpp>
53
54#ifdef DEAL_II_WITH_ZLIB
55# include <boost/iostreams/device/back_inserter.hpp>
56# include <boost/iostreams/filter/gzip.hpp>
57# include <boost/iostreams/filtering_stream.hpp>
58# include <boost/iostreams/stream.hpp>
59#endif
60
61#include <optional>
62#include <set>
63
64#ifdef DEAL_II_HAVE_CXX20
65# include <concepts>
66#endif
67
68
70
71// Forward declarations
72#ifndef DOXYGEN
73namespace parallel
74{
75 namespace distributed
76 {
77 template <int dim, int spacedim>
79 class Triangulation;
80 }
81} // namespace parallel
82
83namespace hp
84{
85 template <int, int>
86 class MappingCollection;
87}
88
89class SparsityPattern;
90
91namespace GridTools
92{
93 template <int dim, int spacedim>
94 class Cache;
95}
96#endif
97
98namespace internal
99{
100 template <int dim, int spacedim, typename MeshType>
103 {
104 public:
105#ifndef _MSC_VER
106 using type = typename MeshType::active_cell_iterator;
107#else
109#endif
110 };
111
112#ifdef _MSC_VER
113 template <int dim, int spacedim>
114 class ActiveCellIterator<dim, spacedim, DoFHandler<dim, spacedim>>
115 {
116 public:
117 using type =
119 };
120#endif
121} // namespace internal
122
131namespace GridTools
132{
219 template <int dim, typename Transformation, int spacedim>
221 (std::invocable<Transformation, Point<spacedim>> &&
222 std::assignable_from<
224 std::invoke_result_t<Transformation, Point<spacedim>>>))
226 Triangulation<dim, spacedim> &triangulation);
227
234 template <int dim, int spacedim>
235 void
236 shift(const Tensor<1, spacedim> &shift_vector,
237 Triangulation<dim, spacedim> &triangulation);
238
239
250 template <int dim, int spacedim>
251 void
252 rotate(const double angle, Triangulation<dim, spacedim> &triangulation);
253
266 template <int dim>
267 void
268 rotate(const Tensor<1, 3, double> &axis,
269 const double angle,
271
329 template <int dim>
330 void
331 laplace_transform(const std::map<unsigned int, Point<dim>> &new_points,
332 Triangulation<dim> &tria,
333 const Function<dim, double> *coefficient = nullptr,
335
343 template <int dim, int spacedim>
344 void
346 Triangulation<dim, spacedim> &triangulation);
347
377 template <int dim, int spacedim>
378 void
380 const double factor,
381 Triangulation<dim, spacedim> &triangulation,
382 const bool keep_boundary = true,
383 const unsigned int seed = boost::random::mt19937::default_seed);
384
474 template <int dim, int spacedim>
475 void
476 regularize_corner_cells(Triangulation<dim, spacedim> &tria,
477 const double limit_angle_fraction = .75);
478
542 template <int dim, int spacedim>
543#ifndef DOXYGEN
544 std::tuple<
545 std::vector<typename Triangulation<dim, spacedim>::active_cell_iterator>,
546 std::vector<std::vector<Point<dim>>>,
547 std::vector<std::vector<unsigned int>>>
548#else
549 return_type
550#endif
552 const Cache<dim, spacedim> &cache,
553 const std::vector<Point<spacedim>> &points,
555 &cell_hint =
557
591 template <int dim, int spacedim>
592#ifndef DOXYGEN
593 std::tuple<
594 std::vector<typename Triangulation<dim, spacedim>::active_cell_iterator>,
595 std::vector<std::vector<Point<dim>>>,
596 std::vector<std::vector<unsigned int>>,
597 std::vector<unsigned int>>
598#else
599 return_type
600#endif
602 const Cache<dim, spacedim> &cache,
603 const std::vector<Point<spacedim>> &points,
605 &cell_hint =
607
687 template <int dim, int spacedim>
688#ifndef DOXYGEN
689 std::tuple<
690 std::vector<typename Triangulation<dim, spacedim>::active_cell_iterator>,
691 std::vector<std::vector<Point<dim>>>,
692 std::vector<std::vector<unsigned int>>,
693 std::vector<std::vector<Point<spacedim>>>,
694 std::vector<std::vector<unsigned int>>>
695#else
696 return_type
697#endif
700 const std::vector<Point<spacedim>> &local_points,
701 const std::vector<std::vector<BoundingBox<spacedim>>> &global_bboxes,
702 const double tolerance = 1e-10,
703 const std::vector<bool> &marked_vertices = {},
704 const bool enforce_unique_mapping = true);
705
706 namespace internal
707 {
722 template <int dim, int spacedim>
724 {
726
733 void
735
739 unsigned int n_searched_points;
740
747 std::vector<std::tuple<std::pair<int, int>,
748 unsigned int,
749 unsigned int,
752 unsigned int>>
754
758 std::vector<unsigned int> send_ranks;
759
765 std::vector<unsigned int> send_ptrs;
766
777 std::vector<std::tuple<unsigned int, unsigned int, unsigned int>>
779
783 std::vector<unsigned int> recv_ranks;
784
790 std::vector<unsigned int> recv_ptrs;
791 };
792
802 template <int dim, int spacedim>
806 const std::vector<Point<spacedim>> &points,
807 const std::vector<std::vector<BoundingBox<spacedim>>> &global_bboxes,
808 const std::vector<bool> &marked_vertices,
809 const double tolerance,
810 const bool perform_handshake,
811 const bool enforce_unique_mapping = false);
812
813
821 template <int structdim, int spacedim>
823 {
828 std::array<::Point<spacedim>, structdim + 1>;
829
838 std::vector<std::tuple<std::pair<int, int>,
839 unsigned int,
840 unsigned int,
843
852 std::vector<std::tuple<unsigned int, unsigned int, IntersectionType>>
854
858 std::vector<unsigned int> recv_ptrs;
859
880 template <int dim>
882 spacedim>
884 const unsigned int n_points_1D,
886 const Mapping<dim, spacedim> &mapping,
888 nullptr,
889 const bool consistent_numbering_of_sender_and_receiver = false) const;
890
891 private:
899 std::map<unsigned int, std::vector<unsigned int>>
901 const std::vector<std::tuple<unsigned int, unsigned int, unsigned int>>
903 const MPI_Comm comm) const;
904 };
905
913 template <int structdim, int dim, int spacedim>
916 const Cache<dim, spacedim> &cache,
917 const std::vector<std::vector<Point<spacedim>>> &intersection_requests,
918 const std::vector<std::vector<BoundingBox<spacedim>>> &global_bboxes,
919 const std::vector<bool> &marked_vertices,
920 const double tolerance);
921
922 } // namespace internal
923
933 template <int spacedim>
934 unsigned int
935 find_closest_vertex(const std::map<unsigned int, Point<spacedim>> &vertices,
936 const Point<spacedim> &p);
937
964 template <int dim, template <int, int> class MeshType, int spacedim>
967 unsigned int find_closest_vertex(
968 const MeshType<dim, spacedim> &mesh,
969 const Point<spacedim> &p,
970 const std::vector<bool> &marked_vertices = {});
971
998 template <int dim, template <int, int> class MeshType, int spacedim>
1001 unsigned int find_closest_vertex(
1002 const Mapping<dim, spacedim> &mapping,
1003 const MeshType<dim, spacedim> &mesh,
1004 const Point<spacedim> &p,
1005 const std::vector<bool> &marked_vertices = {});
1006
1007
1030 template <typename MeshType>
1032#ifndef _MSC_VER
1033 std::vector<typename MeshType::active_cell_iterator>
1034#else
1035 std::vector<
1036 typename ::internal::ActiveCellIterator<MeshType::dimension,
1037 MeshType::space_dimension,
1038 MeshType>::type>
1039#endif
1040 find_cells_adjacent_to_vertex(const MeshType &container,
1041 const unsigned int vertex_index);
1042
1108 template <int dim, template <int, int> class MeshType, int spacedim>
1111#ifndef _MSC_VER
1112 std::pair<typename MeshType<dim, spacedim>::active_cell_iterator, Point<dim>>
1113#else
1114 std::pair<typename ::internal::
1115 ActiveCellIterator<dim, spacedim, MeshType<dim, spacedim>>::type,
1116 Point<dim>>
1117#endif
1120 const Point<spacedim> &p,
1121 const std::vector<bool> &marked_vertices = {},
1122 const double tolerance = 1.e-10);
1123
1134 template <int dim, template <int, int> class MeshType, int spacedim>
1137#ifndef _MSC_VER
1139#else
1140 typename ::internal::
1141 ActiveCellIterator<dim, spacedim, MeshType<dim, spacedim>>::type
1142#endif
1144 const Point<spacedim> &p,
1145 const std::vector<bool> &marked_vertices = {},
1146 const double tolerance = 1.e-10);
1147
1154 template <int dim, int spacedim>
1155 std::pair<typename DoFHandler<dim, spacedim>::active_cell_iterator,
1156 Point<dim>>
1160 const Point<spacedim> &p,
1161 const double tolerance = 1.e-10);
1162
1214 template <int dim, int spacedim>
1215 std::pair<typename Triangulation<dim, spacedim>::active_cell_iterator,
1216 Point<dim>>
1218 const Cache<dim, spacedim> &cache,
1219 const Point<spacedim> &p,
1222 const std::vector<bool> &marked_vertices = {},
1223 const double tolerance = 1.e-10);
1224
1241 template <int dim, template <int, int> class MeshType, int spacedim>
1244#ifndef _MSC_VER
1245 std::pair<typename MeshType<dim, spacedim>::active_cell_iterator, Point<dim>>
1246#else
1247 std::pair<typename ::internal::
1248 ActiveCellIterator<dim, spacedim, MeshType<dim, spacedim>>::type,
1249 Point<dim>>
1250#endif
1252 const Mapping<dim, spacedim> &mapping,
1254 const Point<spacedim> &p,
1255 const std::vector<
1258 const std::vector<std::vector<Tensor<1, spacedim>>>
1259 &vertex_to_cell_centers,
1260 const typename MeshType<dim, spacedim>::active_cell_iterator &cell_hint =
1262 const std::vector<bool> &marked_vertices = {},
1263 const RTree<std::pair<Point<spacedim>, unsigned int>> &
1264 used_vertices_rtree = RTree<std::pair<Point<spacedim>, unsigned int>>{},
1265 const double tolerance = 1.e-10,
1266 const RTree<
1267 std::pair<BoundingBox<spacedim>,
1270
1300 template <int dim, template <int, int> class MeshType, int spacedim>
1303#ifndef _MSC_VER
1304 std::vector<std::pair<typename MeshType<dim, spacedim>::active_cell_iterator,
1305 Point<dim>>>
1306#else
1307 std::vector<std::pair<
1308 typename ::internal::
1309 ActiveCellIterator<dim, spacedim, MeshType<dim, spacedim>>::type,
1310 Point<dim>>>
1311#endif
1313 const Mapping<dim, spacedim> &mapping,
1315 const Point<spacedim> &p,
1316 const double tolerance,
1317 const std::pair<typename MeshType<dim, spacedim>::active_cell_iterator,
1318 Point<dim>> &first_cell,
1319 const std::vector<
1321 *vertex_to_cells = nullptr);
1322
1332 template <int dim, template <int, int> class MeshType, int spacedim>
1335#ifndef _MSC_VER
1336 std::vector<std::pair<typename MeshType<dim, spacedim>::active_cell_iterator,
1337 Point<dim>>>
1338#else
1339 std::vector<std::pair<
1340 typename ::internal::
1341 ActiveCellIterator<dim, spacedim, MeshType<dim, spacedim>>::type,
1342 Point<dim>>>
1343#endif
1345 const Mapping<dim, spacedim> &mapping,
1347 const Point<spacedim> &p,
1348 const double tolerance = 1e-10,
1349 const std::vector<bool> &marked_vertices = {});
1350
1374 template <typename MeshType>
1376 std::vector<typename MeshType::active_cell_iterator> get_active_child_cells(
1377 const typename MeshType::cell_iterator &cell);
1378
1406 DEAL_II_CXX20_REQUIRES(concepts::is_triangulation_or_dof_handler<MeshType>)
1408 const typename MeshType::active_cell_iterator &cell,
1409 std::vector<typename MeshType::active_cell_iterator> &active_neighbors);
1410
1463 DEAL_II_CXX20_REQUIRES(concepts::is_triangulation_or_dof_handler<MeshType>)
1464 std::
1465 vector<typename MeshType::active_cell_iterator> compute_active_cell_halo_layer(
1467 const std::function<bool(const typename MeshType::active_cell_iterator &)>
1468 &predicate);
1469
1470
1481 DEAL_II_CXX20_REQUIRES(concepts::is_triangulation_or_dof_handler<MeshType>)
1482 std::
1483 vector<typename MeshType::cell_iterator> compute_cell_halo_layer_on_level(
1485 const std::function<bool(const typename MeshType::cell_iterator &)>
1486 &predicate,
1487 const unsigned int level);
1488
1489
1505 DEAL_II_CXX20_REQUIRES(concepts::is_triangulation_or_dof_handler<MeshType>)
1506 std::vector<
1508 active_cell_iterator> compute_ghost_cell_halo_layer(const MeshType &mesh);
1509
1561 DEAL_II_CXX20_REQUIRES(concepts::is_triangulation_or_dof_handler<MeshType>)
1562 std::
1563 vector<typename MeshType::active_cell_iterator> compute_active_cell_layer_within_distance(
1565 const std::function<bool(const typename MeshType::active_cell_iterator &)>
1566 &predicate,
1567 const double layer_thickness);
1568
1594 DEAL_II_CXX20_REQUIRES(concepts::is_triangulation_or_dof_handler<MeshType>)
1595 std::
1596 vector<typename MeshType::active_cell_iterator> compute_ghost_cell_layer_within_distance(
1598 const double layer_thickness);
1599
1673 DEAL_II_CXX20_REQUIRES(concepts::is_triangulation_or_dof_handler<MeshType>)
1674 std::
1677 const std::function<bool(const typename MeshType::active_cell_iterator &)>
1678 &predicate,
1679 const unsigned int refinement_level = 0,
1680 const bool allow_merge = false,
1681 const unsigned int max_boxes = numbers::invalid_unsigned_int);
1682
1710 template <int spacedim>
1711#ifndef DOXYGEN
1712 std::tuple<std::vector<std::vector<unsigned int>>,
1713 std::map<unsigned int, unsigned int>,
1714 std::map<unsigned int, std::vector<unsigned int>>>
1715#else
1716 return_type
1717#endif
1719 const std::vector<std::vector<BoundingBox<spacedim>>> &global_bboxes,
1720 const std::vector<Point<spacedim>> &points);
1721
1722
1757 template <int spacedim>
1758#ifndef DOXYGEN
1759 std::tuple<std::map<unsigned int, std::vector<unsigned int>>,
1760 std::map<unsigned int, unsigned int>,
1761 std::map<unsigned int, std::vector<unsigned int>>>
1762#else
1763 return_type
1764#endif
1766 const RTree<std::pair<BoundingBox<spacedim>, unsigned int>> &covering_rtree,
1767 const std::vector<Point<spacedim>> &points);
1768
1781 template <int dim, int spacedim>
1782 std::vector<std::vector<Tensor<1, spacedim>>>
1785 const std::vector<
1787 &vertex_to_cells);
1788
1789
1797 template <int dim, int spacedim>
1798 unsigned int
1801 const Point<spacedim> &position,
1802 const Mapping<dim, spacedim> &mapping =
1803 (ReferenceCells::get_hypercube<dim>()
1806#else
1807 .ReferenceCell::get_default_linear_mapping<dim, spacedim>()
1808#endif
1809 ));
1810
1822 template <int dim, int spacedim>
1823 std::map<unsigned int, types::global_vertex_index>
1826
1853 template <int dim, int spacedim>
1854 void
1855 partition_triangulation(const unsigned int n_partitions,
1857 const SparsityTools::Partitioner partitioner =
1859
1870 template <int dim, int spacedim>
1871 void
1872 partition_triangulation(const unsigned int n_partitions,
1873 const std::vector<unsigned int> &cell_weights,
1875 const SparsityTools::Partitioner partitioner =
1877
1923 template <int dim, int spacedim>
1924 void
1925 partition_triangulation(const unsigned int n_partitions,
1928 const SparsityTools::Partitioner partitioner =
1930
1941 template <int dim, int spacedim>
1942 void
1943 partition_triangulation(const unsigned int n_partitions,
1944 const std::vector<unsigned int> &cell_weights,
1947 const SparsityTools::Partitioner partitioner =
1949
1964 template <int dim, int spacedim>
1965 void
1968 const bool group_siblings = true);
1969
1981 template <int dim, int spacedim>
1982 void
1984
1992 template <int dim, int spacedim>
1993 std::vector<types::subdomain_id>
1995 const std::vector<CellId> &cell_ids);
1996
2007 template <int dim, int spacedim>
2008 void
2010 std::vector<types::subdomain_id> &subdomain);
2011
2026 template <int dim, int spacedim>
2027 unsigned int
2031
2061 template <int dim, int spacedim>
2062 std::vector<bool>
2064
2091 template <int dim, int spacedim>
2095 &distorted_cells,
2097
2098
2099
2149 template <typename MeshType>
2151 std::vector<typename MeshType::active_cell_iterator> get_patch_around_cell(
2152 const typename MeshType::active_cell_iterator &cell);
2153
2154
2176 template <class Container>
2177 std::vector<typename Container::cell_iterator>
2179 const std::vector<typename Container::active_cell_iterator> &patch_cells);
2180
2247 template <class Container>
2248 void
2250 const std::vector<typename Container::active_cell_iterator> &patch,
2253 std::map<
2254 typename Triangulation<Container::dimension,
2255 Container::space_dimension>::active_cell_iterator,
2256 typename Container::active_cell_iterator> &patch_to_global_tria_map);
2257
2289 template <int dim, int spacedim>
2290 std::map<
2292 std::vector<typename DoFHandler<dim, spacedim>::active_cell_iterator>>
2294
2295
2310 template <typename CellIterator>
2312 {
2316 CellIterator cell[2];
2317
2322 unsigned int face_idx[2];
2323
2330
2344
2348 std::size_t
2350 };
2351
2352
2374 template <typename FaceIterator>
2375 std::optional<types::geometric_orientation>
2377 const FaceIterator &face1,
2378 const FaceIterator &face2,
2379 const unsigned int direction,
2382 const FullMatrix<double> &matrix = FullMatrix<double>());
2383
2442 template <typename MeshType>
2445 const MeshType &mesh,
2448 const unsigned int direction,
2453 const FullMatrix<double> &matrix = FullMatrix<double>());
2454
2455
2476 template <typename MeshType>
2480 const types::boundary_id b_id,
2481 const unsigned int direction,
2482 std::vector<PeriodicFacePair<typename MeshType::cell_iterator>>
2484 const ::Tensor<1, MeshType::space_dimension> &offset =
2485 ::Tensor<1, MeshType::space_dimension>(),
2486 const FullMatrix<double> &matrix = FullMatrix<double>());
2487
2514 template <int dim, int spacedim>
2515 void
2516 copy_boundary_to_manifold_id(Triangulation<dim, spacedim> &tria,
2518
2540 template <int dim, int spacedim>
2541 void
2543 const std::vector<types::boundary_id> &src_boundary_ids,
2544 const std::vector<types::manifold_id> &dst_manifold_ids,
2545 Triangulation<dim, spacedim> &tria,
2546 const std::vector<types::boundary_id> &reset_boundary_ids = {});
2547
2577 template <int dim, int spacedim>
2578 void
2580 const bool compute_face_ids = false);
2581
2606 template <int dim, int spacedim>
2607 void
2610 const std::function<types::manifold_id(
2611 const std::set<types::manifold_id> &)> &disambiguation_function =
2612 [](const std::set<types::manifold_id> &manifold_ids) {
2613 if (manifold_ids.size() == 1)
2614 return *manifold_ids.begin();
2615 else
2617 },
2707 template <typename DataType, typename MeshType>
2711 const std::function<std::optional<DataType>(
2712 const typename MeshType::active_cell_iterator &)> &pack,
2713 const std::function<void(const typename MeshType::active_cell_iterator &,
2714 const DataType &)> &unpack,
2715 const std::function<bool(const typename MeshType::active_cell_iterator &)>
2716 &cell_filter =
2717 always_return<typename MeshType::active_cell_iterator, bool>{true});
2718
2731 template <typename DataType, typename MeshType>
2735 const std::function<std::optional<DataType>(
2736 const typename MeshType::level_cell_iterator &)> &pack,
2737 const std::function<void(const typename MeshType::level_cell_iterator &,
2738 const DataType &)> &unpack,
2739 const std::function<bool(const typename MeshType::level_cell_iterator &)> &
2740 cell_filter = always_return<typename MeshType::level_cell_iterator, bool>{
2741 true});
2742
2743 /* Exchange with all processors of the MPI communicator @p mpi_communicator the vector of bounding
2744 * boxes @p local_bboxes.
2745 *
2746 * This function is meant to exchange bounding boxes describing the locally
2747 * owned cells in a distributed triangulation obtained with the function
2748 * GridTools::compute_mesh_predicate_bounding_box .
2749 *
2750 * The output vector's size is the number of processes of the MPI
2751 * communicator:
2752 * its i-th entry contains the vector @p local_bboxes of the i-th process.
2753 */
2754 template <int spacedim>
2755 std::vector<std::vector<BoundingBox<spacedim>>>
2757 const std::vector<BoundingBox<spacedim>> &local_bboxes,
2758 const MPI_Comm mpi_communicator);
2759
2792 template <int spacedim>
2795 const std::vector<BoundingBox<spacedim>> &local_description,
2796 const MPI_Comm mpi_communicator);
2797
2815 template <int dim, int spacedim>
2816 void
2818 const Triangulation<dim, spacedim> &tria,
2819 std::map<unsigned int, std::vector<unsigned int>> &coinciding_vertex_groups,
2820 std::map<unsigned int, unsigned int> &vertex_to_coinciding_vertex_group);
2821
2841 template <int dim, int spacedim>
2842 std::map<unsigned int, std::set<::types::subdomain_id>>
2844 const Triangulation<dim, spacedim> &tria);
2845
2866 template <int dim, typename VectorType>
2868 {
2869 public:
2873 using value_type = typename VectorType::value_type;
2874
2879 const FiniteElement<dim, dim> &fe,
2880 const unsigned int n_subdivisions = 1,
2881 const double tolerance = 1e-10);
2882
2893 void
2895 const VectorType &ls_vector,
2896 const double iso_level,
2897 std::vector<Point<dim>> &vertices,
2898 std::vector<CellData<dim == 1 ? 1 : dim - 1>> &cells) const;
2899
2904 void
2906 const VectorType &ls_vector,
2907 const double iso_level,
2908 std::vector<Point<dim>> &vertices) const;
2909
2919 void
2921 const VectorType &ls_vector,
2922 const double iso_level,
2923 std::vector<Point<dim>> &vertices,
2924 std::vector<CellData<dim == 1 ? 1 : dim - 1>> &cells) const;
2930 void
2932 const VectorType &ls_vector,
2933 const double iso_level,
2934 std::vector<Point<dim>> &vertices) const;
2935
2936 private:
2941 static Quadrature<dim>
2942 create_quadrature_rule(const unsigned int n_subdivisions);
2943
2947 void
2948 process_cell(std::vector<value_type> &ls_values,
2949 const std::vector<Point<dim>> &points,
2950 const double iso_level,
2951 std::vector<Point<dim>> &vertices,
2952 std::vector<CellData<dim == 1 ? 1 : dim - 1>> &cells,
2953 const bool write_back_cell_data = true) const;
2954
2958 void
2959 process_sub_cell(const std::vector<value_type> &,
2960 const std::vector<Point<1>> &,
2961 const std::vector<unsigned int> &,
2962 const double,
2963 std::vector<Point<1>> &,
2964 std::vector<CellData<1>> &,
2965 const bool) const
2966 {
2968 }
2969
2976 void
2977 process_sub_cell(const std::vector<value_type> &ls_values,
2978 const std::vector<Point<2>> &points,
2979 const std::vector<unsigned int> &mask,
2980 const double iso_level,
2981 std::vector<Point<2>> &vertices,
2982 std::vector<CellData<1>> &cells,
2983 const bool write_back_cell_data) const;
2984
2988 void
2989 process_sub_cell(const std::vector<value_type> &ls_values,
2990 const std::vector<Point<3>> &points,
2991 const std::vector<unsigned int> &mask,
2992 const double iso_level,
2993 std::vector<Point<3>> &vertices,
2994 std::vector<CellData<2>> &cells,
2995 const bool write_back_cell_data) const;
2996
3001 const unsigned int n_subdivisions;
3002
3007 const double tolerance;
3008
3014 };
3015
3016
3017
3027 int,
3028 << "The number of partitions you gave is " << arg1
3029 << ", but must be greater than zero.");
3034 int,
3035 << "The subdomain id " << arg1
3036 << " has no cells associated with it.");
3041
3046 double,
3047 << "The scaling factor must be positive, but it is " << arg1
3048 << '.');
3049
3054 unsigned int,
3055 << "The given vertex with index " << arg1
3056 << " is not used in the given triangulation.");
3057
3060} /*namespace GridTools*/
3061
3062/* ----------------- Template function --------------- */
3063
3064#ifndef DOXYGEN
3065
3066namespace GridTools
3067{
3068 template <int dim>
3069 double
3071 const std::vector<Point<dim>> &all_vertices,
3072 const unsigned int (&indices)[GeometryInfo<dim>::vertices_per_cell])
3073 {
3074 // We forward call to the ArrayView version:
3077 return cell_measure(all_vertices, view);
3078 }
3079
3080
3081
3082 // This specialization is defined here so that the general template in the
3083 // source file doesn't need to have further 1d overloads for the internal
3084 // functions it calls.
3085 template <>
3089 {
3090 return {};
3091 }
3092
3093
3094
3095 template <int dim, typename Transformation, int spacedim>
3097 (std::invocable<Transformation, Point<spacedim>> &&
3098 std::assignable_from<
3100 std::invoke_result_t<Transformation, Point<spacedim>>>))
3102 Triangulation<dim, spacedim> &triangulation)
3103 {
3104 std::vector<bool> treated_vertices(triangulation.n_vertices(), false);
3105
3106 // loop over all active cells, and
3107 // transform those vertices that
3108 // have not yet been touched. note
3109 // that we get to all vertices in
3110 // the triangulation by only
3111 // visiting the active cells.
3113 cell = triangulation.begin_active(),
3114 endc = triangulation.end();
3115 for (; cell != endc; ++cell)
3116 for (const unsigned int v : cell->vertex_indices())
3117 if (treated_vertices[cell->vertex_index(v)] == false)
3118 {
3119 // transform this vertex
3120 cell->vertex(v) = transformation(cell->vertex(v));
3121 // and mark it as treated
3122 treated_vertices[cell->vertex_index(v)] = true;
3123 };
3124
3125
3126 // now fix any vertices on hanging nodes so that we don't create any holes
3127 if (dim == 2)
3128 {
3130 cell = triangulation.begin_active(),
3131 endc = triangulation.end();
3132 for (; cell != endc; ++cell)
3133 for (const unsigned int face : cell->face_indices())
3134 if (cell->face(face)->has_children() &&
3135 !cell->face(face)->at_boundary())
3136 {
3137 Assert(cell->reference_cell() ==
3138 ReferenceCells::get_hypercube<dim>(),
3140
3141 // this line has children
3142 cell->face(face)->child(0)->vertex(1) =
3143 (cell->face(face)->vertex(0) + cell->face(face)->vertex(1)) /
3144 2.0;
3145 }
3146 }
3147 else if (dim == 3)
3148 {
3150 cell = triangulation.begin_active(),
3151 endc = triangulation.end();
3152 for (; cell != endc; ++cell)
3153 for (const unsigned int face : cell->face_indices())
3154 if (cell->face(face)->has_children() &&
3155 !cell->face(face)->at_boundary())
3156 {
3157 if (static_cast<std::uint8_t>(
3158 cell->face(face)->refinement_case()) ==
3160 {
3161 Assert(cell->reference_cell() ==
3162 ReferenceCells::get_hypercube<dim>(),
3164
3165 // this face has hanging nodes
3166 cell->face(face)->child(0)->vertex(1) =
3167 (cell->face(face)->vertex(0) +
3168 cell->face(face)->vertex(1)) /
3169 2.0;
3170 cell->face(face)->child(0)->vertex(2) =
3171 (cell->face(face)->vertex(0) +
3172 cell->face(face)->vertex(2)) /
3173 2.0;
3174 cell->face(face)->child(1)->vertex(3) =
3175 (cell->face(face)->vertex(1) +
3176 cell->face(face)->vertex(3)) /
3177 2.0;
3178 cell->face(face)->child(2)->vertex(3) =
3179 (cell->face(face)->vertex(2) +
3180 cell->face(face)->vertex(3)) /
3181 2.0;
3182
3183 // center of the face
3184 cell->face(face)->child(0)->vertex(3) =
3185 (cell->face(face)->vertex(0) +
3186 cell->face(face)->vertex(1) +
3187 cell->face(face)->vertex(2) +
3188 cell->face(face)->vertex(3)) /
3189 4.0;
3190 }
3191 else
3192 {
3193 // Special case for anisotropic refinement
3194 for (unsigned int line = 0;
3195 line < GeometryInfo<dim - 1>::faces_per_cell;
3196 line++)
3197 if (cell->face(face)->line(line)->has_children())
3198 cell->face(face)->line(line)->child(0)->vertex(1) =
3199 (cell->face(face)->line(line)->vertex(0) +
3200 cell->face(face)->line(line)->vertex(1)) /
3201 2.0;
3202 }
3203 }
3204 }
3205
3206 // Make sure FEValues notices that the mesh has changed
3207 triangulation.signals.mesh_movement();
3208 }
3209
3210
3211
3212 template <typename MeshType>
3214 std::vector<typename MeshType::active_cell_iterator> get_active_child_cells(
3215 const typename MeshType::cell_iterator &cell)
3216 {
3217 std::vector<typename MeshType::active_cell_iterator> child_cells;
3218
3219 if (cell->has_children())
3220 {
3221 for (unsigned int child = 0; child < cell->n_children(); ++child)
3222 if (cell->child(child)->has_children())
3223 {
3224 const std::vector<typename MeshType::active_cell_iterator>
3225 children = get_active_child_cells<MeshType>(cell->child(child));
3226 child_cells.insert(child_cells.end(),
3227 children.begin(),
3228 children.end());
3229 }
3230 else
3231 child_cells.push_back(cell->child(child));
3232 }
3233
3234 return child_cells;
3235 }
3236
3237
3238
3239 template <typename MeshType>
3242 const typename MeshType::active_cell_iterator &cell,
3243 std::vector<typename MeshType::active_cell_iterator> &active_neighbors)
3244 {
3246 for (const unsigned int n : cell->face_indices())
3247 if (!cell->at_boundary(n))
3248 {
3249 if (MeshType::dimension == 1)
3250 {
3251 // check children of neighbor. note
3252 // that in 1d children of the neighbor
3253 // may be further refined. In 1d the
3254 // case is simple since we know what
3255 // children bound to the present cell
3256 typename MeshType::cell_iterator neighbor_child =
3257 cell->neighbor(n);
3258 if (!neighbor_child->is_active())
3259 {
3260 while (neighbor_child->has_children())
3261 neighbor_child = neighbor_child->child(n == 0 ? 1 : 0);
3262
3263 Assert(neighbor_child->neighbor(n == 0 ? 1 : 0) == cell,
3265 }
3267 }
3268 else
3269 {
3270 if (cell->face(n)->has_children())
3271 // this neighbor has children. find
3272 // out which border to the present
3273 // cell
3274 for (unsigned int c = 0;
3275 c < cell->face(n)->n_active_descendants();
3276 ++c)
3277 active_neighbors.push_back(
3278 cell->neighbor_child_on_subface(n, c));
3279 else
3280 {
3281 // the neighbor must be active
3282 // himself
3283 Assert(cell->neighbor(n)->is_active(), ExcInternalError());
3284 active_neighbors.push_back(cell->neighbor(n));
3285 }
3286 }
3287 }
3288 }
3289
3290
3291
3292 template <typename CellIterator>
3293 std::size_t
3295 {
3296 return sizeof(*this) + matrix.memory_consumption();
3297 }
3298
3299
3300
3301 namespace internal
3302 {
3303 template <typename DataType,
3304 typename MeshType,
3305 typename MeshCellIteratorType>
3307 inline void exchange_cell_data(
3308 const MeshType &mesh,
3309 const std::function<std::optional<DataType>(const MeshCellIteratorType &)>
3310 &pack,
3311 const std::function<void(const MeshCellIteratorType &, const DataType &)>
3312 &unpack,
3313 const std::function<bool(const MeshCellIteratorType &)> &cell_filter,
3314 const std::function<void(
3315 const std::function<void(const MeshCellIteratorType &,
3317 const std::function<std::set<types::subdomain_id>(
3319 MeshType::space_dimension> &)>
3321 {
3322# ifndef DEAL_II_WITH_MPI
3323 (void)mesh;
3324 (void)pack;
3325 (void)unpack;
3329 Assert(false, ExcNeedsMPI());
3330# else
3331 constexpr int dim = MeshType::dimension;
3332 constexpr int spacedim = MeshType::space_dimension;
3333 auto tria =
3334 dynamic_cast<const parallel::TriangulationBase<dim, spacedim> *>(
3335 &mesh.get_triangulation());
3336 Assert(
3337 tria != nullptr,
3338 ExcMessage(
3339 "The function exchange_cell_data_to_ghosts() only works with parallel triangulations."));
3340
3341 if (const auto tria = dynamic_cast<
3343 &mesh.get_triangulation()))
3344 {
3345 Assert(
3346 tria->with_artificial_cells(),
3347 ExcMessage(
3348 "The functions GridTools::exchange_cell_data_to_ghosts() and "
3349 "GridTools::exchange_cell_data_to_level_ghosts() can only "
3350 "operate on a single layer of ghost cells. However, you have "
3351 "given a Triangulation object of type "
3352 "parallel::shared::Triangulation without artificial cells "
3353 "resulting in an arbitrary number of ghost layers. "
3354 "To use this function for a Triangulation object of type "
3355 "parallel::shared::Triangulation, make sure to create the "
3356 "Triangulation object with allow_artificial_cells set to true. "
3357 "This results in a parallel::shared::Triangulation with only "
3358 "a single layer of ghost cells."));
3359 }
3360
3361 // build list of cells to request for each neighbor
3362 std::set<::types::subdomain_id> ghost_owners =
3363 compute_ghost_owners(*tria);
3364 std::map<::types::subdomain_id,
3365 std::vector<typename CellId::binary_type>>
3367
3368 for (const auto ghost_owner : ghost_owners)
3370
3371 process_cells([&](const auto &cell, const auto key) -> void {
3372 if (cell_filter(cell))
3373 {
3374 constexpr int spacedim = MeshType::space_dimension;
3375 neighbor_cell_list[key].emplace_back(
3376 cell->id().template to_binary<spacedim>());
3377 }
3378 });
3379
3380 Assert(ghost_owners.size() == neighbor_cell_list.size(),
3382
3383
3384 // Before sending & receiving, make sure we protect this section with
3385 // a mutex:
3388 mutex, tria->get_mpi_communicator());
3389
3390 const int mpi_tag =
3392 const int mpi_tag_reply =
3394
3395 // send our requests
3396 std::vector<MPI_Request> requests(ghost_owners.size());
3397 {
3398 unsigned int idx = 0;
3399 for (const auto &it : neighbor_cell_list)
3400 {
3401 // send the data about the relevant cells
3402 const int ierr = MPI_Isend(it.second.data(),
3403 it.second.size() * sizeof(it.second[0]),
3404 MPI_BYTE,
3405 it.first,
3406 mpi_tag,
3407 tria->get_mpi_communicator(),
3408 &requests[idx]);
3410 ++idx;
3411 }
3412 }
3413
3414 // receive requests and reply with the results
3415 std::vector<MPI_Request> reply_requests(ghost_owners.size());
3416 std::vector<std::vector<char>> sendbuffers(ghost_owners.size());
3417
3418 for (unsigned int idx = 0; idx < ghost_owners.size(); ++idx)
3419 {
3420 MPI_Status status;
3422 mpi_tag,
3423 tria->get_mpi_communicator(),
3424 &status);
3426
3427 int len;
3428 ierr = MPI_Get_count(&status, MPI_BYTE, &len);
3430 Assert(len % sizeof(typename CellId::binary_type) == 0,
3432
3433 const unsigned int n_cells =
3434 len / sizeof(typename CellId::binary_type);
3435 std::vector<typename CellId::binary_type> cells_with_requests(
3436 n_cells);
3437 std::vector<DataType> data_to_send;
3438 data_to_send.reserve(n_cells);
3439 std::vector<bool> cell_carries_data(n_cells, false);
3440
3442 len,
3443 MPI_BYTE,
3444 status.MPI_SOURCE,
3445 status.MPI_TAG,
3446 tria->get_mpi_communicator(),
3447 &status);
3449
3450 // store data for each cell
3451 for (unsigned int c = 0; c < static_cast<unsigned int>(n_cells); ++c)
3452 {
3453 const auto cell =
3454 tria->create_cell_iterator(CellId(cells_with_requests[c]));
3455
3457 cell->level(),
3458 cell->index(),
3459 &mesh);
3460
3461 const std::optional<DataType> data = pack(mesh_it);
3462 if (data)
3463 {
3464 data_to_send.emplace_back(*data);
3465 cell_carries_data[c] = true;
3466 }
3467 }
3468
3469 // collect data for sending the reply in a buffer
3470
3471 // (a) make room for storing the local offsets in case we receive
3472 // other data
3473 sendbuffers[idx].resize(sizeof(std::size_t));
3474
3475 // (b) append the actual data and store how much memory it
3476 // corresponds to, which we then insert into the leading position of
3477 // the sendbuffer
3478 std::size_t size_of_send =
3480 sendbuffers[idx],
3481 /*enable_compression*/ false);
3482 std::memcpy(sendbuffers[idx].data(),
3483 &size_of_send,
3484 sizeof(std::size_t));
3485
3486 // (c) append information of certain cells that got left out in case
3487 // we need it
3488 if (data_to_send.size() < n_cells)
3490 sendbuffers[idx],
3491 /*enable_compression*/ false);
3492
3493 // send data
3494 ierr = MPI_Isend(sendbuffers[idx].data(),
3495 sendbuffers[idx].size(),
3496 MPI_BYTE,
3497 status.MPI_SOURCE,
3499 tria->get_mpi_communicator(),
3500 &reply_requests[idx]);
3502 }
3503
3504 // finally receive the replies
3505 std::vector<char> receive;
3506 for (unsigned int id = 0; id < neighbor_cell_list.size(); ++id)
3507 {
3508 MPI_Status status;
3511 tria->get_mpi_communicator(),
3512 &status);
3514
3515 int len;
3516 ierr = MPI_Get_count(&status, MPI_BYTE, &len);
3518
3519 receive.resize(len);
3520
3521 ierr = MPI_Recv(receive.data(),
3522 len,
3523 MPI_BYTE,
3524 status.MPI_SOURCE,
3525 status.MPI_TAG,
3526 tria->get_mpi_communicator(),
3527 &status);
3529
3530 // (a) first determine the length of the data section in the
3531 // received buffer
3532 auto data_iterator = receive.begin();
3533 std::size_t size_of_received_data =
3534 Utilities::unpack<std::size_t>(data_iterator,
3535 data_iterator + sizeof(std::size_t));
3536 data_iterator += sizeof(std::size_t);
3537
3538 // (b) unpack the data section in the indicated region
3539 auto received_data = Utilities::unpack<std::vector<DataType>>(
3542 /*enable_compression*/ false);
3544
3545 // (c) check if the received data contained fewer entries than the
3546 // number of cells we identified in the beginning, in which case we
3547 // need to extract the boolean vector with the relevant information
3548 const std::vector<typename CellId::binary_type> &this_cell_list =
3549 neighbor_cell_list[status.MPI_SOURCE];
3550 AssertIndexRange(received_data.size(), this_cell_list.size() + 1);
3551 std::vector<bool> cells_with_data;
3552 if (received_data.size() < this_cell_list.size())
3553 {
3554 cells_with_data = Utilities::unpack<std::vector<bool>>(
3555 data_iterator, receive.end(), /*enable_compression*/ false);
3557 }
3558
3559 // (d) go through the received data and call the user-provided
3560 // unpack function
3562 for (unsigned int c = 0; c < this_cell_list.size(); ++c)
3563 if (cells_with_data.empty() || cells_with_data[c])
3564 {
3566 tria_cell = tria->create_cell_iterator(this_cell_list[c]);
3567
3568 MeshCellIteratorType cell(tria,
3569 tria_cell->level(),
3570 tria_cell->index(),
3571 &mesh);
3572
3575 }
3576 }
3577
3578 // make sure that all communication is finished
3579 // when we leave this function.
3580 if (requests.size() > 0)
3581 {
3582 const int ierr =
3583 MPI_Waitall(requests.size(), requests.data(), MPI_STATUSES_IGNORE);
3585 }
3586 if (reply_requests.size() > 0)
3587 {
3588 const int ierr = MPI_Waitall(reply_requests.size(),
3589 reply_requests.data(),
3592 }
3593
3594
3595# endif // DEAL_II_WITH_MPI
3596 }
3597
3598 } // namespace internal
3599
3600 template <typename DataType, typename MeshType>
3602 inline void exchange_cell_data_to_ghosts(
3603 const MeshType &mesh,
3604 const std::function<std::optional<DataType>(
3605 const typename MeshType::active_cell_iterator &)> &pack,
3606 const std::function<void(const typename MeshType::active_cell_iterator &,
3607 const DataType &)> &unpack,
3608 const std::function<bool(const typename MeshType::active_cell_iterator &)>
3609 &cell_filter)
3610 {
3611# ifndef DEAL_II_WITH_MPI
3612 (void)mesh;
3613 (void)pack;
3614 (void)unpack;
3616 Assert(false, ExcNeedsMPI());
3617# else
3618 internal::exchange_cell_data<DataType,
3619 MeshType,
3620 typename MeshType::active_cell_iterator>(
3621 mesh,
3622 pack,
3623 unpack,
3625 [&](const auto &process) {
3626 for (const auto &cell : mesh.active_cell_iterators())
3627 if (cell->is_ghost())
3628 process(cell, cell->subdomain_id());
3629 },
3630 [](const auto &tria) { return tria.ghost_owners(); });
3631# endif
3632 }
3633
3634
3635
3636 template <typename DataType, typename MeshType>
3639 const MeshType &mesh,
3640 const std::function<std::optional<DataType>(
3641 const typename MeshType::level_cell_iterator &)> &pack,
3642 const std::function<void(const typename MeshType::level_cell_iterator &,
3643 const DataType &)> &unpack,
3644 const std::function<bool(const typename MeshType::level_cell_iterator &)>
3645 &cell_filter)
3646 {
3647# ifndef DEAL_II_WITH_MPI
3648 (void)mesh;
3649 (void)pack;
3650 (void)unpack;
3652 Assert(false, ExcNeedsMPI());
3653# else
3654 internal::exchange_cell_data<DataType,
3655 MeshType,
3656 typename MeshType::level_cell_iterator>(
3657 mesh,
3658 pack,
3659 unpack,
3661 [&](const auto &process) {
3662 for (const auto &cell : mesh.cell_iterators())
3663 if (cell->is_ghost_on_level())
3664 process(cell, cell->level_subdomain_id());
3665 },
3666 [](const auto &tria) { return tria.level_ghost_owners(); });
3667# endif
3668 }
3669} // namespace GridTools
3670
3671#endif // DOXYGEN
3672
3674
3675#endif
std::array< unsigned int, 4 > binary_type
Definition cell_id.h:80
typename VectorType::value_type value_type
const unsigned int n_subdivisions
static Quadrature< dim > create_quadrature_rule(const unsigned int n_subdivisions)
void process_cell(const typename DoFHandler< dim >::active_cell_iterator &cell, const VectorType &ls_vector, const double iso_level, std::vector< Point< dim > > &vertices, std::vector< CellData< dim==1 ? 1 :dim - 1 > > &cells) const
void process_sub_cell(const std::vector< value_type > &, const std::vector< Point< 1 > > &, const std::vector< unsigned int > &, const double, std::vector< Point< 1 > > &, std::vector< CellData< 1 > > &, const bool) const
void process(const DoFHandler< dim > &background_dof_handler, const VectorType &ls_vector, const double iso_level, std::vector< Point< dim > > &vertices, std::vector< CellData< dim==1 ? 1 :dim - 1 > > &cells) const
Abstract base class for mapping classes.
Definition mapping.h:320
Definition point.h:113
constexpr void clear()
static constexpr unsigned int dimension
Definition tensor.h:477
typename MeshType::active_cell_iterator type
Definition grid_tools.h:106
#define DEAL_II_DEPRECATED
Definition config.h:281
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:35
#define DEAL_II_CXX20_REQUIRES(condition)
Definition config.h:243
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:36
unsigned int level
Definition grid_out.cc:4635
unsigned int vertex_indices[2]
#define DeclException0(Exception0)
static ::ExceptionBase & ExcNotImplemented()
static ::ExceptionBase & ExcNeedsMPI()
static ::ExceptionBase & ExcNonExistentSubdomain(int arg1)
#define Assert(cond, exc)
static ::ExceptionBase & ExcVertexNotUsed(unsigned int arg1)
#define AssertDimension(dim1, dim2)
#define AssertThrowMPI(error_code)
#define AssertIndexRange(index, range)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcTriangulationHasBeenRefined()
#define DeclException1(Exception1, type1, outsequence)
static ::ExceptionBase & ExcInvalidNumberOfPartitions(int arg1)
static ::ExceptionBase & ExcMessage(std::string arg1)
static ::ExceptionBase & ExcScalingFactorNotPositive(double arg1)
#define AssertThrow(cond, exc)
typename ActiveSelector::active_cell_iterator active_cell_iterator
void copy_boundary_to_manifold_id(Triangulation< dim, spacedim > &tria, const bool reset_boundary_ids=false)
void copy_material_to_manifold_id(Triangulation< dim, spacedim > &tria, const bool compute_face_ids=false)
void map_boundary_to_manifold_ids(const std::vector< types::boundary_id > &src_boundary_ids, const std::vector< types::manifold_id > &dst_manifold_ids, Triangulation< dim, spacedim > &tria, const std::vector< types::boundary_id > &reset_boundary_ids={})
void assign_co_dimensional_manifold_indicators(Triangulation< dim, spacedim > &tria, const std::function< types::manifold_id(const std::set< types::manifold_id > &)> &disambiguation_function=[](const std::set< types::manifold_id > &manifold_ids) { if(manifold_ids.size()==1) return *manifold_ids.begin();else return numbers::flat_manifold_id;}, bool overwrite_only_flat_manifold_ids=true)
std::vector< index_type > data
Definition mpi.cc:746
std::size_t size
Definition mpi.cc:745
const MPI_Comm comm
Definition mpi.cc:924
DistributedComputePointLocationsInternal< dim, spacedim > distributed_compute_point_locations(const GridTools::Cache< dim, spacedim > &cache, const std::vector< Point< spacedim > > &points, const std::vector< std::vector< BoundingBox< spacedim > > > &global_bboxes, const std::vector< bool > &marked_vertices, const double tolerance, const bool perform_handshake, const bool enforce_unique_mapping=false)
DistributedComputeIntersectionLocationsInternal< structdim, spacedim > distributed_compute_intersection_locations(const Cache< dim, spacedim > &cache, const std::vector< std::vector< Point< spacedim > > > &intersection_requests, const std::vector< std::vector< BoundingBox< spacedim > > > &global_bboxes, const std::vector< bool > &marked_vertices, const double tolerance)
std::vector< BoundingBox< MeshType::space_dimension > > compute_mesh_predicate_bounding_box(const MeshType &mesh, const std::function< bool(const typename MeshType::active_cell_iterator &)> &predicate, const unsigned int refinement_level=0, const bool allow_merge=false, const unsigned int max_boxes=numbers::invalid_unsigned_int)
void scale(const double scaling_factor, Triangulation< dim, spacedim > &triangulation)
RTree< std::pair< BoundingBox< spacedim >, unsigned int > > build_global_description_tree(const std::vector< BoundingBox< spacedim > > &local_description, const MPI_Comm mpi_communicator)
std::vector< typename MeshType::active_cell_iterator > get_active_child_cells(const typename MeshType::cell_iterator &cell)
void partition_triangulation_zorder(const unsigned int n_partitions, Triangulation< dim, spacedim > &triangulation, const bool group_siblings=true)
Triangulation< dim, spacedim >::DistortedCellList fix_up_distorted_child_cells(const typename Triangulation< dim, spacedim >::DistortedCellList &distorted_cells, Triangulation< dim, spacedim > &triangulation)
std::vector< typename Container::cell_iterator > get_cells_at_coarsest_common_level(const std::vector< typename Container::active_cell_iterator > &patch_cells)
void rotate(const double angle, Triangulation< dim, spacedim > &triangulation)
return_type compute_point_locations(const Cache< dim, spacedim > &cache, const std::vector< Point< spacedim > > &points, const typename Triangulation< dim, spacedim >::active_cell_iterator &cell_hint=typename Triangulation< dim, spacedim >::active_cell_iterator())
unsigned int find_closest_vertex(const std::map< unsigned int, Point< spacedim > > &vertices, const Point< spacedim > &p)
void transform(const Transformation &transformation, Triangulation< dim, spacedim > &triangulation)
unsigned int find_closest_vertex_of_cell(const typename Triangulation< dim, spacedim >::active_cell_iterator &cell, const Point< spacedim > &position, const Mapping< dim, spacedim > &mapping=(ReferenceCells::get_hypercube< dim >() .template get_default_linear_mapping< dim, spacedim >()))
std::pair< typename MeshType< dim, spacedim >::active_cell_iterator, Point< dim > > find_active_cell_around_point(const Mapping< dim, spacedim > &mapping, const MeshType< dim, spacedim > &mesh, const Point< spacedim > &p, const std::vector< bool > &marked_vertices={}, const double tolerance=1.e-10)
void get_active_neighbors(const typename MeshType::active_cell_iterator &cell, std::vector< typename MeshType::active_cell_iterator > &active_neighbors)
std::vector< bool > get_locally_owned_vertices(const Triangulation< dim, spacedim > &triangulation)
void regularize_corner_cells(Triangulation< dim, spacedim > &tria, const double limit_angle_fraction=.75)
void shift(const Tensor< 1, spacedim > &shift_vector, Triangulation< dim, spacedim > &triangulation)
std::vector< typename MeshType::active_cell_iterator > find_cells_adjacent_to_vertex(const MeshType &container, const unsigned int vertex_index)
std::vector< typename MeshType::active_cell_iterator > compute_active_cell_halo_layer(const MeshType &mesh, const std::function< bool(const typename MeshType::active_cell_iterator &)> &predicate)
void exchange_cell_data_to_level_ghosts(const MeshType &mesh, const std::function< std::optional< DataType >(const typename MeshType::level_cell_iterator &)> &pack, const std::function< void(const typename MeshType::level_cell_iterator &, const DataType &)> &unpack, const std::function< bool(const typename MeshType::level_cell_iterator &)> &cell_filter=always_return< typename MeshType::level_cell_iterator, bool >{ true})
std::vector< typename MeshType::active_cell_iterator > compute_active_cell_layer_within_distance(const MeshType &mesh, const std::function< bool(const typename MeshType::active_cell_iterator &)> &predicate, const double layer_thickness)
std::map< unsigned int, types::global_vertex_index > compute_local_to_global_vertex_index_map(const Triangulation< dim, spacedim > &triangulation)
std::vector< typename MeshType::active_cell_iterator > compute_ghost_cell_halo_layer(const MeshType &mesh)
void collect_periodic_faces(const MeshType &mesh, const types::boundary_id b_id1, const types::boundary_id b_id2, const unsigned int direction, std::vector< PeriodicFacePair< typename MeshType::cell_iterator > > &matched_pairs, const Tensor< 1, MeshType::space_dimension > &offset=::Tensor< 1, MeshType::space_dimension >(), const FullMatrix< double > &matrix=FullMatrix< double >())
void exchange_cell_data_to_ghosts(const MeshType &mesh, const std::function< std::optional< DataType >(const typename MeshType::active_cell_iterator &)> &pack, const std::function< void(const typename MeshType::active_cell_iterator &, const DataType &)> &unpack, const std::function< bool(const typename MeshType::active_cell_iterator &)> &cell_filter=always_return< typename MeshType::active_cell_iterator, bool >{true})
void laplace_transform(const std::map< unsigned int, Point< dim > > &new_points, Triangulation< dim > &tria, const Function< dim, double > *coefficient=nullptr, const bool solve_for_absolute_positions=false)
void partition_multigrid_levels(Triangulation< dim, spacedim > &triangulation)
std::map< unsigned int, std::set<::types::subdomain_id > > compute_vertices_with_ghost_neighbors(const Triangulation< dim, spacedim > &tria)
void collect_coinciding_vertices(const Triangulation< dim, spacedim > &tria, std::map< unsigned int, std::vector< unsigned int > > &coinciding_vertex_groups, std::map< unsigned int, unsigned int > &vertex_to_coinciding_vertex_group)
unsigned int count_cells_with_subdomain_association(const Triangulation< dim, spacedim > &triangulation, const types::subdomain_id subdomain)
return_type guess_point_owner(const std::vector< std::vector< BoundingBox< spacedim > > > &global_bboxes, const std::vector< Point< spacedim > > &points)
std::map< types::global_dof_index, std::vector< typename DoFHandler< dim, spacedim >::active_cell_iterator > > get_dof_to_support_patch_map(DoFHandler< dim, spacedim > &dof_handler)
std::vector< typename MeshType::cell_iterator > compute_cell_halo_layer_on_level(const MeshType &mesh, const std::function< bool(const typename MeshType::cell_iterator &)> &predicate, const unsigned int level)
void partition_triangulation(const unsigned int n_partitions, Triangulation< dim, spacedim > &triangulation, const SparsityTools::Partitioner partitioner=SparsityTools::Partitioner::metis)
std::vector< std::set< typename Triangulation< dim, spacedim >::active_cell_iterator > > vertex_to_cell_map(const Triangulation< dim, spacedim > &triangulation)
std::vector< typename MeshType::active_cell_iterator > compute_ghost_cell_layer_within_distance(const MeshType &mesh, const double layer_thickness)
return_type compute_point_locations_try_all(const Cache< dim, spacedim > &cache, const std::vector< Point< spacedim > > &points, const typename Triangulation< dim, spacedim >::active_cell_iterator &cell_hint=typename Triangulation< dim, spacedim >::active_cell_iterator())
std::vector< typename MeshType::active_cell_iterator > get_patch_around_cell(const typename MeshType::active_cell_iterator &cell)
std::vector< types::subdomain_id > get_subdomain_association(const Triangulation< dim, spacedim > &triangulation, const std::vector< CellId > &cell_ids)
void distort_random(const double factor, Triangulation< dim, spacedim > &triangulation, const bool keep_boundary=true, const unsigned int seed=boost::random::mt19937::default_seed)
std::vector< std::vector< Tensor< 1, spacedim > > > vertex_to_cell_centers_directions(const Triangulation< dim, spacedim > &mesh, const std::vector< std::set< typename Triangulation< dim, spacedim >::active_cell_iterator > > &vertex_to_cells)
std::vector< std::pair< typename MeshType< dim, spacedim >::active_cell_iterator, Point< dim > > > find_all_active_cells_around_point(const Mapping< dim, spacedim > &mapping, const MeshType< dim, spacedim > &mesh, const Point< spacedim > &p, const double tolerance, const std::pair< typename MeshType< dim, spacedim >::active_cell_iterator, Point< dim > > &first_cell, const std::vector< std::set< typename MeshType< dim, spacedim >::active_cell_iterator > > *vertex_to_cells=nullptr)
void build_triangulation_from_patch(const std::vector< typename Container::active_cell_iterator > &patch, Triangulation< Container::dimension, Container::space_dimension > &local_triangulation, std::map< typename Triangulation< Container::dimension, Container::space_dimension >::active_cell_iterator, typename Container::active_cell_iterator > &patch_to_global_tria_map)
std::optional< types::geometric_orientation > orthogonal_equality(const FaceIterator &face1, const FaceIterator &face2, const unsigned int direction, const Tensor< 1, FaceIterator::AccessorType::space_dimension > &offset=Tensor< 1, FaceIterator::AccessorType::space_dimension >(), const FullMatrix< double > &matrix=FullMatrix< double >())
std::vector< std::vector< BoundingBox< spacedim > > > exchange_local_bounding_boxes(const std::vector< BoundingBox< spacedim > > &local_bboxes, const MPI_Comm mpi_communicator)
double cell_measure(const std::vector< Point< dim > > &all_vertices, const ArrayView< const unsigned int > &vertex_indices)
return_type distributed_compute_point_locations(const GridTools::Cache< dim, spacedim > &cache, const std::vector< Point< spacedim > > &local_points, const std::vector< std::vector< BoundingBox< spacedim > > > &global_bboxes, const double tolerance=1e-10, const std::vector< bool > &marked_vertices={}, const bool enforce_unique_mapping=true)
@ matrix
Contents is actually a matrix.
@ exchange_cell_data_request
grid_tools.h: exchange_cell_ghosts()
Definition mpi_tags.h:66
@ exchange_cell_data_reply
grid_tools.h: exchange_cell_ghosts()
Definition mpi_tags.h:69
std::size_t pack(const T &object, std::vector< char > &dest_buffer, const bool allow_compression=true)
Definition utilities.h:1382
T unpack(const std::vector< char > &buffer, const bool allow_compression=true)
Definition utilities.h:1539
Definition hp.h:117
unsigned int n_cells(const internal::TriangulationImplementation::NumberCache< 1 > &c)
Definition tria.cc:14906
constexpr types::manifold_id flat_manifold_id
Definition types.h:342
STL namespace.
Definition types.h:32
unsigned int global_dof_index
Definition types.h:94
unsigned int subdomain_id
Definition types.h:52
const ::parallel::distributed::Triangulation< dim, spacedim > * triangulation
boost::geometry::index::rtree< LeafType, IndexType, IndexableGetter > RTree
Definition rtree.h:145
std::size_t memory_consumption() const
FullMatrix< double > matrix
types::geometric_orientation orientation
std::map< unsigned int, std::vector< unsigned int > > communicate_indices(const std::vector< std::tuple< unsigned int, unsigned int, unsigned int > > &point_recv_components, const MPI_Comm comm) const
GridTools::internal::DistributedComputePointLocationsInternal< dim, spacedim > convert_to_distributed_compute_point_locations_internal(const unsigned int n_points_1D, const Triangulation< dim, spacedim > &tria, const Mapping< dim, spacedim > &mapping, std::vector< Quadrature< spacedim > > *mapped_quadratures_recv_comp=nullptr, const bool consistent_numbering_of_sender_and_receiver=false) const
std::vector< std::tuple< std::pair< int, int >, unsigned int, unsigned int, IntersectionType > > send_components
Definition grid_tools.h:842
std::vector< std::tuple< unsigned int, unsigned int, IntersectionType > > recv_components
Definition grid_tools.h:853
std::array<::Point< spacedim >, structdim+1 > IntersectionType
Definition grid_tools.h:828
std::vector< std::tuple< unsigned int, unsigned int, unsigned int > > recv_components
Definition grid_tools.h:778
std::vector< std::tuple< std::pair< int, int >, unsigned int, unsigned int, Point< dim >, Point< spacedim >, unsigned int > > send_components
Definition grid_tools.h:753