Reference documentation for deal.II version Git d0adf306fe 2021-04-19 12:46:27 -0400
\(\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.h
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 1998 - 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_tria_h
17 #define dealii_tria_h
18 
19 
20 #include <deal.II/base/config.h>
21 
24 #include <deal.II/base/point.h>
27 
28 #include <deal.II/grid/cell_id.h>
32 
33 #include <boost/serialization/map.hpp>
34 #include <boost/serialization/split_member.hpp>
35 #include <boost/serialization/unique_ptr.hpp>
36 #include <boost/serialization/vector.hpp>
37 #include <boost/signals2.hpp>
38 
39 #include <bitset>
40 #include <functional>
41 #include <list>
42 #include <map>
43 #include <memory>
44 #include <numeric>
45 #include <vector>
46 
47 
49 
50 #ifdef signals
51 # error \
52  "The name 'signals' is already defined. You are most likely using the QT library \
53 and using the 'signals' keyword. You can either #include the Qt headers (or any conflicting headers) \
54 *after* the deal.II headers or you can define the 'QT_NO_KEYWORDS' macro and use the 'Q_SIGNALS' macro."
55 #endif
56 
57 // Forward declarations
58 #ifndef DOXYGEN
59 template <int dim, int spacedim>
60 class Manifold;
61 
62 template <int dim>
63 struct CellData;
64 
65 struct SubCellData;
66 
68 {
69  template <int, int>
70  struct Description;
71 }
72 
73 namespace GridTools
74 {
75  template <typename CellIterator>
76  struct PeriodicFacePair;
77 }
78 
79 template <int, int, int>
80 class TriaAccessor;
81 template <int spacedim>
82 class TriaAccessor<0, 1, spacedim>;
83 template <int, int, int>
84 class TriaAccessorBase;
85 
86 namespace internal
87 {
88  namespace TriangulationImplementation
89  {
90  class TriaFaces;
91 
92  class TriaObjects;
93 
94  template <int, int>
95  class Policy;
96 
102  struct Implementation;
103  struct ImplementationMixedMesh;
104  } // namespace TriangulationImplementation
105 
106  namespace TriaAccessorImplementation
107  {
108  struct Implementation;
109  }
110 } // namespace internal
111 
112 namespace hp
113 {
114  template <int dim, int spacedim>
115  class DoFHandler;
116 }
117 #endif
118 
119 
120 /*------------------------------------------------------------------------*/
121 
122 
123 namespace internal
124 {
129  namespace TriangulationImplementation
130  {
142  template <int dim>
143  struct NumberCache
144  {};
145 
157  template <>
158  struct NumberCache<1>
159  {
163  unsigned int n_levels;
164 
168  unsigned int n_lines;
169 
173  std::vector<unsigned int> n_lines_level;
174 
178  unsigned int n_active_lines;
179 
183  std::vector<unsigned int> n_active_lines_level;
184 
188  NumberCache();
189 
194  std::size_t
195  memory_consumption() const;
196 
202  template <class Archive>
203  void
204  serialize(Archive &ar, const unsigned int version);
205  };
206 
207 
220  template <>
221  struct NumberCache<2> : public NumberCache<1>
222  {
226  unsigned int n_quads;
227 
231  std::vector<unsigned int> n_quads_level;
232 
236  unsigned int n_active_quads;
237 
241  std::vector<unsigned int> n_active_quads_level;
242 
246  NumberCache();
247 
252  std::size_t
253  memory_consumption() const;
254 
260  template <class Archive>
261  void
262  serialize(Archive &ar, const unsigned int version);
263  };
264 
265 
279  template <>
280  struct NumberCache<3> : public NumberCache<2>
281  {
285  unsigned int n_hexes;
286 
290  std::vector<unsigned int> n_hexes_level;
291 
295  unsigned int n_active_hexes;
296 
300  std::vector<unsigned int> n_active_hexes_level;
301 
305  NumberCache();
306 
311  std::size_t
312  memory_consumption() const;
313 
319  template <class Archive>
320  void
321  serialize(Archive &ar, const unsigned int version);
322  };
323  } // namespace TriangulationImplementation
324 } // namespace internal
325 
326 
327 /*------------------------------------------------------------------------*/
328 
329 
1126 template <int dim, int spacedim = dim>
1128 {
1129 private:
1134  using IteratorSelector =
1136 
1137 public:
1143  {
1148  none = 0x0,
1192  limit_level_difference_at_vertices = 0x1,
1213  eliminate_unrefined_islands = 0x2,
1229  patch_level_1 = 0x4,
1253  coarsest_level_1 = 0x8,
1278  allow_anisotropic_smoothing = 0x10,
1311  eliminate_refined_inner_islands = 0x100,
1316  eliminate_refined_boundary_islands = 0x200,
1322  do_not_produce_unrefined_islands = 0x400,
1323 
1328  smoothing_on_refinement =
1329  (limit_level_difference_at_vertices | eliminate_unrefined_islands),
1334  smoothing_on_coarsening =
1335  (eliminate_refined_inner_islands | eliminate_refined_boundary_islands |
1336  do_not_produce_unrefined_islands),
1337 
1343  maximum_smoothing = 0xffff ^ allow_anisotropic_smoothing
1344  };
1345 
1362 
1368 
1386 
1400  using face_iterator = TriaIterator<TriaAccessor<dim - 1, dim, spacedim>>;
1401 
1413  using active_face_iterator =
1414  TriaActiveIterator<TriaAccessor<dim - 1, dim, spacedim>>;
1415 
1425 
1438  using active_vertex_iterator =
1440 
1448  using line_iterator = typename IteratorSelector::line_iterator;
1449 
1463  using active_line_iterator = typename IteratorSelector::active_line_iterator;
1464 
1472  using quad_iterator = typename IteratorSelector::quad_iterator;
1473 
1487  using active_quad_iterator = typename IteratorSelector::active_quad_iterator;
1488 
1496  using hex_iterator = typename IteratorSelector::hex_iterator;
1497 
1507  using active_hex_iterator = typename IteratorSelector::active_hex_iterator;
1508 
1528  {
1535  virtual ~DistortedCellList() noexcept override = default;
1536 
1541  std::list<typename Triangulation<dim, spacedim>::cell_iterator>
1543  };
1544 
1548  static const unsigned int dimension = dim;
1549 
1553  static const unsigned int space_dimension = spacedim;
1554 
1569  Triangulation(const MeshSmoothing smooth_grid = none,
1570  const bool check_for_distorted_cells = false);
1571 
1587  Triangulation(const Triangulation<dim, spacedim> &) = delete;
1588 
1596 
1600  Triangulation &
1601  operator=(Triangulation<dim, spacedim> &&tria) noexcept;
1602 
1606  virtual ~Triangulation() override;
1607 
1614  virtual void
1615  clear();
1616 
1621  virtual MPI_Comm
1622  get_communicator() const;
1623 
1629  virtual void
1630  set_mesh_smoothing(const MeshSmoothing mesh_smoothing);
1631 
1635  virtual const MeshSmoothing &
1636  get_mesh_smoothing() const;
1637 
1660  void
1661  set_manifold(const types::manifold_id number,
1662  const Manifold<dim, spacedim> &manifold_object);
1663 
1676  void
1677  reset_manifold(const types::manifold_id manifold_number);
1678 
1690  void
1691  reset_all_manifolds();
1692 
1701  void
1702  set_all_manifold_ids(const types::manifold_id number);
1703 
1712  void
1713  set_all_manifold_ids_on_boundary(const types::manifold_id number);
1714 
1724  void
1725  set_all_manifold_ids_on_boundary(const types::boundary_id b_id,
1726  const types::manifold_id number);
1727 
1739  const Manifold<dim, spacedim> &
1740  get_manifold(const types::manifold_id number) const;
1741 
1754  virtual std::vector<types::boundary_id>
1755  get_boundary_ids() const;
1756 
1769  virtual std::vector<types::manifold_id>
1770  get_manifold_ids() const;
1771 
1798  virtual void
1799  copy_triangulation(const Triangulation<dim, spacedim> &other_tria);
1800 
1848  virtual void
1849  create_triangulation(const std::vector<Point<spacedim>> &vertices,
1850  const std::vector<CellData<dim>> & cells,
1851  const SubCellData & subcelldata);
1852 
1865  virtual void
1868  &construction_data);
1869 
1879  virtual void
1880  create_triangulation_compatibility(
1881  const std::vector<Point<spacedim>> &vertices,
1882  const std::vector<CellData<dim>> & cells,
1883  const SubCellData & subcelldata);
1884 
1891  void
1892  flip_all_direction_flags();
1893 
1905  void
1906  set_all_refine_flags();
1907 
1930  void
1931  refine_global(const unsigned int times = 1);
1932 
1945  void
1946  coarsen_global(const unsigned int times = 1);
1947 
1979  virtual void
1980  execute_coarsening_and_refinement();
1981 
2011  virtual bool
2012  prepare_coarsening_and_refinement();
2013 
2014  /*
2015  * @}
2016  */
2017 
2032  {
2049  CELL_INVALID
2050  };
2051 
2057  template <typename T>
2059  {
2060  using result_type = T;
2061 
2062  template <typename InputIterator>
2063  T
2064  operator()(InputIterator first, InputIterator last) const
2065  {
2066  return std::accumulate(first, last, T());
2067  }
2068  };
2069 
2079  struct Signals
2080  {
2088  boost::signals2::signal<void()> create;
2089 
2097  boost::signals2::signal<void()> pre_refinement;
2098 
2104  boost::signals2::signal<void()> post_refinement;
2105 
2112  boost::signals2::signal<void()> pre_partition;
2113 
2121  boost::signals2::signal<void()> mesh_movement;
2122 
2130  boost::signals2::signal<void(
2131  const typename Triangulation<dim, spacedim>::cell_iterator &cell)>
2133 
2140  boost::signals2::signal<void(
2141  const typename Triangulation<dim, spacedim>::cell_iterator &cell)>
2143 
2150  boost::signals2::signal<void(
2151  const Triangulation<dim, spacedim> &destination_tria)>
2153 
2167  boost::signals2::signal<void()> clear;
2168 
2178  boost::signals2::signal<void()> any_change;
2179 
2205  boost::signals2::signal<unsigned int(const cell_iterator &,
2206  const CellStatus),
2209 
2221  boost::signals2::signal<void()> pre_distributed_refinement;
2222 
2230  boost::signals2::signal<void()> post_p4est_refinement;
2231 
2240  boost::signals2::signal<void()> post_distributed_refinement;
2241 
2252  boost::signals2::signal<void()> pre_distributed_repartition;
2253 
2259  boost::signals2::signal<void()> post_distributed_repartition;
2260 
2267  boost::signals2::signal<void()> pre_distributed_save;
2268 
2274  boost::signals2::signal<void()> post_distributed_save;
2275 
2282  boost::signals2::signal<void()> pre_distributed_load;
2283 
2289  boost::signals2::signal<void()> post_distributed_load;
2290  };
2291 
2295  mutable Signals signals;
2296 
2297  /*
2298  * @}
2299  */
2300 
2310  void
2311  save_refine_flags(std::ostream &out) const;
2312 
2316  void
2317  save_refine_flags(std::vector<bool> &v) const;
2318 
2322  void
2323  load_refine_flags(std::istream &in);
2324 
2328  void
2329  load_refine_flags(const std::vector<bool> &v);
2330 
2334  void
2335  save_coarsen_flags(std::ostream &out) const;
2336 
2340  void
2341  save_coarsen_flags(std::vector<bool> &v) const;
2342 
2346  void
2347  load_coarsen_flags(std::istream &out);
2348 
2352  void
2353  load_coarsen_flags(const std::vector<bool> &v);
2354 
2359  bool
2360  get_anisotropic_refinement_flag() const;
2361 
2362  /*
2363  * @}
2364  */
2365 
2375  void
2376  clear_user_flags();
2377 
2383  void
2384  save_user_flags(std::ostream &out) const;
2385 
2391  void
2392  save_user_flags(std::vector<bool> &v) const;
2393 
2398  void
2399  load_user_flags(std::istream &in);
2400 
2405  void
2406  load_user_flags(const std::vector<bool> &v);
2407 
2412  void
2413  clear_user_flags_line();
2414 
2419  void
2420  save_user_flags_line(std::ostream &out) const;
2421 
2427  void
2428  save_user_flags_line(std::vector<bool> &v) const;
2429 
2434  void
2435  load_user_flags_line(std::istream &in);
2436 
2441  void
2442  load_user_flags_line(const std::vector<bool> &v);
2443 
2448  void
2449  clear_user_flags_quad();
2450 
2455  void
2456  save_user_flags_quad(std::ostream &out) const;
2457 
2463  void
2464  save_user_flags_quad(std::vector<bool> &v) const;
2465 
2470  void
2471  load_user_flags_quad(std::istream &in);
2472 
2477  void
2478  load_user_flags_quad(const std::vector<bool> &v);
2479 
2480 
2485  void
2486  clear_user_flags_hex();
2487 
2492  void
2493  save_user_flags_hex(std::ostream &out) const;
2494 
2500  void
2501  save_user_flags_hex(std::vector<bool> &v) const;
2502 
2507  void
2508  load_user_flags_hex(std::istream &in);
2509 
2514  void
2515  load_user_flags_hex(const std::vector<bool> &v);
2516 
2522  void
2523  clear_user_data();
2524 
2530  void
2531  save_user_indices(std::vector<unsigned int> &v) const;
2532 
2537  void
2538  load_user_indices(const std::vector<unsigned int> &v);
2539 
2545  void
2546  save_user_pointers(std::vector<void *> &v) const;
2547 
2552  void
2553  load_user_pointers(const std::vector<void *> &v);
2554 
2560  void
2561  save_user_indices_line(std::vector<unsigned int> &v) const;
2562 
2567  void
2568  load_user_indices_line(const std::vector<unsigned int> &v);
2569 
2575  void
2576  save_user_indices_quad(std::vector<unsigned int> &v) const;
2577 
2582  void
2583  load_user_indices_quad(const std::vector<unsigned int> &v);
2584 
2590  void
2591  save_user_indices_hex(std::vector<unsigned int> &v) const;
2592 
2597  void
2598  load_user_indices_hex(const std::vector<unsigned int> &v);
2604  void
2605  save_user_pointers_line(std::vector<void *> &v) const;
2606 
2611  void
2612  load_user_pointers_line(const std::vector<void *> &v);
2613 
2619  void
2620  save_user_pointers_quad(std::vector<void *> &v) const;
2621 
2626  void
2627  load_user_pointers_quad(const std::vector<void *> &v);
2628 
2634  void
2635  save_user_pointers_hex(std::vector<void *> &v) const;
2636 
2641  void
2642  load_user_pointers_hex(const std::vector<void *> &v);
2643 
2644  /*
2645  * @}
2646  */
2647 
2671  begin(const unsigned int level = 0) const;
2672 
2704  begin_active(const unsigned int level = 0) const;
2705 
2711  end() const;
2712 
2732  end(const unsigned int level) const;
2733 
2754  end_active(const unsigned int level) const;
2755 
2756 
2761  last() const;
2762 
2767  last_active() const;
2768 
2782  create_cell_iterator(const CellId &cell_id) const;
2783 
2799  cell_iterators() const;
2800 
2837  active_cell_iterators() const;
2838 
2855  cell_iterators_on_level(const unsigned int level) const;
2856 
2873  active_cell_iterators_on_level(const unsigned int level) const;
2874 
2875  /*
2876  * @}
2877  */
2878 
2879  /*-------------------------------------------------------------------------*/
2880 
2890  begin_face() const;
2891 
2896  begin_active_face() const;
2897 
2903  end_face() const;
2904 
2924  active_face_iterators() const;
2925 
2926  /*
2927  * @}
2928  */
2929 
2930  /*-------------------------------------------------------------------------*/
2931 
2942  begin_vertex() const;
2943 
2950  begin_active_vertex() const;
2951 
2958  end_vertex() const;
2959 
2960  /*
2961  * @}
2962  */
2963 
2981  unsigned int
2982  n_lines() const;
2983 
2987  unsigned int
2988  n_lines(const unsigned int level) const;
2989 
2993  unsigned int
2994  n_active_lines() const;
2995 
2999  unsigned int
3000  n_active_lines(const unsigned int level) const;
3001 
3005  unsigned int
3006  n_quads() const;
3007 
3011  unsigned int
3012  n_quads(const unsigned int level) const;
3013 
3017  unsigned int
3018  n_active_quads() const;
3019 
3023  unsigned int
3024  n_active_quads(const unsigned int level) const;
3025 
3029  unsigned int
3030  n_hexs() const;
3031 
3036  unsigned int
3037  n_hexs(const unsigned int level) const;
3038 
3042  unsigned int
3043  n_active_hexs() const;
3044 
3049  unsigned int
3050  n_active_hexs(const unsigned int level) const;
3051 
3056  unsigned int
3057  n_cells() const;
3058 
3063  unsigned int
3064  n_cells(const unsigned int level) const;
3065 
3070  unsigned int
3071  n_active_cells() const;
3072 
3080  virtual types::global_cell_index
3081  n_global_active_cells() const;
3082 
3083 
3088  unsigned int
3089  n_active_cells(const unsigned int level) const;
3090 
3096  unsigned int
3097  n_faces() const;
3098 
3104  unsigned int
3105  n_active_faces() const;
3106 
3124  unsigned int
3125  n_levels() const;
3126 
3133  virtual unsigned int
3134  n_global_levels() const;
3135 
3145  virtual bool
3146  has_hanging_nodes() const;
3147 
3155  unsigned int
3156  n_vertices() const;
3157 
3166  const std::vector<Point<spacedim>> &
3167  get_vertices() const;
3168 
3173  unsigned int
3174  n_used_vertices() const;
3175 
3179  bool
3180  vertex_used(const unsigned int index) const;
3181 
3186  const std::vector<bool> &
3187  get_used_vertices() const;
3188 
3200  unsigned int
3201  max_adjacent_cells() const;
3202 
3209  virtual types::subdomain_id
3210  locally_owned_subdomain() const;
3211 
3222  get_triangulation();
3223 
3229  get_triangulation() const;
3230 
3231 
3232  /*
3233  * @}
3234  */
3235 
3250  unsigned int
3251  n_raw_lines() const;
3252 
3262  unsigned int
3263  n_raw_lines(const unsigned int level) const;
3264 
3274  unsigned int
3275  n_raw_quads() const;
3276 
3286  unsigned int
3287  n_raw_quads(const unsigned int level) const;
3288 
3298  unsigned int
3299  n_raw_hexs(const unsigned int level) const;
3300 
3310  unsigned int
3311  n_raw_cells(const unsigned int level) const;
3312 
3324  unsigned int
3325  n_raw_faces() const;
3326 
3327  /*
3328  * @}
3329  */
3330 
3339  virtual std::size_t
3340  memory_consumption() const;
3341 
3351  template <class Archive>
3352  void
3353  save(Archive &ar, const unsigned int version) const;
3354 
3372  template <class Archive>
3373  void
3374  load(Archive &ar, const unsigned int version);
3375 
3376 
3392  virtual void
3393  add_periodicity(
3394  const std::vector<GridTools::PeriodicFacePair<cell_iterator>> &);
3395 
3399  const std::map<
3400  std::pair<cell_iterator, unsigned int>,
3401  std::pair<std::pair<cell_iterator, unsigned int>, std::bitset<3>>> &
3402  get_periodic_face_map() const;
3403 
3408  const std::vector<ReferenceCell> &
3409  get_reference_cells() const;
3410 
3415  bool
3416  all_reference_cells_are_hyper_cube() const;
3417 
3418 #ifdef DOXYGEN
3419 
3424  template <class Archive>
3425  void
3426  serialize(Archive &archive, const unsigned int version);
3427 #else
3428  // This macro defines the serialize() method that is compatible with
3429  // the templated save() and load() method that have been implemented.
3430  BOOST_SERIALIZATION_SPLIT_MEMBER()
3431 #endif
3432 
3443  DeclException2(ExcInvalidLevel,
3444  int,
3445  int,
3446  << "You are requesting information from refinement level "
3447  << arg1
3448  << " of a triangulation, but this triangulation only has "
3449  << arg2 << " refinement levels. The given level " << arg1
3450  << " must be *less* than " << arg2 << ".");
3458  ExcTriangulationNotEmpty,
3459  int,
3460  int,
3461  << "You are trying to perform an operation on a triangulation "
3462  << "that is only allowed if the triangulation is currently empty. "
3463  << "However, it currently stores " << arg1 << " vertices and has "
3464  << "cells on " << arg2 << " levels.");
3470  DeclException0(ExcGridReadError);
3481  DeclException1(ExcEmptyLevel,
3482  int,
3483  << "You tried to do something on level " << arg1
3484  << ", but this level is empty.");
3490  DeclException0(ExcNonOrientableTriangulation);
3491 
3499  DeclException1(ExcBoundaryIdNotFound,
3501  << "The given boundary_id " << arg1
3502  << " is not defined in this Triangulation!");
3503 
3510  ExcInconsistentCoarseningFlags,
3511  "A cell is flagged for coarsening, but either not all of its siblings "
3512  "are active or flagged for coarsening as well. Please clean up all "
3513  "coarsen flags on your triangulation via "
3514  "Triangulation::prepare_coarsening_and_refinement() beforehand!");
3515 
3516  /*
3517  * @}
3518  */
3519 
3520 protected:
3526 
3531  std::vector<ReferenceCell> reference_cells;
3532 
3546  static void
3547  write_bool_vector(const unsigned int magic_number1,
3548  const std::vector<bool> &v,
3549  const unsigned int magic_number2,
3550  std::ostream & out);
3551 
3556  static void
3557  read_bool_vector(const unsigned int magic_number1,
3558  std::vector<bool> &v,
3559  const unsigned int magic_number2,
3560  std::istream & in);
3561 
3566  void
3567  update_periodic_face_map();
3568 
3572  virtual void
3573  update_reference_cells();
3574 
3575 
3576 private:
3581  std::unique_ptr<
3584 
3591  std::vector<GridTools::PeriodicFacePair<cell_iterator>>
3593 
3598  std::map<std::pair<cell_iterator, unsigned int>,
3599  std::pair<std::pair<cell_iterator, unsigned int>, std::bitset<3>>>
3601 
3616  using raw_face_iterator =
3617  TriaRawIterator<TriaAccessor<dim - 1, dim, spacedim>>;
3618  using raw_vertex_iterator =
3620  using raw_line_iterator = typename IteratorSelector::raw_line_iterator;
3621  using raw_quad_iterator = typename IteratorSelector::raw_quad_iterator;
3622  using raw_hex_iterator = typename IteratorSelector::raw_hex_iterator;
3623 
3629  begin_raw(const unsigned int level = 0) const;
3630 
3636  end_raw(const unsigned int level) const;
3637 
3638  /*
3639  * @}
3640  */
3641 
3654  begin_raw_line(const unsigned int level = 0) const;
3655 
3674  begin_line(const unsigned int level = 0) const;
3675 
3694  begin_active_line(const unsigned int level = 0) const;
3695 
3701  end_line() const;
3702 
3703  /*
3704  * @}
3705  */
3706 
3732  begin_raw_quad(const unsigned int level = 0) const;
3733 
3752  begin_quad(const unsigned int level = 0) const;
3753 
3772  begin_active_quad(const unsigned int level = 0) const;
3773 
3779  end_quad() const;
3780 
3781  /*
3782  * @}
3783  */
3784 
3809  begin_raw_hex(const unsigned int level = 0) const;
3810 
3828  hex_iterator
3829  begin_hex(const unsigned int level = 0) const;
3830 
3849  begin_active_hex(const unsigned int level = 0) const;
3850 
3855  hex_iterator
3856  end_hex() const;
3857 
3858  /*
3859  * @}
3860  */
3861 
3862 
3876  void
3877  clear_despite_subscriptions();
3878 
3882  void
3883  reset_policy();
3884 
3891  void
3892  reset_active_cell_indices();
3893 
3897  void
3898  reset_global_cell_indices();
3899 
3913  DistortedCellList
3914  execute_refinement();
3915 
3922  void
3923  execute_coarsening();
3924 
3929  void
3930  fix_coarsen_flags();
3931 
3945  virtual unsigned int
3946  coarse_cell_id_to_coarse_cell_index(
3948 
3949 
3962  virtual types::coarse_cell_id
3963  coarse_cell_index_to_coarse_cell_id(
3964  const unsigned int coarse_cell_index) const;
3965 
3970  std::vector<
3971  std::unique_ptr<::internal::TriangulationImplementation::TriaLevel>>
3973 
3979  std::unique_ptr<::internal::TriangulationImplementation::TriaFaces>
3981 
3982 
3986  std::vector<Point<spacedim>> vertices;
3987 
3991  std::vector<bool> vertices_used;
3992 
3997  std::map<types::manifold_id, std::unique_ptr<const Manifold<dim, spacedim>>>
3999 
4004 
4005 
4011 
4022 
4037  std::unique_ptr<std::map<unsigned int, types::boundary_id>>
4039 
4040 
4060  std::unique_ptr<std::map<unsigned int, types::manifold_id>>
4062 
4063  // make a couple of classes friends
4064  template <int, int, int>
4065  friend class TriaAccessorBase;
4066  template <int, int, int>
4067  friend class TriaAccessor;
4068  friend class TriaAccessor<0, 1, spacedim>;
4069 
4070  friend class CellAccessor<dim, spacedim>;
4071 
4072  friend struct ::internal::TriaAccessorImplementation::Implementation;
4073 
4074  friend struct ::internal::TriangulationImplementation::Implementation;
4075  friend struct ::internal::TriangulationImplementation::
4076  ImplementationMixedMesh;
4077 
4078  friend class ::internal::TriangulationImplementation::TriaObjects;
4079 
4080  // explicitly check for sensible template arguments, but not on windows
4081  // because MSVC creates bogus warnings during normal compilation
4082 #ifndef DEAL_II_MSVC
4083  static_assert(dim <= spacedim,
4084  "The dimension <dim> of a Triangulation must be less than or "
4085  "equal to the space dimension <spacedim> in which it lives.");
4086 #endif
4087 };
4088 
4089 
4090 #ifndef DOXYGEN
4091 
4092 
4093 
4094 namespace internal
4095 {
4096  namespace TriangulationImplementation
4097  {
4098  template <class Archive>
4099  void
4100  NumberCache<1>::serialize(Archive &ar, const unsigned int)
4101  {
4102  ar &n_levels;
4103  ar &n_lines &n_lines_level;
4104  ar &n_active_lines &n_active_lines_level;
4105  }
4106 
4107 
4108  template <class Archive>
4109  void
4110  NumberCache<2>::serialize(Archive &ar, const unsigned int version)
4111  {
4112  this->NumberCache<1>::serialize(ar, version);
4113 
4114  ar &n_quads &n_quads_level;
4115  ar &n_active_quads &n_active_quads_level;
4116  }
4117 
4118 
4119  template <class Archive>
4120  void
4121  NumberCache<3>::serialize(Archive &ar, const unsigned int version)
4122  {
4123  this->NumberCache<2>::serialize(ar, version);
4124 
4125  ar &n_hexes &n_hexes_level;
4126  ar &n_active_hexes &n_active_hexes_level;
4127  }
4128 
4129  } // namespace TriangulationImplementation
4130 } // namespace internal
4131 
4132 
4133 template <int dim, int spacedim>
4134 inline bool
4135 Triangulation<dim, spacedim>::vertex_used(const unsigned int index) const
4136 {
4137  AssertIndexRange(index, vertices_used.size());
4138  return vertices_used[index];
4139 }
4140 
4141 
4142 
4143 template <int dim, int spacedim>
4144 inline unsigned int
4146 {
4147  return number_cache.n_levels;
4148 }
4149 
4150 template <int dim, int spacedim>
4151 inline unsigned int
4153 {
4154  return number_cache.n_levels;
4155 }
4156 
4157 
4158 template <int dim, int spacedim>
4159 inline unsigned int
4161 {
4162  return vertices.size();
4163 }
4164 
4165 
4166 
4167 template <int dim, int spacedim>
4168 inline const std::vector<Point<spacedim>> &
4170 {
4171  return vertices;
4172 }
4173 
4174 
4175 template <int dim, int spacedim>
4176 template <class Archive>
4177 void
4178 Triangulation<dim, spacedim>::save(Archive &ar, const unsigned int) const
4179 {
4180  // as discussed in the documentation, do not store the signals as
4181  // well as boundary and manifold description but everything else
4182  ar &smooth_grid;
4183 
4184  unsigned int n_levels = levels.size();
4185  ar & n_levels;
4186  for (const auto &level : levels)
4187  ar &level;
4188 
4189  // boost dereferences a nullptr when serializing a nullptr
4190  // at least up to 1.65.1. This causes problems with clang-5.
4191  // Therefore, work around it.
4192  bool faces_is_nullptr = (faces.get() == nullptr);
4193  ar & faces_is_nullptr;
4194  if (!faces_is_nullptr)
4195  ar &faces;
4196 
4197  ar &vertices;
4198  ar &vertices_used;
4199 
4200  ar &anisotropic_refinement;
4201  ar &number_cache;
4202 
4203  ar &check_for_distorted_cells;
4204 
4205  if (dim == 1)
4206  {
4207  ar &vertex_to_boundary_id_map_1d;
4208  ar &vertex_to_manifold_id_map_1d;
4209  }
4210 }
4211 
4212 
4213 
4214 template <int dim, int spacedim>
4215 template <class Archive>
4216 void
4217 Triangulation<dim, spacedim>::load(Archive &ar, const unsigned int)
4218 {
4219  // clear previous content. this also calls the respective signal
4220  clear();
4221 
4222  // as discussed in the documentation, do not store the signals as
4223  // well as boundary and manifold description but everything else
4224  ar &smooth_grid;
4225 
4226  unsigned int size;
4227  ar & size;
4228  levels.resize(size);
4229  for (auto &level_ : levels)
4230  {
4231  std::unique_ptr<internal::TriangulationImplementation::TriaLevel> level;
4232  ar & level;
4233  level_ = std::move(level);
4234  }
4235 
4236  // Workaround for nullptr, see in save().
4237  bool faces_is_nullptr = true;
4238  ar & faces_is_nullptr;
4239  if (!faces_is_nullptr)
4240  ar &faces;
4241 
4242  ar &vertices;
4243  ar &vertices_used;
4244 
4245  ar &anisotropic_refinement;
4246  ar &number_cache;
4247 
4248  // the levels do not serialize the active_cell_indices because
4249  // they are easy enough to rebuild upon re-loading data. do
4250  // this here. don't forget to first resize the fields appropriately
4251  {
4252  for (auto &level : levels)
4253  {
4254  level->active_cell_indices.resize(level->refine_flags.size());
4255  level->global_active_cell_indices.resize(level->refine_flags.size());
4256  level->global_level_cell_indices.resize(level->refine_flags.size());
4257  }
4258  reset_active_cell_indices();
4259  reset_global_cell_indices();
4260  }
4261 
4262  reset_policy();
4263 
4264  bool my_check_for_distorted_cells;
4265  ar & my_check_for_distorted_cells;
4266 
4267  Assert(my_check_for_distorted_cells == check_for_distorted_cells,
4268  ExcMessage("The triangulation loaded into here must have the "
4269  "same setting with regard to reporting distorted "
4270  "cell as the one previously stored."));
4271 
4272  if (dim == 1)
4273  {
4274  ar &vertex_to_boundary_id_map_1d;
4275  ar &vertex_to_manifold_id_map_1d;
4276  }
4277 
4278  // trigger the create signal to indicate
4279  // that new content has been imported into
4280  // the triangulation
4281  signals.create();
4282 }
4283 
4284 
4285 
4286 template <int dim, int spacedim>
4287 inline unsigned int
4290 {
4291  return coarse_cell_id;
4292 }
4293 
4294 
4295 
4296 template <int dim, int spacedim>
4297 inline types::coarse_cell_id
4299  const unsigned int coarse_cell_index) const
4300 {
4301  return coarse_cell_index;
4302 }
4303 
4304 
4305 
4306 /* -------------- declaration of explicit specializations ------------- */
4307 
4308 template <>
4309 unsigned int
4311 template <>
4312 unsigned int
4313 Triangulation<1, 1>::n_quads(const unsigned int level) const;
4314 template <>
4315 unsigned int
4316 Triangulation<1, 1>::n_raw_quads(const unsigned int level) const;
4317 template <>
4318 unsigned int
4319 Triangulation<2, 2>::n_raw_quads(const unsigned int level) const;
4320 template <>
4321 unsigned int
4322 Triangulation<3, 3>::n_raw_quads(const unsigned int level) const;
4323 template <>
4324 unsigned int
4326 template <>
4327 unsigned int
4328 Triangulation<1, 1>::n_active_quads(const unsigned int level) const;
4329 template <>
4330 unsigned int
4332 template <>
4333 unsigned int
4334 Triangulation<1, 1>::n_raw_hexs(const unsigned int level) const;
4335 template <>
4336 unsigned int
4337 Triangulation<3, 3>::n_raw_hexs(const unsigned int level) const;
4338 template <>
4339 unsigned int
4341 template <>
4342 unsigned int
4344 template <>
4345 unsigned int
4346 Triangulation<3, 3>::n_active_hexs(const unsigned int) const;
4347 template <>
4348 unsigned int
4349 Triangulation<3, 3>::n_hexs(const unsigned int level) const;
4350 
4351 template <>
4352 unsigned int
4354 
4355 
4356 // -------------------------------------------------------------------
4357 // -- Explicit specializations for codimension one grids
4358 
4359 
4360 template <>
4361 unsigned int
4363 template <>
4364 unsigned int
4365 Triangulation<1, 2>::n_quads(const unsigned int level) const;
4366 template <>
4367 unsigned int
4368 Triangulation<1, 2>::n_raw_quads(const unsigned int level) const;
4369 template <>
4370 unsigned int
4371 Triangulation<2, 3>::n_raw_quads(const unsigned int level) const;
4372 template <>
4373 unsigned int
4374 Triangulation<1, 2>::n_raw_hexs(const unsigned int level) const;
4375 template <>
4376 unsigned int
4377 Triangulation<1, 2>::n_active_quads(const unsigned int level) const;
4378 template <>
4379 unsigned int
4381 template <>
4382 unsigned int
4384 
4385 // -------------------------------------------------------------------
4386 // -- Explicit specializations for codimension two grids
4387 
4388 template <>
4389 unsigned int
4391 template <>
4392 unsigned int
4393 Triangulation<1, 3>::n_quads(const unsigned int level) const;
4394 template <>
4395 unsigned int
4396 Triangulation<1, 3>::n_raw_quads(const unsigned int level) const;
4397 template <>
4398 unsigned int
4399 Triangulation<2, 3>::n_raw_quads(const unsigned int level) const;
4400 template <>
4401 unsigned int
4402 Triangulation<1, 3>::n_raw_hexs(const unsigned int level) const;
4403 template <>
4404 unsigned int
4405 Triangulation<1, 3>::n_active_quads(const unsigned int level) const;
4406 template <>
4407 unsigned int
4409 template <>
4410 unsigned int
4412 
4413 template <>
4414 bool
4416 template <>
4417 bool
4419 template <>
4420 bool
4422 
4423 
4424 extern template class Triangulation<1, 1>;
4425 extern template class Triangulation<1, 2>;
4426 extern template class Triangulation<1, 3>;
4427 extern template class Triangulation<2, 2>;
4428 extern template class Triangulation<2, 3>;
4429 extern template class Triangulation<3, 3>;
4430 
4431 #endif // DOXYGEN
4432 
4434 
4435 // Include tria_accessor.h here, so that it is possible for an end
4436 // user to use the iterators of Triangulation<dim> directly without
4437 // the need to include tria_accessor.h separately. (Otherwise the
4438 // iterators are an 'opaque' or 'incomplete' type.)
4440 
4441 #endif
boost::signals2::signal< void(const Triangulation< dim, spacedim > &destination_tria)> copy
Definition: tria.h:2152
::internal::TriangulationImplementation::NumberCache< dim > number_cache
Definition: tria.h:4021
virtual unsigned int coarse_cell_id_to_coarse_cell_index(const types::coarse_cell_id coarse_cell_id) const
boost::signals2::signal< void()> post_refinement
Definition: tria.h:2104
unsigned int n_vertices() const
boost::signals2::signal< void(const typename Triangulation< dim, spacedim >::cell_iterator &cell)> pre_coarsening_on_cell
Definition: tria.h:2132
#define DeclException2(Exception2, type1, type2, outsequence)
Definition: exceptions.h:538
boost::signals2::signal< void()> post_distributed_repartition
Definition: tria.h:2259
typename IteratorSelector::line_iterator line_iterator
Definition: tria.h:1448
T operator()(InputIterator first, InputIterator last) const
Definition: tria.h:2064
#define DEAL_II_DEPRECATED_EARLY
Definition: config.h:166
MeshSmoothing smooth_grid
Definition: tria.h:3525
typename IteratorSelector::raw_line_iterator raw_line_iterator
Definition: tria.h:3620
std::vector< Point< spacedim > > vertices
Definition: tria.h:3986
boost::signals2::signal< void()> post_p4est_refinement
Definition: tria.h:2230
std::map< types::manifold_id, std::unique_ptr< const Manifold< dim, spacedim > > > manifold
Definition: tria.h:3998
typename IteratorSelector::hex_iterator hex_iterator
Definition: tria.h:1496
typename IteratorSelector::active_line_iterator active_line_iterator
Definition: tria.h:1463
boost::signals2::signal< void()> pre_distributed_refinement
Definition: tria.h:2221
bool anisotropic_refinement
Definition: tria.h:4003
#define AssertIndexRange(index, range)
Definition: exceptions.h:1691
std::unique_ptr< ::internal::TriangulationImplementation::Policy< dim, spacedim > > policy
Definition: tria.h:3583
std::vector< GridTools::PeriodicFacePair< cell_iterator > > periodic_face_pairs_level_0
Definition: tria.h:3592
std::vector< ReferenceCell > reference_cells
Definition: tria.h:3531
unsigned int n_active_hexs() const
Definition: tria.cc:13181
static ::ExceptionBase & ExcFacesHaveNoLevel()
unsigned int n_levels() const
void create_triangulation(Triangulation< dim, dim > &tria, const AdditionalData &additional_data=AdditionalData())
virtual bool prepare_coarsening_and_refinement()
Definition: tria.cc:14144
static ::ExceptionBase & ExcMessage(std::string arg1)
boost::signals2::signal< void()> pre_refinement
Definition: tria.h:2097
const bool check_for_distorted_cells
Definition: tria.h:4010
#define DeclException1(Exception1, type1, outsequence)
Definition: exceptions.h:515
static const char T
unsigned int n_raw_quads() const
Definition: tria.cc:13117
#define Assert(cond, exc)
Definition: exceptions.h:1466
Signals signals
Definition: tria.h:2295
std::vector< std::unique_ptr<::internal::TriangulationImplementation::TriaLevel > > levels
Definition: tria.h:3972
boost::signals2::signal< void()> clear
Definition: tria.h:2167
unsigned int n_raw_hexs(const unsigned int level) const
Definition: tria.cc:13173
unsigned int max_adjacent_cells() const
Definition: tria.cc:13290
void load(Archive &ar, const unsigned int version)
std::list< typename Triangulation< dim, spacedim >::cell_iterator > distorted_cells
Definition: tria.h:1542
unsigned int n_quads() const
Definition: tria.cc:13069
#define DeclExceptionMsg(Exception, defaulttext)
Definition: exceptions.h:493
std::unique_ptr< std::map< unsigned int, types::manifold_id > > vertex_to_manifold_id_map_1d
Definition: tria.h:4061
std::vector< bool > vertices_used
Definition: tria.h:3991
#define DeclException0(Exception0)
Definition: exceptions.h:470
virtual types::coarse_cell_id coarse_cell_index_to_coarse_cell_id(const unsigned int coarse_cell_index) const
boost::signals2::signal< void(const typename Triangulation< dim, spacedim >::cell_iterator &cell)> post_refinement_on_cell
Definition: tria.h:2142
typename IteratorSelector::active_quad_iterator active_quad_iterator
Definition: tria.h:1487
const std::vector< Point< spacedim > > & get_vertices() const
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:396
boost::signals2::signal< void()> mesh_movement
Definition: tria.h:2121
unsigned int level
Definition: grid_out.cc:4590
typename IteratorSelector::raw_quad_iterator raw_quad_iterator
Definition: tria.h:3621
VectorType::value_type * end(VectorType &V)
std::unique_ptr<::internal::TriangulationImplementation::TriaFaces > faces
Definition: tria.h:3980
Point< 3 > vertices[4]
boost::signals2::signal< void()> pre_distributed_save
Definition: tria.h:2267
void save(Archive &ar, const unsigned int version) const
unsigned int n_active_cells(const internal::TriangulationImplementation::NumberCache< 1 > &c)
Definition: tria.cc:12662
typename IteratorSelector::quad_iterator quad_iterator
Definition: tria.h:1472
TriangulationBase< dim, spacedim > Triangulation
Definition: tria_base.h:396
boost::signals2::signal< void()> create
Definition: tria.h:2088
std::unique_ptr< std::map< unsigned int, types::boundary_id > > vertex_to_boundary_id_map_1d
Definition: tria.h:4038
unsigned int n_hexs() const
Definition: tria.cc:13155
Definition: hp.h:117
unsigned int n_active_quads() const
Definition: tria.cc:13136
unsigned int n_cells(const internal::TriangulationImplementation::NumberCache< 1 > &c)
Definition: tria.cc:12655
Definition: cell_id.h:70
Point< 2 > first
Definition: grid_out.cc:4587
boost::signals2::signal< void()> pre_partition
Definition: tria.h:2112
typename IteratorSelector::active_hex_iterator active_hex_iterator
Definition: tria.h:1507
boost::signals2::signal< void()> post_distributed_save
Definition: tria.h:2274
std::vector< unsigned int > n_active_hexes_level
Definition: tria.h:300
std::map< std::pair< cell_iterator, unsigned int >, std::pair< std::pair< cell_iterator, unsigned int >, std::bitset< 3 > > > periodic_face_map
Definition: tria.h:3600
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:395
virtual unsigned int n_global_levels() const
VectorType::value_type * begin(VectorType &V)
typename IteratorSelector::raw_hex_iterator raw_hex_iterator
Definition: tria.h:3622
boost::signals2::signal< unsigned int(const cell_iterator &, const CellStatus), CellWeightSum< unsigned int > > cell_weight
Definition: tria.h:2208
boost::signals2::signal< void()> pre_distributed_load
Definition: tria.h:2282
std::vector< unsigned int > n_active_lines_level
Definition: tria.h:183
std::vector< unsigned int > n_active_quads_level
Definition: tria.h:241
boost::signals2::signal< void()> post_distributed_load
Definition: tria.h:2289
global_cell_index coarse_cell_id
Definition: types.h:114
boost::signals2::signal< void()> pre_distributed_repartition
Definition: tria.h:2252
bool vertex_used(const unsigned int index) const
boost::signals2::signal< void()> any_change
Definition: tria.h:2178
std::enable_if< std::is_fundamental< T >::value, std::size_t >::type memory_consumption(const T &t)
boost::signals2::signal< void()> post_distributed_refinement
Definition: tria.h:2240