Reference documentation for deal.II version 8.5.1
tria.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2008 - 2017 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 at
12 // the top level of the deal.II distribution.
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 #include <deal.II/base/subscriptor.h>
22 #include <deal.II/base/smartpointer.h>
23 #include <deal.II/base/template_constraints.h>
24 #include <deal.II/grid/tria.h>
25 
26 #include <deal.II/base/std_cxx11/function.h>
27 #include <deal.II/base/std_cxx11/tuple.h>
28 
29 #include <deal.II/distributed/tria_base.h>
30 #include <deal.II/distributed/p4est_wrappers.h>
31 
32 #include <set>
33 #include <vector>
34 #include <list>
35 #include <utility>
36 
37 #ifdef DEAL_II_WITH_MPI
38 # include <mpi.h>
39 #endif
40 
41 #ifdef DEAL_II_WITH_P4EST
42 #include <p4est_connectivity.h>
43 #include <p4est.h>
44 #include <p4est_ghost.h>
45 
46 #include <p8est_connectivity.h>
47 #include <p8est.h>
48 #include <p8est_ghost.h>
49 #endif
50 
51 
52 DEAL_II_NAMESPACE_OPEN
53 
54 #ifdef DEAL_II_WITH_P4EST
55 
56 namespace internal
57 {
58  namespace DoFHandler
59  {
60  namespace Policy
61  {
62  template <int, int> class ParallelDistributed;
63  }
64  }
65 }
66 
67 namespace FETools
68 {
69  namespace internal
70  {
71  template <int, int, class> class ExtrapolateImplementation;
72  }
73 }
74 
75 //forward declaration of the data type for periodic face pairs
76 namespace GridTools
77 {
78  template <typename CellIterator> struct PeriodicFacePair;
79 }
80 
81 namespace parallel
82 {
83  namespace distributed
84  {
85 
86 
244  template <int dim, int spacedim = dim>
245  class Triangulation : public ::parallel::Triangulation<dim,spacedim>
246  {
247  public:
265  typedef typename ::Triangulation<dim,spacedim>::cell_iterator cell_iterator;
266 
285  typedef typename ::Triangulation<dim,spacedim>::active_cell_iterator active_cell_iterator;
286 
287  typedef typename ::Triangulation<dim,spacedim>::CellStatus CellStatus;
288 
293  enum Settings
294  {
321  };
322 
323 
324 
357  const typename ::Triangulation<dim,spacedim>::MeshSmoothing
360 
364  virtual ~Triangulation ();
365 
372  virtual void clear ();
373 
383  virtual void copy_triangulation (const ::Triangulation<dim, spacedim> &other_tria);
384 
394  virtual void create_triangulation (const std::vector<Point<spacedim> > &vertices,
395  const std::vector<CellData<dim> > &cells,
396  const SubCellData &subcelldata);
397 
427  virtual void execute_coarsening_and_refinement ();
428 
435  virtual bool prepare_coarsening_and_refinement ();
436 
477  void repartition ();
478 
531  void
532  communicate_locally_moved_vertices (const std::vector<bool> &vertex_locally_moved);
533 
534 
550  virtual
551  bool has_hanging_nodes() const;
552 
556  virtual std::size_t memory_consumption () const;
557 
563  virtual std::size_t memory_consumption_p4est () const;
564 
572  void write_mesh_vtk (const char *file_basename) const;
573 
578  unsigned int get_checksum () const;
579 
587  void save(const char *filename) const;
588 
607  void load(const char *filename,
608  const bool autopartition = true);
609 
645  unsigned int
646  register_data_attach (const std::size_t size,
647  const std_cxx11::function<void (const cell_iterator &,
648  const CellStatus,
649  void *)> &pack_callback);
650 
665  void
666  notify_ready_to_unpack (const unsigned int offset,
667  const std_cxx11::function<void (const cell_iterator &,
668  const CellStatus,
669  const void *)> &unpack_callback);
670 
677  const std::vector<types::global_dof_index> &
679 
685  const std::vector<types::global_dof_index> &
687 
706  virtual void
708  (const std::vector<GridTools::PeriodicFacePair<cell_iterator> > &);
709 
710 
711  private:
712 
718  virtual void update_number_cache ();
719 
724 
729 
735  typename ::internal::p4est::types<dim>::connectivity *connectivity;
736 
741  typename ::internal::p4est::types<dim>::forest *parallel_forest;
746  typename ::internal::p4est::types<dim>::ghost *parallel_ghost;
747 
759 
760 
765  unsigned int attached_data_size;
766 
771  unsigned int n_attached_datas;
772 
778 
779  typedef std_cxx11::function<
781  > pack_callback_t;
782 
783  typedef std::pair<unsigned int, pack_callback_t> callback_pair_t;
784 
785  typedef std::list<callback_pair_t> callback_list_t;
786 
792 
793 
807  std::vector<types::global_dof_index> coarse_cell_to_p4est_tree_permutation;
808  std::vector<types::global_dof_index> p4est_tree_to_coarse_cell_permutation;
809 
814  typename ::internal::p4est::types<dim>::tree *
815  init_tree(const int dealii_coarse_cell_index) const;
816 
822 
831 
837 
843  void attach_mesh_data();
844 
858  std::vector<unsigned int>
860 
866  void
868  (std::map<unsigned int, std::set<::types::subdomain_id> >
869  &vertices_with_ghost_neighbors);
870 
876  void
878  (const int level,
879  std::map<unsigned int, std::set<::types::subdomain_id> >
880  &vertices_with_ghost_neighbors);
881 
891  std::vector<bool>
892  mark_locally_active_vertices_on_level(const int level) const;
893 
894  template <int, int> friend class ::internal::DoFHandler::Policy::ParallelDistributed;
895 
896  template <int,int,class> friend class ::FETools::internal::ExtrapolateImplementation;
897  };
898 
899 
905  template <int spacedim>
906  class Triangulation<1,spacedim> : public ::parallel::Triangulation<1,spacedim>
907  {
908  public:
913  Triangulation (MPI_Comm mpi_communicator);
914 
918  virtual ~Triangulation ();
919 
926  const std::vector<types::global_dof_index> &
928 
962  void
963  communicate_locally_moved_vertices (const std::vector<bool> &vertex_locally_moved);
964 
969  std::vector<types::global_dof_index> coarse_cell_to_p4est_tree_permutation;
970  std::vector<types::global_dof_index> p4est_tree_to_coarse_cell_permutation;
971 
975  enum Settings
976  {
977  default_setting = 0x0,
980  };
981 
982 
983 //TODO: The following variable should really be private, but it is used in dof_handler_policy.cc ...
988 
993  void
995  (std::map<unsigned int, std::set<::types::subdomain_id> >
996  &vertices_with_ghost_neighbors);
997 
1002  void
1004  (const unsigned int level,
1005  std::map<unsigned int, std::set<::types::subdomain_id> >
1006  &vertices_with_ghost_neighbors);
1007 
1012  std::vector<bool>
1013  mark_locally_active_vertices_on_level(const unsigned int level) const;
1014 
1015  };
1016  }
1017 }
1018 
1019 
1020 #else // DEAL_II_WITH_P4EST
1021 
1022 namespace parallel
1023 {
1024  namespace distributed
1025  {
1036  template <int dim, int spacedim = dim>
1037  class Triangulation : public ::parallel::Triangulation<dim,spacedim>
1038  {
1039  private:
1043  Triangulation ();
1044 
1045  };
1046  }
1047 }
1048 
1049 
1050 #endif
1051 
1052 
1053 DEAL_II_NAMESPACE_CLOSE
1054 
1055 #endif
std::vector< unsigned int > get_cell_weights()
Definition: tria.cc:3819
Definition: tria.h:67
void fill_vertices_with_ghost_neighbors(std::map< unsigned int, std::set<::types::subdomain_id > > &vertices_with_ghost_neighbors)
Definition: tria.cc:3391
typename ::internal::p4est::types< dim >::connectivity * connectivity
Definition: tria.h:735
unsigned int register_data_attach(const std::size_t size, const std_cxx11::function< void(const cell_iterator &, const CellStatus, void *)> &pack_callback)
Definition: tria.cc:3277
std::vector< types::global_dof_index > coarse_cell_to_p4est_tree_permutation
Definition: tria.h:969
std::vector< Point< spacedim > > vertices
Definition: tria.h:3447
virtual std::size_t memory_consumption() const
Definition: tria.cc:3674
void notify_ready_to_unpack(const unsigned int offset, const std_cxx11::function< void(const cell_iterator &, const CellStatus, const void *)> &unpack_callback)
Definition: tria.cc:3300
void copy_new_triangulation_to_p4est(::internal::int2type< 2 >)
virtual std::size_t memory_consumption_p4est() const
Definition: tria.cc:3696
void load(const char *filename, const bool autopartition=true)
Definition: tria.cc:1814
callback_list_t attached_data_pack_callbacks
Definition: tria.h:791
const std::vector< types::global_dof_index > & get_p4est_tree_to_coarse_cell_permutation() const
Definition: tria.cc:3368
virtual void add_periodicity(const std::vector< GridTools::PeriodicFacePair< cell_iterator > > &)
Definition: tria.cc:3529
typename ::internal::p4est::types< dim >::ghost * parallel_ghost
Definition: tria.h:746
typename ::internal::p4est::types< dim >::forest * parallel_forest
Definition: tria.h:741
virtual void copy_triangulation(const ::Triangulation< dim, spacedim > &other_tria)
Definition: tria.cc:3707
virtual void create_triangulation(const std::vector< Point< spacedim > > &vertices, const std::vector< CellData< dim > > &cells, const SubCellData &subcelldata)
Definition: tria.cc:1325
void fill_level_vertices_with_ghost_neighbors(const int level, std::map< unsigned int, std::set<::types::subdomain_id > > &vertices_with_ghost_neighbors)
Definition: tria.cc:3418
virtual bool prepare_coarsening_and_refinement()
Definition: tria.cc:2486
Definition: tria.h:76
const std::vector< types::global_dof_index > & get_coarse_cell_to_p4est_tree_permutation() const
Definition: tria.cc:3377
virtual bool has_hanging_nodes() const
Definition: tria.cc:1708
void save(const char *filename) const
Definition: tria.cc:1766
typename ::internal::p4est::types< dim >::tree * init_tree(const int dealii_coarse_cell_index) const
Definition: tria.cc:1985
virtual void execute_coarsening_and_refinement()
Definition: tria.cc:2836
::Triangulation< dim, spacedim >::active_cell_iterator active_cell_iterator
Definition: tria.h:285
void communicate_locally_moved_vertices(const std::vector< bool > &vertex_locally_moved)
Definition: tria.cc:3120
unsigned int get_checksum() const
Definition: tria.cc:1898
MeshSmoothing smooth_grid
Definition: tria.h:3185
void setup_coarse_cell_to_p4est_tree_permutation()
Definition: tria.cc:1737
::Triangulation< dim, spacedim >::cell_iterator cell_iterator
Definition: tria.h:265
Triangulation(MPI_Comm mpi_communicator, const typename ::Triangulation< dim, spacedim >::MeshSmoothing smooth_grid=(::Triangulation< dim, spacedim >::none), const Settings settings=default_setting)
Definition: tria.cc:1279
unsigned int n_attached_deserialize
Definition: tria.h:777
virtual void update_number_cache()
Definition: tria.cc:1908
std::vector< bool > mark_locally_active_vertices_on_level(const int level) const
Definition: tria.cc:3474
std::vector< types::global_dof_index > coarse_cell_to_p4est_tree_permutation
Definition: tria.h:807
void write_mesh_vtk(const char *file_basename) const
Definition: tria.cc:1754