deal.II version GIT relicensing-1873-gbe302a5b2e 2024-09-18 11:00: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 {
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
670 void
671 load(const typename ::internal::p4est::types<dim>::forest *forest);
672
679 const std::vector<types::global_dof_index> &
680 get_p4est_tree_to_coarse_cell_permutation() const;
681
687 const std::vector<types::global_dof_index> &
688 get_coarse_cell_to_p4est_tree_permutation() const;
689
697 const typename ::internal::p4est::types<dim>::forest *
698 get_p4est() const;
699
719 virtual void
720 add_periodicity(
722 override;
723
724
725 private:
730
735
741 typename ::internal::p4est::types<dim>::connectivity *connectivity;
742
747 typename ::internal::p4est::types<dim>::forest *parallel_forest;
748
753 typename ::internal::p4est::types<dim>::ghost *parallel_ghost;
754
776 void
777 update_cell_relations();
778
792 std::vector<types::global_dof_index>
794 std::vector<types::global_dof_index>
796
801 typename ::internal::p4est::types<dim>::tree *
802 init_tree(const int dealii_coarse_cell_index) const;
803
808 void
809 setup_coarse_cell_to_p4est_tree_permutation();
810
817 void copy_new_triangulation_to_p4est(std::integral_constant<int, 2>);
818 void copy_new_triangulation_to_p4est(std::integral_constant<int, 3>);
819
824 void
825 copy_local_forest_to_triangulation();
826
840 std::vector<unsigned int>
841 get_cell_weights() const;
842
852 std::vector<bool>
853 mark_locally_active_vertices_on_level(const int level) const;
854
855 virtual unsigned int
856 coarse_cell_id_to_coarse_cell_index(
857 const types::coarse_cell_id coarse_cell_id) const override;
858
861 const unsigned int coarse_cell_index) const override;
862
863 template <int, int, class>
864 friend class ::FETools::internal::ExtrapolateImplementation;
865
866 template <int, int>
868 };
869
870
878 template <int spacedim>
880 class Triangulation<1, spacedim>
881 : public ::parallel::DistributedTriangulationBase<1, spacedim>
882 {
883 public:
888 {
889 default_setting = 0x0,
890 mesh_reconstruction_after_repartitioning = 0x1,
891 construct_multigrid_hierarchy = 0x2,
892 no_automatic_repartitioning = 0x4,
893 communicate_vertices_to_p4est = 0x8
894 };
895
901 const MPI_Comm mpi_communicator,
902 const typename ::Triangulation<1, spacedim>::MeshSmoothing
904 const Settings settings = default_setting);
905
909 virtual ~Triangulation() override;
910
917 const std::vector<types::global_dof_index> &
918 get_p4est_tree_to_coarse_cell_permutation() const;
919
924 virtual void
925 load(const std::string &filename) override;
926
931 virtual void
932 save(const std::string &filename) const override;
933
938 virtual bool
939 is_multilevel_hierarchy_constructed() const override;
940
945 bool
946 are_vertices_communicated_to_p4est() const;
947
952 void
953 update_cell_relations();
954
959 std::vector<types::global_dof_index>
961 std::vector<types::global_dof_index>
963
968 virtual std::map<unsigned int, std::set<::types::subdomain_id>>
969 compute_level_vertices_with_ghost_neighbors(
970 const unsigned int level) const;
971
976 virtual std::vector<bool>
977 mark_locally_active_vertices_on_level(const unsigned int level) const;
978
979 virtual unsigned int
980 coarse_cell_id_to_coarse_cell_index(
981 const types::coarse_cell_id coarse_cell_id) const override;
982
985 const unsigned int coarse_cell_index) const override;
986
987 template <int, int>
989 };
990 } // namespace distributed
991} // namespace parallel
992
993
994#else // DEAL_II_WITH_P4EST
995
996namespace parallel
997{
998 namespace distributed
999 {
1013 template <int dim, int spacedim = dim>
1015 class Triangulation
1016 : public ::parallel::DistributedTriangulationBase<dim, spacedim>
1017 {
1018 public:
1022 enum Settings
1023 {
1024 default_setting = 0x0,
1029 };
1030
1035 explicit Triangulation(
1036 const MPI_Comm /*mpi_communicator*/,
1037 const typename ::Triangulation<dim, spacedim>::MeshSmoothing
1038 /*smooth_grid*/
1040 const Settings /*settings*/ = default_setting) = delete;
1041
1046 virtual bool
1048 {
1049 return false;
1050 }
1051
1056 bool
1058 {
1059 return false;
1060 }
1061
1066 virtual void
1067 save(const std::string & /*filename*/) const override
1068 {}
1069
1074 virtual void
1075 load(const std::string & /*filename*/) override
1076 {}
1077
1082 void
1084 {}
1085 };
1086 } // namespace distributed
1087} // namespace parallel
1088
1089
1090#endif
1091
1092
1093
1094namespace parallel
1095{
1096 namespace distributed
1097 {
1115 template <int dim, int spacedim = dim>
1158 } // namespace distributed
1159} // namespace parallel
1160
1161
1163
1164#endif
Definition point.h:111
const ObserverPointer< ::parallel::distributed::Triangulation< dim, spacedim > > distributed_tria
Definition tria.h:1144
std::vector< types::global_dof_index > p4est_tree_to_coarse_cell_permutation
Definition tria.h:962
std::vector< types::global_dof_index > coarse_cell_to_p4est_tree_permutation
Definition tria.h:960
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:795
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:747
typename::internal::p4est::types< dim >::connectivity * connectivity
Definition tria.h:741
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:793
typename::internal::p4est::types< dim >::ghost * parallel_ghost
Definition tria.h:753
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:500
#define DEAL_II_CXX20_REQUIRES(condition)
Definition config.h:177
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:501
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