deal.II version GIT relicensing-2165-gc91f007519 2024-11-20 01:40:00+00:00
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
tria.h
Go to the documentation of this file.
1// ------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: LGPL-2.1-or-later
4// Copyright (C) 2010 - 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_distributed_tria_h
16#define dealii_distributed_tria_h
17
18
19#include <deal.II/base/config.h>
20
25
28
29#include <deal.II/grid/tria.h>
30
31#include <boost/range/iterator_range.hpp>
32
33#include <functional>
34#include <list>
35#include <set>
36#include <type_traits>
37#include <utility>
38#include <vector>
39
40#ifdef DEAL_II_WITH_P4EST
41# include <p4est.h>
42# include <p4est_connectivity.h>
43# include <p4est_ghost.h>
44# include <p8est.h>
45# include <p8est_connectivity.h>
46# include <p8est_ghost.h>
47#endif
48
50
51// Forward declarations
52#ifndef DOXYGEN
53
54namespace FETools
55{
56 namespace internal
57 {
58 template <int, int, class>
59 class ExtrapolateImplementation;
60 }
61} // namespace FETools
62
63// forward declaration of the data type for periodic face pairs
64namespace GridTools
65{
66 template <typename CellIterator>
67 struct PeriodicFacePair;
68}
69
70namespace parallel
71{
72 namespace distributed
73 {
74 template <int, int>
75 class TemporarilyMatchRefineFlags;
76 }
77} // namespace parallel
78
79namespace internal
80{
81 namespace parallel
82 {
83 namespace distributed
84 {
85 namespace TriangulationImplementation
86 {
87 template <int dim, int spacedim>
88 void
91 }
92 } // namespace distributed
93 } // namespace parallel
94} // namespace internal
95#endif
96
97
98
99#ifdef DEAL_II_WITH_P4EST
100
101namespace parallel
102{
103 namespace distributed
104 {
300 template <int dim, int spacedim = dim>
303 : public ::parallel::DistributedTriangulationBase<dim, spacedim>
304 {
305 public:
324 typename ::Triangulation<dim, spacedim>::cell_iterator;
325
345 typename ::Triangulation<dim, spacedim>::active_cell_iterator;
346
352 {
356 default_setting = 0x0,
365 mesh_reconstruction_after_repartitioning = 0x1,
371 construct_multigrid_hierarchy = 0x2,
377 no_automatic_repartitioning = 0x4,
384 communicate_vertices_to_p4est = 0x8
385 };
386
387
388
420 explicit Triangulation(
421 const MPI_Comm mpi_communicator,
422 const typename ::Triangulation<dim, spacedim>::MeshSmoothing
424 const Settings settings = default_setting);
425
429 virtual ~Triangulation() override;
430
437 virtual void
438 clear() override;
439
443 bool
444 is_multilevel_hierarchy_constructed() const override;
445
449 bool
450 are_vertices_communicated_to_p4est() const;
451
465 void
466 execute_transfer(
467 const typename ::internal::p4est::types<dim>::forest
468 *parallel_forest,
469 const typename ::internal::p4est::types<dim>::gloidx
470 *previous_global_first_quadrant);
471
479 virtual void
480 copy_triangulation(
481 const ::Triangulation<dim, spacedim> &other_tria) override;
482
492 virtual void
493 create_triangulation(const std::vector<Point<spacedim>> &vertices,
494 const std::vector<CellData<dim>> &cells,
495 const SubCellData &subcelldata) override;
496
502 virtual void
503 create_triangulation(
505 &construction_data) override;
506
516 find_point_owner_rank(const Point<dim> &p);
517
534 std::vector<types::subdomain_id>
535 find_point_owner_rank(const std::vector<Point<dim>> &points);
536
569 virtual void
570 execute_coarsening_and_refinement() override;
571
584 virtual bool
585 prepare_coarsening_and_refinement() override;
586
627 void
628 repartition();
629
633 virtual std::size_t
634 memory_consumption() const override;
635
641 virtual std::size_t
642 memory_consumption_p4est() const;
643
656 void
657 write_mesh_vtk(const std::string &file_basename) const;
658
663 unsigned int
664 get_checksum() const;
665
676 virtual void
677 save(const std::string &file_basename) const override;
678
698 virtual void
699 load(const std::string &file_basename) override;
700
706 void
707 load(const typename ::internal::p4est::types<dim>::forest *forest);
708
715 const std::vector<types::global_dof_index> &
716 get_p4est_tree_to_coarse_cell_permutation() const;
717
723 const std::vector<types::global_dof_index> &
724 get_coarse_cell_to_p4est_tree_permutation() const;
725
733 const typename ::internal::p4est::types<dim>::forest *
734 get_p4est() const;
735
755 virtual void
756 add_periodicity(
758 override;
759
760
761 private:
766
771
777 typename ::internal::p4est::types<dim>::connectivity *connectivity;
778
783 typename ::internal::p4est::types<dim>::forest *parallel_forest;
784
789 typename ::internal::p4est::types<dim>::ghost *parallel_ghost;
790
812 void
813 update_cell_relations();
814
828 std::vector<types::global_dof_index>
830 std::vector<types::global_dof_index>
832
837 typename ::internal::p4est::types<dim>::tree *
838 init_tree(const int dealii_coarse_cell_index) const;
839
844 void
845 setup_coarse_cell_to_p4est_tree_permutation();
846
853 void copy_new_triangulation_to_p4est(std::integral_constant<int, 2>);
854 void copy_new_triangulation_to_p4est(std::integral_constant<int, 3>);
855
860 void
861 copy_local_forest_to_triangulation();
862
876 std::vector<unsigned int>
877 get_cell_weights() const;
878
888 std::vector<bool>
889 mark_locally_active_vertices_on_level(const int level) const;
890
891 virtual unsigned int
892 coarse_cell_id_to_coarse_cell_index(
893 const types::coarse_cell_id coarse_cell_id) const override;
894
897 const unsigned int coarse_cell_index) const override;
898
899 template <int, int, class>
900 friend class ::FETools::internal::ExtrapolateImplementation;
901
902 template <int, int>
904 };
905
906
914 template <int spacedim>
916 class Triangulation<1, spacedim>
917 : public ::parallel::DistributedTriangulationBase<1, spacedim>
918 {
919 public:
924 {
925 default_setting = 0x0,
926 mesh_reconstruction_after_repartitioning = 0x1,
927 construct_multigrid_hierarchy = 0x2,
928 no_automatic_repartitioning = 0x4,
929 communicate_vertices_to_p4est = 0x8
930 };
931
937 const MPI_Comm mpi_communicator,
938 const typename ::Triangulation<1, spacedim>::MeshSmoothing
940 const Settings settings = default_setting);
941
945 virtual ~Triangulation() override;
946
953 const std::vector<types::global_dof_index> &
954 get_p4est_tree_to_coarse_cell_permutation() const;
955
960 virtual void
961 load(const std::string &filename) override;
962
967 virtual void
968 save(const std::string &filename) const override;
969
974 virtual bool
975 is_multilevel_hierarchy_constructed() const override;
976
981 bool
982 are_vertices_communicated_to_p4est() const;
983
988 void
989 update_cell_relations();
990
995 std::vector<types::global_dof_index>
997 std::vector<types::global_dof_index>
999
1004 virtual std::map<unsigned int, std::set<::types::subdomain_id>>
1005 compute_level_vertices_with_ghost_neighbors(
1006 const unsigned int level) const;
1007
1012 virtual std::vector<bool>
1013 mark_locally_active_vertices_on_level(const unsigned int level) const;
1014
1015 virtual unsigned int
1016 coarse_cell_id_to_coarse_cell_index(
1017 const types::coarse_cell_id coarse_cell_id) const override;
1018
1019 virtual types::coarse_cell_id
1021 const unsigned int coarse_cell_index) const override;
1022
1023 template <int, int>
1025 };
1026 } // namespace distributed
1027} // namespace parallel
1028
1029
1030#else // DEAL_II_WITH_P4EST
1031
1032namespace parallel
1033{
1034 namespace distributed
1035 {
1049 template <int dim, int spacedim = dim>
1051 class Triangulation
1052 : public ::parallel::DistributedTriangulationBase<dim, spacedim>
1053 {
1054 public:
1058 enum Settings
1059 {
1060 default_setting = 0x0,
1065 };
1066
1071 explicit Triangulation(
1072 const MPI_Comm /*mpi_communicator*/,
1073 const typename ::Triangulation<dim, spacedim>::MeshSmoothing
1074 /*smooth_grid*/
1076 const Settings /*settings*/ = default_setting) = delete;
1077
1082 virtual bool
1084 {
1085 return false;
1086 }
1087
1092 bool
1094 {
1095 return false;
1096 }
1097
1102 virtual void
1103 save(const std::string & /*filename*/) const override
1104 {}
1105
1110 virtual void
1111 load(const std::string & /*filename*/) override
1112 {}
1113
1118 void
1120 {}
1121 };
1122 } // namespace distributed
1123} // namespace parallel
1124
1125
1126#endif
1127
1128
1129
1130namespace parallel
1131{
1132 namespace distributed
1133 {
1151 template <int dim, int spacedim = dim>
1194 } // namespace distributed
1195} // namespace parallel
1196
1197
1199
1200#endif
Definition point.h:111
const ObserverPointer< ::parallel::distributed::Triangulation< dim, spacedim > > distributed_tria
Definition tria.h:1180
std::vector< types::global_dof_index > p4est_tree_to_coarse_cell_permutation
Definition tria.h:998
std::vector< types::global_dof_index > coarse_cell_to_p4est_tree_permutation
Definition tria.h:996
bool are_vertices_communicated_to_p4est() const
Definition tria.cc:1908
virtual void save(const std::string &file_basename) const override
Definition tria.cc:2038
std::vector< types::global_dof_index > p4est_tree_to_coarse_cell_permutation
Definition tria.h:831
void copy_new_triangulation_to_p4est(std::integral_constant< int, 3 >)
virtual void load(const std::string &file_basename) override
Definition tria.cc:2092
typename::internal::p4est::types< dim >::forest * parallel_forest
Definition tria.h:783
typename::internal::p4est::types< dim >::connectivity * connectivity
Definition tria.h:777
void copy_new_triangulation_to_p4est(std::integral_constant< int, 2 >)
bool is_multilevel_hierarchy_constructed() const override
Definition tria.cc:1897
std::vector< types::global_dof_index > coarse_cell_to_p4est_tree_permutation
Definition tria.h:829
typename::internal::p4est::types< dim >::ghost * parallel_ghost
Definition tria.h:789
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:498
#define DEAL_II_CXX20_REQUIRES(condition)
Definition config.h:175
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:499
unsigned int level
Definition grid_out.cc:4626
typename ::Triangulation< dim, spacedim >::cell_iterator cell_iterator
Definition tria.h:324
typename ::Triangulation< dim, spacedim >::active_cell_iterator active_cell_iterator
Definition tria.h:345
void exchange_refinement_flags(::parallel::distributed::Triangulation< dim, spacedim > &tria)
Definition tria.cc:56
std::vector< types::coarse_cell_id > coarse_cell_index_to_coarse_cell_id