Reference documentation for deal.II version GIT 44af803bb8 2022-12-03 23:15: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_stub.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 
205  const std::weak_ptr<const Utilities::MPI::Partitioner>
206  global_active_cell_index_partitioner() const override;
207 
208  const std::weak_ptr<const Utilities::MPI::Partitioner>
210  const unsigned int level) const override;
211 
218  virtual std::vector<types::boundary_id>
219  get_boundary_ids() const override;
220 
227  virtual std::vector<types::manifold_id>
228  get_manifold_ids() const override;
229 
282  void
284  const std::vector<bool> &vertex_locally_moved);
285 
286  virtual types::coarse_cell_id
287  n_global_coarse_cells() const override;
288 
289  protected:
295  const MPI_Comm mpi_communicator;
296 
302 
307 
312  struct NumberCache
313  {
318 
324 
329 
335  unsigned int n_global_levels;
336 
341  std::set<types::subdomain_id> ghost_owners;
342 
347  std::set<types::subdomain_id> level_ghost_owners;
348 
352  std::shared_ptr<const Utilities::MPI::Partitioner>
354 
358  std::vector<std::shared_ptr<const Utilities::MPI::Partitioner>>
360 
361  NumberCache();
362  };
363 
365 
369  virtual void
371 
375  void
376  update_reference_cells() override;
377 
381  void
383  };
384 
385 
386 
432  template <int dim, int spacedim = dim>
434  : public ::parallel::TriangulationBase<dim, spacedim>
435  {
436  public:
441  const MPI_Comm &mpi_communicator,
442  const typename ::Triangulation<dim, spacedim>::MeshSmoothing
444  const bool check_for_distorted_cells = false);
445 
452  virtual void
453  clear() override;
454 
456  typename ::Triangulation<dim, spacedim>::cell_iterator;
457 
458  using CellStatus =
459  typename ::Triangulation<dim, spacedim>::CellStatus;
460 
476  virtual bool
477  has_hanging_nodes() const override;
478 
486  virtual void
487  save(const std::string &filename) const = 0;
488 
494  virtual void
495  load(const std::string &filename) = 0;
496 
503  virtual void
504  load(const std::string &filename, const bool autopartition) = 0;
505 
614  unsigned int
616  const std::function<std::vector<char>(const cell_iterator &,
617  const CellStatus)> &pack_callback,
618  const bool returns_variable_size_data);
619 
668  void
670  const unsigned int handle,
671  const std::function<
672  void(const cell_iterator &,
673  const CellStatus,
674  const boost::iterator_range<std::vector<char>::const_iterator> &)>
675  &unpack_callback);
676 
677  protected:
685  void
686  save_attached_data(const unsigned int global_first_cell,
687  const unsigned int global_num_cells,
688  const std::string &filename) const;
689 
698  void
699  load_attached_data(const unsigned int global_first_cell,
700  const unsigned int global_num_cells,
701  const unsigned int local_num_cells,
702  const std::string &filename,
703  const unsigned int n_attached_deserialize_fixed,
704  const unsigned int n_attached_deserialize_variable);
705 
716  virtual void
718 
724  using cell_relation_t = typename std::pair<cell_iterator, CellStatus>;
725 
731  std::vector<cell_relation_t> local_cell_relations;
732 
739  {
744  unsigned int n_attached_data_sets;
745 
751 
752  using pack_callback_t = std::function<std::vector<char>(
753  typename ::Triangulation<dim, spacedim>::cell_iterator,
754  typename ::Triangulation<dim, spacedim>::CellStatus)>;
755 
760  std::vector<pack_callback_t> pack_callbacks_fixed;
761  std::vector<pack_callback_t> pack_callbacks_variable;
762  };
763 
765 
774  {
775  public:
776  DataTransfer(const MPI_Comm &mpi_communicator);
777 
787  void
788  pack_data(const std::vector<cell_relation_t> &cell_relations,
789  const std::vector<typename CellAttachedData::pack_callback_t>
790  &pack_callbacks_fixed,
791  const std::vector<typename CellAttachedData::pack_callback_t>
792  &pack_callbacks_variable);
793 
794 
795 
803  void
804  unpack_cell_status(std::vector<cell_relation_t> &cell_relations) const;
805 
818  void
819  unpack_data(
820  const std::vector<cell_relation_t> &cell_relations,
821  const unsigned int handle,
822  const std::function<void(
823  const typename ::Triangulation<dim, spacedim>::cell_iterator &,
824  const typename ::Triangulation<dim, spacedim>::CellStatus &,
825  const boost::iterator_range<std::vector<char>::const_iterator> &)>
826  &unpack_callback) const;
827 
842  void
843  save(const unsigned int global_first_cell,
844  const unsigned int global_num_cells,
845  const std::string &filename) const;
846 
865  void
866  load(const unsigned int global_first_cell,
867  const unsigned int global_num_cells,
868  const unsigned int local_num_cells,
869  const std::string &filename,
870  const unsigned int n_attached_deserialize_fixed,
871  const unsigned int n_attached_deserialize_variable);
872 
879  void
880  clear();
881 
886 
897  std::vector<unsigned int> sizes_fixed_cumulative;
898 
903  std::vector<char> src_data_fixed;
904  std::vector<char> dest_data_fixed;
905 
910  std::vector<int> src_sizes_variable;
911  std::vector<int> dest_sizes_variable;
912  std::vector<char> src_data_variable;
913  std::vector<char> dest_data_variable;
914 
915  private:
917  };
918 
920  };
921 
922 } // namespace parallel
923 
925 
926 #endif
const bool check_for_distorted_cells
Definition: tria.h:4220
MeshSmoothing smooth_grid
Definition: tria.h:3729
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:851
void save(const unsigned int global_first_cell, const unsigned int global_num_cells, const std::string &filename) const
Definition: tria_base.cc:1394
void unpack_cell_status(std::vector< cell_relation_t > &cell_relations) const
Definition: tria_base.cc:1187
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:1223
DataTransfer(const MPI_Comm &mpi_communicator)
Definition: tria_base.cc:841
std::vector< unsigned int > sizes_fixed_cumulative
Definition: tria_base.h:897
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:1575
virtual void clear() override
Definition: tria_base.cc:654
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:666
virtual bool has_hanging_nodes() const override
Definition: tria_base.cc:703
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:637
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:797
typename ::Triangulation< dim, spacedim >::CellStatus CellStatus
Definition: tria_base.h:459
std::vector< cell_relation_t > local_cell_relations
Definition: tria_base.h:731
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:767
typename ::Triangulation< dim, spacedim >::cell_iterator cell_iterator
Definition: tria_base.h:456
typename std::pair< cell_iterator, CellStatus > cell_relation_t
Definition: tria_base.h:724
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:730
const std::set< types::subdomain_id > & level_ghost_owners() const
Definition: tria_base.cc:342
virtual std::size_t memory_consumption() const override
Definition: tria_base.cc:92
virtual types::global_cell_index n_global_active_cells() const override
Definition: tria_base.cc:136
void update_reference_cells() override
Definition: tria_base.cc:296
const std::set< types::subdomain_id > & ghost_owners() const
Definition: tria_base.cc:333
types::subdomain_id n_subdomains
Definition: tria_base.h:306
const std::weak_ptr< const Utilities::MPI::Partitioner > global_active_cell_index_partitioner() const override
Definition: tria_base.cc:607
const std::weak_ptr< const Utilities::MPI::Partitioner > global_level_cell_index_partitioner(const unsigned int level) const override
Definition: tria_base.cc:616
types::subdomain_id locally_owned_subdomain() const override
Definition: tria_base.cc:324
const MPI_Comm mpi_communicator
Definition: tria_base.h:295
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:47
virtual unsigned int n_global_levels() const override
Definition: tria_base.cc:129
virtual std::vector< types::boundary_id > get_boundary_ids() const override
Definition: tria_base.cc:351
unsigned int n_locally_owned_active_cells() const
Definition: tria_base.cc:122
virtual types::coarse_cell_id n_global_coarse_cells() const override
Definition: tria_base.cc:629
virtual bool is_multilevel_hierarchy_constructed() const =0
virtual void update_number_cache()
Definition: tria_base.cc:151
void communicate_locally_moved_vertices(const std::vector< bool > &vertex_locally_moved)
Definition: tria_base.cc:557
virtual MPI_Comm get_communicator() const override
Definition: tria_base.cc:143
types::subdomain_id my_subdomain
Definition: tria_base.h:301
virtual std::vector< types::manifold_id > get_manifold_ids() const override
Definition: tria_base.cc:362
virtual void copy_triangulation(const ::Triangulation< dim, spacedim > &old_tria) override
Definition: tria_base.cc:67
virtual ~TriangulationBase() override
Definition: tria_base.cc:105
#define DEAL_II_DEPRECATED
Definition: config.h:164
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:458
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:459
unsigned int level
Definition: grid_out.cc:4608
global_cell_index coarse_cell_id
Definition: types.h:119
unsigned int subdomain_id
Definition: types.h:43
unsigned int global_cell_index
Definition: types.h:110
std::vector< pack_callback_t > pack_callbacks_fixed
Definition: tria_base.h:760
std::vector< pack_callback_t > pack_callbacks_variable
Definition: tria_base.h:761
std::function< std::vector< char >(typename ::Triangulation< dim, spacedim >::cell_iterator, typename ::Triangulation< dim, spacedim >::CellStatus)> pack_callback_t
Definition: tria_base.h:754
std::set< types::subdomain_id > level_ghost_owners
Definition: tria_base.h:347
types::global_cell_index n_global_active_cells
Definition: tria_base.h:323
std::set< types::subdomain_id > ghost_owners
Definition: tria_base.h:341
std::shared_ptr< const Utilities::MPI::Partitioner > active_cell_index_partitioner
Definition: tria_base.h:353
std::vector< std::shared_ptr< const Utilities::MPI::Partitioner > > level_cell_index_partitioners
Definition: tria_base.h:359
types::coarse_cell_id number_of_global_coarse_cells
Definition: tria_base.h:328