13#ifndef dealii_grid_tools_h
14#define dealii_grid_tools_h
46#include <boost/archive/binary_iarchive.hpp>
47#include <boost/archive/binary_oarchive.hpp>
48#include <boost/random/mersenne_twister.hpp>
49#include <boost/serialization/array.hpp>
50#include <boost/serialization/vector.hpp>
52#ifdef DEAL_II_WITH_ZLIB
53# include <boost/iostreams/device/back_inserter.hpp>
54# include <boost/iostreams/filter/gzip.hpp>
55# include <boost/iostreams/filtering_stream.hpp>
56# include <boost/iostreams/stream.hpp>
62#ifdef DEAL_II_HAVE_CXX20
75 template <
int dim,
int spacedim>
91 template <
int dim,
int spacedim>
98 template <
int dim,
int spacedim,
typename MeshType>
104 using type =
typename MeshType::active_cell_iterator;
111 template <
int dim,
int spacedim>
217 template <
int dim,
typename Transformation,
int spacedim>
219 (std::invocable<Transformation, Point<spacedim>> &&
220 std::assignable_from<
222 std::invoke_result_t<Transformation, Point<spacedim>>>))
232 template <
int dim,
int spacedim>
248 template <
int dim,
int spacedim>
331 const
Function<dim,
double> *coefficient =
nullptr,
332 const
bool solve_for_absolute_positions = false);
341 template <
int dim,
int spacedim>
343 scale(const
double scaling_factor,
375 template <
int dim,
int spacedim>
380 const
bool keep_boundary = true,
381 const
unsigned int seed =
boost::random::mt19937::default_seed);
472 template <
int dim,
int spacedim>
475 const
double limit_angle_fraction = .75);
540 template <
int dim,
int spacedim>
543 std::vector<typename Triangulation<dim, spacedim>::active_cell_iterator>,
544 std::vector<std::vector<Point<dim>>>,
545 std::vector<std::vector<unsigned int>>>
589 template <
int dim,
int spacedim>
592 std::vector<typename Triangulation<dim, spacedim>::active_cell_iterator>,
593 std::vector<std::vector<Point<dim>>>,
594 std::vector<std::vector<unsigned int>>,
595 std::vector<unsigned int>>
685 template <
int dim,
int spacedim>
688 std::vector<typename Triangulation<dim, spacedim>::active_cell_iterator>,
689 std::vector<std::vector<Point<dim>>>,
690 std::vector<std::vector<unsigned int>>,
691 std::vector<std::vector<Point<spacedim>>>,
692 std::vector<std::vector<unsigned int>>>
700 const double tolerance = 1e-10,
701 const std::vector<bool> &marked_vertices = {},
702 const bool enforce_unique_mapping =
true);
720 template <
int dim,
int spacedim>
745 std::vector<std::tuple<std::pair<int, int>,
775 std::vector<std::tuple<unsigned int, unsigned int, unsigned int>>
800 template <
int dim,
int spacedim>
806 const std::vector<bool> &marked_vertices,
807 const double tolerance,
808 const bool perform_handshake,
809 const bool enforce_unique_mapping =
false);
819 template <
int structdim,
int spacedim>
826 std::array<::Point<spacedim>, structdim + 1>;
836 std::vector<std::tuple<std::pair<int, int>,
850 std::vector<std::tuple<unsigned int, unsigned int, IntersectionType>>
882 const unsigned int n_points_1D,
887 const bool consistent_numbering_of_sender_and_receiver =
false)
const;
897 std::map<unsigned int, std::vector<unsigned int>>
899 const std::vector<std::tuple<unsigned int, unsigned int, unsigned int>>
900 &point_recv_components,
911 template <
int structdim,
int dim,
int spacedim>
915 const std::vector<std::vector<
Point<spacedim>>> &intersection_requests,
917 const std::vector<bool> &marked_vertices,
918 const double tolerance);
931 template <
int spacedim>
962 template <
int dim,
template <
int,
int>
class MeshType,
int spacedim>
966 const MeshType<dim, spacedim> &mesh,
967 const
Point<spacedim> &p,
968 const
std::vector<
bool> &marked_vertices = {});
996 template <
int dim,
template <
int,
int>
class MeshType,
int spacedim>
1001 const MeshType<dim, spacedim> &mesh,
1002 const
Point<spacedim> &p,
1003 const
std::vector<
bool> &marked_vertices = {});
1028 template <
typename MeshType>
1031 std::vector<typename MeshType::active_cell_iterator>
1034 typename ::internal::ActiveCellIterator<MeshType::dimension,
1035 MeshType::space_dimension,
1039 const unsigned int vertex_index);
1106 template <
int dim,
template <
int,
int>
class MeshType,
int spacedim>
1108 (concepts::is_triangulation_or_dof_handler<MeshType<dim, spacedim>>))
1110 std::pair<typename MeshType<dim, spacedim>::active_cell_iterator, Point<dim>>
1112 std::pair<typename ::internal::
1113 ActiveCellIterator<dim, spacedim, MeshType<dim, spacedim>>::type,
1117 const MeshType<dim, spacedim> &mesh,
1118 const Point<spacedim> &p,
1119 const std::vector<bool> &marked_vertices = {},
1120 const double tolerance = 1.e-10);
1132 template <
int dim,
template <
int,
int>
class MeshType,
int spacedim>
1134 (concepts::is_triangulation_or_dof_handler<MeshType<dim, spacedim>>))
1136 typename MeshType<dim, spacedim>::active_cell_iterator
1138 typename ::internal::
1139 ActiveCellIterator<dim, spacedim, MeshType<dim, spacedim>>::type
1142 const Point<spacedim> &p,
1143 const std::vector<bool> &marked_vertices = {},
1144 const double tolerance = 1.e-10);
1152 template <
int dim,
int spacedim>
1153 std::pair<typename DoFHandler<dim, spacedim>::active_cell_iterator,
1156 const hp::MappingCollection<dim, spacedim> &
mapping,
1157 const DoFHandler<dim, spacedim> &mesh,
1158 const Point<spacedim> &p,
1159 const double tolerance = 1.e-10);
1212 template <
int dim,
int spacedim>
1213 std::pair<typename Triangulation<dim, spacedim>::active_cell_iterator,
1217 const Point<spacedim> &p,
1220 const std::vector<bool> &marked_vertices = {},
1221 const double tolerance = 1.e-10);
1239 template <
int dim,
template <
int,
int>
class MeshType,
int spacedim>
1241 (concepts::is_triangulation_or_dof_handler<MeshType<dim, spacedim>>))
1243 std::pair<typename MeshType<dim, spacedim>::active_cell_iterator, Point<dim>>
1245 std::pair<typename ::internal::
1246 ActiveCellIterator<dim, spacedim, MeshType<dim, spacedim>>::type,
1250 const Mapping<dim, spacedim> &
mapping,
1251 const MeshType<dim, spacedim> &mesh,
1252 const Point<spacedim> &p,
1254 std::set<
typename MeshType<dim, spacedim>::active_cell_iterator>>
1256 const std::vector<std::vector<Tensor<1, spacedim>>>
1257 &vertex_to_cell_centers,
1258 const typename MeshType<dim, spacedim>::active_cell_iterator &cell_hint =
1259 typename MeshType<dim, spacedim>::active_cell_iterator(),
1260 const std::vector<bool> &marked_vertices = {},
1263 const double tolerance = 1.e-10,
1265 std::pair<BoundingBox<spacedim>,
1267 *relevant_cell_bounding_boxes_rtree =
nullptr);
1298 template <
int dim,
template <
int,
int>
class MeshType,
int spacedim>
1300 (concepts::is_triangulation_or_dof_handler<MeshType<dim, spacedim>>))
1302 std::vector<std::pair<typename MeshType<dim, spacedim>::active_cell_iterator,
1305 std::vector<std::pair<
1306 typename ::internal::
1307 ActiveCellIterator<dim, spacedim, MeshType<dim, spacedim>>::type,
1311 const Mapping<dim, spacedim> &
mapping,
1312 const MeshType<dim, spacedim> &mesh,
1313 const Point<spacedim> &p,
1314 const double tolerance,
1315 const std::pair<
typename MeshType<dim, spacedim>::active_cell_iterator,
1316 Point<dim>> &first_cell,
1318 std::set<
typename MeshType<dim, spacedim>::active_cell_iterator>>
1319 *vertex_to_cells =
nullptr);
1330 template <
int dim,
template <
int,
int>
class MeshType,
int spacedim>
1332 (concepts::is_triangulation_or_dof_handler<MeshType<dim, spacedim>>))
1334 std::vector<std::pair<typename MeshType<dim, spacedim>::active_cell_iterator,
1337 std::vector<std::pair<
1338 typename ::internal::
1339 ActiveCellIterator<dim, spacedim, MeshType<dim, spacedim>>::type,
1343 const Mapping<dim, spacedim> &
mapping,
1344 const MeshType<dim, spacedim> &mesh,
1345 const Point<spacedim> &p,
1346 const double tolerance = 1e-10,
1347 const std::vector<bool> &marked_vertices = {});
1372 template <
typename MeshType>
1375 const typename MeshType::cell_iterator &cell);
1403 template <typename MeshType>
1406 const typename MeshType::active_cell_iterator &cell,
1407 std::vector<typename MeshType::active_cell_iterator> &active_neighbors);
1460 template <typename MeshType>
1464 const MeshType &mesh,
1465 const
std::function<
bool(const typename MeshType::active_cell_iterator &)>
1478 template <typename MeshType>
1482 const MeshType &mesh,
1483 const
std::function<
bool(const typename MeshType::cell_iterator &)>
1485 const
unsigned int level);
1502 template <typename MeshType>
1558 template <typename MeshType>
1562 const MeshType &mesh,
1563 const
std::function<
bool(const typename MeshType::active_cell_iterator &)>
1565 const
double layer_thickness);
1591 template <typename MeshType>
1595 const MeshType &mesh,
1596 const
double layer_thickness);
1670 template <typename MeshType>
1674 const MeshType &mesh,
1675 const
std::function<
bool(const typename MeshType::active_cell_iterator &)>
1677 const
unsigned int refinement_level = 0,
1678 const
bool allow_merge = false,
1679 const
unsigned int max_boxes =
numbers::invalid_unsigned_int);
1708 template <
int spacedim>
1710 std::tuple<std::vector<std::vector<unsigned int>>,
1711 std::map<unsigned int, unsigned int>,
1712 std::map<unsigned int, std::vector<unsigned int>>>
1755 template <
int spacedim>
1757 std::tuple<std::map<unsigned int, std::vector<unsigned int>>,
1758 std::map<unsigned int, unsigned int>,
1759 std::map<unsigned int, std::vector<unsigned int>>>
1779 template <
int dim,
int spacedim>
1780 std::vector<std::vector<Tensor<1, spacedim>>>
1795 template <
int dim,
int spacedim>
1820 template <
int dim,
int spacedim>
1821 std::map<unsigned int, types::global_vertex_index>
1853 template <
int dim,
int spacedim>
1854 std::vector<types::global_vertex_index>
1885 template <
int dim,
int spacedim>
1902 template <
int dim,
int spacedim>
1905 const std::vector<unsigned int> &cell_weights,
1955 template <
int dim,
int spacedim>
1973 template <
int dim,
int spacedim>
1976 const std::vector<unsigned int> &cell_weights,
1996 template <
int dim,
int spacedim>
2000 const bool group_siblings =
true);
2013 template <
int dim,
int spacedim>
2024 template <
int dim,
int spacedim>
2025 std::vector<types::subdomain_id>
2027 const std::vector<CellId> &cell_ids);
2039 template <
int dim,
int spacedim>
2042 std::vector<types::subdomain_id> &subdomain);
2058 template <
int dim,
int spacedim>
2093 template <
int dim,
int spacedim>
2146 template <
typename MeshType>
2149 const typename MeshType::active_cell_iterator &cell);
2173 template <
class Container>
2174 std::vector<typename Container::cell_iterator>
2176 const std::vector<typename Container::active_cell_iterator> &patch_cells);
2244 template <
class Container>
2247 const std::vector<typename Container::active_cell_iterator> &patch,
2249 &local_triangulation,
2252 Container::space_dimension>::active_cell_iterator,
2253 typename Container::active_cell_iterator> &patch_to_global_tria_map);
2286 template <
int dim,
int spacedim>
2289 std::vector<typename DoFHandler<dim, spacedim>::active_cell_iterator>>
2307 template <
typename CellIterator>
2373 template <
typename FaceIterator>
2374 std::optional<types::geometric_orientation>
2376 const FaceIterator &face1,
2377 const FaceIterator &face2,
2378 const unsigned int direction,
2382 const double abs_tol = 1e-10);
2443 template <
typename MeshType>
2446 const MeshType &mesh,
2449 const unsigned int direction,
2455 const double abs_tol = 1e-10);
2478 template <
typename MeshType>
2481 const MeshType &mesh,
2482 const
types::boundary_id b_id,
2483 const
unsigned int direction,
2489 const
double abs_tol = 1e-10);
2517 template <
int dim,
int spacedim>
2520 const
bool reset_boundary_ids = false);
2543 template <
int dim,
int spacedim>
2546 const
std::vector<
types::boundary_id> &src_boundary_ids,
2547 const
std::vector<
types::manifold_id> &dst_manifold_ids,
2549 const
std::vector<
types::boundary_id> &reset_boundary_ids = {});
2580 template <
int dim,
int spacedim>
2583 const bool compute_face_ids =
false);
2609 template <
int dim,
int spacedim>
2614 const std::set<types::manifold_id> &)> &disambiguation_function =
2615 [](
const std::set<types::manifold_id> &manifold_ids) {
2616 if (manifold_ids.size() == 1)
2617 return *manifold_ids.begin();
2621 bool overwrite_only_flat_manifold_ids =
true);
2710 template <
typename DataType,
typename MeshType>
2713 const MeshType &mesh,
2714 const
std::function<
std::optional<DataType>(
2715 const typename MeshType::active_cell_iterator &)> &pack,
2716 const
std::function<
void(const typename MeshType::active_cell_iterator &,
2717 const DataType &)> &unpack,
2718 const
std::function<
bool(const typename MeshType::active_cell_iterator &)>
2720 always_return<typename MeshType::active_cell_iterator,
bool>{
true});
2734 template <
typename DataType,
typename MeshType>
2737 const MeshType &mesh,
2738 const
std::function<
std::optional<DataType>(
2739 const typename MeshType::level_cell_iterator &)> &pack,
2740 const
std::function<
void(const typename MeshType::level_cell_iterator &,
2741 const DataType &)> &unpack,
2742 const
std::function<
bool(const typename MeshType::level_cell_iterator &)> &
2743 cell_filter =
always_return<typename MeshType::level_cell_iterator,
bool>{
2757 template <
int spacedim>
2758 std::vector<std::vector<BoundingBox<spacedim>>>
2795 template <
int spacedim>
2818 template <
int dim,
int spacedim>
2822 std::map<
unsigned int, std::vector<unsigned int>> &coinciding_vertex_groups,
2823 std::map<unsigned int, unsigned int> &vertex_to_coinciding_vertex_group);
2844 template <
int dim,
int spacedim>
2845 std::map<unsigned int, std::set<::types::subdomain_id>>
2869 template <
int dim,
typename VectorType>
2898 const VectorType &ls_vector,
2899 const double iso_level,
2909 const VectorType &ls_vector,
2910 const double iso_level,
2924 const VectorType &ls_vector,
2925 const double iso_level,
2935 const VectorType &ls_vector,
2936 const double iso_level,
2953 const double iso_level,
2956 const bool write_back_cell_data =
true)
const;
2964 const std::vector<unsigned int> &,
2981 const std::vector<
Point<2>> &points,
2982 const std::vector<unsigned int> &mask,
2983 const double iso_level,
2986 const bool write_back_cell_data)
const;
2993 const std::vector<
Point<3>> &points,
2994 const std::vector<unsigned int> &mask,
2995 const double iso_level,
2998 const bool write_back_cell_data)
const;
3031 <<
"The number of partitions you gave is " << arg1
3032 <<
", but must be greater than zero.");
3038 <<
"The subdomain id " << arg1
3039 <<
" has no cells associated with it.");
3050 <<
"The scaling factor must be positive, but it is " << arg1
3058 <<
"The given vertex with index " << arg1
3059 <<
" is not used in the given triangulation.");
3085 template <
int dim,
typename Transformation,
int spacedim>
3087 (std::invocable<Transformation, Point<spacedim>> &&
3088 std::assignable_from<
3090 std::invoke_result_t<Transformation, Point<spacedim>>>))
3091 void
transform(const Transformation &transformation,
3092 Triangulation<dim, spacedim> &triangulation)
3094 std::vector<bool> treated_vertices(triangulation.n_vertices(),
false);
3103 cell = triangulation.begin_active(),
3104 endc = triangulation.end();
3105 for (; cell != endc; ++cell)
3106 for (
const unsigned int v : cell->vertex_indices())
3107 if (treated_vertices[cell->vertex_index(v)] ==
false)
3110 cell->vertex(v) = transformation(cell->vertex(v));
3112 treated_vertices[cell->vertex_index(v)] =
true;
3120 cell = triangulation.begin_active(),
3121 endc = triangulation.end();
3122 for (; cell != endc; ++cell)
3123 for (
const unsigned int face : cell->face_indices())
3124 if (cell->face(face)->has_children() &&
3125 !cell->face(face)->at_boundary())
3127 Assert(cell->reference_cell() ==
3132 cell->face(face)->child(0)->vertex(1) =
3133 (cell->face(face)->vertex(0) + cell->face(face)->vertex(1)) /
3140 cell = triangulation.begin_active(),
3141 endc = triangulation.end();
3142 for (; cell != endc; ++cell)
3143 for (
const unsigned int face : cell->face_indices())
3144 if (cell->face(face)->has_children() &&
3145 !cell->face(face)->at_boundary())
3147 if (
static_cast<std::uint8_t
>(
3148 cell->face(face)->refinement_case()) ==
3151 Assert(cell->reference_cell() ==
3156 cell->face(face)->child(0)->vertex(1) =
3157 (cell->face(face)->vertex(0) +
3158 cell->face(face)->vertex(1)) /
3160 cell->face(face)->child(0)->vertex(2) =
3161 (cell->face(face)->vertex(0) +
3162 cell->face(face)->vertex(2)) /
3164 cell->face(face)->child(1)->vertex(3) =
3165 (cell->face(face)->vertex(1) +
3166 cell->face(face)->vertex(3)) /
3168 cell->face(face)->child(2)->vertex(3) =
3169 (cell->face(face)->vertex(2) +
3170 cell->face(face)->vertex(3)) /
3174 cell->face(face)->child(0)->vertex(3) =
3175 (cell->face(face)->vertex(0) +
3176 cell->face(face)->vertex(1) +
3177 cell->face(face)->vertex(2) +
3178 cell->face(face)->vertex(3)) /
3184 for (
unsigned int line = 0;
3187 if (cell->face(face)->line(line)->has_children())
3188 cell->face(face)->line(line)->child(0)->vertex(1) =
3189 (cell->face(face)->line(line)->vertex(0) +
3190 cell->face(face)->line(line)->vertex(1)) /
3197 triangulation.signals.mesh_movement();
3202 template <
typename MeshType>
3205 const typename MeshType::cell_iterator &cell)
3207 std::vector<typename MeshType::active_cell_iterator> child_cells;
3209 if (cell->has_children())
3211 for (
unsigned int child = 0; child < cell->n_children(); ++child)
3212 if (cell->child(child)->has_children())
3214 const std::vector<typename MeshType::active_cell_iterator>
3216 child_cells.insert(child_cells.end(),
3221 child_cells.push_back(cell->child(child));
3229 template <
typename MeshType>
3232 const typename MeshType::active_cell_iterator &cell,
3233 std::vector<typename MeshType::active_cell_iterator> &active_neighbors)
3235 active_neighbors.clear();
3236 for (
const unsigned int n : cell->face_indices())
3237 if (!cell->at_boundary(n))
3239 if (MeshType::dimension == 1)
3246 typename MeshType::cell_iterator neighbor_child =
3248 if (!neighbor_child->is_active())
3250 while (neighbor_child->has_children())
3251 neighbor_child = neighbor_child->child(n == 0 ? 1 : 0);
3253 Assert(neighbor_child->neighbor(n == 0 ? 1 : 0) == cell,
3256 active_neighbors.push_back(neighbor_child);
3260 if (cell->face(n)->has_children())
3264 for (
unsigned int c = 0;
3265 c < cell->face(n)->n_active_descendants();
3267 active_neighbors.push_back(
3268 cell->neighbor_child_on_subface(n, c));
3274 active_neighbors.push_back(cell->neighbor(n));
3282 template <
typename CellIterator>
3286 return sizeof(*this) +
matrix.memory_consumption();
3293 template <
typename DataType,
3295 typename MeshCellIteratorType>
3297 inline void exchange_cell_data(
3298 const MeshType &mesh,
3299 const std::function<std::optional<DataType>(
const MeshCellIteratorType &)>
3301 const std::function<
void(
const MeshCellIteratorType &,
const DataType &)>
3303 const std::function<
bool(
const MeshCellIteratorType &)> &cell_filter,
3304 const std::function<
void(
3305 const std::function<
void(
const MeshCellIteratorType &,
3307 const std::function<std::set<types::subdomain_id>(
3308 const parallel::TriangulationBase<MeshType::dimension,
3309 MeshType::space_dimension> &)>
3310 &compute_ghost_owners)
3312# ifndef DEAL_II_WITH_MPI
3317 (void)process_cells;
3318 (void)compute_ghost_owners;
3321 constexpr int dim = MeshType::dimension;
3322 constexpr int spacedim = MeshType::space_dimension;
3324 dynamic_cast<const parallel::TriangulationBase<dim, spacedim> *
>(
3325 &mesh.get_triangulation());
3329 "The function exchange_cell_data_to_ghosts() only works with parallel triangulations."));
3331 if (
const auto tria =
dynamic_cast<
3332 const parallel::shared::Triangulation<dim, spacedim> *
>(
3333 &mesh.get_triangulation()))
3336 tria->with_artificial_cells(),
3338 "The functions GridTools::exchange_cell_data_to_ghosts() and "
3339 "GridTools::exchange_cell_data_to_level_ghosts() can only "
3340 "operate on a single layer of ghost cells. However, you have "
3341 "given a Triangulation object of type "
3342 "parallel::shared::Triangulation without artificial cells "
3343 "resulting in an arbitrary number of ghost layers. "
3344 "To use this function for a Triangulation object of type "
3345 "parallel::shared::Triangulation, make sure to create the "
3346 "Triangulation object with allow_artificial_cells set to true. "
3347 "This results in a parallel::shared::Triangulation with only "
3348 "a single layer of ghost cells."));
3352 std::set<types::subdomain_id> ghost_owners = compute_ghost_owners(*tria);
3353 std::map<types::subdomain_id, std::vector<CellId::binary_type>>
3356 for (
const auto ghost_owner : ghost_owners)
3357 neighbor_cell_list[ghost_owner] = {};
3359 process_cells([&](
const auto &cell,
const auto key) ->
void {
3360 if (cell_filter(cell))
3362 neighbor_cell_list[key].emplace_back(
3363 cell->id().template to_binary<spacedim>());
3367 Assert(ghost_owners.size() == neighbor_cell_list.size(),
3373 static Utilities::MPI::CollectiveMutex mutex;
3374 Utilities::MPI::CollectiveMutex::ScopedLock lock(
3379 const int mpi_tag_reply =
3383 std::vector<MPI_Request> requests(ghost_owners.size());
3385 unsigned int idx = 0;
3386 for (
const auto &it : neighbor_cell_list)
3389 const int ierr = MPI_Isend(it.second.data(),
3390 it.second.size() *
sizeof(it.second[0]),
3402 std::vector<MPI_Request> reply_requests(ghost_owners.size());
3403 std::vector<std::vector<char>> sendbuffers(ghost_owners.size());
3405 for (
unsigned int idx = 0; idx < ghost_owners.size(); ++idx)
3408 int ierr = MPI_Probe(MPI_ANY_SOURCE,
3415 ierr = MPI_Get_count(&status, MPI_BYTE, &len);
3421 std::vector<CellId::binary_type> cells_with_requests(n_cells);
3422 std::vector<DataType> data_to_send;
3423 data_to_send.reserve(n_cells);
3424 std::vector<bool> cell_carries_data(n_cells,
false);
3426 ierr = MPI_Recv(cells_with_requests.data(),
3436 for (
unsigned int c = 0; c <
n_cells; ++c)
3441 MeshCellIteratorType mesh_it(tria,
3446 std::optional<DataType> data =
pack(mesh_it);
3449 data_to_send.emplace_back(std::move(*data));
3450 cell_carries_data[c] =
true;
3458 sendbuffers[idx].resize(
sizeof(std::size_t));
3463 std::size_t size_of_send =
3467 std::memcpy(sendbuffers[idx].data(),
3469 sizeof(std::size_t));
3473 if (data_to_send.size() < n_cells)
3479 ierr = MPI_Isend(sendbuffers[idx].data(),
3480 sendbuffers[idx].size(),
3485 &reply_requests[idx]);
3490 std::vector<char> receive;
3491 for (
unsigned int id = 0;
id < neighbor_cell_list.size(); ++id)
3494 int ierr = MPI_Probe(MPI_ANY_SOURCE,
3501 ierr = MPI_Get_count(&status, MPI_BYTE, &len);
3504 receive.resize(len);
3506 ierr = MPI_Recv(receive.data(),
3517 auto data_iterator = receive.begin();
3518 std::size_t size_of_received_data =
3520 data_iterator +
sizeof(std::size_t));
3521 data_iterator +=
sizeof(std::size_t);
3526 data_iterator + size_of_received_data,
3528 data_iterator += size_of_received_data;
3533 const std::vector<CellId::binary_type> &this_cell_list =
3534 neighbor_cell_list[status.MPI_SOURCE];
3536 std::vector<bool> cells_with_data;
3537 if (received_data.size() < this_cell_list.size())
3540 data_iterator, receive.end(),
false);
3546 auto received_data_iterator = received_data.begin();
3547 for (
unsigned int c = 0; c < this_cell_list.size(); ++c)
3548 if (cells_with_data.empty() || cells_with_data[c])
3553 MeshCellIteratorType cell(tria,
3558 unpack(cell, *received_data_iterator);
3559 ++received_data_iterator;
3565 if (requests.size() > 0)
3568 MPI_Waitall(requests.size(), requests.data(), MPI_STATUSES_IGNORE);
3571 if (reply_requests.size() > 0)
3573 const int ierr = MPI_Waitall(reply_requests.size(),
3574 reply_requests.data(),
3575 MPI_STATUSES_IGNORE);
3585 template <
typename DataType,
typename MeshType>
3588 const MeshType &mesh,
3589 const std::function<std::optional<DataType>(
3590 const typename MeshType::active_cell_iterator &)> &pack,
3591 const std::function<
void(
const typename MeshType::active_cell_iterator &,
3592 const DataType &)> &unpack,
3593 const std::function<
bool(
const typename MeshType::active_cell_iterator &)>
3596# ifndef DEAL_II_WITH_MPI
3603 internal::exchange_cell_data<DataType,
3605 typename MeshType::active_cell_iterator>(
3610 [&](
const auto &process) {
3611 for (
const auto &cell : mesh.active_cell_iterators())
3612 if (cell->is_ghost())
3613 process(cell, cell->subdomain_id());
3615 [](
const auto &tria) {
return tria.ghost_owners(); });
3621 template <
typename DataType,
typename MeshType>
3624 const MeshType &mesh,
3625 const std::function<std::optional<DataType>(
3626 const typename MeshType::level_cell_iterator &)> &pack,
3627 const std::function<
void(
const typename MeshType::level_cell_iterator &,
3628 const DataType &)> &unpack,
3629 const std::function<
bool(
const typename MeshType::level_cell_iterator &)>
3632# ifndef DEAL_II_WITH_MPI
3639 internal::exchange_cell_data<DataType,
3641 typename MeshType::level_cell_iterator>(
3646 [&](
const auto &process) {
3647 for (
const auto &cell : mesh.cell_iterators())
3648 if (cell->is_ghost_on_level())
3649 process(cell, cell->level_subdomain_id());
3651 [](
const auto &tria) {
return tria.level_ghost_owners(); });
std::array< std::uint64_t, 3 > binary_type
Abstract base class for mapping classes.
const Mapping< dim, spacedim > & get_default_linear_mapping() const
cell_iterator create_cell_iterator(const CellId &cell_id) const
virtual MPI_Comm get_mpi_communicator() const
typename MeshType::active_cell_iterator type
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_CXX20_REQUIRES(condition)
#define DEAL_II_NAMESPACE_CLOSE
const unsigned int DoFAccessor< structdim, dim, spacedim, level_dof_access >::space_dimension
constexpr unsigned int GeometryInfo< dim >::faces_per_cell
#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)
TriaActiveIterator< CellAccessor< dim, spacedim > > active_cell_iterator
typename ActiveSelector::active_cell_iterator active_cell_iterator
TriaIterator< CellAccessor< dim, spacedim > > 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)
const Mapping< dim, spacedim > & get_default_linear_mapping(const Triangulation< dim, spacedim > &triangulation)
MappingQ< dim, spacedim > StaticMappingQ1< dim, spacedim >::mapping
@ matrix
Contents is actually a matrix.
constexpr const ReferenceCell< dim > & get_hypercube()
std::size_t pack(const T &object, std::vector< char > &dest_buffer, const bool allow_compression=true)
T unpack(const std::vector< char > &buffer, const bool allow_compression=true)
unsigned int n_cells(const internal::TriangulationImplementation::NumberCache< 1 > &c)
constexpr types::manifold_id flat_manifold_id
unsigned int subdomain_id
unsigned int global_dof_index
std::uint8_t geometric_orientation
*braid_SplitCommworld & comm
boost::geometry::index::rtree< LeafType, IndexType, IndexableGetter > RTree
static constexpr unsigned int vertices_per_cell