Reference documentation for deal.II version Git 54662f1c23 2021-02-26 09:51:10 -0500
\(\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 <tuple>
34 #include <utility>
35 #include <vector>
36 
37 
39 
40 namespace parallel
41 {
78  template <int dim, int spacedim = dim>
79  class TriangulationBase : public ::Triangulation<dim, spacedim>
80  {
81  public:
87  const typename ::Triangulation<dim, spacedim>::MeshSmoothing
89  const bool check_for_distorted_cells = false);
90 
94  virtual ~TriangulationBase() override;
95 
99  virtual const MPI_Comm &
100  get_communicator() const;
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 
211 
217  global_level_cell_index_partitioner(const unsigned int level) const;
218 
227  DEAL_II_DEPRECATED virtual std::map<unsigned int,
228  std::set<::types::subdomain_id>>
230 
237  virtual std::vector<types::boundary_id>
238  get_boundary_ids() const override;
239 
246  virtual std::vector<types::manifold_id>
247  get_manifold_ids() const override;
248 
301  void
303  const std::vector<bool> &vertex_locally_moved);
304 
305  protected:
312 
318 
323 
328  struct NumberCache
329  {
344  unsigned int n_global_levels;
349  std::set<types::subdomain_id> ghost_owners;
354  std::set<types::subdomain_id> level_ghost_owners;
355 
360 
364  std::vector<Utilities::MPI::Partitioner> level_cell_index_partitioners;
365 
366  NumberCache();
367  };
368 
370 
374  virtual void
376 
380  void
381  update_reference_cells() override;
382 
386  void
388  };
389 
394  template <int dim, int spacedim = dim>
396 
397 
398 
444  template <int dim, int spacedim = dim>
446  : public ::parallel::TriangulationBase<dim, spacedim>
447  {
448  public:
453  const MPI_Comm &mpi_communicator,
454  const typename ::Triangulation<dim, spacedim>::MeshSmoothing
456  const bool check_for_distorted_cells = false);
457 
464  virtual void
465  clear() override;
466 
467  using cell_iterator =
468  typename ::Triangulation<dim, spacedim>::cell_iterator;
469 
470  using CellStatus =
471  typename ::Triangulation<dim, spacedim>::CellStatus;
472 
480  virtual void
481  save(const std::string &filename) const = 0;
482 
488  virtual void
489  load(const std::string &filename, const bool autopartition = true) = 0;
490 
599  unsigned int
600  register_data_attach(
601  const std::function<std::vector<char>(const cell_iterator &,
602  const CellStatus)> &pack_callback,
603  const bool returns_variable_size_data);
604 
653  void
654  notify_ready_to_unpack(
655  const unsigned int handle,
656  const std::function<
657  void(const cell_iterator &,
658  const CellStatus,
659  const boost::iterator_range<std::vector<char>::const_iterator> &)>
660  &unpack_callback);
661 
662  protected:
669  void
670  save_attached_data(const unsigned int global_first_cell,
671  const unsigned int global_num_cells,
672  const std::string &filename) const;
673 
681  void
682  load_attached_data(const unsigned int global_first_cell,
683  const unsigned int global_num_cells,
684  const unsigned int local_num_cells,
685  const std::string &filename,
686  const unsigned int n_attached_deserialize_fixed,
687  const unsigned int n_attached_deserialize_variable);
688 
696  virtual void
697  update_cell_relations() = 0;
698 
705  using cell_relation_t = typename std::tuple<CellStatus, cell_iterator>;
706 
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:132
const std::set< types::subdomain_id > & level_ghost_owners() const
Definition: tria_base.cc:337
const Utilities::MPI::Partitioner & global_level_cell_index_partitioner(const unsigned int level) const
Definition: tria_base.cc:609
virtual std::vector< types::boundary_id > get_boundary_ids() const override
Definition: tria_base.cc:356
const std::set< types::subdomain_id > & ghost_owners() const
Definition: tria_base.cc:328
virtual void copy_triangulation(const ::Triangulation< dim, spacedim > &old_tria) override
Definition: tria_base.cc:64
MeshSmoothing smooth_grid
Definition: tria.h:3508
virtual std::vector< types::manifold_id > get_manifold_ids() const override
Definition: tria_base.cc:367
virtual ~TriangulationBase() override
Definition: tria_base.cc:102
std::vector< Utilities::MPI::Partitioner > level_cell_index_partitioners
Definition: tria_base.h:364
std::vector< pack_callback_t > pack_callbacks_variable
Definition: tria_base.h:745
std::set< types::subdomain_id > ghost_owners
Definition: tria_base.h:349
virtual std::size_t memory_consumption() const override
Definition: tria_base.cc:89
virtual bool is_multilevel_hierarchy_constructed() const =0
const bool check_for_distorted_cells
Definition: tria.h:3987
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:394
unsigned int level
Definition: grid_out.cc:4578
types::global_cell_index n_global_active_cells
Definition: tria_base.h:338
typename std::tuple< CellStatus, cell_iterator > cell_relation_t
Definition: tria_base.h:705
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:44
types::subdomain_id locally_owned_subdomain() const override
Definition: tria_base.cc:319
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:552
virtual const MPI_Comm & get_communicator() const
Definition: tria_base.cc:139
std::set< types::subdomain_id > level_ghost_owners
Definition: tria_base.h:354
virtual std::map< unsigned int, std::set<::types::subdomain_id > > compute_vertices_with_ghost_neighbors() const
Definition: tria_base.cc:346
void update_reference_cells() override
Definition: tria_base.cc:292
virtual void update_number_cache()
Definition: tria_base.cc:147
typename ::Triangulation< dim, spacedim >::cell_iterator cell_iterator
Definition: tria_base.h:468
unsigned int n_locally_owned_active_cells() const
Definition: tria_base.cc:118
const Utilities::MPI::Partitioner & global_active_cell_index_partitioner() const
Definition: tria_base.cc:602
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:393
virtual unsigned int n_global_levels() const override
Definition: tria_base.cc:125
Utilities::MPI::Partitioner active_cell_index_partitioner
Definition: tria_base.h:359
std::vector< unsigned int > sizes_fixed_cumulative
Definition: tria_base.h:881
types::subdomain_id my_subdomain
Definition: tria_base.h:317
#define DEAL_II_DEPRECATED
Definition: config.h:156
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:322
virtual void clear()
Definition: tria.cc:10180