Reference documentation for deal.II version GIT relicensing-822-gf1642d4ea5 2024-06-12 14:10: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
p4est_wrappers.h
Go to the documentation of this file.
1// ------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: LGPL-2.1-or-later
4// Copyright (C) 2016 - 2023 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_p4est_wrappers_h
16#define dealii_p4est_wrappers_h
17
18#include <deal.II/base/config.h>
19
21
22#ifdef DEAL_II_WITH_P4EST
23# include <p4est_bits.h>
24# include <p4est_communication.h>
25# include <p4est_extended.h>
26# include <p4est_ghost.h>
27# include <p4est_iterate.h>
28# include <p4est_search.h>
29# include <p4est_vtk.h>
30# include <p8est_bits.h>
31# include <p8est_communication.h>
32# include <p8est_extended.h>
33# include <p8est_ghost.h>
34# include <p8est_iterate.h>
35# include <p8est_search.h>
36# include <p8est_vtk.h>
37
38# include <limits>
39
41
42// Forward declaration
43# ifndef DOXYGEN
44namespace parallel
45{
46 namespace distributed
47 {
48 template <int dim, int spacedim>
50 class Triangulation;
51 }
52} // namespace parallel
53# endif
54
55namespace internal
56{
57 namespace p4est
58 {
66 template <int>
67 struct types;
68
69 // these struct mimics p4est for 1d
70 template <>
71 struct types<1>
72 {
73 // id of a quadrant is an integeger
74 using quadrant = int;
75
76 // maximum number of children
77 static const int max_n_child_indices_bits = 27;
78
79 // number of bits the data type of id has
80 static const int n_bits = std::numeric_limits<quadrant>::digits;
81 };
82
83 template <>
101
102 template <>
120
121
122
130 template <int dim>
131 struct functions;
132
133 template <>
134 struct functions<2>
135 {
136 static int (&quadrant_compare)(const void *v1, const void *v2);
137
138 static void (&quadrant_childrenv)(const types<2>::quadrant *q,
140
141 static int (&quadrant_overlaps_tree)(types<2>::tree *tree,
142 const types<2>::quadrant *q);
143
144 static void (&quadrant_set_morton)(types<2>::quadrant *quadrant,
145 int level,
146 std::uint64_t id);
147
149 const types<2>::quadrant *q2);
150
151 static int (&quadrant_is_sibling)(const types<2>::quadrant *q1,
152 const types<2>::quadrant *q2);
153
155 const types<2>::quadrant *q2);
156
157 static int (&quadrant_ancestor_id)(const types<2>::quadrant *q,
158 int level);
159
160 static int (&comm_find_owner)(types<2>::forest *p4est,
162 const types<2>::quadrant *q,
163 const int guess);
164
170
175 const double *vertices,
176 const types<2>::topidx *ttv,
177 const types<2>::topidx *ttt,
178 const int8_t *ttf,
179 const types<2>::topidx *ttc,
180 const types<2>::topidx *coff,
181 const types<2>::topidx *ctt,
182 const int8_t *ctc);
183
184 static void (&connectivity_join_faces)(types<2>::connectivity *conn,
187 int face_left,
188 int face_right,
189 int orientation);
190
191
192
193 static void (&connectivity_destroy)(p4est_connectivity_t *connectivity);
194
197 types<2>::connectivity *connectivity,
199 int min_level,
200 int fill_uniform,
201 std::size_t data_size,
203 void *user_pointer);
204
206 int copy_data);
207
208 static void (&destroy)(types<2>::forest *p4est);
209
210 static void (&refine)(types<2>::forest *p4est,
214
215 static void (&coarsen)(types<2>::forest *p4est,
219
220 static void (&balance)(types<2>::forest *p4est,
223
224 static types<2>::gloidx (&partition)(types<2>::forest *p4est,
227
228 static void (&save)(const char *filename,
229 types<2>::forest *p4est,
230 int save_data);
231
232 static types<2>::forest *(&load_ext)(const char *filename,
234 std::size_t data_size,
235 int load_data,
236 int autopartition,
237 int broadcasthead,
238 void *user_pointer,
239 types<2>::connectivity **p4est);
240
241 static int (&connectivity_save)(const char *filename,
242 types<2>::connectivity *connectivity);
243
244 static int (&connectivity_is_valid)(types<2>::connectivity *connectivity);
245
247 std::size_t *length);
248
249 static unsigned int (&checksum)(types<2>::forest *p4est);
250
251 static void (&vtk_write_file)(types<2>::forest *p4est,
253 const char *baseName);
254
257
258 static void (&ghost_destroy)(types<2>::ghost *ghost);
259
260 static void (&reset_data)(types<2>::forest *p4est,
261 std::size_t data_size,
263 void *user_pointer);
264
265 static std::size_t (&forest_memory_used)(types<2>::forest *p4est);
266
267 static std::size_t (&connectivity_memory_used)(
269
270 template <int spacedim>
271 static void
274 void *user_data);
275
276 static constexpr unsigned int max_level = P4EST_MAXLEVEL;
277
278 static void (&transfer_fixed)(const types<2>::gloidx *dest_gfq,
281 int tag,
282 void *dest_data,
283 const void *src_data,
284 std::size_t data_size);
285
290 int tag,
291 void *dest_data,
292 const void *src_data,
293 std::size_t data_size);
294
295 static void (&transfer_fixed_end)(types<2>::transfer_context *tc);
296
297 static void (&transfer_custom)(const types<2>::gloidx *dest_gfq,
300 int tag,
301 void *dest_data,
302 const int *dest_sizes,
303 const void *src_data,
304 const int *src_sizes);
305
310 int tag,
311 void *dest_data,
312 const int *dest_sizes,
313 const void *src_data,
314 const int *src_sizes);
315
316 static void (&transfer_custom_end)(types<2>::transfer_context *tc);
317
318# ifdef P4EST_SEARCH_LOCAL
319 static void (&search_partition)(
320 types<2>::forest *forest,
321 int call_post,
324 sc_array_t *points);
325# endif
326
327 static void (&quadrant_coord_to_vertex)(
328 types<2>::connectivity *connectivity,
332 double vxyz[3]);
333 };
334
335
336 template <>
337 struct functions<3>
338 {
339 static int (&quadrant_compare)(const void *v1, const void *v2);
340
341 static void (&quadrant_childrenv)(const types<3>::quadrant *q,
343
344 static int (&quadrant_overlaps_tree)(types<3>::tree *tree,
345 const types<3>::quadrant *q);
346
347 static void (&quadrant_set_morton)(types<3>::quadrant *quadrant,
348 int level,
349 std::uint64_t id);
350
352 const types<3>::quadrant *q2);
353
354 static int (&quadrant_is_sibling)(const types<3>::quadrant *q1,
355 const types<3>::quadrant *q2);
356
358 const types<3>::quadrant *q2);
359 static int (&quadrant_ancestor_id)(const types<3>::quadrant *q,
360 int level);
361
362 static int (&comm_find_owner)(types<3>::forest *p4est,
364 const types<3>::quadrant *q,
365 const int guess);
366
374
380 const double *vertices,
381 const types<3>::topidx *ttv,
382 const types<3>::topidx *ttt,
383 const int8_t *ttf,
384 const types<3>::topidx *tte,
385 const types<3>::topidx *eoff,
386 const types<3>::topidx *ett,
387 const int8_t *ete,
388 const types<3>::topidx *ttc,
389 const types<3>::topidx *coff,
390 const types<3>::topidx *ctt,
391 const int8_t *ctc);
392
393 static void (&connectivity_join_faces)(types<3>::connectivity *conn,
396 int face_left,
397 int face_right,
398 int orientation);
399
400 static void (&connectivity_destroy)(p8est_connectivity_t *connectivity);
401
404 types<3>::connectivity *connectivity,
406 int min_level,
407 int fill_uniform,
408 std::size_t data_size,
410 void *user_pointer);
411
413 int copy_data);
414
415 static void (&destroy)(types<3>::forest *p8est);
416
417 static void (&refine)(types<3>::forest *p8est,
421
422 static void (&coarsen)(types<3>::forest *p8est,
426
427 static void (&balance)(types<3>::forest *p8est,
430
434
435 static void (&save)(const char *filename,
436 types<3>::forest *p4est,
437 int save_data);
438
439 static types<3>::forest *(&load_ext)(const char *filename,
441 std::size_t data_size,
442 int load_data,
443 int autopartition,
444 int broadcasthead,
445 void *user_pointer,
446 types<3>::connectivity **p4est);
447
448 static int (&connectivity_save)(const char *filename,
449 types<3>::connectivity *connectivity);
450
451 static int (&connectivity_is_valid)(types<3>::connectivity *connectivity);
452
454 std::size_t *length);
455
456 static unsigned int (&checksum)(types<3>::forest *p8est);
457
458 static void (&vtk_write_file)(types<3>::forest *p8est,
460 const char *baseName);
463
464 static void (&ghost_destroy)(types<3>::ghost *ghost);
465
466 static void (&reset_data)(types<3>::forest *p4est,
467 std::size_t data_size,
469 void *user_pointer);
470
471 static std::size_t (&forest_memory_used)(types<3>::forest *p4est);
472
473 static std::size_t (&connectivity_memory_used)(
475
476 static constexpr unsigned int max_level = P8EST_MAXLEVEL;
477
478 static void (&transfer_fixed)(const types<3>::gloidx *dest_gfq,
481 int tag,
482 void *dest_data,
483 const void *src_data,
484 std::size_t data_size);
485
490 int tag,
491 void *dest_data,
492 const void *src_data,
493 std::size_t data_size);
494
495 static void (&transfer_fixed_end)(types<3>::transfer_context *tc);
496
497 static void (&transfer_custom)(const types<3>::gloidx *dest_gfq,
500 int tag,
501 void *dest_data,
502 const int *dest_sizes,
503 const void *src_data,
504 const int *src_sizes);
505
510 int tag,
511 void *dest_data,
512 const int *dest_sizes,
513 const void *src_data,
514 const int *src_sizes);
515
516 static void (&transfer_custom_end)(types<3>::transfer_context *tc);
517
518# ifdef P4EST_SEARCH_LOCAL
519 static void (&search_partition)(
520 types<3>::forest *forest,
521 int call_post,
524 sc_array_t *points);
525# endif
526
527 static void (&quadrant_coord_to_vertex)(
528 types<3>::connectivity *connectivity,
533 double vxyz[3]);
534 };
535
536
537
544 template <int dim>
545 struct iter;
546
547 template <>
557
558 template <>
571
572
573
578 template <int dim>
579 void
581 const typename types<dim>::quadrant &p4est_cell,
582 typename types<dim>::quadrant (
584
585
586
590 template <int dim>
591 void
593
594
595
599 template <int dim>
600 bool
602 const typename types<dim>::quadrant &q2);
603
604
605
609 template <int dim>
610 bool
612 const typename types<dim>::quadrant &q2);
613
614
615
619 template <int dim>
620 bool
621 tree_exists_locally(const typename types<dim>::forest *parallel_forest,
622 const typename types<dim>::topidx coarse_grid_cell);
623
624
628 template <int dim>
629 typename types<dim>::connectivity *
630 copy_connectivity(const typename types<dim>::connectivity *connectivity);
631
632# ifndef DOXYGEN
633 template <>
634 typename types<2>::connectivity *
635 copy_connectivity<2>(const typename types<2>::connectivity *connectivity);
636
637 template <>
638 typename types<3>::connectivity *
639 copy_connectivity<3>(const typename types<3>::connectivity *connectivity);
640# endif
641 } // namespace p4est
642} // namespace internal
643
645
646#endif // DEAL_II_WITH_P4EST
647
648#endif // dealii_p4est_wrappers_h
#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
Point< 3 > vertices[4]
unsigned int level
Definition grid_out.cc:4626
const unsigned int v1
void init_coarse_quadrant(typename types< dim >::quadrant &quad)
types< 2 >::connectivity * copy_connectivity< 2 >(const typename types< 2 >::connectivity *connectivity)
types< 3 >::connectivity * copy_connectivity< 3 >(const typename types< 3 >::connectivity *connectivity)
bool quadrant_is_equal(const typename types< dim >::quadrant &q1, const typename types< dim >::quadrant &q2)
void init_quadrant_children(const typename types< dim >::quadrant &p4est_cell, typename types< dim >::quadrant(&p4est_children)[::GeometryInfo< dim >::max_children_per_cell])
bool quadrant_is_ancestor(const typename types< dim >::quadrant &q1, const typename types< dim >::quadrant &q2)
bool tree_exists_locally(const typename types< dim >::forest *parallel_forest, const typename types< dim >::topidx coarse_grid_cell)
types< dim >::connectivity * copy_connectivity(const typename types< dim >::connectivity *connectivity)
Definition types.h:32
static types< 2 >::forest *(&) new_forest(MPI_Comm mpicomm, types< 2 >::connectivity *connectivity, types< 2 >::locidx min_quadrants, int min_level, int fill_uniform, std::size_t data_size, p4est_init_t init_fn, void *user_pointer)
static types< 2 >::forest *(&) copy_forest(types< 2 >::forest *input, int copy_data)
static types< 2 >::connectivity *(&) connectivity_new(types< 2 >::topidx num_vertices, types< 2 >::topidx num_trees, types< 2 >::topidx num_corners, types< 2 >::topidx num_vtt)
static types< 2 >::forest *(&) load_ext(const char *filename, MPI_Comm mpicomm, std::size_t data_size, int load_data, int autopartition, int broadcasthead, void *user_pointer, types< 2 >::connectivity **p4est)
static types< 2 >::connectivity *(&) connectivity_load(const char *filename, std::size_t *length)
static types< 2 >::connectivity *(&) connectivity_new_copy(types< 2 >::topidx num_vertices, types< 2 >::topidx num_trees, types< 2 >::topidx num_corners, const double *vertices, const types< 2 >::topidx *ttv, const types< 2 >::topidx *ttt, const int8_t *ttf, const types< 2 >::topidx *ttc, const types< 2 >::topidx *coff, const types< 2 >::topidx *ctt, const int8_t *ctc)
static void iterate(::internal::p4est::types< 2 >::forest *parallel_forest, ::internal::p4est::types< 2 >::ghost *parallel_ghost, void *user_data)
static types< 2 >::transfer_context *(&) transfer_fixed_begin(const types< 2 >::gloidx *dest_gfq, const types< 2 >::gloidx *src_gfq, MPI_Comm mpicomm, int tag, void *dest_data, const void *src_data, std::size_t data_size)
static types< 2 >::ghost *(&) ghost_new(types< 2 >::forest *p4est, types< 2 >::balance_type btype)
static types< 2 >::transfer_context *(&) transfer_custom_begin(const types< 2 >::gloidx *dest_gfq, const types< 2 >::gloidx *src_gfq, MPI_Comm mpicomm, int tag, void *dest_data, const int *dest_sizes, const void *src_data, const int *src_sizes)
static types< 3 >::connectivity *(&) connectivity_new_copy(types< 3 >::topidx num_vertices, types< 3 >::topidx num_trees, types< 3 >::topidx num_edges, types< 3 >::topidx num_corners, const double *vertices, const types< 3 >::topidx *ttv, const types< 3 >::topidx *ttt, const int8_t *ttf, const types< 3 >::topidx *tte, const types< 3 >::topidx *eoff, const types< 3 >::topidx *ett, const int8_t *ete, const types< 3 >::topidx *ttc, const types< 3 >::topidx *coff, const types< 3 >::topidx *ctt, const int8_t *ctc)
static types< 3 >::forest *(&) load_ext(const char *filename, MPI_Comm mpicomm, std::size_t data_size, int load_data, int autopartition, int broadcasthead, void *user_pointer, types< 3 >::connectivity **p4est)
static types< 3 >::transfer_context *(&) transfer_custom_begin(const types< 3 >::gloidx *dest_gfq, const types< 3 >::gloidx *src_gfq, MPI_Comm mpicomm, int tag, void *dest_data, const int *dest_sizes, const void *src_data, const int *src_sizes)
static types< 3 >::ghost *(&) ghost_new(types< 3 >::forest *p4est, types< 3 >::balance_type btype)
static types< 3 >::connectivity *(&) connectivity_new(types< 3 >::topidx num_vertices, types< 3 >::topidx num_trees, types< 3 >::topidx num_edges, types< 3 >::topidx num_ett, types< 3 >::topidx num_corners, types< 3 >::topidx num_ctt)
static types< 3 >::connectivity *(&) connectivity_load(const char *filename, std::size_t *length)
static types< 3 >::forest *(&) copy_forest(types< 3 >::forest *input, int copy_data)
static types< 3 >::transfer_context *(&) transfer_fixed_begin(const types< 3 >::gloidx *dest_gfq, const types< 3 >::gloidx *src_gfq, MPI_Comm mpicomm, int tag, void *dest_data, const void *src_data, std::size_t data_size)
static types< 3 >::forest *(&) new_forest(MPI_Comm mpicomm, types< 3 >::connectivity *connectivity, types< 3 >::locidx min_quadrants, int min_level, int fill_uniform, std::size_t data_size, p8est_init_t init_fn, void *user_pointer)