Reference documentation for deal.II version 9.6.0
\(\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 {
264 template <int dim, int spacedim = dim>
267 : public ::parallel::DistributedTriangulationBase<dim, spacedim>
268 {
269 public:
288 typename ::Triangulation<dim, spacedim>::cell_iterator;
289
309 typename ::Triangulation<dim, spacedim>::active_cell_iterator;
310
316 {
320 default_setting = 0x0,
329 mesh_reconstruction_after_repartitioning = 0x1,
335 construct_multigrid_hierarchy = 0x2,
341 no_automatic_repartitioning = 0x4,
348 communicate_vertices_to_p4est = 0x8
349 };
350
351
352
384 explicit Triangulation(
385 const MPI_Comm mpi_communicator,
386 const typename ::Triangulation<dim, spacedim>::MeshSmoothing
388 const Settings settings = default_setting);
389
393 virtual ~Triangulation() override;
394
401 virtual void
402 clear() override;
403
407 bool
408 is_multilevel_hierarchy_constructed() const override;
409
413 bool
414 are_vertices_communicated_to_p4est() const;
415
429 void
430 execute_transfer(
431 const typename ::internal::p4est::types<dim>::forest
432 *parallel_forest,
433 const typename ::internal::p4est::types<dim>::gloidx
434 *previous_global_first_quadrant);
435
443 virtual void
444 copy_triangulation(
445 const ::Triangulation<dim, spacedim> &other_tria) override;
446
456 virtual void
457 create_triangulation(const std::vector<Point<spacedim>> &vertices,
458 const std::vector<CellData<dim>> &cells,
459 const SubCellData &subcelldata) override;
460
466 virtual void
467 create_triangulation(
469 &construction_data) override;
470
480 find_point_owner_rank(const Point<dim> &p);
481
498 std::vector<types::subdomain_id>
499 find_point_owner_rank(const std::vector<Point<dim>> &points);
500
533 virtual void
534 execute_coarsening_and_refinement() override;
535
548 virtual bool
549 prepare_coarsening_and_refinement() override;
550
591 void
592 repartition();
593
597 virtual std::size_t
598 memory_consumption() const override;
599
605 virtual std::size_t
606 memory_consumption_p4est() const;
607
620 void
621 write_mesh_vtk(const std::string &file_basename) const;
622
627 unsigned int
628 get_checksum() const;
629
640 virtual void
641 save(const std::string &file_basename) const override;
642
662 virtual void
663 load(const std::string &file_basename) override;
664
671 virtual void
672 load(const std::string &filename, const bool autopartition) override;
673
679 void
680 load(const typename ::internal::p4est::types<dim>::forest *forest);
681
688 const std::vector<types::global_dof_index> &
689 get_p4est_tree_to_coarse_cell_permutation() const;
690
696 const std::vector<types::global_dof_index> &
697 get_coarse_cell_to_p4est_tree_permutation() const;
698
706 const typename ::internal::p4est::types<dim>::forest *
707 get_p4est() const;
708
728 virtual void
729 add_periodicity(
731 override;
732
733
734 private:
739
744
750 typename ::internal::p4est::types<dim>::connectivity *connectivity;
751
756 typename ::internal::p4est::types<dim>::forest *parallel_forest;
757
762 typename ::internal::p4est::types<dim>::ghost *parallel_ghost;
763
785 void
786 update_cell_relations();
787
801 std::vector<types::global_dof_index>
803 std::vector<types::global_dof_index>
805
810 typename ::internal::p4est::types<dim>::tree *
811 init_tree(const int dealii_coarse_cell_index) const;
812
817 void
818 setup_coarse_cell_to_p4est_tree_permutation();
819
826 void copy_new_triangulation_to_p4est(std::integral_constant<int, 2>);
827 void copy_new_triangulation_to_p4est(std::integral_constant<int, 3>);
828
833 void
834 copy_local_forest_to_triangulation();
835
849 std::vector<unsigned int>
850 get_cell_weights() const;
851
861 std::vector<bool>
862 mark_locally_active_vertices_on_level(const int level) const;
863
864 virtual unsigned int
865 coarse_cell_id_to_coarse_cell_index(
866 const types::coarse_cell_id coarse_cell_id) const override;
867
870 const unsigned int coarse_cell_index) const override;
871
872 template <int, int, class>
873 friend class ::FETools::internal::ExtrapolateImplementation;
874
875 template <int, int>
877 };
878
879
887 template <int spacedim>
889 class Triangulation<1, spacedim>
890 : public ::parallel::DistributedTriangulationBase<1, spacedim>
891 {
892 public:
897 {
898 default_setting = 0x0,
899 mesh_reconstruction_after_repartitioning = 0x1,
900 construct_multigrid_hierarchy = 0x2,
901 no_automatic_repartitioning = 0x4,
902 communicate_vertices_to_p4est = 0x8
903 };
904
910 const MPI_Comm mpi_communicator,
911 const typename ::Triangulation<1, spacedim>::MeshSmoothing
913 const Settings settings = default_setting);
914
918 virtual ~Triangulation() override;
919
926 const std::vector<types::global_dof_index> &
927 get_p4est_tree_to_coarse_cell_permutation() const;
928
933 virtual void
934 load(const std::string &filename) override;
935
941 virtual void
942 load(const std::string &filename, const bool autopartition) override;
943
948 virtual void
949 save(const std::string &filename) const override;
950
955 virtual bool
956 is_multilevel_hierarchy_constructed() const override;
957
962 bool
963 are_vertices_communicated_to_p4est() const;
964
969 void
970 update_cell_relations();
971
976 std::vector<types::global_dof_index>
978 std::vector<types::global_dof_index>
980
985 virtual std::map<unsigned int, std::set<::types::subdomain_id>>
986 compute_level_vertices_with_ghost_neighbors(
987 const unsigned int level) const;
988
993 virtual std::vector<bool>
994 mark_locally_active_vertices_on_level(const unsigned int level) const;
995
996 virtual unsigned int
997 coarse_cell_id_to_coarse_cell_index(
998 const types::coarse_cell_id coarse_cell_id) const override;
999
1000 virtual types::coarse_cell_id
1002 const unsigned int coarse_cell_index) const override;
1003
1004 template <int, int>
1006 };
1007 } // namespace distributed
1008} // namespace parallel
1009
1010
1011#else // DEAL_II_WITH_P4EST
1012
1013namespace parallel
1014{
1015 namespace distributed
1016 {
1030 template <int dim, int spacedim = dim>
1032 class Triangulation
1033 : public ::parallel::DistributedTriangulationBase<dim, spacedim>
1034 {
1035 public:
1039 enum Settings
1040 {
1041 default_setting = 0x0,
1046 };
1047
1052 explicit Triangulation(
1053 const MPI_Comm /*mpi_communicator*/,
1054 const typename ::Triangulation<dim, spacedim>::MeshSmoothing
1055 /*smooth_grid*/
1057 const Settings /*settings*/ = default_setting) = delete;
1058
1063 virtual bool
1065 {
1066 return false;
1067 }
1068
1073 bool
1075 {
1076 return false;
1077 }
1078
1083 virtual void
1084 save(const std::string & /*filename*/) const override
1085 {}
1086
1091 virtual void
1092 load(const std::string & /*filename*/) override
1093 {}
1094
1100 virtual void
1101 load(const std::string & /*filename*/,
1102 const bool /*autopartition*/) override
1103 {}
1104
1109 void
1111 {}
1112 };
1113 } // namespace distributed
1114} // namespace parallel
1115
1116
1117#endif
1118
1119
1120
1121namespace parallel
1122{
1123 namespace distributed
1124 {
1142 template <int dim, int spacedim = dim>
1185 } // namespace distributed
1186} // namespace parallel
1187
1188
1190
1191#endif
Definition point.h:111
TemporarilyMatchRefineFlags(::Triangulation< dim, spacedim > &tria)
Definition tria.cc:4306
const SmartPointer< ::parallel::distributed::Triangulation< dim, spacedim > > distributed_tria
Definition tria.h:1171
std::vector< types::global_dof_index > p4est_tree_to_coarse_cell_permutation
Definition tria.h:979
std::vector< types::global_dof_index > coarse_cell_to_p4est_tree_permutation
Definition tria.h:977
bool are_vertices_communicated_to_p4est() const
Definition tria.cc:1911
virtual void save(const std::string &file_basename) const override
Definition tria.cc:2054
std::vector< types::global_dof_index > p4est_tree_to_coarse_cell_permutation
Definition tria.h:804
void copy_new_triangulation_to_p4est(std::integral_constant< int, 3 >)
virtual void load(const std::string &file_basename) override
Definition tria.cc:2109
typename::internal::p4est::types< dim >::forest * parallel_forest
Definition tria.h:756
typename::internal::p4est::types< dim >::connectivity * connectivity
Definition tria.h:750
void copy_new_triangulation_to_p4est(std::integral_constant< int, 2 >)
Triangulation(const MPI_Comm mpi_communicator, const typename ::Triangulation< dim, spacedim >::MeshSmoothing smooth_grid=(::Triangulation< dim, spacedim >::none), const Settings settings=default_setting)
Definition tria.cc:1748
bool is_multilevel_hierarchy_constructed() const override
Definition tria.cc:1900
std::vector< types::global_dof_index > coarse_cell_to_p4est_tree_permutation
Definition tria.h:802
typename::internal::p4est::types< dim >::ghost * parallel_ghost
Definition tria.h:762
#define DEAL_II_DEPRECATED
Definition config.h:207
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:503
#define DEAL_II_CXX20_REQUIRES(condition)
Definition config.h:177
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:504
Point< 3 > vertices[4]
unsigned int level
Definition grid_out.cc:4626
typename ::Triangulation< dim, spacedim >::cell_iterator cell_iterator
Definition tria.h:287
typename ::Triangulation< dim, spacedim >::active_cell_iterator active_cell_iterator
Definition tria.h:308
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