Reference documentation for deal.II version Git 1dc1051882 2021-04-22 23:57:03 +0200
\(\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 - 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_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 {
77  template <int dim, int spacedim = dim>
78  class TriangulationBase : public ::Triangulation<dim, spacedim>
79  {
80  public:
86  const typename ::Triangulation<dim, spacedim>::MeshSmoothing
88  const bool check_for_distorted_cells = false);
89 
93  virtual ~TriangulationBase() override;
94 
98  virtual MPI_Comm
99  get_communicator() const override;
100 
104  virtual bool
106 
115  virtual void
117  const ::Triangulation<dim, spacedim> &old_tria) override;
118 
137  unsigned int
139 
146  n_global_active_cells() const override;
147 
151  virtual std::size_t
152  memory_consumption() const override;
153 
154 
162  virtual unsigned int
163  n_global_levels() const override;
164 
172  locally_owned_subdomain() const override;
173 
183  const std::set<types::subdomain_id> &
184  ghost_owners() const;
185 
201  const std::set<types::subdomain_id> &
202  level_ghost_owners() const;
203 
208  const std::weak_ptr<const Utilities::MPI::Partitioner>
210 
215  const std::weak_ptr<const Utilities::MPI::Partitioner>
216  global_level_cell_index_partitioner(const unsigned int level) const;
217 
226  DEAL_II_DEPRECATED virtual std::map<unsigned int,
227  std::set<::types::subdomain_id>>
229 
236  virtual std::vector<types::boundary_id>
237  get_boundary_ids() const override;
238 
245  virtual std::vector<types::manifold_id>
246  get_manifold_ids() const override;
247 
300  void
302  const std::vector<bool> &vertex_locally_moved);
303 
304  protected:
311 
317 
322 
327  struct NumberCache
328  {
343  unsigned int n_global_levels;
348  std::set<types::subdomain_id> ghost_owners;
353  std::set<types::subdomain_id> level_ghost_owners;
354 
358  std::shared_ptr<const Utilities::MPI::Partitioner>
360 
364  std::vector<std::shared_ptr<const Utilities::MPI::Partitioner>>
366 
367  NumberCache();
368  };
369 
371 
375  virtual void
377 
381  void
382  update_reference_cells() override;
383 
387  void
389  };
390 
395  template <int dim, int spacedim = dim>
397 
398 
399 
445  template <int dim, int spacedim = dim>
447  : public ::parallel::TriangulationBase<dim, spacedim>
448  {
449  public:
454  const MPI_Comm &mpi_communicator,
455  const typename ::Triangulation<dim, spacedim>::MeshSmoothing
457  const bool check_for_distorted_cells = false);
458 
465  virtual void
466  clear() override;
467 
468  using cell_iterator =
469  typename ::Triangulation<dim, spacedim>::cell_iterator;
470 
471  using CellStatus =
472  typename ::Triangulation<dim, spacedim>::CellStatus;
473 
481  virtual void
482  save(const std::string &filename) const = 0;
483 
489  virtual void
490  load(const std::string &filename, const bool autopartition = true) = 0;
491 
600  unsigned int
601  register_data_attach(
602  const std::function<std::vector<char>(const cell_iterator &,
603  const CellStatus)> &pack_callback,
604  const bool returns_variable_size_data);
605 
654  void
655  notify_ready_to_unpack(
656  const unsigned int handle,
657  const std::function<
658  void(const cell_iterator &,
659  const CellStatus,
660  const boost::iterator_range<std::vector<char>::const_iterator> &)>
661  &unpack_callback);
662 
663  protected:
670  void
671  save_attached_data(const unsigned int global_first_cell,
672  const unsigned int global_num_cells,
673  const std::string &filename) const;
674 
682  void
683  load_attached_data(const unsigned int global_first_cell,
684  const unsigned int global_num_cells,
685  const unsigned int local_num_cells,
686  const std::string &filename,
687  const unsigned int n_attached_deserialize_fixed,
688  const unsigned int n_attached_deserialize_variable);
689 
700  virtual void
701  update_cell_relations() = 0;
702 
708  using cell_relation_t = typename std::pair<cell_iterator, CellStatus>;
709 
715  std::vector<cell_relation_t> local_cell_relations;
716 
723  {
728  unsigned int n_attached_data_sets;
729 
735 
736  using pack_callback_t = std::function<std::vector<char>(
737  typename ::Triangulation<dim, spacedim>::cell_iterator,
738  typename ::Triangulation<dim, spacedim>::CellStatus)>;
739 
744  std::vector<pack_callback_t> pack_callbacks_fixed;
745  std::vector<pack_callback_t> pack_callbacks_variable;
746  };
747 
748  CellAttachedData cell_attached_data;
749 
758  {
759  public:
760  DataTransfer(const MPI_Comm &mpi_communicator);
761 
771  void
772  pack_data(const std::vector<cell_relation_t> &cell_relations,
773  const std::vector<typename CellAttachedData::pack_callback_t>
774  &pack_callbacks_fixed,
775  const std::vector<typename CellAttachedData::pack_callback_t>
776  &pack_callbacks_variable);
777 
778 
779 
787  void
788  unpack_cell_status(std::vector<cell_relation_t> &cell_relations) const;
789 
802  void
803  unpack_data(
804  const std::vector<cell_relation_t> &cell_relations,
805  const unsigned int handle,
806  const std::function<void(
807  const typename ::Triangulation<dim, spacedim>::cell_iterator &,
808  const typename ::Triangulation<dim, spacedim>::CellStatus &,
809  const boost::iterator_range<std::vector<char>::const_iterator> &)>
810  &unpack_callback) const;
811 
826  void
827  save(const unsigned int global_first_cell,
828  const unsigned int global_num_cells,
829  const std::string &filename) const;
830 
849  void
850  load(const unsigned int global_first_cell,
851  const unsigned int global_num_cells,
852  const unsigned int local_num_cells,
853  const std::string &filename,
854  const unsigned int n_attached_deserialize_fixed,
855  const unsigned int n_attached_deserialize_variable);
856 
863  void
864  clear();
865 
870 
881  std::vector<unsigned int> sizes_fixed_cumulative;
882 
887  std::vector<char> src_data_fixed;
888  std::vector<char> dest_data_fixed;
889 
894  std::vector<int> src_sizes_variable;
895  std::vector<int> dest_sizes_variable;
896  std::vector<char> src_data_variable;
897  std::vector<char> dest_data_variable;
898 
899  private:
901  };
902 
903  DataTransfer data_transfer;
904  };
905 
906 } // namespace parallel
907 
909 
910 #endif
virtual types::global_cell_index n_global_active_cells() const override
Definition: tria_base.cc:133
const std::set< types::subdomain_id > & level_ghost_owners() const
Definition: tria_base.cc:338
virtual std::vector< types::boundary_id > get_boundary_ids() const override
Definition: tria_base.cc:357
const std::set< types::subdomain_id > & ghost_owners() const
Definition: tria_base.cc:329
typename std::pair< cell_iterator, CellStatus > cell_relation_t
Definition: tria_base.h:708
std::shared_ptr< const Utilities::MPI::Partitioner > active_cell_index_partitioner
Definition: tria_base.h:359
virtual void copy_triangulation(const ::Triangulation< dim, spacedim > &old_tria) override
Definition: tria_base.cc:65
std::vector< std::shared_ptr< const Utilities::MPI::Partitioner > > level_cell_index_partitioners
Definition: tria_base.h:365
MeshSmoothing smooth_grid
Definition: tria.h:3525
virtual std::vector< types::manifold_id > get_manifold_ids() const override
Definition: tria_base.cc:368
virtual ~TriangulationBase() override
Definition: tria_base.cc:103
std::vector< pack_callback_t > pack_callbacks_variable
Definition: tria_base.h:745
std::set< types::subdomain_id > ghost_owners
Definition: tria_base.h:348
virtual MPI_Comm get_communicator() const override
Definition: tria_base.cc:140
virtual std::size_t memory_consumption() const override
Definition: tria_base.cc:90
virtual bool is_multilevel_hierarchy_constructed() const =0
const bool check_for_distorted_cells
Definition: tria.h:4010
void load(Archive &ar, const unsigned int version)
std::function< std::vector< char >(typename ::Triangulation< dim, spacedim >::cell_iterator, typename ::Triangulation< dim, spacedim >::CellStatus)> pack_callback_t
Definition: tria_base.h:738
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:396
unsigned int level
Definition: grid_out.cc:4590
types::global_cell_index n_global_active_cells
Definition: tria_base.h:337
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:45
types::subdomain_id locally_owned_subdomain() const override
Definition: tria_base.cc:320
void save(Archive &ar, const unsigned int version) const
void communicate_locally_moved_vertices(const std::vector< bool > &vertex_locally_moved)
Definition: tria_base.cc:594
const MPI_Comm mpi_communicator
Definition: tria_base.h:310
std::set< types::subdomain_id > level_ghost_owners
Definition: tria_base.h:353
virtual std::map< unsigned int, std::set<::types::subdomain_id > > compute_vertices_with_ghost_neighbors() const
Definition: tria_base.cc:347
const std::weak_ptr< const Utilities::MPI::Partitioner > global_active_cell_index_partitioner() const
Definition: tria_base.cc:644
void update_reference_cells() override
Definition: tria_base.cc:293
virtual void update_number_cache()
Definition: tria_base.cc:148
typename ::Triangulation< dim, spacedim >::cell_iterator cell_iterator
Definition: tria_base.h:469
unsigned int n_locally_owned_active_cells() const
Definition: tria_base.cc:119
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:395
virtual unsigned int n_global_levels() const override
Definition: tria_base.cc:126
std::vector< unsigned int > sizes_fixed_cumulative
Definition: tria_base.h:881
types::subdomain_id my_subdomain
Definition: tria_base.h:316
#define DEAL_II_DEPRECATED
Definition: config.h:158
const std::weak_ptr< const Utilities::MPI::Partitioner > global_level_cell_index_partitioner(const unsigned int level) const
Definition: tria_base.cc:651
std::vector< cell_relation_t > local_cell_relations
Definition: tria_base.h:715
std::vector< pack_callback_t > pack_callbacks_fixed
Definition: tria_base.h:744
types::subdomain_id n_subdomains
Definition: tria_base.h:321
virtual void clear()
Definition: tria.cc:10180