Reference documentation for deal.II version GIT relicensing-31-gf283a0fc39 2024-02-29 06:50:02+00:00
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
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 <bitset>
62#include <optional>
63#include <set>
64
65#ifdef DEAL_II_HAVE_CXX20
66# include <concepts>
67#endif
68
69
71
72// Forward declarations
73#ifndef DOXYGEN
74namespace parallel
75{
76 namespace distributed
77 {
78 template <int dim, int spacedim>
80 class Triangulation;
81 }
82} // namespace parallel
83
84namespace hp
85{
86 template <int, int>
87 class MappingCollection;
88}
89
90class SparsityPattern;
91
92namespace GridTools
93{
94 template <int dim, int spacedim>
95 class Cache;
96}
97#endif
98
99namespace internal
100{
101 template <int dim, int spacedim, typename MeshType>
104 {
105 public:
106#ifndef _MSC_VER
107 using type = typename MeshType::active_cell_iterator;
108#else
110#endif
111 };
112
113#ifdef _MSC_VER
114 template <int dim, int spacedim>
115 class ActiveCellIterator<dim, spacedim, DoFHandler<dim, spacedim>>
116 {
117 public:
118 using type =
120 };
121#endif
122} // namespace internal
123
132namespace GridTools
133{
220 template <int dim, typename Transformation, int spacedim>
222 (std::invocable<Transformation, Point<spacedim>> &&
223 std::assignable_from<
225 std::invoke_result_t<Transformation, Point<spacedim>>>))
226 void transform(const Transformation &transformation,
227 Triangulation<dim, spacedim> &triangulation);
228
235 template <int dim, int spacedim>
236 void
237 shift(const Tensor<1, spacedim> &shift_vector,
238 Triangulation<dim, spacedim> &triangulation);
239
240
251 template <int dim, int spacedim>
252 void
253 rotate(const double angle, Triangulation<dim, spacedim> &triangulation);
254
267 template <int dim>
268 void
269 rotate(const Tensor<1, 3, double> &axis,
270 const double angle,
272
288 template <int dim>
290 rotate(const double angle,
291 const unsigned int axis,
293
351 template <int dim>
352 void
353 laplace_transform(const std::map<unsigned int, Point<dim>> &new_points,
354 Triangulation<dim> &tria,
355 const Function<dim, double> *coefficient = nullptr,
356 const bool solve_for_absolute_positions = false);
357
365 template <int dim, int spacedim>
366 void
367 scale(const double scaling_factor,
368 Triangulation<dim, spacedim> &triangulation);
369
389 template <int dim, int spacedim>
390 void
392 const double factor,
393 Triangulation<dim, spacedim> &triangulation,
394 const bool keep_boundary = true,
395 const unsigned int seed = boost::random::mt19937::default_seed);
396
486 template <int dim, int spacedim>
487 void
489 const double limit_angle_fraction = .75);
490
554 template <int dim, int spacedim>
555#ifndef DOXYGEN
556 std::tuple<
557 std::vector<typename Triangulation<dim, spacedim>::active_cell_iterator>,
558 std::vector<std::vector<Point<dim>>>,
559 std::vector<std::vector<unsigned int>>>
560#else
561 return_type
562#endif
564 const Cache<dim, spacedim> &cache,
565 const std::vector<Point<spacedim>> &points,
567 &cell_hint =
569
603 template <int dim, int spacedim>
604#ifndef DOXYGEN
605 std::tuple<
606 std::vector<typename Triangulation<dim, spacedim>::active_cell_iterator>,
607 std::vector<std::vector<Point<dim>>>,
608 std::vector<std::vector<unsigned int>>,
609 std::vector<unsigned int>>
610#else
611 return_type
612#endif
614 const Cache<dim, spacedim> &cache,
615 const std::vector<Point<spacedim>> &points,
617 &cell_hint =
619
699 template <int dim, int spacedim>
700#ifndef DOXYGEN
701 std::tuple<
702 std::vector<typename Triangulation<dim, spacedim>::active_cell_iterator>,
703 std::vector<std::vector<Point<dim>>>,
704 std::vector<std::vector<unsigned int>>,
705 std::vector<std::vector<Point<spacedim>>>,
706 std::vector<std::vector<unsigned int>>>
707#else
708 return_type
709#endif
712 const std::vector<Point<spacedim>> &local_points,
713 const std::vector<std::vector<BoundingBox<spacedim>>> &global_bboxes,
714 const double tolerance = 1e-10,
715 const std::vector<bool> &marked_vertices = {},
716 const bool enforce_unique_mapping = true);
717
718 namespace internal
719 {
734 template <int dim, int spacedim>
736 {
738
745 void
747
751 unsigned int n_searched_points;
752
759 std::vector<std::tuple<std::pair<int, int>,
760 unsigned int,
761 unsigned int,
764 unsigned int>>
766
770 std::vector<unsigned int> send_ranks;
771
777 std::vector<unsigned int> send_ptrs;
778
789 std::vector<std::tuple<unsigned int, unsigned int, unsigned int>>
791
795 std::vector<unsigned int> recv_ranks;
796
802 std::vector<unsigned int> recv_ptrs;
803 };
804
814 template <int dim, int spacedim>
818 const std::vector<Point<spacedim>> &points,
819 const std::vector<std::vector<BoundingBox<spacedim>>> &global_bboxes,
820 const std::vector<bool> &marked_vertices,
821 const double tolerance,
822 const bool perform_handshake,
823 const bool enforce_unique_mapping = false);
824
825
833 template <int structdim, int spacedim>
835 {
840 std::array<::Point<spacedim>, structdim + 1>;
841
850 std::vector<std::tuple<std::pair<int, int>,
851 unsigned int,
852 unsigned int,
855
864 std::vector<std::tuple<unsigned int, unsigned int, IntersectionType>>
866
870 std::vector<unsigned int> recv_ptrs;
871
892 template <int dim>
894 spacedim>
896 const unsigned int n_points_1D,
899 std::vector<Quadrature<spacedim>> *mapped_quadratures_recv_comp =
900 nullptr,
901 const bool consistent_numbering_of_sender_and_receiver = false) const;
902
903 private:
911 std::map<unsigned int, std::vector<unsigned int>>
913 const std::vector<std::tuple<unsigned int, unsigned int, unsigned int>>
914 &point_recv_components,
915 const MPI_Comm comm) const;
916 };
917
925 template <int structdim, int dim, int spacedim>
928 const Cache<dim, spacedim> &cache,
929 const std::vector<std::vector<Point<spacedim>>> &intersection_requests,
930 const std::vector<std::vector<BoundingBox<spacedim>>> &global_bboxes,
931 const std::vector<bool> &marked_vertices,
932 const double tolerance);
933
934 } // namespace internal
935
945 template <int spacedim>
946 unsigned int
947 find_closest_vertex(const std::map<unsigned int, Point<spacedim>> &vertices,
948 const Point<spacedim> &p);
949
976 template <int dim, template <int, int> class MeshType, int spacedim>
978 (concepts::is_triangulation_or_dof_handler<MeshType<dim, spacedim>>))
979 unsigned int find_closest_vertex(
980 const MeshType<dim, spacedim> &mesh,
981 const Point<spacedim> &p,
982 const std::vector<bool> &marked_vertices = {});
983
1010 template <int dim, template <int, int> class MeshType, int spacedim>
1012 (concepts::is_triangulation_or_dof_handler<MeshType<dim, spacedim>>))
1013 unsigned int find_closest_vertex(
1014 const Mapping<dim, spacedim> &mapping,
1015 const MeshType<dim, spacedim> &mesh,
1016 const Point<spacedim> &p,
1017 const std::vector<bool> &marked_vertices = {});
1018
1019
1042 template <typename MeshType>
1044#ifndef _MSC_VER
1045 std::vector<typename MeshType::active_cell_iterator>
1046#else
1047 std::vector<
1048 typename ::internal::ActiveCellIterator<MeshType::dimension,
1049 MeshType::space_dimension,
1050 MeshType>::type>
1051#endif
1052 find_cells_adjacent_to_vertex(const MeshType &container,
1053 const unsigned int vertex_index);
1054
1120 template <int dim, template <int, int> class MeshType, int spacedim>
1122 (concepts::is_triangulation_or_dof_handler<MeshType<dim, spacedim>>))
1123#ifndef _MSC_VER
1124 std::pair<typename MeshType<dim, spacedim>::active_cell_iterator, Point<dim>>
1125#else
1126 std::pair<typename ::internal::
1127 ActiveCellIterator<dim, spacedim, MeshType<dim, spacedim>>::type,
1128 Point<dim>>
1129#endif
1131 const MeshType<dim, spacedim> &mesh,
1132 const Point<spacedim> &p,
1133 const std::vector<bool> &marked_vertices = {},
1134 const double tolerance = 1.e-10);
1135
1146 template <int dim, template <int, int> class MeshType, int spacedim>
1148 (concepts::is_triangulation_or_dof_handler<MeshType<dim, spacedim>>))
1149#ifndef _MSC_VER
1150 typename MeshType<dim, spacedim>::active_cell_iterator
1151#else
1152 typename ::internal::
1153 ActiveCellIterator<dim, spacedim, MeshType<dim, spacedim>>::type
1154#endif
1155 find_active_cell_around_point(const MeshType<dim, spacedim> &mesh,
1156 const Point<spacedim> &p,
1157 const std::vector<bool> &marked_vertices = {},
1158 const double tolerance = 1.e-10);
1159
1166 template <int dim, int spacedim>
1167 std::pair<typename DoFHandler<dim, spacedim>::active_cell_iterator,
1168 Point<dim>>
1172 const Point<spacedim> &p,
1173 const double tolerance = 1.e-10);
1174
1226 template <int dim, int spacedim>
1227 std::pair<typename Triangulation<dim, spacedim>::active_cell_iterator,
1228 Point<dim>>
1230 const Cache<dim, spacedim> &cache,
1231 const Point<spacedim> &p,
1234 const std::vector<bool> &marked_vertices = {},
1235 const double tolerance = 1.e-10);
1236
1253 template <int dim, template <int, int> class MeshType, int spacedim>
1255 (concepts::is_triangulation_or_dof_handler<MeshType<dim, spacedim>>))
1256#ifndef _MSC_VER
1257 std::pair<typename MeshType<dim, spacedim>::active_cell_iterator, Point<dim>>
1258#else
1259 std::pair<typename ::internal::
1260 ActiveCellIterator<dim, spacedim, MeshType<dim, spacedim>>::type,
1261 Point<dim>>
1262#endif
1265 const MeshType<dim, spacedim> &mesh,
1266 const Point<spacedim> &p,
1267 const std::vector<
1268 std::set<typename MeshType<dim, spacedim>::active_cell_iterator>>
1270 const std::vector<std::vector<Tensor<1, spacedim>>>
1271 &vertex_to_cell_centers,
1272 const typename MeshType<dim, spacedim>::active_cell_iterator &cell_hint =
1273 typename MeshType<dim, spacedim>::active_cell_iterator(),
1274 const std::vector<bool> &marked_vertices = {},
1275 const RTree<std::pair<Point<spacedim>, unsigned int>> &
1276 used_vertices_rtree = RTree<std::pair<Point<spacedim>, unsigned int>>{},
1277 const double tolerance = 1.e-10,
1278 const RTree<
1279 std::pair<BoundingBox<spacedim>,
1281 *relevant_cell_bounding_boxes_rtree = nullptr);
1282
1312 template <int dim, template <int, int> class MeshType, int spacedim>
1314 (concepts::is_triangulation_or_dof_handler<MeshType<dim, spacedim>>))
1315#ifndef _MSC_VER
1316 std::vector<std::pair<typename MeshType<dim, spacedim>::active_cell_iterator,
1317 Point<dim>>>
1318#else
1319 std::vector<std::pair<
1320 typename ::internal::
1321 ActiveCellIterator<dim, spacedim, MeshType<dim, spacedim>>::type,
1322 Point<dim>>>
1323#endif
1324 find_all_active_cells_around_point(
1326 const MeshType<dim, spacedim> &mesh,
1327 const Point<spacedim> &p,
1328 const double tolerance,
1329 const std::pair<typename MeshType<dim, spacedim>::active_cell_iterator,
1330 Point<dim>> &first_cell,
1331 const std::vector<
1332 std::set<typename MeshType<dim, spacedim>::active_cell_iterator>>
1333 *vertex_to_cells = nullptr);
1334
1344 template <int dim, template <int, int> class MeshType, int spacedim>
1346 (concepts::is_triangulation_or_dof_handler<MeshType<dim, spacedim>>))
1347#ifndef _MSC_VER
1348 std::vector<std::pair<typename MeshType<dim, spacedim>::active_cell_iterator,
1349 Point<dim>>>
1350#else
1351 std::vector<std::pair<
1352 typename ::internal::
1353 ActiveCellIterator<dim, spacedim, MeshType<dim, spacedim>>::type,
1354 Point<dim>>>
1355#endif
1356 find_all_active_cells_around_point(
1358 const MeshType<dim, spacedim> &mesh,
1359 const Point<spacedim> &p,
1360 const double tolerance = 1e-10,
1361 const std::vector<bool> &marked_vertices = {});
1362
1386 template <typename MeshType>
1388 std::vector<typename MeshType::active_cell_iterator> get_active_child_cells(
1389 const typename MeshType::cell_iterator &cell);
1390
1417 template <typename MeshType>
1418 DEAL_II_CXX20_REQUIRES(concepts::is_triangulation_or_dof_handler<MeshType>)
1420 const typename MeshType::active_cell_iterator &cell,
1421 std::vector<typename MeshType::active_cell_iterator> &active_neighbors);
1422
1474 template <typename MeshType>
1475 DEAL_II_CXX20_REQUIRES(concepts::is_triangulation_or_dof_handler<MeshType>)
1476 std::
1477 vector<typename MeshType::active_cell_iterator> compute_active_cell_halo_layer(
1478 const MeshType &mesh,
1479 const std::function<bool(const typename MeshType::active_cell_iterator &)>
1480 &predicate);
1481
1482
1492 template <typename MeshType>
1493 DEAL_II_CXX20_REQUIRES(concepts::is_triangulation_or_dof_handler<MeshType>)
1494 std::
1495 vector<typename MeshType::cell_iterator> compute_cell_halo_layer_on_level(
1496 const MeshType &mesh,
1497 const std::function<bool(const typename MeshType::cell_iterator &)>
1498 &predicate,
1499 const unsigned int level);
1500
1501
1516 template <typename MeshType>
1517 DEAL_II_CXX20_REQUIRES(concepts::is_triangulation_or_dof_handler<MeshType>)
1518 std::vector<
1519 typename MeshType::
1520 active_cell_iterator> compute_ghost_cell_halo_layer(const MeshType &mesh);
1521
1572 template <typename MeshType>
1573 DEAL_II_CXX20_REQUIRES(concepts::is_triangulation_or_dof_handler<MeshType>)
1574 std::
1575 vector<typename MeshType::active_cell_iterator> compute_active_cell_layer_within_distance(
1576 const MeshType &mesh,
1577 const std::function<bool(const typename MeshType::active_cell_iterator &)>
1578 &predicate,
1579 const double layer_thickness);
1580
1605 template <typename MeshType>
1606 DEAL_II_CXX20_REQUIRES(concepts::is_triangulation_or_dof_handler<MeshType>)
1607 std::
1608 vector<typename MeshType::active_cell_iterator> compute_ghost_cell_layer_within_distance(
1609 const MeshType &mesh,
1610 const double layer_thickness);
1611
1684 template <typename MeshType>
1685 DEAL_II_CXX20_REQUIRES(concepts::is_triangulation_or_dof_handler<MeshType>)
1686 std::
1687 vector<BoundingBox<MeshType::space_dimension>> compute_mesh_predicate_bounding_box(
1688 const MeshType &mesh,
1689 const std::function<bool(const typename MeshType::active_cell_iterator &)>
1690 &predicate,
1691 const unsigned int refinement_level = 0,
1692 const bool allow_merge = false,
1693 const unsigned int max_boxes = numbers::invalid_unsigned_int);
1694
1722 template <int spacedim>
1723#ifndef DOXYGEN
1724 std::tuple<std::vector<std::vector<unsigned int>>,
1725 std::map<unsigned int, unsigned int>,
1726 std::map<unsigned int, std::vector<unsigned int>>>
1727#else
1728 return_type
1729#endif
1731 const std::vector<std::vector<BoundingBox<spacedim>>> &global_bboxes,
1732 const std::vector<Point<spacedim>> &points);
1733
1734
1769 template <int spacedim>
1770#ifndef DOXYGEN
1771 std::tuple<std::map<unsigned int, std::vector<unsigned int>>,
1772 std::map<unsigned int, unsigned int>,
1773 std::map<unsigned int, std::vector<unsigned int>>>
1774#else
1775 return_type
1776#endif
1778 const RTree<std::pair<BoundingBox<spacedim>, unsigned int>> &covering_rtree,
1779 const std::vector<Point<spacedim>> &points);
1780
1793 template <int dim, int spacedim>
1794 std::vector<std::vector<Tensor<1, spacedim>>>
1797 const std::vector<
1799 &vertex_to_cells);
1800
1801
1809 template <int dim, int spacedim>
1810 unsigned int
1813 const Point<spacedim> &position,
1815 (ReferenceCells::get_hypercube<dim>()
1816#ifndef _MSC_VER
1817 .template get_default_linear_mapping<dim, spacedim>()
1818#else
1819 .ReferenceCell::get_default_linear_mapping<dim, spacedim>()
1820#endif
1821 ));
1822
1834 template <int dim, int spacedim>
1835 std::map<unsigned int, types::global_vertex_index>
1838
1865 template <int dim, int spacedim>
1866 void
1867 partition_triangulation(const unsigned int n_partitions,
1869 const SparsityTools::Partitioner partitioner =
1871
1882 template <int dim, int spacedim>
1883 void
1884 partition_triangulation(const unsigned int n_partitions,
1885 const std::vector<unsigned int> &cell_weights,
1887 const SparsityTools::Partitioner partitioner =
1889
1935 template <int dim, int spacedim>
1936 void
1937 partition_triangulation(const unsigned int n_partitions,
1938 const SparsityPattern &cell_connection_graph,
1940 const SparsityTools::Partitioner partitioner =
1942
1953 template <int dim, int spacedim>
1954 void
1955 partition_triangulation(const unsigned int n_partitions,
1956 const std::vector<unsigned int> &cell_weights,
1957 const SparsityPattern &cell_connection_graph,
1959 const SparsityTools::Partitioner partitioner =
1961
1976 template <int dim, int spacedim>
1977 void
1978 partition_triangulation_zorder(const unsigned int n_partitions,
1980 const bool group_siblings = true);
1981
1993 template <int dim, int spacedim>
1994 void
1996
2004 template <int dim, int spacedim>
2005 std::vector<types::subdomain_id>
2007 const std::vector<CellId> &cell_ids);
2008
2019 template <int dim, int spacedim>
2020 void
2022 std::vector<types::subdomain_id> &subdomain);
2023
2038 template <int dim, int spacedim>
2039 unsigned int
2042 const types::subdomain_id subdomain);
2043
2073 template <int dim, int spacedim>
2074 std::vector<bool>
2076
2103 template <int dim, int spacedim>
2107 &distorted_cells,
2109
2110
2111
2161 template <typename MeshType>
2163 std::vector<typename MeshType::active_cell_iterator> get_patch_around_cell(
2164 const typename MeshType::active_cell_iterator &cell);
2165
2166
2188 template <class Container>
2189 std::vector<typename Container::cell_iterator>
2191 const std::vector<typename Container::active_cell_iterator> &patch_cells);
2192
2259 template <class Container>
2260 void
2262 const std::vector<typename Container::active_cell_iterator> &patch,
2264 &local_triangulation,
2265 std::map<
2266 typename Triangulation<Container::dimension,
2267 Container::space_dimension>::active_cell_iterator,
2268 typename Container::active_cell_iterator> &patch_to_global_tria_map);
2269
2301 template <int dim, int spacedim>
2302 std::map<
2304 std::vector<typename DoFHandler<dim, spacedim>::active_cell_iterator>>
2306
2307
2322 template <typename CellIterator>
2324 {
2328 CellIterator cell[2];
2329
2334 unsigned int face_idx[2];
2335
2341 std::bitset<3> orientation;
2342
2356
2360 std::size_t
2362 };
2363
2364
2431 template <typename FaceIterator>
2432 std::optional<std::bitset<3>>
2434 const FaceIterator &face1,
2435 const FaceIterator &face2,
2436 const unsigned int direction,
2439 const FullMatrix<double> &matrix = FullMatrix<double>());
2440
2499 template <typename MeshType>
2502 const MeshType &mesh,
2503 const types::boundary_id b_id1,
2504 const types::boundary_id b_id2,
2505 const unsigned int direction,
2507 &matched_pairs,
2510 const FullMatrix<double> &matrix = FullMatrix<double>());
2511
2512
2537 template <typename MeshType>
2540 const MeshType &mesh,
2541 const types::boundary_id b_id,
2542 const unsigned int direction,
2543 std::vector<PeriodicFacePair<typename MeshType::cell_iterator>>
2544 &matched_pairs,
2545 const ::Tensor<1, MeshType::space_dimension> &offset =
2546 ::Tensor<1, MeshType::space_dimension>(),
2547 const FullMatrix<double> &matrix = FullMatrix<double>());
2548
2575 template <int dim, int spacedim>
2576 void
2578 const bool reset_boundary_ids = false);
2579
2601 template <int dim, int spacedim>
2602 void
2604 const std::vector<types::boundary_id> &src_boundary_ids,
2605 const std::vector<types::manifold_id> &dst_manifold_ids,
2606 Triangulation<dim, spacedim> &tria,
2607 const std::vector<types::boundary_id> &reset_boundary_ids = {});
2608
2638 template <int dim, int spacedim>
2639 void
2641 const bool compute_face_ids = false);
2642
2667 template <int dim, int spacedim>
2668 void
2671 const std::function<types::manifold_id(
2672 const std::set<types::manifold_id> &)> &disambiguation_function =
2673 [](const std::set<types::manifold_id> &manifold_ids) {
2674 if (manifold_ids.size() == 1)
2675 return *manifold_ids.begin();
2676 else
2678 },
2679 bool overwrite_only_flat_manifold_ids = true);
2768 template <typename DataType, typename MeshType>
2771 const MeshType &mesh,
2772 const std::function<std::optional<DataType>(
2773 const typename MeshType::active_cell_iterator &)> &pack,
2774 const std::function<void(const typename MeshType::active_cell_iterator &,
2775 const DataType &)> &unpack,
2776 const std::function<bool(const typename MeshType::active_cell_iterator &)>
2777 &cell_filter =
2778 always_return<typename MeshType::active_cell_iterator, bool>{true});
2779
2792 template <typename DataType, typename MeshType>
2795 const MeshType &mesh,
2796 const std::function<std::optional<DataType>(
2797 const typename MeshType::level_cell_iterator &)> &pack,
2798 const std::function<void(const typename MeshType::level_cell_iterator &,
2799 const DataType &)> &unpack,
2800 const std::function<bool(const typename MeshType::level_cell_iterator &)> &
2801 cell_filter = always_return<typename MeshType::level_cell_iterator, bool>{
2802 true});
2803
2804 /* Exchange with all processors of the MPI communicator @p mpi_communicator the vector of bounding
2805 * boxes @p local_bboxes.
2806 *
2807 * This function is meant to exchange bounding boxes describing the locally
2808 * owned cells in a distributed triangulation obtained with the function
2809 * GridTools::compute_mesh_predicate_bounding_box .
2810 *
2811 * The output vector's size is the number of processes of the MPI
2812 * communicator:
2813 * its i-th entry contains the vector @p local_bboxes of the i-th process.
2814 */
2815 template <int spacedim>
2816 std::vector<std::vector<BoundingBox<spacedim>>>
2818 const std::vector<BoundingBox<spacedim>> &local_bboxes,
2819 const MPI_Comm mpi_communicator);
2820
2853 template <int spacedim>
2856 const std::vector<BoundingBox<spacedim>> &local_description,
2857 const MPI_Comm mpi_communicator);
2858
2876 template <int dim, int spacedim>
2877 void
2880 std::map<unsigned int, std::vector<unsigned int>> &coinciding_vertex_groups,
2881 std::map<unsigned int, unsigned int> &vertex_to_coinciding_vertex_group);
2882
2902 template <int dim, int spacedim>
2903 std::map<unsigned int, std::set<::types::subdomain_id>>
2906
2927 template <int dim, typename VectorType>
2929 {
2930 public:
2934 using value_type = typename VectorType::value_type;
2935
2940 const FiniteElement<dim, dim> &fe,
2941 const unsigned int n_subdivisions = 1,
2942 const double tolerance = 1e-10);
2943
2954 void
2955 process(const DoFHandler<dim> &background_dof_handler,
2956 const VectorType &ls_vector,
2957 const double iso_level,
2958 std::vector<Point<dim>> &vertices,
2959 std::vector<CellData<dim == 1 ? 1 : dim - 1>> &cells) const;
2960
2965 void
2966 process(const DoFHandler<dim> &background_dof_handler,
2967 const VectorType &ls_vector,
2968 const double iso_level,
2969 std::vector<Point<dim>> &vertices) const;
2970
2980 void
2982 const VectorType &ls_vector,
2983 const double iso_level,
2984 std::vector<Point<dim>> &vertices,
2985 std::vector<CellData<dim == 1 ? 1 : dim - 1>> &cells) const;
2991 void
2993 const VectorType &ls_vector,
2994 const double iso_level,
2995 std::vector<Point<dim>> &vertices) const;
2996
2997 private:
3002 static Quadrature<dim>
3003 create_quadrature_rule(const unsigned int n_subdivisions);
3004
3008 void
3009 process_cell(std::vector<value_type> &ls_values,
3010 const std::vector<Point<dim>> &points,
3011 const double iso_level,
3012 std::vector<Point<dim>> &vertices,
3013 std::vector<CellData<dim == 1 ? 1 : dim - 1>> &cells,
3014 const bool write_back_cell_data = true) const;
3015
3019 void
3020 process_sub_cell(const std::vector<value_type> &,
3021 const std::vector<Point<1>> &,
3022 const std::vector<unsigned int> &,
3023 const double,
3024 std::vector<Point<1>> &,
3025 std::vector<CellData<1>> &,
3026 const bool) const
3027 {
3029 }
3030
3037 void
3038 process_sub_cell(const std::vector<value_type> &ls_values,
3039 const std::vector<Point<2>> &points,
3040 const std::vector<unsigned int> &mask,
3041 const double iso_level,
3042 std::vector<Point<2>> &vertices,
3043 std::vector<CellData<1>> &cells,
3044 const bool write_back_cell_data) const;
3045
3049 void
3050 process_sub_cell(const std::vector<value_type> &ls_values,
3051 const std::vector<Point<3>> &points,
3052 const std::vector<unsigned int> &mask,
3053 const double iso_level,
3054 std::vector<Point<3>> &vertices,
3055 std::vector<CellData<2>> &cells,
3056 const bool write_back_cell_data) const;
3057
3062 const unsigned int n_subdivisions;
3063
3068 const double tolerance;
3069
3075 };
3076
3077
3078
3088 int,
3089 << "The number of partitions you gave is " << arg1
3090 << ", but must be greater than zero.");
3095 int,
3096 << "The subdomain id " << arg1
3097 << " has no cells associated with it.");
3102
3107 double,
3108 << "The scaling factor must be positive, but it is " << arg1
3109 << '.');
3110
3115 unsigned int,
3116 << "The given vertex with index " << arg1
3117 << " is not used in the given triangulation.");
3118
3121} /*namespace GridTools*/
3122
3123/* ----------------- Template function --------------- */
3124
3125#ifndef DOXYGEN
3126
3127namespace GridTools
3128{
3129 template <int dim>
3130 double
3132 const std::vector<Point<dim>> &all_vertices,
3133 const unsigned int (&indices)[GeometryInfo<dim>::vertices_per_cell])
3134 {
3135 // We forward call to the ArrayView version:
3138 return cell_measure(all_vertices, view);
3139 }
3140
3141
3142
3143 // This specialization is defined here so that the general template in the
3144 // source file doesn't need to have further 1d overloads for the internal
3145 // functions it calls.
3146 template <>
3150 {
3151 return {};
3152 }
3153
3154
3155
3156 template <int dim, typename Transformation, int spacedim>
3158 (std::invocable<Transformation, Point<spacedim>> &&
3159 std::assignable_from<
3161 std::invoke_result_t<Transformation, Point<spacedim>>>))
3162 void transform(const Transformation &transformation,
3163 Triangulation<dim, spacedim> &triangulation)
3164 {
3165 std::vector<bool> treated_vertices(triangulation.n_vertices(), false);
3166
3167 // loop over all active cells, and
3168 // transform those vertices that
3169 // have not yet been touched. note
3170 // that we get to all vertices in
3171 // the triangulation by only
3172 // visiting the active cells.
3174 cell = triangulation.begin_active(),
3175 endc = triangulation.end();
3176 for (; cell != endc; ++cell)
3177 for (const unsigned int v : cell->vertex_indices())
3178 if (treated_vertices[cell->vertex_index(v)] == false)
3179 {
3180 // transform this vertex
3181 cell->vertex(v) = transformation(cell->vertex(v));
3182 // and mark it as treated
3183 treated_vertices[cell->vertex_index(v)] = true;
3184 };
3185
3186
3187 // now fix any vertices on hanging nodes so that we don't create any holes
3188 if (dim == 2)
3189 {
3191 cell = triangulation.begin_active(),
3192 endc = triangulation.end();
3193 for (; cell != endc; ++cell)
3194 for (const unsigned int face : cell->face_indices())
3195 if (cell->face(face)->has_children() &&
3196 !cell->face(face)->at_boundary())
3197 {
3198 Assert(cell->reference_cell() ==
3199 ReferenceCells::get_hypercube<dim>(),
3201
3202 // this line has children
3203 cell->face(face)->child(0)->vertex(1) =
3204 (cell->face(face)->vertex(0) + cell->face(face)->vertex(1)) /
3205 2;
3206 }
3207 }
3208 else if (dim == 3)
3209 {
3211 cell = triangulation.begin_active(),
3212 endc = triangulation.end();
3213 for (; cell != endc; ++cell)
3214 for (const unsigned int face : cell->face_indices())
3215 if (cell->face(face)->has_children() &&
3216 !cell->face(face)->at_boundary())
3217 {
3218 Assert(cell->reference_cell() ==
3219 ReferenceCells::get_hypercube<dim>(),
3221
3222 // this face has hanging nodes
3223 cell->face(face)->child(0)->vertex(1) =
3224 (cell->face(face)->vertex(0) + cell->face(face)->vertex(1)) /
3225 2.0;
3226 cell->face(face)->child(0)->vertex(2) =
3227 (cell->face(face)->vertex(0) + cell->face(face)->vertex(2)) /
3228 2.0;
3229 cell->face(face)->child(1)->vertex(3) =
3230 (cell->face(face)->vertex(1) + cell->face(face)->vertex(3)) /
3231 2.0;
3232 cell->face(face)->child(2)->vertex(3) =
3233 (cell->face(face)->vertex(2) + cell->face(face)->vertex(3)) /
3234 2.0;
3235
3236 // center of the face
3237 cell->face(face)->child(0)->vertex(3) =
3238 (cell->face(face)->vertex(0) + cell->face(face)->vertex(1) +
3239 cell->face(face)->vertex(2) + cell->face(face)->vertex(3)) /
3240 4.0;
3241 }
3242 }
3243
3244 // Make sure FEValues notices that the mesh has changed
3245 triangulation.signals.mesh_movement();
3246 }
3247
3248
3249
3250 template <typename MeshType>
3252 std::vector<typename MeshType::active_cell_iterator> get_active_child_cells(
3253 const typename MeshType::cell_iterator &cell)
3254 {
3255 std::vector<typename MeshType::active_cell_iterator> child_cells;
3256
3257 if (cell->has_children())
3258 {
3259 for (unsigned int child = 0; child < cell->n_children(); ++child)
3260 if (cell->child(child)->has_children())
3261 {
3262 const std::vector<typename MeshType::active_cell_iterator>
3263 children = get_active_child_cells<MeshType>(cell->child(child));
3264 child_cells.insert(child_cells.end(),
3265 children.begin(),
3266 children.end());
3267 }
3268 else
3269 child_cells.push_back(cell->child(child));
3270 }
3271
3272 return child_cells;
3273 }
3274
3275
3276
3277 template <typename MeshType>
3280 const typename MeshType::active_cell_iterator &cell,
3281 std::vector<typename MeshType::active_cell_iterator> &active_neighbors)
3282 {
3283 active_neighbors.clear();
3284 for (const unsigned int n : cell->face_indices())
3285 if (!cell->at_boundary(n))
3286 {
3287 if (MeshType::dimension == 1)
3288 {
3289 // check children of neighbor. note
3290 // that in 1d children of the neighbor
3291 // may be further refined. In 1d the
3292 // case is simple since we know what
3293 // children bound to the present cell
3294 typename MeshType::cell_iterator neighbor_child =
3295 cell->neighbor(n);
3296 if (!neighbor_child->is_active())
3297 {
3298 while (neighbor_child->has_children())
3299 neighbor_child = neighbor_child->child(n == 0 ? 1 : 0);
3300
3301 Assert(neighbor_child->neighbor(n == 0 ? 1 : 0) == cell,
3303 }
3304 active_neighbors.push_back(neighbor_child);
3305 }
3306 else
3307 {
3308 if (cell->face(n)->has_children())
3309 // this neighbor has children. find
3310 // out which border to the present
3311 // cell
3312 for (unsigned int c = 0;
3313 c < cell->face(n)->n_active_descendants();
3314 ++c)
3315 active_neighbors.push_back(
3316 cell->neighbor_child_on_subface(n, c));
3317 else
3318 {
3319 // the neighbor must be active
3320 // himself
3321 Assert(cell->neighbor(n)->is_active(), ExcInternalError());
3322 active_neighbors.push_back(cell->neighbor(n));
3323 }
3324 }
3325 }
3326 }
3327
3328
3329
3330 template <typename CellIterator>
3331 std::size_t
3333 {
3334 return sizeof(*this) + matrix.memory_consumption();
3335 }
3336
3337
3338
3339 namespace internal
3340 {
3341 template <typename DataType,
3342 typename MeshType,
3343 typename MeshCellIteratorType>
3345 inline void exchange_cell_data(
3346 const MeshType &mesh,
3347 const std::function<std::optional<DataType>(const MeshCellIteratorType &)>
3348 &pack,
3349 const std::function<void(const MeshCellIteratorType &, const DataType &)>
3350 &unpack,
3351 const std::function<bool(const MeshCellIteratorType &)> &cell_filter,
3352 const std::function<void(
3353 const std::function<void(const MeshCellIteratorType &,
3354 const types::subdomain_id)> &)> &process_cells,
3355 const std::function<std::set<types::subdomain_id>(
3356 const parallel::TriangulationBase<MeshType::dimension,
3357 MeshType::space_dimension> &)>
3358 &compute_ghost_owners)
3359 {
3360# ifndef DEAL_II_WITH_MPI
3361 (void)mesh;
3362 (void)pack;
3363 (void)unpack;
3364 (void)cell_filter;
3365 (void)process_cells;
3366 (void)compute_ghost_owners;
3367 Assert(false, ExcNeedsMPI());
3368# else
3369 constexpr int dim = MeshType::dimension;
3370 constexpr int spacedim = MeshType::space_dimension;
3371 auto tria =
3372 dynamic_cast<const parallel::TriangulationBase<dim, spacedim> *>(
3373 &mesh.get_triangulation());
3374 Assert(
3375 tria != nullptr,
3376 ExcMessage(
3377 "The function exchange_cell_data_to_ghosts() only works with parallel triangulations."));
3378
3379 if (const auto tria = dynamic_cast<
3381 &mesh.get_triangulation()))
3382 {
3383 Assert(
3384 tria->with_artificial_cells(),
3385 ExcMessage(
3386 "The functions GridTools::exchange_cell_data_to_ghosts() and "
3387 "GridTools::exchange_cell_data_to_level_ghosts() can only "
3388 "operate on a single layer of ghost cells. However, you have "
3389 "given a Triangulation object of type "
3390 "parallel::shared::Triangulation without artificial cells "
3391 "resulting in an arbitrary number of ghost layers. "
3392 "To use this function for a Triangulation object of type "
3393 "parallel::shared::Triangulation, make sure to create the "
3394 "Triangulation object with allow_artificial_cells set to true. "
3395 "This results in a parallel::shared::Triangulation with only "
3396 "a single layer of ghost cells."));
3397 }
3398
3399 // build list of cells to request for each neighbor
3400 std::set<::types::subdomain_id> ghost_owners =
3401 compute_ghost_owners(*tria);
3402 std::map<::types::subdomain_id,
3403 std::vector<typename CellId::binary_type>>
3404 neighbor_cell_list;
3405
3406 for (const auto ghost_owner : ghost_owners)
3407 neighbor_cell_list[ghost_owner] = {};
3408
3409 process_cells([&](const auto &cell, const auto key) -> void {
3410 if (cell_filter(cell))
3411 {
3412 constexpr int spacedim = MeshType::space_dimension;
3413 neighbor_cell_list[key].emplace_back(
3414 cell->id().template to_binary<spacedim>());
3415 }
3416 });
3417
3418 Assert(ghost_owners.size() == neighbor_cell_list.size(),
3420
3421
3422 // Before sending & receiving, make sure we protect this section with
3423 // a mutex:
3426 mutex, tria->get_communicator());
3427
3428 const int mpi_tag =
3430 const int mpi_tag_reply =
3432
3433 // send our requests
3434 std::vector<MPI_Request> requests(ghost_owners.size());
3435 {
3436 unsigned int idx = 0;
3437 for (const auto &it : neighbor_cell_list)
3438 {
3439 // send the data about the relevant cells
3440 const int ierr = MPI_Isend(it.second.data(),
3441 it.second.size() * sizeof(it.second[0]),
3442 MPI_BYTE,
3443 it.first,
3444 mpi_tag,
3446 &requests[idx]);
3447 AssertThrowMPI(ierr);
3448 ++idx;
3449 }
3450 }
3451
3452 // receive requests and reply with the results
3453 std::vector<MPI_Request> reply_requests(ghost_owners.size());
3454 std::vector<std::vector<char>> sendbuffers(ghost_owners.size());
3455
3456 for (unsigned int idx = 0; idx < ghost_owners.size(); ++idx)
3457 {
3458 MPI_Status status;
3459 int ierr = MPI_Probe(MPI_ANY_SOURCE,
3460 mpi_tag,
3462 &status);
3463 AssertThrowMPI(ierr);
3464
3465 int len;
3466 ierr = MPI_Get_count(&status, MPI_BYTE, &len);
3467 AssertThrowMPI(ierr);
3468 Assert(len % sizeof(typename CellId::binary_type) == 0,
3470
3471 const unsigned int n_cells =
3472 len / sizeof(typename CellId::binary_type);
3473 std::vector<typename CellId::binary_type> cells_with_requests(
3474 n_cells);
3475 std::vector<DataType> data_to_send;
3476 data_to_send.reserve(n_cells);
3477 std::vector<bool> cell_carries_data(n_cells, false);
3478
3479 ierr = MPI_Recv(cells_with_requests.data(),
3480 len,
3481 MPI_BYTE,
3482 status.MPI_SOURCE,
3483 status.MPI_TAG,
3485 &status);
3486 AssertThrowMPI(ierr);
3487
3488 // store data for each cell
3489 for (unsigned int c = 0; c < static_cast<unsigned int>(n_cells); ++c)
3490 {
3491 const auto cell =
3492 tria->create_cell_iterator(CellId(cells_with_requests[c]));
3493
3494 MeshCellIteratorType mesh_it(tria,
3495 cell->level(),
3496 cell->index(),
3497 &mesh);
3498
3499 const std::optional<DataType> data = pack(mesh_it);
3500 if (data)
3501 {
3502 data_to_send.emplace_back(*data);
3503 cell_carries_data[c] = true;
3504 }
3505 }
3506
3507 // collect data for sending the reply in a buffer
3508
3509 // (a) make room for storing the local offsets in case we receive
3510 // other data
3511 sendbuffers[idx].resize(sizeof(std::size_t));
3512
3513 // (b) append the actual data and store how much memory it
3514 // corresponds to, which we then insert into the leading position of
3515 // the sendbuffer
3516 std::size_t size_of_send =
3517 Utilities::pack(data_to_send,
3518 sendbuffers[idx],
3519 /*enable_compression*/ false);
3520 std::memcpy(sendbuffers[idx].data(),
3521 &size_of_send,
3522 sizeof(std::size_t));
3523
3524 // (c) append information of certain cells that got left out in case
3525 // we need it
3526 if (data_to_send.size() < n_cells)
3527 Utilities::pack(cell_carries_data,
3528 sendbuffers[idx],
3529 /*enable_compression*/ false);
3530
3531 // send data
3532 ierr = MPI_Isend(sendbuffers[idx].data(),
3533 sendbuffers[idx].size(),
3534 MPI_BYTE,
3535 status.MPI_SOURCE,
3536 mpi_tag_reply,
3538 &reply_requests[idx]);
3539 AssertThrowMPI(ierr);
3540 }
3541
3542 // finally receive the replies
3543 std::vector<char> receive;
3544 for (unsigned int id = 0; id < neighbor_cell_list.size(); ++id)
3545 {
3546 MPI_Status status;
3547 int ierr = MPI_Probe(MPI_ANY_SOURCE,
3548 mpi_tag_reply,
3550 &status);
3551 AssertThrowMPI(ierr);
3552
3553 int len;
3554 ierr = MPI_Get_count(&status, MPI_BYTE, &len);
3555 AssertThrowMPI(ierr);
3556
3557 receive.resize(len);
3558
3559 ierr = MPI_Recv(receive.data(),
3560 len,
3561 MPI_BYTE,
3562 status.MPI_SOURCE,
3563 status.MPI_TAG,
3565 &status);
3566 AssertThrowMPI(ierr);
3567
3568 // (a) first determine the length of the data section in the
3569 // received buffer
3570 auto data_iterator = receive.begin();
3571 std::size_t size_of_received_data =
3572 Utilities::unpack<std::size_t>(data_iterator,
3573 data_iterator + sizeof(std::size_t));
3574 data_iterator += sizeof(std::size_t);
3575
3576 // (b) unpack the data section in the indicated region
3577 auto received_data = Utilities::unpack<std::vector<DataType>>(
3578 data_iterator,
3579 data_iterator + size_of_received_data,
3580 /*enable_compression*/ false);
3581 data_iterator += size_of_received_data;
3582
3583 // (c) check if the received data contained fewer entries than the
3584 // number of cells we identified in the beginning, in which case we
3585 // need to extract the boolean vector with the relevant information
3586 const std::vector<typename CellId::binary_type> &this_cell_list =
3587 neighbor_cell_list[status.MPI_SOURCE];
3588 AssertIndexRange(received_data.size(), this_cell_list.size() + 1);
3589 std::vector<bool> cells_with_data;
3590 if (received_data.size() < this_cell_list.size())
3591 {
3592 cells_with_data = Utilities::unpack<std::vector<bool>>(
3593 data_iterator, receive.end(), /*enable_compression*/ false);
3594 AssertDimension(cells_with_data.size(), this_cell_list.size());
3595 }
3596
3597 // (d) go through the received data and call the user-provided
3598 // unpack function
3599 auto received_data_iterator = received_data.begin();
3600 for (unsigned int c = 0; c < this_cell_list.size(); ++c)
3601 if (cells_with_data.empty() || cells_with_data[c])
3602 {
3604 tria_cell = tria->create_cell_iterator(this_cell_list[c]);
3605
3606 MeshCellIteratorType cell(tria,
3607 tria_cell->level(),
3608 tria_cell->index(),
3609 &mesh);
3610
3611 unpack(cell, *received_data_iterator);
3612 ++received_data_iterator;
3613 }
3614 }
3615
3616 // make sure that all communication is finished
3617 // when we leave this function.
3618 if (requests.size() > 0)
3619 {
3620 const int ierr =
3621 MPI_Waitall(requests.size(), requests.data(), MPI_STATUSES_IGNORE);
3622 AssertThrowMPI(ierr);
3623 }
3624 if (reply_requests.size() > 0)
3625 {
3626 const int ierr = MPI_Waitall(reply_requests.size(),
3627 reply_requests.data(),
3628 MPI_STATUSES_IGNORE);
3629 AssertThrowMPI(ierr);
3630 }
3631
3632
3633# endif // DEAL_II_WITH_MPI
3634 }
3635
3636 } // namespace internal
3637
3638 template <typename DataType, typename MeshType>
3640 inline void exchange_cell_data_to_ghosts(
3641 const MeshType &mesh,
3642 const std::function<std::optional<DataType>(
3643 const typename MeshType::active_cell_iterator &)> &pack,
3644 const std::function<void(const typename MeshType::active_cell_iterator &,
3645 const DataType &)> &unpack,
3646 const std::function<bool(const typename MeshType::active_cell_iterator &)>
3647 &cell_filter)
3648 {
3649# ifndef DEAL_II_WITH_MPI
3650 (void)mesh;
3651 (void)pack;
3652 (void)unpack;
3653 (void)cell_filter;
3654 Assert(false, ExcNeedsMPI());
3655# else
3656 internal::exchange_cell_data<DataType,
3657 MeshType,
3658 typename MeshType::active_cell_iterator>(
3659 mesh,
3660 pack,
3661 unpack,
3662 cell_filter,
3663 [&](const auto &process) {
3664 for (const auto &cell : mesh.active_cell_iterators())
3665 if (cell->is_ghost())
3666 process(cell, cell->subdomain_id());
3667 },
3668 [](const auto &tria) { return tria.ghost_owners(); });
3669# endif
3670 }
3671
3672
3673
3674 template <typename DataType, typename MeshType>
3677 const MeshType &mesh,
3678 const std::function<std::optional<DataType>(
3679 const typename MeshType::level_cell_iterator &)> &pack,
3680 const std::function<void(const typename MeshType::level_cell_iterator &,
3681 const DataType &)> &unpack,
3682 const std::function<bool(const typename MeshType::level_cell_iterator &)>
3683 &cell_filter)
3684 {
3685# ifndef DEAL_II_WITH_MPI
3686 (void)mesh;
3687 (void)pack;
3688 (void)unpack;
3689 (void)cell_filter;
3690 Assert(false, ExcNeedsMPI());
3691# else
3692 internal::exchange_cell_data<DataType,
3693 MeshType,
3694 typename MeshType::level_cell_iterator>(
3695 mesh,
3696 pack,
3697 unpack,
3698 cell_filter,
3699 [&](const auto &process) {
3700 for (const auto &cell : mesh.cell_iterators())
3701 if (cell->is_ghost_on_level())
3702 process(cell, cell->level_subdomain_id());
3703 },
3704 [](const auto &tria) { return tria.level_ghost_owners(); });
3705# endif
3706 }
3707} // namespace GridTools
3708
3709#endif // DOXYGEN
3710
3712
3713#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:316
Definition point.h:111
virtual MPI_Comm get_communicator() const
cell_iterator create_cell_iterator(const CellId &cell_id) const
cell_iterator end() const
Signals signals
Definition tria.h:2529
unsigned int n_vertices() const
active_cell_iterator begin_active(const unsigned int level=0) const
typename MeshType::active_cell_iterator type
Definition grid_tools.h:107
#define DEAL_II_DEPRECATED
Definition config.h:207
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:502
#define DEAL_II_CXX20_REQUIRES(condition)
Definition config.h:177
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:503
unsigned int level
Definition grid_out.cc:4616
unsigned int vertex_indices[2]
#define DeclException0(Exception0)
Definition exceptions.h:471
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)
Definition exceptions.h:516
static ::ExceptionBase & ExcInvalidNumberOfPartitions(int arg1)
static ::ExceptionBase & ExcMessage(std::string arg1)
static ::ExceptionBase & ExcScalingFactorNotPositive(double arg1)
#define AssertThrow(cond, exc)
TriaActiveIterator< CellAccessor< dim, spacedim > > active_cell_iterator
Definition tria.h:1594
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)
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)
spacedim & mapping
void partition_triangulation_zorder(const unsigned int n_partitions, Triangulation< dim, spacedim > &triangulation, const bool group_siblings=true)
spacedim const Point< spacedim > & p
Definition grid_tools.h:981
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)
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 >()))
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)
const Triangulation< dim, spacedim > & tria
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)
const std::vector< Point< spacedim > > & vertices
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::optional< std::bitset< 3 > > 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< 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::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)
Triangulation< dim, spacedim > & triangulation
Definition grid_tools.h:227
spacedim & mesh
Definition grid_tools.h:980
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)
DEAL_II_CXX20_REQUIRES((concepts::is_triangulation_or_dof_handler< MeshType< dim, spacedim > >)) std DEAL_II_CXX20_REQUIRES((concepts::is_triangulation_or_dof_handler< MeshType< dim, spacedim > >)) std DEAL_II_CXX20_REQUIRES((concepts::is_triangulation_or_dof_handler< MeshType< dim, spacedim > >)) std std::vector< typename MeshType::active_cell_iterator > get_active_child_cells(const typename MeshType::cell_iterator &cell)
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)
spacedim const Point< spacedim > const std::vector< bool > & marked_vertices
Definition grid_tools.h:982
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::map< unsigned int, types::global_vertex_index > compute_local_to_global_vertex_index_map(const parallel::distributed::Triangulation< dim, spacedim > &triangulation)
if(marked_vertices.size() !=0) for(auto it
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)
DEAL_II_CXX20_REQUIRES((concepts::is_triangulation_or_dof_handler< MeshType< dim, spacedim > >)) std spacedim ::active_cell_iterator find_active_cell_around_point(const MeshType< dim, spacedim > &mesh, const Point< spacedim > &p, const std::vector< bool > &marked_vertices={}, const double tolerance=1.e-10)
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:65
@ exchange_cell_data_reply
grid_tools.h: exchange_cell_ghosts()
Definition mpi_tags.h:68
size_t pack(const T &object, std::vector< char > &dest_buffer, const bool allow_compression=true)
Definition utilities.h:1364
T unpack(const std::vector< char > &buffer, const bool allow_compression=true)
Definition utilities.h:1521
Definition hp.h:117
unsigned int n_cells(const internal::TriangulationImplementation::NumberCache< 1 > &c)
Definition tria.cc:14903
const types::manifold_id flat_manifold_id
Definition types.h:325
STL namespace.
Definition types.h:32
unsigned int global_dof_index
Definition types.h:81
unsigned int subdomain_id
Definition types.h:43
*braid_SplitCommworld & comm
boost::geometry::index::rtree< LeafType, IndexType, IndexableGetter > RTree
Definition rtree.h:143
std::bitset< 3 > orientation
std::size_t memory_consumption() const
FullMatrix< double > matrix
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:854
std::vector< std::tuple< unsigned int, unsigned int, IntersectionType > > recv_components
Definition grid_tools.h:865
std::array<::Point< spacedim >, structdim+1 > IntersectionType
Definition grid_tools.h:840
std::vector< std::tuple< unsigned int, unsigned int, unsigned int > > recv_components
Definition grid_tools.h:790
std::vector< std::tuple< std::pair< int, int >, unsigned int, unsigned int, Point< dim >, Point< spacedim >, unsigned int > > send_components
Definition grid_tools.h:765