Reference documentation for deal.II version GIT relicensing-14-gd371fb467a 2024-02-26 20:50:01+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#ifdef DEAL_II_WITH_P4EST
52
53// Forward declarations
54# ifndef DOXYGEN
55
56namespace FETools
57{
58 namespace internal
59 {
60 template <int, int, class>
61 class ExtrapolateImplementation;
62 }
63} // namespace FETools
64
65// forward declaration of the data type for periodic face pairs
66namespace GridTools
67{
68 template <typename CellIterator>
69 struct PeriodicFacePair;
70}
71
72namespace parallel
73{
74 namespace distributed
75 {
76 template <int, int>
77 class TemporarilyMatchRefineFlags;
78 }
79} // namespace parallel
80# endif
81
82namespace parallel
83{
84 namespace distributed
85 {
245 template <int dim, int spacedim = dim>
248 : public ::parallel::DistributedTriangulationBase<dim, spacedim>
249 {
250 public:
269 typename ::Triangulation<dim, spacedim>::cell_iterator;
270
290 typename ::Triangulation<dim, spacedim>::active_cell_iterator;
291
297 {
301 default_setting = 0x0,
310 mesh_reconstruction_after_repartitioning = 0x1,
316 construct_multigrid_hierarchy = 0x2,
322 no_automatic_repartitioning = 0x4,
329 communicate_vertices_to_p4est = 0x8
330 };
331
332
333
365 explicit Triangulation(
366 const MPI_Comm mpi_communicator,
367 const typename ::Triangulation<dim, spacedim>::MeshSmoothing
369 const Settings settings = default_setting);
370
374 virtual ~Triangulation() override;
375
382 virtual void
383 clear() override;
384
388 bool
389 is_multilevel_hierarchy_constructed() const override;
390
394 bool
395 are_vertices_communicated_to_p4est() const;
396
410 void
411 execute_transfer(
412 const typename ::internal::p4est::types<dim>::forest
413 *parallel_forest,
414 const typename ::internal::p4est::types<dim>::gloidx
415 *previous_global_first_quadrant);
416
424 virtual void
425 copy_triangulation(
426 const ::Triangulation<dim, spacedim> &other_tria) override;
427
437 virtual void
438 create_triangulation(const std::vector<Point<spacedim>> &vertices,
439 const std::vector<CellData<dim>> &cells,
440 const SubCellData &subcelldata) override;
441
447 virtual void
448 create_triangulation(
450 &construction_data) override;
451
461 find_point_owner_rank(const Point<dim> &p);
462
479 std::vector<types::subdomain_id>
480 find_point_owner_rank(const std::vector<Point<dim>> &points);
481
514 virtual void
515 execute_coarsening_and_refinement() override;
516
529 virtual bool
530 prepare_coarsening_and_refinement() override;
531
572 void
573 repartition();
574
578 virtual std::size_t
579 memory_consumption() const override;
580
586 virtual std::size_t
587 memory_consumption_p4est() const;
588
601 void
602 write_mesh_vtk(const std::string &file_basename) const;
603
608 unsigned int
609 get_checksum() const;
610
619 virtual void
620 save(const std::string &filename) const override;
621
641 virtual void
642 load(const std::string &filename) override;
643
650 virtual void
651 load(const std::string &filename, const bool autopartition) override;
652
658 void
659 load(const typename ::internal::p4est::types<dim>::forest *forest);
660
667 const std::vector<types::global_dof_index> &
668 get_p4est_tree_to_coarse_cell_permutation() const;
669
675 const std::vector<types::global_dof_index> &
676 get_coarse_cell_to_p4est_tree_permutation() const;
677
685 const typename ::internal::p4est::types<dim>::forest *
686 get_p4est() const;
687
707 virtual void
708 add_periodicity(
710 override;
711
712
713 private:
718
723
729 typename ::internal::p4est::types<dim>::connectivity *connectivity;
730
735 typename ::internal::p4est::types<dim>::forest *parallel_forest;
736
741 typename ::internal::p4est::types<dim>::ghost *parallel_ghost;
742
764 virtual void
765 update_cell_relations() override;
766
780 std::vector<types::global_dof_index>
782 std::vector<types::global_dof_index>
784
789 typename ::internal::p4est::types<dim>::tree *
790 init_tree(const int dealii_coarse_cell_index) const;
791
796 void
797 setup_coarse_cell_to_p4est_tree_permutation();
798
805 void copy_new_triangulation_to_p4est(std::integral_constant<int, 2>);
806 void copy_new_triangulation_to_p4est(std::integral_constant<int, 3>);
807
812 void
813 copy_local_forest_to_triangulation();
814
828 std::vector<unsigned int>
829 get_cell_weights() const;
830
840 std::vector<bool>
841 mark_locally_active_vertices_on_level(const int level) const;
842
843 virtual unsigned int
844 coarse_cell_id_to_coarse_cell_index(
845 const types::coarse_cell_id coarse_cell_id) const override;
846
849 const unsigned int coarse_cell_index) const override;
850
851 template <int, int, class>
852 friend class ::FETools::internal::ExtrapolateImplementation;
853
854 template <int, int>
856 };
857
858
866 template <int spacedim>
868 class Triangulation<1, spacedim>
869 : public ::parallel::DistributedTriangulationBase<1, spacedim>
870 {
871 public:
876 {
877 default_setting = 0x0,
878 mesh_reconstruction_after_repartitioning = 0x1,
879 construct_multigrid_hierarchy = 0x2,
880 no_automatic_repartitioning = 0x4,
881 communicate_vertices_to_p4est = 0x8
882 };
883
889 const MPI_Comm mpi_communicator,
890 const typename ::Triangulation<1, spacedim>::MeshSmoothing
892 const Settings settings = default_setting);
893
897 virtual ~Triangulation() override;
898
905 const std::vector<types::global_dof_index> &
906 get_p4est_tree_to_coarse_cell_permutation() const;
907
912 virtual void
913 load(const std::string &filename) override;
914
920 virtual void
921 load(const std::string &filename, const bool autopartition) override;
922
927 virtual void
928 save(const std::string &filename) const override;
929
934 virtual bool
935 is_multilevel_hierarchy_constructed() const override;
936
941 bool
942 are_vertices_communicated_to_p4est() const;
943
948 virtual void
949 update_cell_relations() override;
950
955 std::vector<types::global_dof_index>
957 std::vector<types::global_dof_index>
959
964 virtual std::map<unsigned int, std::set<::types::subdomain_id>>
965 compute_level_vertices_with_ghost_neighbors(
966 const unsigned int level) const;
967
972 virtual std::vector<bool>
973 mark_locally_active_vertices_on_level(const unsigned int level) const;
974
975 virtual unsigned int
976 coarse_cell_id_to_coarse_cell_index(
977 const types::coarse_cell_id coarse_cell_id) const override;
978
981 const unsigned int coarse_cell_index) const override;
982
983 template <int, int>
985 };
986 } // namespace distributed
987} // namespace parallel
988
989
990#else // DEAL_II_WITH_P4EST
991
992namespace parallel
993{
994 namespace distributed
995 {
1009 template <int dim, int spacedim = dim>
1011 class Triangulation
1012 : public ::parallel::DistributedTriangulationBase<dim, spacedim>
1013 {
1014 public:
1018 enum Settings
1019 {
1020 default_setting = 0x0,
1025 };
1026
1031 explicit Triangulation(
1032 const MPI_Comm /*mpi_communicator*/,
1033 const typename ::Triangulation<dim, spacedim>::MeshSmoothing
1034 /*smooth_grid*/
1036 const Settings /*settings*/ = default_setting) = delete;
1037
1042 virtual bool
1044 {
1045 return false;
1046 }
1047
1052 bool
1054 {
1055 return false;
1056 }
1057
1062 virtual void
1063 save(const std::string & /*filename*/) const override
1064 {}
1065
1070 virtual void
1071 load(const std::string & /*filename*/) override
1072 {}
1073
1079 virtual void
1080 load(const std::string & /*filename*/,
1081 const bool /*autopartition*/) override
1082 {}
1083
1088 virtual void
1089 update_cell_relations() override
1090 {}
1091 };
1092 } // namespace distributed
1093} // namespace parallel
1094
1095
1096#endif
1097
1098
1099namespace parallel
1100{
1101 namespace distributed
1102 {
1120 template <int dim, int spacedim = dim>
1163 } // namespace distributed
1164} // namespace parallel
1165
1166
1168
1169#endif
Definition point.h:111
const SmartPointer< ::parallel::distributed::Triangulation< dim, spacedim > > distributed_tria
Definition tria.h:1149
std::vector< types::global_dof_index > p4est_tree_to_coarse_cell_permutation
Definition tria.h:958
std::vector< types::global_dof_index > coarse_cell_to_p4est_tree_permutation
Definition tria.h:956
bool are_vertices_communicated_to_p4est() const
Definition tria.cc:1892
std::vector< types::global_dof_index > p4est_tree_to_coarse_cell_permutation
Definition tria.h:783
virtual void update_cell_relations() override
Definition tria.cc:4057
void copy_new_triangulation_to_p4est(std::integral_constant< int, 3 >)
typename::internal::p4est::types< dim >::forest * parallel_forest
Definition tria.h:735
typename::internal::p4est::types< dim >::connectivity * connectivity
Definition tria.h:729
void copy_new_triangulation_to_p4est(std::integral_constant< int, 2 >)
virtual void save(const std::string &filename) const override
Definition tria.cc:2035
bool is_multilevel_hierarchy_constructed() const override
Definition tria.cc:1881
std::vector< types::global_dof_index > coarse_cell_to_p4est_tree_permutation
Definition tria.h:781
virtual void load(const std::string &filename) override
Definition tria.cc:2089
typename::internal::p4est::types< dim >::ghost * parallel_ghost
Definition tria.h:741
#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:4616
typename ::Triangulation< dim, spacedim >::cell_iterator cell_iterator
Definition tria.h:269
typename ::Triangulation< dim, spacedim >::active_cell_iterator active_cell_iterator
Definition tria.h:290
std::vector< types::coarse_cell_id > coarse_cell_index_to_coarse_cell_id