Reference documentation for deal.II version Git 6d836ad036 2021-06-16 20:57:45 +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 - 2021 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 
224  virtual std::vector<types::boundary_id>
225  get_boundary_ids() const override;
226 
233  virtual std::vector<types::manifold_id>
234  get_manifold_ids() const override;
235 
288  void
290  const std::vector<bool> &vertex_locally_moved);
291 
292  protected:
299 
305 
310 
315  struct NumberCache
316  {
331  unsigned int n_global_levels;
336  std::set<types::subdomain_id> ghost_owners;
341  std::set<types::subdomain_id> level_ghost_owners;
342 
346  std::shared_ptr<const Utilities::MPI::Partitioner>
348 
352  std::vector<std::shared_ptr<const Utilities::MPI::Partitioner>>
354 
355  NumberCache();
356  };
357 
359 
363  virtual void
365 
369  void
370  update_reference_cells() override;
371 
375  void
377  };
378 
379 
380 
426  template <int dim, int spacedim = dim>
428  : public ::parallel::TriangulationBase<dim, spacedim>
429  {
430  public:
435  const MPI_Comm &mpi_communicator,
436  const typename ::Triangulation<dim, spacedim>::MeshSmoothing
438  const bool check_for_distorted_cells = false);
439 
446  virtual void
447  clear() override;
448 
449  using cell_iterator =
450  typename ::Triangulation<dim, spacedim>::cell_iterator;
451 
452  using CellStatus =
453  typename ::Triangulation<dim, spacedim>::CellStatus;
454 
462  virtual void
463  save(const std::string &filename) const = 0;
464 
470  virtual void
471  load(const std::string &filename, const bool autopartition = true) = 0;
472 
581  unsigned int
582  register_data_attach(
583  const std::function<std::vector<char>(const cell_iterator &,
584  const CellStatus)> &pack_callback,
585  const bool returns_variable_size_data);
586 
635  void
636  notify_ready_to_unpack(
637  const unsigned int handle,
638  const std::function<
639  void(const cell_iterator &,
640  const CellStatus,
641  const boost::iterator_range<std::vector<char>::const_iterator> &)>
642  &unpack_callback);
643 
644  protected:
651  void
652  save_attached_data(const unsigned int global_first_cell,
653  const unsigned int global_num_cells,
654  const std::string &filename) const;
655 
663  void
664  load_attached_data(const unsigned int global_first_cell,
665  const unsigned int global_num_cells,
666  const unsigned int local_num_cells,
667  const std::string &filename,
668  const unsigned int n_attached_deserialize_fixed,
669  const unsigned int n_attached_deserialize_variable);
670 
681  virtual void
682  update_cell_relations() = 0;
683 
689  using cell_relation_t = typename std::pair<cell_iterator, CellStatus>;
690 
696  std::vector<cell_relation_t> local_cell_relations;
697 
704  {
709  unsigned int n_attached_data_sets;
710 
716 
717  using pack_callback_t = std::function<std::vector<char>(
718  typename ::Triangulation<dim, spacedim>::cell_iterator,
719  typename ::Triangulation<dim, spacedim>::CellStatus)>;
720 
725  std::vector<pack_callback_t> pack_callbacks_fixed;
726  std::vector<pack_callback_t> pack_callbacks_variable;
727  };
728 
729  CellAttachedData cell_attached_data;
730 
739  {
740  public:
741  DataTransfer(const MPI_Comm &mpi_communicator);
742 
752  void
753  pack_data(const std::vector<cell_relation_t> &cell_relations,
754  const std::vector<typename CellAttachedData::pack_callback_t>
755  &pack_callbacks_fixed,
756  const std::vector<typename CellAttachedData::pack_callback_t>
757  &pack_callbacks_variable);
758 
759 
760 
768  void
769  unpack_cell_status(std::vector<cell_relation_t> &cell_relations) const;
770 
783  void
784  unpack_data(
785  const std::vector<cell_relation_t> &cell_relations,
786  const unsigned int handle,
787  const std::function<void(
788  const typename ::Triangulation<dim, spacedim>::cell_iterator &,
789  const typename ::Triangulation<dim, spacedim>::CellStatus &,
790  const boost::iterator_range<std::vector<char>::const_iterator> &)>
791  &unpack_callback) const;
792 
807  void
808  save(const unsigned int global_first_cell,
809  const unsigned int global_num_cells,
810  const std::string &filename) const;
811 
830  void
831  load(const unsigned int global_first_cell,
832  const unsigned int global_num_cells,
833  const unsigned int local_num_cells,
834  const std::string &filename,
835  const unsigned int n_attached_deserialize_fixed,
836  const unsigned int n_attached_deserialize_variable);
837 
844  void
845  clear();
846 
851 
862  std::vector<unsigned int> sizes_fixed_cumulative;
863 
868  std::vector<char> src_data_fixed;
869  std::vector<char> dest_data_fixed;
870 
875  std::vector<int> src_sizes_variable;
876  std::vector<int> dest_sizes_variable;
877  std::vector<char> src_data_variable;
878  std::vector<char> dest_data_variable;
879 
880  private:
882  };
883 
884  DataTransfer data_transfer;
885  };
886 
887 } // namespace parallel
888 
890 
891 #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:347
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:689
std::shared_ptr< const Utilities::MPI::Partitioner > active_cell_index_partitioner
Definition: tria_base.h:347
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:353
MeshSmoothing smooth_grid
Definition: tria.h:3519
virtual std::vector< types::manifold_id > get_manifold_ids() const override
Definition: tria_base.cc:358
virtual ~TriangulationBase() override
Definition: tria_base.cc:103
std::vector< pack_callback_t > pack_callbacks_variable
Definition: tria_base.h:726
std::set< types::subdomain_id > ghost_owners
Definition: tria_base.h:336
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:719
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:399
unsigned int level
Definition: grid_out.cc:4590
types::global_cell_index n_global_active_cells
Definition: tria_base.h:325
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:584
const MPI_Comm mpi_communicator
Definition: tria_base.h:298
std::set< types::subdomain_id > level_ghost_owners
Definition: tria_base.h:341
const std::weak_ptr< const Utilities::MPI::Partitioner > global_active_cell_index_partitioner() const
Definition: tria_base.cc:634
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:450
unsigned int n_locally_owned_active_cells() const
Definition: tria_base.cc:119
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:398
virtual unsigned int n_global_levels() const override
Definition: tria_base.cc:126
std::vector< unsigned int > sizes_fixed_cumulative
Definition: tria_base.h:862
types::subdomain_id my_subdomain
Definition: tria_base.h:304
const std::weak_ptr< const Utilities::MPI::Partitioner > global_level_cell_index_partitioner(const unsigned int level) const
Definition: tria_base.cc:641
std::vector< cell_relation_t > local_cell_relations
Definition: tria_base.h:696
std::vector< pack_callback_t > pack_callbacks_fixed
Definition: tria_base.h:725
types::subdomain_id n_subdomains
Definition: tria_base.h:309
virtual void clear()
Definition: tria.cc:11285