Reference documentation for deal.II version GIT relicensing-761-gcc3619e707 2024-05-25 17:40: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
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
638 virtual void
639 save(const std::string &filename) const override;
640
660 virtual void
661 load(const std::string &filename) override;
662
669 virtual void
670 load(const std::string &filename, const bool autopartition) override;
671
677 void
678 load(const typename ::internal::p4est::types<dim>::forest *forest);
679
686 const std::vector<types::global_dof_index> &
687 get_p4est_tree_to_coarse_cell_permutation() const;
688
694 const std::vector<types::global_dof_index> &
695 get_coarse_cell_to_p4est_tree_permutation() const;
696
704 const typename ::internal::p4est::types<dim>::forest *
705 get_p4est() const;
706
726 virtual void
727 add_periodicity(
729 override;
730
731
732 private:
737
742
748 typename ::internal::p4est::types<dim>::connectivity *connectivity;
749
754 typename ::internal::p4est::types<dim>::forest *parallel_forest;
755
760 typename ::internal::p4est::types<dim>::ghost *parallel_ghost;
761
783 virtual void
784 update_cell_relations() override;
785
799 std::vector<types::global_dof_index>
801 std::vector<types::global_dof_index>
803
808 typename ::internal::p4est::types<dim>::tree *
809 init_tree(const int dealii_coarse_cell_index) const;
810
815 void
816 setup_coarse_cell_to_p4est_tree_permutation();
817
824 void copy_new_triangulation_to_p4est(std::integral_constant<int, 2>);
825 void copy_new_triangulation_to_p4est(std::integral_constant<int, 3>);
826
831 void
832 copy_local_forest_to_triangulation();
833
847 std::vector<unsigned int>
848 get_cell_weights() const;
849
859 std::vector<bool>
860 mark_locally_active_vertices_on_level(const int level) const;
861
862 virtual unsigned int
863 coarse_cell_id_to_coarse_cell_index(
864 const types::coarse_cell_id coarse_cell_id) const override;
865
868 const unsigned int coarse_cell_index) const override;
869
870 template <int, int, class>
871 friend class ::FETools::internal::ExtrapolateImplementation;
872
873 template <int, int>
875 };
876
877
885 template <int spacedim>
887 class Triangulation<1, spacedim>
888 : public ::parallel::DistributedTriangulationBase<1, spacedim>
889 {
890 public:
895 {
896 default_setting = 0x0,
897 mesh_reconstruction_after_repartitioning = 0x1,
898 construct_multigrid_hierarchy = 0x2,
899 no_automatic_repartitioning = 0x4,
900 communicate_vertices_to_p4est = 0x8
901 };
902
908 const MPI_Comm mpi_communicator,
909 const typename ::Triangulation<1, spacedim>::MeshSmoothing
911 const Settings settings = default_setting);
912
916 virtual ~Triangulation() override;
917
924 const std::vector<types::global_dof_index> &
925 get_p4est_tree_to_coarse_cell_permutation() const;
926
931 virtual void
932 load(const std::string &filename) override;
933
939 virtual void
940 load(const std::string &filename, const bool autopartition) override;
941
946 virtual void
947 save(const std::string &filename) const override;
948
953 virtual bool
954 is_multilevel_hierarchy_constructed() const override;
955
960 bool
961 are_vertices_communicated_to_p4est() const;
962
967 virtual void
968 update_cell_relations() override;
969
974 std::vector<types::global_dof_index>
976 std::vector<types::global_dof_index>
978
983 virtual std::map<unsigned int, std::set<::types::subdomain_id>>
984 compute_level_vertices_with_ghost_neighbors(
985 const unsigned int level) const;
986
991 virtual std::vector<bool>
992 mark_locally_active_vertices_on_level(const unsigned int level) const;
993
994 virtual unsigned int
995 coarse_cell_id_to_coarse_cell_index(
996 const types::coarse_cell_id coarse_cell_id) const override;
997
1000 const unsigned int coarse_cell_index) const override;
1001
1002 template <int, int>
1004 };
1005 } // namespace distributed
1006} // namespace parallel
1007
1008
1009#else // DEAL_II_WITH_P4EST
1010
1011namespace parallel
1012{
1013 namespace distributed
1014 {
1028 template <int dim, int spacedim = dim>
1030 class Triangulation
1031 : public ::parallel::DistributedTriangulationBase<dim, spacedim>
1032 {
1033 public:
1037 enum Settings
1038 {
1039 default_setting = 0x0,
1044 };
1045
1050 explicit Triangulation(
1051 const MPI_Comm /*mpi_communicator*/,
1052 const typename ::Triangulation<dim, spacedim>::MeshSmoothing
1053 /*smooth_grid*/
1055 const Settings /*settings*/ = default_setting) = delete;
1056
1061 virtual bool
1063 {
1064 return false;
1065 }
1066
1071 bool
1073 {
1074 return false;
1075 }
1076
1081 virtual void
1082 save(const std::string & /*filename*/) const override
1083 {}
1084
1089 virtual void
1090 load(const std::string & /*filename*/) override
1091 {}
1092
1098 virtual void
1099 load(const std::string & /*filename*/,
1100 const bool /*autopartition*/) override
1101 {}
1102
1107 virtual void
1108 update_cell_relations() override
1109 {}
1110 };
1111 } // namespace distributed
1112} // namespace parallel
1113
1114
1115#endif
1116
1117
1118
1119namespace parallel
1120{
1121 namespace distributed
1122 {
1140 template <int dim, int spacedim = dim>
1183 } // namespace distributed
1184} // namespace parallel
1185
1186
1188
1189#endif
Definition point.h:111
const SmartPointer< ::parallel::distributed::Triangulation< dim, spacedim > > distributed_tria
Definition tria.h:1169
std::vector< types::global_dof_index > p4est_tree_to_coarse_cell_permutation
Definition tria.h:977
std::vector< types::global_dof_index > coarse_cell_to_p4est_tree_permutation
Definition tria.h:975
bool are_vertices_communicated_to_p4est() const
Definition tria.cc:1911
std::vector< types::global_dof_index > p4est_tree_to_coarse_cell_permutation
Definition tria.h:802
virtual void update_cell_relations() override
Definition tria.cc:4076
void copy_new_triangulation_to_p4est(std::integral_constant< int, 3 >)
typename::internal::p4est::types< dim >::forest * parallel_forest
Definition tria.h:754
typename::internal::p4est::types< dim >::connectivity * connectivity
Definition tria.h:748
void copy_new_triangulation_to_p4est(std::integral_constant< int, 2 >)
virtual void save(const std::string &filename) const override
Definition tria.cc:2054
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:800
virtual void load(const std::string &filename) override
Definition tria.cc:2108
typename::internal::p4est::types< dim >::ghost * parallel_ghost
Definition tria.h:760
#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
Point< 3 > vertices[4]
unsigned int level
Definition grid_out.cc:4626
typename ::Triangulation< dim, spacedim >::cell_iterator cell_iterator
Definition tria.h:288
typename ::Triangulation< dim, spacedim >::active_cell_iterator active_cell_iterator
Definition tria.h:309
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