Reference documentation for deal.II version Git e694e60270 2021-02-25 22:28:05 -0500
\(\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 - 2020 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 <tuple>
37 #include <type_traits>
38 #include <utility>
39 #include <vector>
40 
41 #ifdef DEAL_II_WITH_MPI
42 # include <mpi.h>
43 #endif
44 
45 #ifdef DEAL_II_WITH_P4EST
46 # include <p4est.h>
47 # include <p4est_connectivity.h>
48 # include <p4est_ghost.h>
49 # include <p8est.h>
50 # include <p8est_connectivity.h>
51 # include <p8est_ghost.h>
52 #endif
53 
54 
56 
57 #ifdef DEAL_II_WITH_P4EST
58 
59 // Forward declarations
60 # ifndef DOXYGEN
61 
62 namespace FETools
63 {
64  namespace internal
65  {
66  template <int, int, class>
67  class ExtrapolateImplementation;
68  }
69 } // namespace FETools
70 
71 // forward declaration of the data type for periodic face pairs
72 namespace GridTools
73 {
74  template <typename CellIterator>
75  struct PeriodicFacePair;
76 }
77 # endif
78 
79 namespace parallel
80 {
81  namespace distributed
82  {
240  template <int dim, int spacedim = dim>
242  : public ::parallel::DistributedTriangulationBase<dim, spacedim>
243  {
244  public:
262  using cell_iterator =
263  typename ::Triangulation<dim, spacedim>::cell_iterator;
264 
283  using active_cell_iterator =
284  typename ::Triangulation<dim, spacedim>::active_cell_iterator;
285 
286  using CellStatus =
287  typename ::Triangulation<dim, spacedim>::CellStatus;
288 
293  enum Settings
294  {
307  mesh_reconstruction_after_repartitioning = 0x1,
319  no_automatic_repartitioning = 0x4
320  };
321 
322 
323 
355  explicit Triangulation(
356  const MPI_Comm &mpi_communicator,
357  const typename ::Triangulation<dim, spacedim>::MeshSmoothing
358  smooth_grid = (::Triangulation<dim, spacedim>::none),
359  const Settings settings = default_setting);
360 
364  virtual ~Triangulation() override;
365 
372  virtual void
373  clear() override;
374 
378  bool
379  is_multilevel_hierarchy_constructed() const override;
380 
394  void
395  execute_transfer(
396  const typename ::internal::p4est::types<dim>::forest
397  *parallel_forest,
398  const typename ::internal::p4est::types<dim>::gloidx
399  *previous_global_first_quadrant);
400 
410  virtual void
411  copy_triangulation(
412  const ::Triangulation<dim, spacedim> &other_tria) override;
413 
423  virtual void
424  create_triangulation(const std::vector<Point<spacedim>> &vertices,
425  const std::vector<CellData<dim>> & cells,
426  const SubCellData &subcelldata) override;
427 
433  virtual void
436  &construction_data) override;
437 
467  virtual void
468  execute_coarsening_and_refinement() override;
469 
476  virtual bool
477  prepare_coarsening_and_refinement() override;
478 
519  void
520  repartition();
521 
522 
538  virtual bool
539  has_hanging_nodes() const override;
540 
544  virtual std::size_t
545  memory_consumption() const override;
546 
552  virtual std::size_t
553  memory_consumption_p4est() const;
554 
562  void
563  write_mesh_vtk(const std::string &file_basename) const;
564 
569  unsigned int
570  get_checksum() const;
571 
580  virtual void
581  save(const std::string &filename) const override;
582 
603  virtual void
604  load(const std::string &filename,
605  const bool autopartition = true) override;
606 
612  void
613  load(const typename ::internal::p4est::types<dim>::forest *forest);
614 
621  const std::vector<types::global_dof_index> &
622  get_p4est_tree_to_coarse_cell_permutation() const;
623 
629  const std::vector<types::global_dof_index> &
630  get_coarse_cell_to_p4est_tree_permutation() const;
631 
639  const typename ::internal::p4est::types<dim>::forest *
640  get_p4est() const;
641 
661  virtual void
662  add_periodicity(
663  const std::vector<::GridTools::PeriodicFacePair<cell_iterator>> &)
664  override;
665 
666 
667  private:
672 
677 
683  typename ::internal::p4est::types<dim>::connectivity *connectivity;
684 
689  typename ::internal::p4est::types<dim>::forest *parallel_forest;
690 
695  typename ::internal::p4est::types<dim>::ghost *parallel_ghost;
696 
706  virtual void
707  update_cell_relations() override;
708 
722  std::vector<types::global_dof_index>
724  std::vector<types::global_dof_index>
726 
731  typename ::internal::p4est::types<dim>::tree *
732  init_tree(const int dealii_coarse_cell_index) const;
733 
738  void
739  setup_coarse_cell_to_p4est_tree_permutation();
740 
747  void
748  copy_new_triangulation_to_p4est(std::integral_constant<int, 2>);
749  void
750  copy_new_triangulation_to_p4est(std::integral_constant<int, 3>);
751 
756  void
757  copy_local_forest_to_triangulation();
758 
772  std::vector<unsigned int>
773  get_cell_weights() const;
774 
784  std::vector<bool>
785  mark_locally_active_vertices_on_level(const int level) const;
786 
787  virtual unsigned int
788  coarse_cell_id_to_coarse_cell_index(
789  const types::coarse_cell_id coarse_cell_id) const override;
790 
791  virtual types::coarse_cell_id
792  coarse_cell_index_to_coarse_cell_id(
793  const unsigned int coarse_cell_index) const override;
794 
795  template <int, int, class>
796  friend class ::FETools::internal::ExtrapolateImplementation;
797  };
798 
799 
805  template <int spacedim>
806  class Triangulation<1, spacedim>
807  : public ::parallel::DistributedTriangulationBase<1, spacedim>
808  {
809  public:
813  enum Settings
814  {
816  mesh_reconstruction_after_repartitioning = 0x1,
818  };
819 
825  const MPI_Comm &mpi_communicator,
826  const typename ::Triangulation<1, spacedim>::MeshSmoothing
827  smooth_grid = (::Triangulation<1, spacedim>::none),
828  const Settings settings = default_setting);
829 
833  virtual ~Triangulation() override;
834 
841  const std::vector<types::global_dof_index> &
842  get_p4est_tree_to_coarse_cell_permutation() const;
843 
848  virtual void
849  load(const std::string &filename,
850  const bool autopartition = true) override;
851 
856  virtual void
857  save(const std::string &filename) const override;
858 
863  virtual bool
864  is_multilevel_hierarchy_constructed() const override;
865 
870  virtual void
871  update_cell_relations() override;
872 
877  std::vector<types::global_dof_index>
879  std::vector<types::global_dof_index>
881 
886  virtual std::map<unsigned int, std::set<::types::subdomain_id>>
887  compute_level_vertices_with_ghost_neighbors(
888  const unsigned int level) const;
889 
894  virtual std::vector<bool>
895  mark_locally_active_vertices_on_level(const unsigned int level) const;
896 
897  virtual unsigned int
898  coarse_cell_id_to_coarse_cell_index(
899  const types::coarse_cell_id coarse_cell_id) const override;
900 
901  virtual types::coarse_cell_id
902  coarse_cell_index_to_coarse_cell_id(
903  const unsigned int coarse_cell_index) const override;
904  };
905  } // namespace distributed
906 } // namespace parallel
907 
908 
909 #else // DEAL_II_WITH_P4EST
910 
911 namespace parallel
912 {
913  namespace distributed
914  {
926  template <int dim, int spacedim = dim>
927  class Triangulation
928  : public ::parallel::TriangulationBase<dim, spacedim>
929  {
930  public:
935  Triangulation() = delete;
936  };
937  } // namespace distributed
938 } // namespace parallel
939 
940 
941 #endif
942 
943 
945 
946 #endif
typename ::internal::p4est::types< dim >::connectivity * connectivity
Definition: tria.h:683
std::vector< types::global_dof_index > coarse_cell_to_p4est_tree_permutation
Definition: tria.h:878
typename ::internal::p4est::types< dim >::ghost * parallel_ghost
Definition: tria.h:695
typename ::internal::p4est::types< dim >::forest * parallel_forest
Definition: tria.h:689
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:880
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:394
unsigned int level
Definition: grid_out.cc:4578
Point< 3 > vertices[4]
TriangulationBase< dim, spacedim > Triangulation
Definition: tria_base.h:395
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:393
std::vector< types::global_dof_index > p4est_tree_to_coarse_cell_permutation
Definition: tria.h:725
typename ::Triangulation< dim, spacedim >::cell_iterator cell_iterator
Definition: tria.h:263
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:723