Reference documentation for deal.II version 9.5.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// Copyright (C) 2008 - 2023 by the deal.II authors
4//
5// This file is part of the deal.II library.
6//
7// The deal.II library is free software; you can use it, redistribute
8// it, and/or modify it under the terms of the GNU Lesser General
9// Public License as published by the Free Software Foundation; either
10// version 2.1 of the License, or (at your option) any later version.
11// The full text of the license can be found in the file LICENSE.md at
12// the top level directory of deal.II.
13//
14// ---------------------------------------------------------------------
15
16#ifndef dealii_distributed_tria_h
17#define dealii_distributed_tria_h
18
19
20#include <deal.II/base/config.h>
21
26
29
30#include <deal.II/grid/tria.h>
31
32#include <boost/range/iterator_range.hpp>
33
34#include <functional>
35#include <list>
36#include <set>
37#include <type_traits>
38#include <utility>
39#include <vector>
40
41#ifdef DEAL_II_WITH_P4EST
42# include <p4est.h>
43# include <p4est_connectivity.h>
44# include <p4est_ghost.h>
45# include <p8est.h>
46# include <p8est_connectivity.h>
47# include <p8est_ghost.h>
48#endif
49
51
52#ifdef DEAL_II_WITH_P4EST
53
54// Forward declarations
55# ifndef DOXYGEN
56
57namespace FETools
58{
59 namespace internal
60 {
61 template <int, int, class>
62 class ExtrapolateImplementation;
63 }
64} // namespace FETools
65
66// forward declaration of the data type for periodic face pairs
67namespace GridTools
68{
69 template <typename CellIterator>
70 struct PeriodicFacePair;
71}
72
73namespace parallel
74{
75 namespace distributed
76 {
77 template <int, int>
78 class TemporarilyMatchRefineFlags;
79 }
80} // namespace parallel
81# endif
82
83namespace parallel
84{
85 namespace distributed
86 {
246 template <int dim, int spacedim = dim>
249 : public ::parallel::DistributedTriangulationBase<dim, spacedim>
250 {
251 public:
270 typename ::Triangulation<dim, spacedim>::cell_iterator;
271
291 typename ::Triangulation<dim, spacedim>::active_cell_iterator;
292
294 typename ::Triangulation<dim, spacedim>::CellStatus;
295
301 {
305 default_setting = 0x0,
314 mesh_reconstruction_after_repartitioning = 0x1,
320 construct_multigrid_hierarchy = 0x2,
326 no_automatic_repartitioning = 0x4,
333 communicate_vertices_to_p4est = 0x8
334 };
335
336
337
369 explicit Triangulation(
370 const MPI_Comm mpi_communicator,
371 const typename ::Triangulation<dim, spacedim>::MeshSmoothing
373 const Settings settings = default_setting);
374
378 virtual ~Triangulation() override;
379
386 virtual void
387 clear() override;
388
392 bool
393 is_multilevel_hierarchy_constructed() const override;
394
398 bool
399 are_vertices_communicated_to_p4est() const;
400
414 void
415 execute_transfer(
416 const typename ::internal::p4est::types<dim>::forest
417 *parallel_forest,
418 const typename ::internal::p4est::types<dim>::gloidx
419 *previous_global_first_quadrant);
420
428 virtual void
429 copy_triangulation(
430 const ::Triangulation<dim, spacedim> &other_tria) override;
431
441 virtual void
442 create_triangulation(const std::vector<Point<spacedim>> &vertices,
443 const std::vector<CellData<dim>> & cells,
444 const SubCellData &subcelldata) override;
445
451 virtual void
452 create_triangulation(
454 &construction_data) override;
455
465 find_point_owner_rank(const Point<dim> &p);
466
483 std::vector<types::subdomain_id>
484 find_point_owner_rank(const std::vector<Point<dim>> &points);
485
515 virtual void
516 execute_coarsening_and_refinement() override;
517
524 virtual bool
525 prepare_coarsening_and_refinement() override;
526
567 void
568 repartition();
569
573 virtual std::size_t
574 memory_consumption() const override;
575
581 virtual std::size_t
582 memory_consumption_p4est() const;
583
594 void
595 write_mesh_vtk(const std::string &file_basename) const;
596
601 unsigned int
602 get_checksum() const;
603
612 virtual void
613 save(const std::string &filename) const override;
614
634 virtual void
635 load(const std::string &filename) override;
636
643 virtual void
644 load(const std::string &filename, const bool autopartition) override;
645
651 void
652 load(const typename ::internal::p4est::types<dim>::forest *forest);
653
660 const std::vector<types::global_dof_index> &
661 get_p4est_tree_to_coarse_cell_permutation() const;
662
668 const std::vector<types::global_dof_index> &
669 get_coarse_cell_to_p4est_tree_permutation() const;
670
678 const typename ::internal::p4est::types<dim>::forest *
679 get_p4est() const;
680
700 virtual void
701 add_periodicity(
703 override;
704
705
706 private:
711
716
722 typename ::internal::p4est::types<dim>::connectivity *connectivity;
723
728 typename ::internal::p4est::types<dim>::forest *parallel_forest;
729
734 typename ::internal::p4est::types<dim>::ghost *parallel_ghost;
735
757 virtual void
758 update_cell_relations() override;
759
773 std::vector<types::global_dof_index>
775 std::vector<types::global_dof_index>
777
782 typename ::internal::p4est::types<dim>::tree *
783 init_tree(const int dealii_coarse_cell_index) const;
784
789 void
790 setup_coarse_cell_to_p4est_tree_permutation();
791
798 void copy_new_triangulation_to_p4est(std::integral_constant<int, 2>);
799 void copy_new_triangulation_to_p4est(std::integral_constant<int, 3>);
800
805 void
806 copy_local_forest_to_triangulation();
807
821 std::vector<unsigned int>
822 get_cell_weights() const;
823
833 std::vector<bool>
834 mark_locally_active_vertices_on_level(const int level) const;
835
836 virtual unsigned int
837 coarse_cell_id_to_coarse_cell_index(
838 const types::coarse_cell_id coarse_cell_id) const override;
839
842 const unsigned int coarse_cell_index) const override;
843
844 template <int, int, class>
845 friend class ::FETools::internal::ExtrapolateImplementation;
846
847 template <int, int>
849 };
850
851
859 template <int spacedim>
861 class Triangulation<1, spacedim>
862 : public ::parallel::DistributedTriangulationBase<1, spacedim>
863 {
864 public:
869 {
870 default_setting = 0x0,
871 mesh_reconstruction_after_repartitioning = 0x1,
872 construct_multigrid_hierarchy = 0x2,
873 no_automatic_repartitioning = 0x4,
874 communicate_vertices_to_p4est = 0x8
875 };
876
882 const MPI_Comm mpi_communicator,
883 const typename ::Triangulation<1, spacedim>::MeshSmoothing
885 const Settings settings = default_setting);
886
890 virtual ~Triangulation() override;
891
898 const std::vector<types::global_dof_index> &
899 get_p4est_tree_to_coarse_cell_permutation() const;
900
905 virtual void
906 load(const std::string &filename) override;
907
913 virtual void
914 load(const std::string &filename, const bool autopartition) override;
915
920 virtual void
921 save(const std::string &filename) const override;
922
927 virtual bool
928 is_multilevel_hierarchy_constructed() const override;
929
934 bool
935 are_vertices_communicated_to_p4est() const;
936
941 virtual void
942 update_cell_relations() override;
943
948 std::vector<types::global_dof_index>
950 std::vector<types::global_dof_index>
952
957 virtual std::map<unsigned int, std::set<::types::subdomain_id>>
958 compute_level_vertices_with_ghost_neighbors(
959 const unsigned int level) const;
960
965 virtual std::vector<bool>
966 mark_locally_active_vertices_on_level(const unsigned int level) const;
967
968 virtual unsigned int
969 coarse_cell_id_to_coarse_cell_index(
970 const types::coarse_cell_id coarse_cell_id) const override;
971
974 const unsigned int coarse_cell_index) const override;
975
976 template <int, int>
978 };
979 } // namespace distributed
980} // namespace parallel
981
982
983#else // DEAL_II_WITH_P4EST
984
985namespace parallel
986{
987 namespace distributed
988 {
1002 template <int dim, int spacedim = dim>
1004 class Triangulation
1005 : public ::parallel::DistributedTriangulationBase<dim, spacedim>
1006 {
1007 public:
1011 enum Settings
1012 {
1013 default_setting = 0x0,
1018 };
1019
1024 explicit Triangulation(
1025 const MPI_Comm /*mpi_communicator*/,
1026 const typename ::Triangulation<dim, spacedim>::MeshSmoothing
1027 /*smooth_grid*/
1029 const Settings /*settings*/ = default_setting) = delete;
1030
1035 virtual bool
1037 {
1038 return false;
1039 }
1040
1045 bool
1047 {
1048 return false;
1049 }
1050
1055 virtual void
1056 save(const std::string & /*filename*/) const override
1057 {}
1058
1063 virtual void
1064 load(const std::string & /*filename*/) override
1065 {}
1066
1072 virtual void
1073 load(const std::string & /*filename*/,
1074 const bool /*autopartition*/) override
1075 {}
1076
1081 virtual void
1082 update_cell_relations() override
1083 {}
1084 };
1085 } // namespace distributed
1086} // namespace parallel
1087
1088
1089#endif
1090
1091
1092namespace parallel
1093{
1094 namespace distributed
1095 {
1113 template <int dim, int spacedim = dim>
1115 {
1116 public:
1127
1135
1136 private:
1140 const SmartPointer<
1143
1148 std::vector<bool> saved_refine_flags;
1149
1154 std::vector<bool> saved_coarsen_flags;
1155 };
1156 } // namespace distributed
1157} // namespace parallel
1158
1159
1161
1162#endif
Definition point.h:112
const SmartPointer< ::parallel::distributed::Triangulation< dim, spacedim > > distributed_tria
Definition tria.h:1142
std::vector< types::global_dof_index > p4est_tree_to_coarse_cell_permutation
Definition tria.h:951
std::vector< types::global_dof_index > coarse_cell_to_p4est_tree_permutation
Definition tria.h:949
typename ::Triangulation< dim, spacedim >::CellStatus CellStatus
Definition tria.h:294
bool are_vertices_communicated_to_p4est() const
Definition tria.cc:1863
std::vector< types::global_dof_index > p4est_tree_to_coarse_cell_permutation
Definition tria.h:776
virtual void update_cell_relations() override
Definition tria.cc:4007
void copy_new_triangulation_to_p4est(std::integral_constant< int, 3 >)
typename::internal::p4est::types< dim >::forest * parallel_forest
Definition tria.h:728
typename::internal::p4est::types< dim >::connectivity * connectivity
Definition tria.h:722
void copy_new_triangulation_to_p4est(std::integral_constant< int, 2 >)
virtual void save(const std::string &filename) const override
Definition tria.cc:2006
bool is_multilevel_hierarchy_constructed() const override
Definition tria.cc:1852
std::vector< types::global_dof_index > coarse_cell_to_p4est_tree_permutation
Definition tria.h:774
virtual void load(const std::string &filename) override
Definition tria.cc:2061
typename::internal::p4est::types< dim >::ghost * parallel_ghost
Definition tria.h:734
#define DEAL_II_DEPRECATED
Definition config.h:172
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:472
#define DEAL_II_CXX20_REQUIRES(condition)
Definition config.h:160
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:473
Point< 3 > vertices[4]
unsigned int level
Definition grid_out.cc:4618
typename ::Triangulation< dim, spacedim >::cell_iterator cell_iterator
Definition tria.h:270
typename ::Triangulation< dim, spacedim >::active_cell_iterator active_cell_iterator
Definition tria.h:291
const TriangulationDescription::Settings settings
std::vector< types::coarse_cell_id > coarse_cell_index_to_coarse_cell_id
const ::Triangulation< dim, spacedim > & tria