Reference documentation for deal.II version 9.3.3
\(\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
61namespace 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
71namespace GridTools
72{
73 template <typename CellIterator>
74 struct PeriodicFacePair;
75}
76
77namespace parallel
78{
79 namespace distributed
80 {
81 template <int, int>
82 class TemporarilyMatchRefineFlags;
83 }
84} // namespace parallel
85# endif
86
87namespace parallel
88{
89 namespace distributed
90 {
248 template <int dim, int spacedim = dim>
250 : public ::parallel::DistributedTriangulationBase<dim, spacedim>
251 {
252 public:
271 typename ::Triangulation<dim, spacedim>::cell_iterator;
272
292 typename ::Triangulation<dim, spacedim>::active_cell_iterator;
293
295 typename ::Triangulation<dim, spacedim>::CellStatus;
296
302 {
328 };
329
330
331
363 explicit Triangulation(
365 const typename ::Triangulation<dim, spacedim>::MeshSmoothing
368
372 virtual ~Triangulation() override;
373
380 virtual void
381 clear() override;
382
386 bool
388
402 void
404 const typename ::internal::p4est::types<dim>::forest
406 const typename ::internal::p4est::types<dim>::gloidx
407 *previous_global_first_quadrant);
408
416 virtual void
418 const ::Triangulation<dim, spacedim> &other_tria) override;
419
429 virtual void
431 const std::vector<CellData<dim>> & cells,
432 const SubCellData &subcelldata) override;
433
439 virtual void
442 &construction_data) override;
443
473 virtual void
475
482 virtual bool
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
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> &
629
635 const std::vector<types::global_dof_index> &
637
645 const typename ::internal::p4est::types<dim>::forest *
646 get_p4est() const;
647
667 virtual void
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
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
776
790 std::vector<unsigned int>
791 get_cell_weights() const;
792
802 std::vector<bool>
804
805 virtual unsigned int
807 const types::coarse_cell_id coarse_cell_id) const override;
808
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:
835 {
839 };
840
847 const typename ::Triangulation<1, spacedim>::MeshSmoothing
850
854 virtual ~Triangulation() override;
855
862 const std::vector<types::global_dof_index> &
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
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
920 const types::coarse_cell_id coarse_cell_id) const override;
921
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
935namespace 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,
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
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
1019namespace 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
std::vector< Point< spacedim > > vertices
Definition: tria.h:3992
MeshSmoothing smooth_grid
Definition: tria.h:3525
TemporarilyMatchRefineFlags(::Triangulation< dim, spacedim > &tria)
Definition: tria.cc:3571
const SmartPointer< ::parallel::distributed::Triangulation< dim, spacedim > > distributed_tria
Definition: tria.h:1069
std::vector< types::global_dof_index > p4est_tree_to_coarse_cell_permutation
Definition: tria.h:901
std::vector< types::global_dof_index > coarse_cell_to_p4est_tree_permutation
Definition: tria.h:899
virtual void execute_coarsening_and_refinement() override
Definition: tria.cc:2583
void setup_coarse_cell_to_p4est_tree_permutation()
Definition: tria.cc:1395
typename ::Triangulation< dim, spacedim >::CellStatus CellStatus
Definition: tria.h:295
virtual bool has_hanging_nodes() const override
Definition: tria.cc:1368
virtual void add_periodicity(const std::vector<::GridTools::PeriodicFacePair< cell_iterator > > &) override
Definition: tria.cc:3048
virtual types::coarse_cell_id coarse_cell_index_to_coarse_cell_id(const unsigned int coarse_cell_index) const override
Definition: tria.cc:3038
virtual void copy_triangulation(const ::Triangulation< dim, spacedim > &other_tria) override
Definition: tria.cc:3250
const std::vector< types::global_dof_index > & get_p4est_tree_to_coarse_cell_permutation() const
Definition: tria.cc:2940
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:1113
std::vector< unsigned int > get_cell_weights() const
Definition: tria.cc:3369
unsigned int get_checksum() const
Definition: tria.cc:1667
virtual ~Triangulation() override
Definition: tria.cc:1141
std::vector< types::global_dof_index > p4est_tree_to_coarse_cell_permutation
Definition: tria.h:743
virtual void update_cell_relations() override
Definition: tria.cc:3336
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:1274
typename::internal::p4est::types< dim >::tree * init_tree(const int dealii_coarse_cell_index) const
Definition: tria.cc:1690
virtual void load(const std::string &filename, const bool autopartition=true) override
Definition: tria.cc:1480
virtual bool prepare_coarsening_and_refinement() override
Definition: tria.cc:2203
std::vector< bool > mark_locally_active_vertices_on_level(const int level) const
Definition: tria.cc:2960
const ::internal::p4est::types< dim >::forest * get_p4est() const
Definition: tria.cc:1679
typename::internal::p4est::types< dim >::forest * parallel_forest
Definition: tria.h:695
const std::vector< types::global_dof_index > & get_coarse_cell_to_p4est_tree_permutation() const
Definition: tria.cc:2950
typename::internal::p4est::types< dim >::connectivity * connectivity
Definition: tria.h:689
void write_mesh_vtk(const std::string &file_basename) const
Definition: tria.cc:1412
virtual unsigned int coarse_cell_id_to_coarse_cell_index(const types::coarse_cell_id coarse_cell_id) const override
Definition: tria.cc:3028
void copy_new_triangulation_to_p4est(std::integral_constant< int, 2 >)
virtual void save(const std::string &filename) const override
Definition: tria.cc:1425
virtual std::size_t memory_consumption_p4est() const
Definition: tria.cc:3238
virtual void clear() override
Definition: tria.cc:1228
bool is_multilevel_hierarchy_constructed() const override
Definition: tria.cc:1264
std::vector< types::global_dof_index > coarse_cell_to_p4est_tree_permutation
Definition: tria.h:741
virtual void create_triangulation(const std::vector< Point< spacedim > > &vertices, const std::vector< CellData< dim > > &cells, const SubCellData &subcelldata) override
Definition: tria.cc:1162
virtual std::size_t memory_consumption() const override
Definition: tria.cc:3210
typename::internal::p4est::types< dim >::ghost * parallel_ghost
Definition: tria.h:701
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:402
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:403
unsigned int level
Definition: grid_out.cc:4590
typename ::Triangulation< dim, spacedim >::cell_iterator cell_iterator
Definition: tria.h:271
typename ::Triangulation< dim, spacedim >::active_cell_iterator active_cell_iterator
Definition: tria.h:292
global_cell_index coarse_cell_id
Definition: types.h:114