Reference documentation for deal.II version Git d3aed38b93 2021-10-28 13:33:27 +0200
\(\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\}}\)
tria.h
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2008 - 2021 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 
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_MPI
41 # include <mpi.h>
42 #endif
43 
44 #ifdef DEAL_II_WITH_P4EST
45 # include <p4est.h>
46 # include <p4est_connectivity.h>
47 # include <p4est_ghost.h>
48 # include <p8est.h>
49 # include <p8est_connectivity.h>
50 # include <p8est_ghost.h>
51 #endif
52 
54 
55 #ifdef DEAL_II_WITH_P4EST
56 
57 // Forward declarations
58 # ifndef DOXYGEN
59 
60 namespace FETools
61 {
62  namespace internal
63  {
64  template <int, int, class>
65  class ExtrapolateImplementation;
66  }
67 } // namespace FETools
68 
69 // forward declaration of the data type for periodic face pairs
70 namespace GridTools
71 {
72  template <typename CellIterator>
73  struct PeriodicFacePair;
74 }
75 
76 namespace parallel
77 {
78  namespace distributed
79  {
80  template <int, int>
81  class TemporarilyMatchRefineFlags;
82  }
83 } // namespace parallel
84 # endif
85 
86 namespace parallel
87 {
88  namespace distributed
89  {
247  template <int dim, int spacedim = dim>
249  : public ::parallel::DistributedTriangulationBase<dim, spacedim>
250  {
251  public:
269  using cell_iterator =
270  typename ::Triangulation<dim, spacedim>::cell_iterator;
271 
290  using active_cell_iterator =
291  typename ::Triangulation<dim, spacedim>::active_cell_iterator;
292 
293  using CellStatus =
294  typename ::Triangulation<dim, spacedim>::CellStatus;
295 
300  enum Settings
301  {
314  mesh_reconstruction_after_repartitioning = 0x1,
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
372  smooth_grid = (::Triangulation<dim, spacedim>::none),
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
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 
570 
586  virtual bool
587  has_hanging_nodes() const override;
588 
592  virtual std::size_t
593  memory_consumption() const override;
594 
600  virtual std::size_t
601  memory_consumption_p4est() const;
602 
613  void
614  write_mesh_vtk(const std::string &file_basename) const;
615 
620  unsigned int
621  get_checksum() const;
622 
631  virtual void
632  save(const std::string &filename) const override;
633 
653  virtual void
654  load(const std::string &filename) override;
655 
661  DEAL_II_DEPRECATED_EARLY
662  virtual void
663  load(const std::string &filename, const bool autopartition) 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(
721  const std::vector<::GridTools::PeriodicFacePair<cell_iterator>> &)
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  virtual void
777  update_cell_relations() override;
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 
859  virtual types::coarse_cell_id
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 
876  template <int spacedim>
877  class Triangulation<1, spacedim>
878  : public ::parallel::DistributedTriangulationBase<1, spacedim>
879  {
880  public:
884  enum Settings
885  {
887  mesh_reconstruction_after_repartitioning = 0x1,
889  no_automatic_repartitioning = 0x4,
890  communicate_vertices_to_p4est = 0x8
891  };
892 
898  const MPI_Comm &mpi_communicator,
899  const typename ::Triangulation<1, spacedim>::MeshSmoothing
900  smooth_grid = (::Triangulation<1, spacedim>::none),
902 
906  virtual ~Triangulation() override;
907 
914  const std::vector<types::global_dof_index> &
915  get_p4est_tree_to_coarse_cell_permutation() const;
916 
921  virtual void
922  load(const std::string &filename) override;
923 
928  DEAL_II_DEPRECATED_EARLY
929  virtual void
930  load(const std::string &filename, const bool autopartition) override;
931 
936  virtual void
937  save(const std::string &filename) const override;
938 
943  virtual bool
944  is_multilevel_hierarchy_constructed() const override;
945 
950  bool
951  are_vertices_communicated_to_p4est() const;
952 
957  virtual void
958  update_cell_relations() override;
959 
964  std::vector<types::global_dof_index>
966  std::vector<types::global_dof_index>
968 
973  virtual std::map<unsigned int, std::set<::types::subdomain_id>>
974  compute_level_vertices_with_ghost_neighbors(
975  const unsigned int level) const;
976 
981  virtual std::vector<bool>
982  mark_locally_active_vertices_on_level(const unsigned int level) const;
983 
984  virtual unsigned int
985  coarse_cell_id_to_coarse_cell_index(
986  const types::coarse_cell_id coarse_cell_id) const override;
987 
988  virtual types::coarse_cell_id
990  const unsigned int coarse_cell_index) const override;
991 
992  template <int, int>
994  };
995  } // namespace distributed
996 } // namespace parallel
997 
998 
999 #else // DEAL_II_WITH_P4EST
1000 
1001 namespace parallel
1002 {
1003  namespace distributed
1004  {
1016  template <int dim, int spacedim = dim>
1017  class Triangulation
1018  : public ::parallel::DistributedTriangulationBase<dim, spacedim>
1019  {
1020  public:
1024  enum Settings
1025  {
1026  default_setting = 0x0,
1027  mesh_reconstruction_after_repartitioning = 0x1,
1029  no_automatic_repartitioning = 0x4,
1030  communicate_vertices_to_p4est = 0x8
1031  };
1032 
1037  explicit Triangulation(
1038  const MPI_Comm & /*mpi_communicator*/,
1039  const typename ::Triangulation<dim, spacedim>::MeshSmoothing
1040  /*smooth_grid*/
1042  const Settings /*settings*/ = default_setting) = delete;
1043 
1048  virtual bool
1049  is_multilevel_hierarchy_constructed() const override
1050  {
1051  return false;
1052  }
1053 
1058  bool
1059  are_vertices_communicated_to_p4est() const
1060  {
1061  return false;
1062  }
1063 
1068  virtual void
1069  save(const std::string & /*filename*/) const override
1070  {}
1071 
1076  virtual void
1077  load(const std::string & /*filename*/) override
1078  {}
1079 
1084  DEAL_II_DEPRECATED_EARLY
1085  virtual void
1086  load(const std::string & /*filename*/,
1087  const bool /*autopartition*/) override
1088  {}
1089 
1094  virtual void
1095  update_cell_relations() override
1096  {}
1097  };
1098  } // namespace distributed
1099 } // namespace parallel
1100 
1101 
1102 #endif
1103 
1104 
1105 namespace parallel
1106 {
1107  namespace distributed
1108  {
1126  template <int dim, int spacedim = dim>
1128  {
1129  public:
1140 
1148 
1149  private:
1153  const SmartPointer<
1156 
1161  std::vector<bool> saved_refine_flags;
1162 
1167  std::vector<bool> saved_coarsen_flags;
1168  };
1169  } // namespace distributed
1170 } // namespace parallel
1171 
1172 
1174 
1175 #endif
typename ::internal::p4est::types< dim >::connectivity * connectivity
Definition: tria.h:741
std::vector< types::global_dof_index > coarse_cell_to_p4est_tree_permutation
Definition: tria.h:965
const ::Triangulation< dim, spacedim > & tria
std::vector< types::coarse_cell_id > coarse_cell_index_to_coarse_cell_id
typename ::internal::p4est::types< dim >::ghost * parallel_ghost
Definition: tria.h:753
typename ::internal::p4est::types< dim >::forest * parallel_forest
Definition: tria.h:747
void create_triangulation(Triangulation< dim, dim > &tria, const AdditionalData &additional_data=AdditionalData())
std::vector< types::global_dof_index > p4est_tree_to_coarse_cell_permutation
Definition: tria.h:967
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:401
unsigned int level
Definition: grid_out.cc:4589
Point< 3 > vertices[4]
const SmartPointer< ::parallel::distributed::Triangulation< dim, spacedim > > distributed_tria
Definition: tria.h:1155
const TriangulationDescription::Settings settings
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:400
std::vector< types::global_dof_index > p4est_tree_to_coarse_cell_permutation
Definition: tria.h:795
typename ::Triangulation< dim, spacedim >::cell_iterator cell_iterator
Definition: tria.h:270
global_cell_index coarse_cell_id
Definition: types.h:114
std::enable_if< std::is_fundamental< T >::value, std::size_t >::type memory_consumption(const T &t)
std::vector< types::global_dof_index > coarse_cell_to_p4est_tree_permutation
Definition: tria.h:793