Reference documentation for deal.II version GIT 6da2e5d553 2022-07-01 18:55: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\}}\)
tria.h
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2008 - 2022 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:
270  typename ::Triangulation<dim, spacedim>::cell_iterator;
271 
291  typename ::Triangulation<dim, spacedim>::active_cell_iterator;
292 
293  using CellStatus =
294  typename ::Triangulation<dim, spacedim>::CellStatus;
295 
300  enum Settings
301  {
334  };
335 
336 
337 
369  explicit Triangulation(
370  const MPI_Comm &mpi_communicator,
371  const typename ::Triangulation<dim, spacedim>::MeshSmoothing
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
400 
414  void
416  const typename ::internal::p4est::types<dim>::forest
418  const typename ::internal::p4est::types<dim>::gloidx
419  *previous_global_first_quadrant);
420 
428  virtual void
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 
466 
483  std::vector<types::subdomain_id>
484  find_point_owner_rank(const std::vector<Point<dim>> &points);
485 
515  virtual void
517 
524  virtual bool
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> &
662 
668  const std::vector<types::global_dof_index> &
670 
678  const typename ::internal::p4est::types<dim>::forest *
679  get_p4est() const;
680 
700  virtual void
702  const std::vector<::GridTools::PeriodicFacePair<cell_iterator>> &)
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
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
807 
821  std::vector<unsigned int>
822  get_cell_weights() const;
823 
833  std::vector<bool>
835 
836  virtual unsigned int
838  const types::coarse_cell_id coarse_cell_id) const override;
839 
840  virtual types::coarse_cell_id
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 
857  template <int spacedim>
858  class Triangulation<1, spacedim>
859  : public ::parallel::DistributedTriangulationBase<1, spacedim>
860  {
861  public:
865  enum Settings
866  {
872  };
873 
879  const MPI_Comm &mpi_communicator,
880  const typename ::Triangulation<1, spacedim>::MeshSmoothing
883 
887  virtual ~Triangulation() override;
888 
895  const std::vector<types::global_dof_index> &
897 
902  virtual void
903  load(const std::string &filename) override;
904 
910  virtual void
911  load(const std::string &filename, const bool autopartition) override;
912 
917  virtual void
918  save(const std::string &filename) const override;
919 
924  virtual bool
925  is_multilevel_hierarchy_constructed() const override;
926 
931  bool
933 
938  virtual void
939  update_cell_relations() override;
940 
945  std::vector<types::global_dof_index>
947  std::vector<types::global_dof_index>
949 
954  virtual std::map<unsigned int, std::set<::types::subdomain_id>>
955  compute_level_vertices_with_ghost_neighbors(
956  const unsigned int level) const;
957 
962  virtual std::vector<bool>
963  mark_locally_active_vertices_on_level(const unsigned int level) const;
964 
965  virtual unsigned int
967  const types::coarse_cell_id coarse_cell_id) const override;
968 
969  virtual types::coarse_cell_id
971  const unsigned int coarse_cell_index) const override;
972 
973  template <int, int>
975  };
976  } // namespace distributed
977 } // namespace parallel
978 
979 
980 #else // DEAL_II_WITH_P4EST
981 
982 namespace parallel
983 {
984  namespace distributed
985  {
997  template <int dim, int spacedim = dim>
998  class Triangulation
999  : public ::parallel::DistributedTriangulationBase<dim, spacedim>
1000  {
1001  public:
1005  enum Settings
1006  {
1007  default_setting = 0x0,
1012  };
1013 
1018  explicit Triangulation(
1019  const MPI_Comm & /*mpi_communicator*/,
1020  const typename ::Triangulation<dim, spacedim>::MeshSmoothing
1021  /*smooth_grid*/
1023  const Settings /*settings*/ = default_setting) = delete;
1024 
1029  virtual bool
1030  is_multilevel_hierarchy_constructed() const override
1031  {
1032  return false;
1033  }
1034 
1039  bool
1041  {
1042  return false;
1043  }
1044 
1049  virtual void
1050  save(const std::string & /*filename*/) const override
1051  {}
1052 
1057  virtual void
1058  load(const std::string & /*filename*/) override
1059  {}
1060 
1066  virtual void
1067  load(const std::string & /*filename*/,
1068  const bool /*autopartition*/) override
1069  {}
1070 
1075  virtual void
1076  update_cell_relations() override
1077  {}
1078  };
1079  } // namespace distributed
1080 } // namespace parallel
1081 
1082 
1083 #endif
1084 
1085 
1086 namespace parallel
1087 {
1088  namespace distributed
1089  {
1107  template <int dim, int spacedim = dim>
1109  {
1110  public:
1121 
1129 
1130  private:
1134  const SmartPointer<
1137 
1142  std::vector<bool> saved_refine_flags;
1143 
1148  std::vector<bool> saved_coarsen_flags;
1149  };
1150  } // namespace distributed
1151 } // namespace parallel
1152 
1153 
1155 
1156 #endif
std::vector< Point< spacedim > > vertices
Definition: tria.h:4167
MeshSmoothing smooth_grid
Definition: tria.h:3700
TemporarilyMatchRefineFlags(::Triangulation< dim, spacedim > &tria)
Definition: tria.cc:4206
const SmartPointer< ::parallel::distributed::Triangulation< dim, spacedim > > distributed_tria
Definition: tria.h:1136
std::vector< types::global_dof_index > p4est_tree_to_coarse_cell_permutation
Definition: tria.h:948
std::vector< types::global_dof_index > coarse_cell_to_p4est_tree_permutation
Definition: tria.h:946
virtual void execute_coarsening_and_refinement() override
Definition: tria.cc:3227
void setup_coarse_cell_to_p4est_tree_permutation()
Definition: tria.cc:1967
typename ::Triangulation< dim, spacedim >::CellStatus CellStatus
Definition: tria.h:294
bool are_vertices_communicated_to_p4est() const
Definition: tria.cc:1862
virtual types::coarse_cell_id coarse_cell_index_to_coarse_cell_id(const unsigned int coarse_cell_index) const override
Definition: tria.cc:3698
virtual void copy_triangulation(const ::Triangulation< dim, spacedim > &other_tria) override
Definition: tria.cc:3911
const std::vector< types::global_dof_index > & get_p4est_tree_to_coarse_cell_permutation() const
Definition: tria.cc:3600
typename ::internal::p4est::types< dim >::ghost * parallel_ghost
Definition: tria.h:734
Triangulation(const MPI_Comm &mpi_communicator, const typename ::Triangulation< dim, spacedim >::MeshSmoothing smooth_grid=(::Triangulation< dim, spacedim >::none), const Settings settings=default_setting)
Definition: tria.cc:1701
std::vector< unsigned int > get_cell_weights() const
Definition: tria.cc:4028
unsigned int get_checksum() const
Definition: tria.cc:2222
virtual ~Triangulation() override
Definition: tria.cc:1729
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:3995
void copy_new_triangulation_to_p4est(std::integral_constant< int, 3 >)
void execute_transfer(const typename ::internal::p4est::types< dim >::forest *parallel_forest, const typename ::internal::p4est::types< dim >::gloidx *previous_global_first_quadrant)
Definition: tria.cc:1872
typename ::internal::p4est::types< dim >::tree * init_tree(const int dealii_coarse_cell_index) const
Definition: tria.cc:2245
types::subdomain_id find_point_owner_rank(const Point< dim > &p)
Definition: tria.cc:3114
virtual bool prepare_coarsening_and_refinement() override
Definition: tria.cc:2739
std::vector< bool > mark_locally_active_vertices_on_level(const int level) const
Definition: tria.cc:3620
virtual void add_periodicity(const std::vector<::GridTools::PeriodicFacePair< cell_iterator >> &) override
Definition: tria.cc:3708
const ::internal::p4est::types< dim >::forest * get_p4est() const
Definition: tria.cc:2234
const std::vector< types::global_dof_index > & get_coarse_cell_to_p4est_tree_permutation() const
Definition: tria.cc:3610
void write_mesh_vtk(const std::string &file_basename) const
Definition: tria.cc:1984
virtual unsigned int coarse_cell_id_to_coarse_cell_index(const types::coarse_cell_id coarse_cell_id) const override
Definition: tria.cc:3688
void copy_new_triangulation_to_p4est(std::integral_constant< int, 2 >)
virtual void save(const std::string &filename) const override
Definition: tria.cc:2003
virtual void create_triangulation(const std::vector< Point< spacedim >> &vertices, const std::vector< CellData< dim >> &cells, const SubCellData &subcelldata) override
Definition: tria.cc:1750
virtual std::size_t memory_consumption_p4est() const
Definition: tria.cc:3899
virtual void clear() override
Definition: tria.cc:1816
bool is_multilevel_hierarchy_constructed() const override
Definition: tria.cc:1852
typename ::internal::p4est::types< dim >::connectivity * connectivity
Definition: tria.h:722
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:2058
virtual std::size_t memory_consumption() const override
Definition: tria.cc:3871
typename ::internal::p4est::types< dim >::forest * parallel_forest
Definition: tria.h:728
#define DEAL_II_DEPRECATED
Definition: config.h:164
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:442
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:443
unsigned int level
Definition: grid_out.cc:4607
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
global_cell_index coarse_cell_id
Definition: types.h:114
unsigned int subdomain_id
Definition: types.h:43
const ::Triangulation< dim, spacedim > & tria