Reference documentation for deal.II version GIT 4e92747666 2022-12-02 08:40: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 
22 #include <deal.II/base/mpi_stub.h>
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 
57 namespace 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
67 namespace GridTools
68 {
69  template <typename CellIterator>
70  struct PeriodicFacePair;
71 }
72 
73 namespace parallel
74 {
75  namespace distributed
76  {
77  template <int, int>
78  class TemporarilyMatchRefineFlags;
79  }
80 } // namespace parallel
81 # endif
82 
83 namespace parallel
84 {
85  namespace distributed
86  {
244  template <int dim, int spacedim = dim>
246  : public ::parallel::DistributedTriangulationBase<dim, spacedim>
247  {
248  public:
267  typename ::Triangulation<dim, spacedim>::cell_iterator;
268 
288  typename ::Triangulation<dim, spacedim>::active_cell_iterator;
289 
290  using CellStatus =
291  typename ::Triangulation<dim, spacedim>::CellStatus;
292 
297  enum Settings
298  {
331  };
332 
333 
334 
366  explicit Triangulation(
367  const MPI_Comm &mpi_communicator,
368  const typename ::Triangulation<dim, spacedim>::MeshSmoothing
371 
375  virtual ~Triangulation() override;
376 
383  virtual void
384  clear() override;
385 
389  bool
390  is_multilevel_hierarchy_constructed() const override;
391 
395  bool
397 
411  void
413  const typename ::internal::p4est::types<dim>::forest
415  const typename ::internal::p4est::types<dim>::gloidx
416  *previous_global_first_quadrant);
417 
425  virtual void
427  const ::Triangulation<dim, spacedim> &other_tria) override;
428 
438  virtual void
439  create_triangulation(const std::vector<Point<spacedim>> &vertices,
440  const std::vector<CellData<dim>> & cells,
441  const SubCellData &subcelldata) override;
442 
448  virtual void
451  &construction_data) override;
452 
463 
480  std::vector<types::subdomain_id>
481  find_point_owner_rank(const std::vector<Point<dim>> &points);
482 
512  virtual void
514 
521  virtual bool
523 
564  void
565  repartition();
566 
570  virtual std::size_t
571  memory_consumption() const override;
572 
578  virtual std::size_t
579  memory_consumption_p4est() const;
580 
591  void
592  write_mesh_vtk(const std::string &file_basename) const;
593 
598  unsigned int
599  get_checksum() const;
600 
609  virtual void
610  save(const std::string &filename) const override;
611 
631  virtual void
632  load(const std::string &filename) override;
633 
640  virtual void
641  load(const std::string &filename, const bool autopartition) override;
642 
648  void
649  load(const typename ::internal::p4est::types<dim>::forest *forest);
650 
657  const std::vector<types::global_dof_index> &
659 
665  const std::vector<types::global_dof_index> &
667 
675  const typename ::internal::p4est::types<dim>::forest *
676  get_p4est() const;
677 
697  virtual void
699  const std::vector<::GridTools::PeriodicFacePair<cell_iterator>> &)
700  override;
701 
702 
703  private:
708 
713 
719  typename ::internal::p4est::types<dim>::connectivity *connectivity;
720 
725  typename ::internal::p4est::types<dim>::forest *parallel_forest;
726 
731  typename ::internal::p4est::types<dim>::ghost *parallel_ghost;
732 
754  virtual void
755  update_cell_relations() override;
756 
770  std::vector<types::global_dof_index>
772  std::vector<types::global_dof_index>
774 
779  typename ::internal::p4est::types<dim>::tree *
780  init_tree(const int dealii_coarse_cell_index) const;
781 
786  void
788 
795  void copy_new_triangulation_to_p4est(std::integral_constant<int, 2>);
796  void copy_new_triangulation_to_p4est(std::integral_constant<int, 3>);
797 
802  void
804 
818  std::vector<unsigned int>
819  get_cell_weights() const;
820 
830  std::vector<bool>
832 
833  virtual unsigned int
835  const types::coarse_cell_id coarse_cell_id) const override;
836 
837  virtual types::coarse_cell_id
839  const unsigned int coarse_cell_index) const override;
840 
841  template <int, int, class>
842  friend class ::FETools::internal::ExtrapolateImplementation;
843 
844  template <int, int>
846  };
847 
848 
854  template <int spacedim>
855  class Triangulation<1, spacedim>
856  : public ::parallel::DistributedTriangulationBase<1, spacedim>
857  {
858  public:
862  enum Settings
863  {
869  };
870 
876  const MPI_Comm &mpi_communicator,
877  const typename ::Triangulation<1, spacedim>::MeshSmoothing
880 
884  virtual ~Triangulation() override;
885 
892  const std::vector<types::global_dof_index> &
894 
899  virtual void
900  load(const std::string &filename) override;
901 
907  virtual void
908  load(const std::string &filename, const bool autopartition) override;
909 
914  virtual void
915  save(const std::string &filename) const override;
916 
921  virtual bool
922  is_multilevel_hierarchy_constructed() const override;
923 
928  bool
930 
935  virtual void
936  update_cell_relations() override;
937 
942  std::vector<types::global_dof_index>
944  std::vector<types::global_dof_index>
946 
951  virtual std::map<unsigned int, std::set<::types::subdomain_id>>
952  compute_level_vertices_with_ghost_neighbors(
953  const unsigned int level) const;
954 
959  virtual std::vector<bool>
960  mark_locally_active_vertices_on_level(const unsigned int level) const;
961 
962  virtual unsigned int
964  const types::coarse_cell_id coarse_cell_id) const override;
965 
966  virtual types::coarse_cell_id
968  const unsigned int coarse_cell_index) const override;
969 
970  template <int, int>
972  };
973  } // namespace distributed
974 } // namespace parallel
975 
976 
977 #else // DEAL_II_WITH_P4EST
978 
979 namespace parallel
980 {
981  namespace distributed
982  {
994  template <int dim, int spacedim = dim>
995  class Triangulation
996  : public ::parallel::DistributedTriangulationBase<dim, spacedim>
997  {
998  public:
1002  enum Settings
1003  {
1004  default_setting = 0x0,
1009  };
1010 
1015  explicit Triangulation(
1016  const MPI_Comm & /*mpi_communicator*/,
1017  const typename ::Triangulation<dim, spacedim>::MeshSmoothing
1018  /*smooth_grid*/
1020  const Settings /*settings*/ = default_setting) = delete;
1021 
1026  virtual bool
1027  is_multilevel_hierarchy_constructed() const override
1028  {
1029  return false;
1030  }
1031 
1036  bool
1038  {
1039  return false;
1040  }
1041 
1046  virtual void
1047  save(const std::string & /*filename*/) const override
1048  {}
1049 
1054  virtual void
1055  load(const std::string & /*filename*/) override
1056  {}
1057 
1063  virtual void
1064  load(const std::string & /*filename*/,
1065  const bool /*autopartition*/) override
1066  {}
1067 
1072  virtual void
1073  update_cell_relations() override
1074  {}
1075  };
1076  } // namespace distributed
1077 } // namespace parallel
1078 
1079 
1080 #endif
1081 
1082 
1083 namespace parallel
1084 {
1085  namespace distributed
1086  {
1104  template <int dim, int spacedim = dim>
1106  {
1107  public:
1118 
1126 
1127  private:
1131  const SmartPointer<
1134 
1139  std::vector<bool> saved_refine_flags;
1140 
1145  std::vector<bool> saved_coarsen_flags;
1146  };
1147  } // namespace distributed
1148 } // namespace parallel
1149 
1150 
1152 
1153 #endif
std::vector< Point< spacedim > > vertices
Definition: tria.h:4196
MeshSmoothing smooth_grid
Definition: tria.h:3729
TemporarilyMatchRefineFlags(::Triangulation< dim, spacedim > &tria)
Definition: tria.cc:4204
const SmartPointer< ::parallel::distributed::Triangulation< dim, spacedim > > distributed_tria
Definition: tria.h:1133
std::vector< types::global_dof_index > p4est_tree_to_coarse_cell_permutation
Definition: tria.h:945
std::vector< types::global_dof_index > coarse_cell_to_p4est_tree_permutation
Definition: tria.h:943
virtual void execute_coarsening_and_refinement() override
Definition: tria.cc:3225
void setup_coarse_cell_to_p4est_tree_permutation()
Definition: tria.cc:1965
typename ::Triangulation< dim, spacedim >::CellStatus CellStatus
Definition: tria.h:291
bool are_vertices_communicated_to_p4est() const
Definition: tria.cc:1860
virtual types::coarse_cell_id coarse_cell_index_to_coarse_cell_id(const unsigned int coarse_cell_index) const override
Definition: tria.cc:3696
virtual void copy_triangulation(const ::Triangulation< dim, spacedim > &other_tria) override
Definition: tria.cc:3909
const std::vector< types::global_dof_index > & get_p4est_tree_to_coarse_cell_permutation() const
Definition: tria.cc:3598
typename ::internal::p4est::types< dim >::ghost * parallel_ghost
Definition: tria.h:731
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:1699
std::vector< unsigned int > get_cell_weights() const
Definition: tria.cc:4026
unsigned int get_checksum() const
Definition: tria.cc:2220
virtual ~Triangulation() override
Definition: tria.cc:1727
std::vector< types::global_dof_index > p4est_tree_to_coarse_cell_permutation
Definition: tria.h:773
virtual void update_cell_relations() override
Definition: tria.cc:3993
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:1870
typename ::internal::p4est::types< dim >::tree * init_tree(const int dealii_coarse_cell_index) const
Definition: tria.cc:2243
types::subdomain_id find_point_owner_rank(const Point< dim > &p)
Definition: tria.cc:3112
virtual bool prepare_coarsening_and_refinement() override
Definition: tria.cc:2737
std::vector< bool > mark_locally_active_vertices_on_level(const int level) const
Definition: tria.cc:3618
virtual void add_periodicity(const std::vector<::GridTools::PeriodicFacePair< cell_iterator >> &) override
Definition: tria.cc:3706
const ::internal::p4est::types< dim >::forest * get_p4est() const
Definition: tria.cc:2232
const std::vector< types::global_dof_index > & get_coarse_cell_to_p4est_tree_permutation() const
Definition: tria.cc:3608
void write_mesh_vtk(const std::string &file_basename) const
Definition: tria.cc:1982
virtual unsigned int coarse_cell_id_to_coarse_cell_index(const types::coarse_cell_id coarse_cell_id) const override
Definition: tria.cc:3686
void copy_new_triangulation_to_p4est(std::integral_constant< int, 2 >)
virtual void save(const std::string &filename) const override
Definition: tria.cc:2001
virtual void create_triangulation(const std::vector< Point< spacedim >> &vertices, const std::vector< CellData< dim >> &cells, const SubCellData &subcelldata) override
Definition: tria.cc:1748
virtual std::size_t memory_consumption_p4est() const
Definition: tria.cc:3897
virtual void clear() override
Definition: tria.cc:1814
bool is_multilevel_hierarchy_constructed() const override
Definition: tria.cc:1850
typename ::internal::p4est::types< dim >::connectivity * connectivity
Definition: tria.h:719
std::vector< types::global_dof_index > coarse_cell_to_p4est_tree_permutation
Definition: tria.h:771
virtual void load(const std::string &filename) override
Definition: tria.cc:2056
virtual std::size_t memory_consumption() const override
Definition: tria.cc:3869
typename ::internal::p4est::types< dim >::forest * parallel_forest
Definition: tria.h:725
#define DEAL_II_DEPRECATED
Definition: config.h:164
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:458
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:459
unsigned int level
Definition: grid_out.cc:4608
typename ::Triangulation< dim, spacedim >::cell_iterator cell_iterator
Definition: tria.h:267
typename ::Triangulation< dim, spacedim >::active_cell_iterator active_cell_iterator
Definition: tria.h:288
global_cell_index coarse_cell_id
Definition: types.h:119
unsigned int subdomain_id
Definition: types.h:43
const ::Triangulation< dim, spacedim > & tria