Reference documentation for deal.II version Git 6d836ad036 2021-06-16 20:57:45 +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 
53 
55 
56 #ifdef DEAL_II_WITH_P4EST
57 
58 // Forward declarations
59 # ifndef DOXYGEN
60 
61 namespace FETools
62 {
63  namespace internal
64  {
65  template <int, int, class>
66  class ExtrapolateImplementation;
67  }
68 } // namespace FETools
69 
70 // forward declaration of the data type for periodic face pairs
71 namespace GridTools
72 {
73  template <typename CellIterator>
74  struct PeriodicFacePair;
75 }
76 
77 namespace parallel
78 {
79  namespace distributed
80  {
81  template <int, int>
82  class TemporarilyMatchRefineFlags;
83  }
84 } // namespace parallel
85 # endif
86 
87 namespace parallel
88 {
89  namespace distributed
90  {
248  template <int dim, int spacedim = dim>
250  : public ::parallel::DistributedTriangulationBase<dim, spacedim>
251  {
252  public:
270  using cell_iterator =
271  typename ::Triangulation<dim, spacedim>::cell_iterator;
272 
291  using active_cell_iterator =
292  typename ::Triangulation<dim, spacedim>::active_cell_iterator;
293 
294  using CellStatus =
295  typename ::Triangulation<dim, spacedim>::CellStatus;
296 
301  enum Settings
302  {
315  mesh_reconstruction_after_repartitioning = 0x1,
327  no_automatic_repartitioning = 0x4
328  };
329 
330 
331 
363  explicit Triangulation(
364  const MPI_Comm &mpi_communicator,
365  const typename ::Triangulation<dim, spacedim>::MeshSmoothing
366  smooth_grid = (::Triangulation<dim, spacedim>::none),
367  const Settings settings = default_setting);
368 
372  virtual ~Triangulation() override;
373 
380  virtual void
381  clear() override;
382 
386  bool
387  is_multilevel_hierarchy_constructed() const override;
388 
402  void
403  execute_transfer(
404  const typename ::internal::p4est::types<dim>::forest
405  *parallel_forest,
406  const typename ::internal::p4est::types<dim>::gloidx
407  *previous_global_first_quadrant);
408 
416  virtual void
417  copy_triangulation(
418  const ::Triangulation<dim, spacedim> &other_tria) override;
419 
429  virtual void
430  create_triangulation(const std::vector<Point<spacedim>> &vertices,
431  const std::vector<CellData<dim>> & cells,
432  const SubCellData &subcelldata) override;
433 
439  virtual void
442  &construction_data) override;
443 
473  virtual void
474  execute_coarsening_and_refinement() override;
475 
482  virtual bool
483  prepare_coarsening_and_refinement() override;
484 
525  void
526  repartition();
527 
528 
544  virtual bool
545  has_hanging_nodes() const override;
546 
550  virtual std::size_t
551  memory_consumption() const override;
552 
558  virtual std::size_t
559  memory_consumption_p4est() const;
560 
568  void
569  write_mesh_vtk(const std::string &file_basename) const;
570 
575  unsigned int
576  get_checksum() const;
577 
586  virtual void
587  save(const std::string &filename) const override;
588 
609  virtual void
610  load(const std::string &filename,
611  const bool autopartition = true) override;
612 
618  void
619  load(const typename ::internal::p4est::types<dim>::forest *forest);
620 
627  const std::vector<types::global_dof_index> &
628  get_p4est_tree_to_coarse_cell_permutation() const;
629 
635  const std::vector<types::global_dof_index> &
636  get_coarse_cell_to_p4est_tree_permutation() const;
637 
645  const typename ::internal::p4est::types<dim>::forest *
646  get_p4est() const;
647 
667  virtual void
668  add_periodicity(
669  const std::vector<::GridTools::PeriodicFacePair<cell_iterator>> &)
670  override;
671 
672 
673  private:
678 
683 
689  typename ::internal::p4est::types<dim>::connectivity *connectivity;
690 
695  typename ::internal::p4est::types<dim>::forest *parallel_forest;
696 
701  typename ::internal::p4est::types<dim>::ghost *parallel_ghost;
702 
724  virtual void
725  update_cell_relations() override;
726 
740  std::vector<types::global_dof_index>
742  std::vector<types::global_dof_index>
744 
749  typename ::internal::p4est::types<dim>::tree *
750  init_tree(const int dealii_coarse_cell_index) const;
751 
756  void
757  setup_coarse_cell_to_p4est_tree_permutation();
758 
765  void
766  copy_new_triangulation_to_p4est(std::integral_constant<int, 2>);
767  void
768  copy_new_triangulation_to_p4est(std::integral_constant<int, 3>);
769 
774  void
775  copy_local_forest_to_triangulation();
776 
790  std::vector<unsigned int>
791  get_cell_weights() const;
792 
802  std::vector<bool>
803  mark_locally_active_vertices_on_level(const int level) const;
804 
805  virtual unsigned int
806  coarse_cell_id_to_coarse_cell_index(
807  const types::coarse_cell_id coarse_cell_id) const override;
808 
809  virtual types::coarse_cell_id
810  coarse_cell_index_to_coarse_cell_id(
811  const unsigned int coarse_cell_index) const override;
812 
813  template <int, int, class>
814  friend class ::FETools::internal::ExtrapolateImplementation;
815 
816  template <int, int>
818  };
819 
820 
826  template <int spacedim>
827  class Triangulation<1, spacedim>
828  : public ::parallel::DistributedTriangulationBase<1, spacedim>
829  {
830  public:
834  enum Settings
835  {
837  mesh_reconstruction_after_repartitioning = 0x1,
839  };
840 
846  const MPI_Comm &mpi_communicator,
847  const typename ::Triangulation<1, spacedim>::MeshSmoothing
848  smooth_grid = (::Triangulation<1, spacedim>::none),
849  const Settings settings = default_setting);
850 
854  virtual ~Triangulation() override;
855 
862  const std::vector<types::global_dof_index> &
863  get_p4est_tree_to_coarse_cell_permutation() const;
864 
869  virtual void
870  load(const std::string &filename,
871  const bool autopartition = true) override;
872 
877  virtual void
878  save(const std::string &filename) const override;
879 
884  virtual bool
885  is_multilevel_hierarchy_constructed() const override;
886 
891  virtual void
892  update_cell_relations() override;
893 
898  std::vector<types::global_dof_index>
900  std::vector<types::global_dof_index>
902 
907  virtual std::map<unsigned int, std::set<::types::subdomain_id>>
908  compute_level_vertices_with_ghost_neighbors(
909  const unsigned int level) const;
910 
915  virtual std::vector<bool>
916  mark_locally_active_vertices_on_level(const unsigned int level) const;
917 
918  virtual unsigned int
919  coarse_cell_id_to_coarse_cell_index(
920  const types::coarse_cell_id coarse_cell_id) const override;
921 
922  virtual types::coarse_cell_id
923  coarse_cell_index_to_coarse_cell_id(
924  const unsigned int coarse_cell_index) const override;
925 
926  template <int, int>
928  };
929  } // namespace distributed
930 } // namespace parallel
931 
932 
933 #else // DEAL_II_WITH_P4EST
934 
935 namespace parallel
936 {
937  namespace distributed
938  {
950  template <int dim, int spacedim = dim>
951  class Triangulation
952  : public ::parallel::DistributedTriangulationBase<dim, spacedim>
953  {
954  public:
958  enum Settings
959  {
960  default_setting = 0x0,
961  mesh_reconstruction_after_repartitioning = 0x1,
963  no_automatic_repartitioning = 0x4
964  };
965 
970  explicit Triangulation(
971  const MPI_Comm & /*mpi_communicator*/,
972  const typename ::Triangulation<dim, spacedim>::MeshSmoothing
973  /*smooth_grid*/
975  const Settings /*settings*/ = default_setting) = delete;
976 
981  virtual bool
982  is_multilevel_hierarchy_constructed() const override
983  {
984  return false;
985  }
986 
991  virtual void
992  save(const std::string & /*filename*/) const override
993  {}
994 
999  virtual void
1000  load(const std::string & /*filename*/,
1001  const bool /*autopartition*/ = true) override
1002  {}
1003 
1008  virtual void
1009  update_cell_relations() override
1010  {}
1011  };
1012  } // namespace distributed
1013 } // namespace parallel
1014 
1015 
1016 #endif
1017 
1018 
1019 namespace parallel
1020 {
1021  namespace distributed
1022  {
1040  template <int dim, int spacedim = dim>
1042  {
1043  public:
1054 
1062 
1063  private:
1067  const SmartPointer<
1070 
1075  std::vector<bool> saved_refine_flags;
1076 
1081  std::vector<bool> saved_coarsen_flags;
1082  };
1083  } // namespace distributed
1084 } // namespace parallel
1085 
1086 
1088 
1089 #endif
typename ::internal::p4est::types< dim >::connectivity * connectivity
Definition: tria.h:689
std::vector< types::global_dof_index > coarse_cell_to_p4est_tree_permutation
Definition: tria.h:899
typename ::internal::p4est::types< dim >::ghost * parallel_ghost
Definition: tria.h:701
typename ::internal::p4est::types< dim >::forest * parallel_forest
Definition: tria.h:695
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:901
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:399
unsigned int level
Definition: grid_out.cc:4590
Point< 3 > vertices[4]
const SmartPointer< ::parallel::distributed::Triangulation< dim, spacedim > > distributed_tria
Definition: tria.h:1069
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:398
std::vector< types::global_dof_index > p4est_tree_to_coarse_cell_permutation
Definition: tria.h:743
typename ::Triangulation< dim, spacedim >::cell_iterator cell_iterator
Definition: tria.h:271
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:741