Reference documentation for deal.II version Git d3aed38b93 2021-10-28 13:33:27 +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  virtual types::coarse_cell_id
293  n_global_coarse_cells() const override;
294 
295  protected:
302 
308 
313 
318  struct NumberCache
319  {
324 
330 
335 
341  unsigned int n_global_levels;
342 
347  std::set<types::subdomain_id> ghost_owners;
348 
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 
391 
392 
438  template <int dim, int spacedim = dim>
440  : public ::parallel::TriangulationBase<dim, spacedim>
441  {
442  public:
447  const MPI_Comm &mpi_communicator,
448  const typename ::Triangulation<dim, spacedim>::MeshSmoothing
450  const bool check_for_distorted_cells = false);
451 
458  virtual void
459  clear() override;
460 
461  using cell_iterator =
462  typename ::Triangulation<dim, spacedim>::cell_iterator;
463 
464  using CellStatus =
465  typename ::Triangulation<dim, spacedim>::CellStatus;
466 
474  virtual void
475  save(const std::string &filename) const = 0;
476 
482  virtual void
483  load(const std::string &filename) = 0;
484 
490  DEAL_II_DEPRECATED_EARLY
491  virtual void
492  load(const std::string &filename, const bool autopartition) = 0;
493 
602  unsigned int
603  register_data_attach(
604  const std::function<std::vector<char>(const cell_iterator &,
605  const CellStatus)> &pack_callback,
606  const bool returns_variable_size_data);
607 
656  void
657  notify_ready_to_unpack(
658  const unsigned int handle,
659  const std::function<
660  void(const cell_iterator &,
661  const CellStatus,
662  const boost::iterator_range<std::vector<char>::const_iterator> &)>
663  &unpack_callback);
664 
665  protected:
672  void
673  save_attached_data(const unsigned int global_first_cell,
674  const unsigned int global_num_cells,
675  const std::string &filename) const;
676 
684  void
685  load_attached_data(const unsigned int global_first_cell,
686  const unsigned int global_num_cells,
687  const unsigned int local_num_cells,
688  const std::string &filename,
689  const unsigned int n_attached_deserialize_fixed,
690  const unsigned int n_attached_deserialize_variable);
691 
702  virtual void
703  update_cell_relations() = 0;
704 
710  using cell_relation_t = typename std::pair<cell_iterator, CellStatus>;
711 
717  std::vector<cell_relation_t> local_cell_relations;
718 
725  {
730  unsigned int n_attached_data_sets;
731 
737 
738  using pack_callback_t = std::function<std::vector<char>(
739  typename ::Triangulation<dim, spacedim>::cell_iterator,
740  typename ::Triangulation<dim, spacedim>::CellStatus)>;
741 
746  std::vector<pack_callback_t> pack_callbacks_fixed;
747  std::vector<pack_callback_t> pack_callbacks_variable;
748  };
749 
750  CellAttachedData cell_attached_data;
751 
760  {
761  public:
762  DataTransfer(const MPI_Comm &mpi_communicator);
763 
773  void
774  pack_data(const std::vector<cell_relation_t> &cell_relations,
775  const std::vector<typename CellAttachedData::pack_callback_t>
776  &pack_callbacks_fixed,
777  const std::vector<typename CellAttachedData::pack_callback_t>
778  &pack_callbacks_variable);
779 
780 
781 
789  void
790  unpack_cell_status(std::vector<cell_relation_t> &cell_relations) const;
791 
804  void
805  unpack_data(
806  const std::vector<cell_relation_t> &cell_relations,
807  const unsigned int handle,
808  const std::function<void(
809  const typename ::Triangulation<dim, spacedim>::cell_iterator &,
810  const typename ::Triangulation<dim, spacedim>::CellStatus &,
811  const boost::iterator_range<std::vector<char>::const_iterator> &)>
812  &unpack_callback) const;
813 
828  void
829  save(const unsigned int global_first_cell,
830  const unsigned int global_num_cells,
831  const std::string &filename) const;
832 
851  void
852  load(const unsigned int global_first_cell,
853  const unsigned int global_num_cells,
854  const unsigned int local_num_cells,
855  const std::string &filename,
856  const unsigned int n_attached_deserialize_fixed,
857  const unsigned int n_attached_deserialize_variable);
858 
865  void
866  clear();
867 
872 
883  std::vector<unsigned int> sizes_fixed_cumulative;
884 
889  std::vector<char> src_data_fixed;
890  std::vector<char> dest_data_fixed;
891 
896  std::vector<int> src_sizes_variable;
897  std::vector<int> dest_sizes_variable;
898  std::vector<char> src_data_variable;
899  std::vector<char> dest_data_variable;
900 
901  private:
903  };
904 
905  DataTransfer data_transfer;
906  };
907 
908 } // namespace parallel
909 
911 
912 #endif
virtual types::global_cell_index n_global_active_cells() const override
Definition: tria_base.cc:135
virtual types::coarse_cell_id n_global_coarse_cells() const override
Definition: tria_base.cc:653
const std::set< types::subdomain_id > & level_ghost_owners() const
Definition: tria_base.cc:337
virtual std::vector< types::boundary_id > get_boundary_ids() const override
Definition: tria_base.cc:346
const std::set< types::subdomain_id > & ghost_owners() const
Definition: tria_base.cc:328
typename std::pair< cell_iterator, CellStatus > cell_relation_t
Definition: tria_base.h:710
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:66
std::vector< std::shared_ptr< const Utilities::MPI::Partitioner > > level_cell_index_partitioners
Definition: tria_base.h:365
MeshSmoothing smooth_grid
Definition: tria.h:3526
virtual std::vector< types::manifold_id > get_manifold_ids() const override
Definition: tria_base.cc:357
virtual ~TriangulationBase() override
Definition: tria_base.cc:104
std::vector< pack_callback_t > pack_callbacks_variable
Definition: tria_base.h:747
std::set< types::subdomain_id > ghost_owners
Definition: tria_base.h:347
types::coarse_cell_id number_of_global_coarse_cells
Definition: tria_base.h:334
virtual MPI_Comm get_communicator() const override
Definition: tria_base.cc:142
virtual std::size_t memory_consumption() const override
Definition: tria_base.cc:91
virtual bool is_multilevel_hierarchy_constructed() const =0
const bool check_for_distorted_cells
Definition: tria.h:4017
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:740
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:401
unsigned int level
Definition: grid_out.cc:4589
types::global_cell_index n_global_active_cells
Definition: tria_base.h:329
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:46
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:583
const MPI_Comm mpi_communicator
Definition: tria_base.h:301
std::set< types::subdomain_id > level_ghost_owners
Definition: tria_base.h:353
const std::weak_ptr< const Utilities::MPI::Partitioner > global_active_cell_index_partitioner() const
Definition: tria_base.cc:633
void update_reference_cells() override
Definition: tria_base.cc:292
virtual void update_number_cache()
Definition: tria_base.cc:150
typename ::Triangulation< dim, spacedim >::cell_iterator cell_iterator
Definition: tria_base.h:462
unsigned int n_locally_owned_active_cells() const
Definition: tria_base.cc:121
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:400
virtual unsigned int n_global_levels() const override
Definition: tria_base.cc:128
std::vector< unsigned int > sizes_fixed_cumulative
Definition: tria_base.h:883
types::subdomain_id my_subdomain
Definition: tria_base.h:307
const std::weak_ptr< const Utilities::MPI::Partitioner > global_level_cell_index_partitioner(const unsigned int level) const
Definition: tria_base.cc:640
std::vector< cell_relation_t > local_cell_relations
Definition: tria_base.h:717
std::vector< pack_callback_t > pack_callbacks_fixed
Definition: tria_base.h:746
types::subdomain_id n_subdomains
Definition: tria_base.h:312
virtual void clear()
Definition: tria.cc:11218