Reference documentation for deal.II version GIT b6bf1e606d 2022-08-11 15:25: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_base.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_base_h
17 #define dealii_distributed_tria_base_h
18 
19 
20 #include <deal.II/base/config.h>
21 
22 #include <deal.II/base/mpi.h>
27 
28 #include <deal.II/grid/tria.h>
29 
30 #include <functional>
31 #include <list>
32 #include <set>
33 #include <utility>
34 #include <vector>
35 
36 
38 
39 namespace parallel
40 {
78  template <int dim, int spacedim = dim>
79  class TriangulationBase : public ::Triangulation<dim, spacedim>
80  {
81  public:
86  const MPI_Comm &mpi_communicator,
87  const typename ::Triangulation<dim, spacedim>::MeshSmoothing
89  const bool check_for_distorted_cells = false);
90 
94  virtual ~TriangulationBase() override;
95 
99  virtual MPI_Comm
100  get_communicator() const override;
101 
105  virtual bool
107 
116  virtual void
118  const ::Triangulation<dim, spacedim> &old_tria) override;
119 
138  unsigned int
140 
147  n_global_active_cells() const override;
148 
152  virtual std::size_t
153  memory_consumption() const override;
154 
155 
163  virtual unsigned int
164  n_global_levels() const override;
165 
173  locally_owned_subdomain() const override;
174 
184  const std::set<types::subdomain_id> &
185  ghost_owners() const;
186 
202  const std::set<types::subdomain_id> &
203  level_ghost_owners() const;
204 
210  const std::weak_ptr<const Utilities::MPI::Partitioner>
212 
218  const std::weak_ptr<const Utilities::MPI::Partitioner>
219  global_level_cell_index_partitioner(const unsigned int level) const;
220 
227  virtual std::vector<types::boundary_id>
228  get_boundary_ids() const override;
229 
236  virtual std::vector<types::manifold_id>
237  get_manifold_ids() const override;
238 
291  void
293  const std::vector<bool> &vertex_locally_moved);
294 
295  virtual types::coarse_cell_id
296  n_global_coarse_cells() const override;
297 
298  protected:
304  const MPI_Comm mpi_communicator;
305 
311 
316 
321  struct NumberCache
322  {
327 
333 
338 
344  unsigned int n_global_levels;
345 
350  std::set<types::subdomain_id> ghost_owners;
351 
356  std::set<types::subdomain_id> level_ghost_owners;
357 
361  std::shared_ptr<const Utilities::MPI::Partitioner>
363 
367  std::vector<std::shared_ptr<const Utilities::MPI::Partitioner>>
369 
370  NumberCache();
371  };
372 
374 
378  virtual void
380 
384  void
385  update_reference_cells() override;
386 
390  void
392  };
393 
394 
395 
441  template <int dim, int spacedim = dim>
443  : public ::parallel::TriangulationBase<dim, spacedim>
444  {
445  public:
450  const MPI_Comm &mpi_communicator,
451  const typename ::Triangulation<dim, spacedim>::MeshSmoothing
453  const bool check_for_distorted_cells = false);
454 
461  virtual void
462  clear() override;
463 
465  typename ::Triangulation<dim, spacedim>::cell_iterator;
466 
467  using CellStatus =
468  typename ::Triangulation<dim, spacedim>::CellStatus;
469 
485  virtual bool
486  has_hanging_nodes() const override;
487 
495  virtual void
496  save(const std::string &filename) const = 0;
497 
503  virtual void
504  load(const std::string &filename) = 0;
505 
512  virtual void
513  load(const std::string &filename, const bool autopartition) = 0;
514 
623  unsigned int
625  const std::function<std::vector<char>(const cell_iterator &,
626  const CellStatus)> &pack_callback,
627  const bool returns_variable_size_data);
628 
677  void
679  const unsigned int handle,
680  const std::function<
681  void(const cell_iterator &,
682  const CellStatus,
683  const boost::iterator_range<std::vector<char>::const_iterator> &)>
684  &unpack_callback);
685 
686  protected:
694  void
695  save_attached_data(const unsigned int global_first_cell,
696  const unsigned int global_num_cells,
697  const std::string &filename) const;
698 
707  void
708  load_attached_data(const unsigned int global_first_cell,
709  const unsigned int global_num_cells,
710  const unsigned int local_num_cells,
711  const std::string &filename,
712  const unsigned int n_attached_deserialize_fixed,
713  const unsigned int n_attached_deserialize_variable);
714 
725  virtual void
727 
733  using cell_relation_t = typename std::pair<cell_iterator, CellStatus>;
734 
740  std::vector<cell_relation_t> local_cell_relations;
741 
748  {
753  unsigned int n_attached_data_sets;
754 
760 
761  using pack_callback_t = std::function<std::vector<char>(
762  typename ::Triangulation<dim, spacedim>::cell_iterator,
763  typename ::Triangulation<dim, spacedim>::CellStatus)>;
764 
769  std::vector<pack_callback_t> pack_callbacks_fixed;
770  std::vector<pack_callback_t> pack_callbacks_variable;
771  };
772 
774 
783  {
784  public:
785  DataTransfer(const MPI_Comm &mpi_communicator);
786 
796  void
797  pack_data(const std::vector<cell_relation_t> &cell_relations,
798  const std::vector<typename CellAttachedData::pack_callback_t>
799  &pack_callbacks_fixed,
800  const std::vector<typename CellAttachedData::pack_callback_t>
801  &pack_callbacks_variable);
802 
803 
804 
812  void
813  unpack_cell_status(std::vector<cell_relation_t> &cell_relations) const;
814 
827  void
828  unpack_data(
829  const std::vector<cell_relation_t> &cell_relations,
830  const unsigned int handle,
831  const std::function<void(
832  const typename ::Triangulation<dim, spacedim>::cell_iterator &,
833  const typename ::Triangulation<dim, spacedim>::CellStatus &,
834  const boost::iterator_range<std::vector<char>::const_iterator> &)>
835  &unpack_callback) const;
836 
851  void
852  save(const unsigned int global_first_cell,
853  const unsigned int global_num_cells,
854  const std::string &filename) const;
855 
874  void
875  load(const unsigned int global_first_cell,
876  const unsigned int global_num_cells,
877  const unsigned int local_num_cells,
878  const std::string &filename,
879  const unsigned int n_attached_deserialize_fixed,
880  const unsigned int n_attached_deserialize_variable);
881 
888  void
889  clear();
890 
895 
906  std::vector<unsigned int> sizes_fixed_cumulative;
907 
912  std::vector<char> src_data_fixed;
913  std::vector<char> dest_data_fixed;
914 
919  std::vector<int> src_sizes_variable;
920  std::vector<int> dest_sizes_variable;
921  std::vector<char> src_data_variable;
922  std::vector<char> dest_data_variable;
923 
924  private:
926  };
927 
929  };
930 
931 } // namespace parallel
932 
934 
935 #endif
const bool check_for_distorted_cells
Definition: tria.h:4191
MeshSmoothing smooth_grid
Definition: tria.h:3700
void pack_data(const std::vector< cell_relation_t > &cell_relations, const std::vector< typename CellAttachedData::pack_callback_t > &pack_callbacks_fixed, const std::vector< typename CellAttachedData::pack_callback_t > &pack_callbacks_variable)
Definition: tria_base.cc:852
void save(const unsigned int global_first_cell, const unsigned int global_num_cells, const std::string &filename) const
Definition: tria_base.cc:1395
void unpack_cell_status(std::vector< cell_relation_t > &cell_relations) const
Definition: tria_base.cc:1188
void unpack_data(const std::vector< cell_relation_t > &cell_relations, const unsigned int handle, const std::function< void(const typename ::Triangulation< dim, spacedim >::cell_iterator &, const typename ::Triangulation< dim, spacedim >::CellStatus &, const boost::iterator_range< std::vector< char >::const_iterator > &)> &unpack_callback) const
Definition: tria_base.cc:1224
DataTransfer(const MPI_Comm &mpi_communicator)
Definition: tria_base.cc:842
std::vector< unsigned int > sizes_fixed_cumulative
Definition: tria_base.h:906
void load(const unsigned int global_first_cell, const unsigned int global_num_cells, const unsigned int local_num_cells, const std::string &filename, const unsigned int n_attached_deserialize_fixed, const unsigned int n_attached_deserialize_variable)
Definition: tria_base.cc:1576
virtual void clear() override
Definition: tria_base.cc:655
virtual void load(const std::string &filename)=0
virtual void load(const std::string &filename, const bool autopartition)=0
void save_attached_data(const unsigned int global_first_cell, const unsigned int global_num_cells, const std::string &filename) const
Definition: tria_base.cc:667
virtual bool has_hanging_nodes() const override
Definition: tria_base.cc:704
DistributedTriangulationBase(const MPI_Comm &mpi_communicator, const typename ::Triangulation< dim, spacedim >::MeshSmoothing smooth_grid=(::Triangulation< dim, spacedim >::none), const bool check_for_distorted_cells=false)
Definition: tria_base.cc:638
void notify_ready_to_unpack(const unsigned int handle, const std::function< void(const cell_iterator &, const CellStatus, const boost::iterator_range< std::vector< char >::const_iterator > &)> &unpack_callback)
Definition: tria_base.cc:798
typename ::Triangulation< dim, spacedim >::CellStatus CellStatus
Definition: tria_base.h:468
std::vector< cell_relation_t > local_cell_relations
Definition: tria_base.h:740
virtual void save(const std::string &filename) const =0
unsigned int register_data_attach(const std::function< std::vector< char >(const cell_iterator &, const CellStatus)> &pack_callback, const bool returns_variable_size_data)
Definition: tria_base.cc:768
typename ::Triangulation< dim, spacedim >::cell_iterator cell_iterator
Definition: tria_base.h:465
typename std::pair< cell_iterator, CellStatus > cell_relation_t
Definition: tria_base.h:733
void load_attached_data(const unsigned int global_first_cell, const unsigned int global_num_cells, const unsigned int local_num_cells, const std::string &filename, const unsigned int n_attached_deserialize_fixed, const unsigned int n_attached_deserialize_variable)
Definition: tria_base.cc:731
const std::set< types::subdomain_id > & level_ghost_owners() const
Definition: tria_base.cc:343
virtual std::size_t memory_consumption() const override
Definition: tria_base.cc:93
virtual types::global_cell_index n_global_active_cells() const override
Definition: tria_base.cc:137
void update_reference_cells() override
Definition: tria_base.cc:297
const std::set< types::subdomain_id > & ghost_owners() const
Definition: tria_base.cc:334
types::subdomain_id n_subdomains
Definition: tria_base.h:315
const std::weak_ptr< const Utilities::MPI::Partitioner > global_level_cell_index_partitioner(const unsigned int level) const
Definition: tria_base.cc:617
types::subdomain_id locally_owned_subdomain() const override
Definition: tria_base.cc:325
const MPI_Comm mpi_communicator
Definition: tria_base.h:304
TriangulationBase(const MPI_Comm &mpi_communicator, const typename ::Triangulation< dim, spacedim >::MeshSmoothing smooth_grid=(::Triangulation< dim, spacedim >::none), const bool check_for_distorted_cells=false)
Definition: tria_base.cc:48
virtual unsigned int n_global_levels() const override
Definition: tria_base.cc:130
virtual std::vector< types::boundary_id > get_boundary_ids() const override
Definition: tria_base.cc:352
unsigned int n_locally_owned_active_cells() const
Definition: tria_base.cc:123
virtual types::coarse_cell_id n_global_coarse_cells() const override
Definition: tria_base.cc:630
virtual bool is_multilevel_hierarchy_constructed() const =0
virtual void update_number_cache()
Definition: tria_base.cc:152
const std::weak_ptr< const Utilities::MPI::Partitioner > global_active_cell_index_partitioner() const
Definition: tria_base.cc:608
void communicate_locally_moved_vertices(const std::vector< bool > &vertex_locally_moved)
Definition: tria_base.cc:558
virtual MPI_Comm get_communicator() const override
Definition: tria_base.cc:144
types::subdomain_id my_subdomain
Definition: tria_base.h:310
virtual std::vector< types::manifold_id > get_manifold_ids() const override
Definition: tria_base.cc:363
virtual void copy_triangulation(const ::Triangulation< dim, spacedim > &old_tria) override
Definition: tria_base.cc:68
virtual ~TriangulationBase() override
Definition: tria_base.cc:106
#define DEAL_II_DEPRECATED
Definition: config.h:164
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:442
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:443
unsigned int level
Definition: grid_out.cc:4607
global_cell_index coarse_cell_id
Definition: types.h:114
unsigned int subdomain_id
Definition: types.h:43
unsigned int global_cell_index
Definition: types.h:105
std::vector< pack_callback_t > pack_callbacks_fixed
Definition: tria_base.h:769
std::vector< pack_callback_t > pack_callbacks_variable
Definition: tria_base.h:770
std::function< std::vector< char >(typename ::Triangulation< dim, spacedim >::cell_iterator, typename ::Triangulation< dim, spacedim >::CellStatus)> pack_callback_t
Definition: tria_base.h:763
std::set< types::subdomain_id > level_ghost_owners
Definition: tria_base.h:356
types::global_cell_index n_global_active_cells
Definition: tria_base.h:332
std::set< types::subdomain_id > ghost_owners
Definition: tria_base.h:350
std::shared_ptr< const Utilities::MPI::Partitioner > active_cell_index_partitioner
Definition: tria_base.h:362
std::vector< std::shared_ptr< const Utilities::MPI::Partitioner > > level_cell_index_partitioners
Definition: tria_base.h:368
types::coarse_cell_id number_of_global_coarse_cells
Definition: tria_base.h:337