Reference documentation for deal.II version Git 53084d8c6a 2020-10-21 00:34:33 -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 
31 
32 #include <boost/serialization/map.hpp>
33 #include <boost/serialization/split_member.hpp>
34 #include <boost/serialization/unique_ptr.hpp>
35 #include <boost/serialization/vector.hpp>
36 #include <boost/signals2.hpp>
37 
38 #include <bitset>
39 #include <functional>
40 #include <list>
41 #include <map>
42 #include <memory>
43 #include <numeric>
44 #include <vector>
45 
46 
48 
49 #ifdef signals
50 # error \
51  "The name 'signals' is already defined. You are most likely using the QT library \
52 and using the 'signals' keyword. You can either #include the Qt headers (or any conflicting headers) \
53 *after* the deal.II headers or you can define the 'QT_NO_KEYWORDS' macro and use the 'Q_SIGNALS' macro."
54 #endif
55 
56 // Forward declarations
57 #ifndef DOXYGEN
58 template <int dim, int spacedim>
59 class Manifold;
60 
61 template <int dim>
62 struct CellData;
63 
64 struct SubCellData;
65 
67 {
68  template <int, int>
69  struct Description;
70 }
71 
72 namespace GridTools
73 {
74  template <typename CellIterator>
75  struct PeriodicFacePair;
76 }
77 
78 template <int, int, int>
79 class TriaAccessor;
80 template <int spacedim>
81 class TriaAccessor<0, 1, spacedim>;
82 template <int, int, int>
83 class TriaAccessorBase;
84 
85 namespace internal
86 {
87  namespace TriangulationImplementation
88  {
89  class TriaFaces;
90 
91  class TriaObjects;
92 
98  struct Implementation;
99  } // namespace TriangulationImplementation
100 
101  namespace TriaAccessorImplementation
102  {
103  struct Implementation;
104  }
105 } // namespace internal
106 
107 namespace hp
108 {
109  template <int dim, int spacedim>
110  class DoFHandler;
111 }
112 #endif
113 
114 
115 /*------------------------------------------------------------------------*/
116 
117 
118 namespace internal
119 {
124  namespace TriangulationImplementation
125  {
137  template <int dim>
138  struct NumberCache
139  {};
140 
152  template <>
153  struct NumberCache<1>
154  {
158  unsigned int n_levels;
159 
163  unsigned int n_lines;
164 
168  std::vector<unsigned int> n_lines_level;
169 
173  unsigned int n_active_lines;
174 
178  std::vector<unsigned int> n_active_lines_level;
179 
183  NumberCache();
184 
189  std::size_t
190  memory_consumption() const;
191 
196  template <class Archive>
197  void
198  serialize(Archive &ar, const unsigned int version);
199  };
200 
201 
214  template <>
215  struct NumberCache<2> : public NumberCache<1>
216  {
220  unsigned int n_quads;
221 
225  std::vector<unsigned int> n_quads_level;
226 
230  unsigned int n_active_quads;
231 
235  std::vector<unsigned int> n_active_quads_level;
236 
240  NumberCache();
241 
246  std::size_t
247  memory_consumption() const;
248 
253  template <class Archive>
254  void
255  serialize(Archive &ar, const unsigned int version);
256  };
257 
258 
272  template <>
273  struct NumberCache<3> : public NumberCache<2>
274  {
278  unsigned int n_hexes;
279 
283  std::vector<unsigned int> n_hexes_level;
284 
288  unsigned int n_active_hexes;
289 
293  std::vector<unsigned int> n_active_hexes_level;
294 
298  NumberCache();
299 
304  std::size_t
305  memory_consumption() const;
306 
311  template <class Archive>
312  void
313  serialize(Archive &ar, const unsigned int version);
314  };
315  } // namespace TriangulationImplementation
316 } // namespace internal
317 
318 
319 /*------------------------------------------------------------------------*/
320 
321 
1116 template <int dim, int spacedim = dim>
1118 {
1119 private:
1124  using IteratorSelector =
1126 
1127 public:
1133  {
1138  none = 0x0,
1182  limit_level_difference_at_vertices = 0x1,
1203  eliminate_unrefined_islands = 0x2,
1219  patch_level_1 = 0x4,
1243  coarsest_level_1 = 0x8,
1268  allow_anisotropic_smoothing = 0x10,
1301  eliminate_refined_inner_islands = 0x100,
1306  eliminate_refined_boundary_islands = 0x200,
1312  do_not_produce_unrefined_islands = 0x400,
1313 
1318  smoothing_on_refinement =
1319  (limit_level_difference_at_vertices | eliminate_unrefined_islands),
1324  smoothing_on_coarsening =
1325  (eliminate_refined_inner_islands | eliminate_refined_boundary_islands |
1326  do_not_produce_unrefined_islands),
1327 
1333  maximum_smoothing = 0xffff ^ allow_anisotropic_smoothing
1334  };
1335 
1352 
1358 
1376 
1390  using face_iterator = TriaIterator<TriaAccessor<dim - 1, dim, spacedim>>;
1391 
1403  using active_face_iterator =
1404  TriaActiveIterator<TriaAccessor<dim - 1, dim, spacedim>>;
1405 
1415 
1428  using active_vertex_iterator =
1430 
1438  using line_iterator = typename IteratorSelector::line_iterator;
1439 
1453  using active_line_iterator = typename IteratorSelector::active_line_iterator;
1454 
1462  using quad_iterator = typename IteratorSelector::quad_iterator;
1463 
1477  using active_quad_iterator = typename IteratorSelector::active_quad_iterator;
1478 
1486  using hex_iterator = typename IteratorSelector::hex_iterator;
1487 
1497  using active_hex_iterator = typename IteratorSelector::active_hex_iterator;
1498 
1518  {
1525  virtual ~DistortedCellList() noexcept override = default;
1526 
1531  std::list<typename Triangulation<dim, spacedim>::cell_iterator>
1533  };
1534 
1538  static const unsigned int dimension = dim;
1539 
1543  static const unsigned int space_dimension = spacedim;
1544 
1559  Triangulation(const MeshSmoothing smooth_grid = none,
1560  const bool check_for_distorted_cells = false);
1561 
1577  Triangulation(const Triangulation<dim, spacedim> &) = delete;
1578 
1586 
1590  Triangulation &
1591  operator=(Triangulation<dim, spacedim> &&tria) noexcept;
1592 
1596  virtual ~Triangulation() override;
1597 
1604  virtual void
1605  clear();
1606 
1612  virtual void
1613  set_mesh_smoothing(const MeshSmoothing mesh_smoothing);
1614 
1618  virtual const MeshSmoothing &
1619  get_mesh_smoothing() const;
1620 
1643  void
1644  set_manifold(const types::manifold_id number,
1645  const Manifold<dim, spacedim> &manifold_object);
1646 
1659  void
1660  reset_manifold(const types::manifold_id manifold_number);
1661 
1673  void
1674  reset_all_manifolds();
1675 
1684  void
1685  set_all_manifold_ids(const types::manifold_id number);
1686 
1695  void
1696  set_all_manifold_ids_on_boundary(const types::manifold_id number);
1697 
1707  void
1708  set_all_manifold_ids_on_boundary(const types::boundary_id b_id,
1709  const types::manifold_id number);
1710 
1722  const Manifold<dim, spacedim> &
1723  get_manifold(const types::manifold_id number) const;
1724 
1737  virtual std::vector<types::boundary_id>
1738  get_boundary_ids() const;
1739 
1752  virtual std::vector<types::manifold_id>
1753  get_manifold_ids() const;
1754 
1781  virtual void
1782  copy_triangulation(const Triangulation<dim, spacedim> &other_tria);
1783 
1829  virtual void
1830  create_triangulation(const std::vector<Point<spacedim>> &vertices,
1831  const std::vector<CellData<dim>> & cells,
1832  const SubCellData & subcelldata);
1833 
1846  virtual void
1849  &construction_data);
1850 
1859  virtual void
1860  create_triangulation_compatibility(
1861  const std::vector<Point<spacedim>> &vertices,
1862  const std::vector<CellData<dim>> & cells,
1863  const SubCellData & subcelldata);
1864 
1871  void
1872  flip_all_direction_flags();
1873 
1885  void
1886  set_all_refine_flags();
1887 
1910  void
1911  refine_global(const unsigned int times = 1);
1912 
1925  void
1926  coarsen_global(const unsigned int times = 1);
1927 
1959  virtual void
1960  execute_coarsening_and_refinement();
1961 
1991  virtual bool
1992  prepare_coarsening_and_refinement();
1993 
1994  /*
1995  * @}
1996  */
1997 
2012  {
2029  CELL_INVALID
2030  };
2031 
2037  template <typename T>
2039  {
2040  using result_type = T;
2041 
2042  template <typename InputIterator>
2043  T
2044  operator()(InputIterator first, InputIterator last) const
2045  {
2046  return std::accumulate(first, last, T());
2047  }
2048  };
2049 
2059  struct Signals
2060  {
2068  boost::signals2::signal<void()> create;
2069 
2077  boost::signals2::signal<void()> pre_refinement;
2078 
2084  boost::signals2::signal<void()> post_refinement;
2085 
2092  boost::signals2::signal<void()> pre_partition;
2093 
2101  boost::signals2::signal<void()> mesh_movement;
2102 
2110  boost::signals2::signal<void(
2111  const typename Triangulation<dim, spacedim>::cell_iterator &cell)>
2113 
2120  boost::signals2::signal<void(
2121  const typename Triangulation<dim, spacedim>::cell_iterator &cell)>
2123 
2130  boost::signals2::signal<void(
2131  const Triangulation<dim, spacedim> &destination_tria)>
2133 
2147  boost::signals2::signal<void()> clear;
2148 
2158  boost::signals2::signal<void()> any_change;
2159 
2185  boost::signals2::signal<unsigned int(const cell_iterator &,
2186  const CellStatus),
2189 
2201  boost::signals2::signal<void()> pre_distributed_refinement;
2202 
2211  boost::signals2::signal<void()> post_distributed_refinement;
2212 
2223  boost::signals2::signal<void()> pre_distributed_repartition;
2224 
2230  boost::signals2::signal<void()> post_distributed_repartition;
2231 
2238  boost::signals2::signal<void()> pre_distributed_save;
2239 
2245  boost::signals2::signal<void()> post_distributed_save;
2246 
2253  boost::signals2::signal<void()> pre_distributed_load;
2254 
2260  boost::signals2::signal<void()> post_distributed_load;
2261  };
2262 
2266  mutable Signals signals;
2267 
2268  /*
2269  * @}
2270  */
2271 
2281  void
2282  save_refine_flags(std::ostream &out) const;
2283 
2287  void
2288  save_refine_flags(std::vector<bool> &v) const;
2289 
2293  void
2294  load_refine_flags(std::istream &in);
2295 
2299  void
2300  load_refine_flags(const std::vector<bool> &v);
2301 
2305  void
2306  save_coarsen_flags(std::ostream &out) const;
2307 
2311  void
2312  save_coarsen_flags(std::vector<bool> &v) const;
2313 
2317  void
2318  load_coarsen_flags(std::istream &out);
2319 
2323  void
2324  load_coarsen_flags(const std::vector<bool> &v);
2325 
2330  bool
2331  get_anisotropic_refinement_flag() const;
2332 
2333  /*
2334  * @}
2335  */
2336 
2346  void
2347  clear_user_flags();
2348 
2354  void
2355  save_user_flags(std::ostream &out) const;
2356 
2362  void
2363  save_user_flags(std::vector<bool> &v) const;
2364 
2369  void
2370  load_user_flags(std::istream &in);
2371 
2376  void
2377  load_user_flags(const std::vector<bool> &v);
2378 
2383  void
2384  clear_user_flags_line();
2385 
2390  void
2391  save_user_flags_line(std::ostream &out) const;
2392 
2398  void
2399  save_user_flags_line(std::vector<bool> &v) const;
2400 
2405  void
2406  load_user_flags_line(std::istream &in);
2407 
2412  void
2413  load_user_flags_line(const std::vector<bool> &v);
2414 
2419  void
2420  clear_user_flags_quad();
2421 
2426  void
2427  save_user_flags_quad(std::ostream &out) const;
2428 
2434  void
2435  save_user_flags_quad(std::vector<bool> &v) const;
2436 
2441  void
2442  load_user_flags_quad(std::istream &in);
2443 
2448  void
2449  load_user_flags_quad(const std::vector<bool> &v);
2450 
2451 
2456  void
2457  clear_user_flags_hex();
2458 
2463  void
2464  save_user_flags_hex(std::ostream &out) const;
2465 
2471  void
2472  save_user_flags_hex(std::vector<bool> &v) const;
2473 
2478  void
2479  load_user_flags_hex(std::istream &in);
2480 
2485  void
2486  load_user_flags_hex(const std::vector<bool> &v);
2487 
2493  void
2494  clear_user_data();
2495 
2501  void
2502  save_user_indices(std::vector<unsigned int> &v) const;
2503 
2508  void
2509  load_user_indices(const std::vector<unsigned int> &v);
2510 
2516  void
2517  save_user_pointers(std::vector<void *> &v) const;
2518 
2523  void
2524  load_user_pointers(const std::vector<void *> &v);
2525 
2531  void
2532  save_user_indices_line(std::vector<unsigned int> &v) const;
2533 
2538  void
2539  load_user_indices_line(const std::vector<unsigned int> &v);
2540 
2546  void
2547  save_user_indices_quad(std::vector<unsigned int> &v) const;
2548 
2553  void
2554  load_user_indices_quad(const std::vector<unsigned int> &v);
2555 
2561  void
2562  save_user_indices_hex(std::vector<unsigned int> &v) const;
2563 
2568  void
2569  load_user_indices_hex(const std::vector<unsigned int> &v);
2575  void
2576  save_user_pointers_line(std::vector<void *> &v) const;
2577 
2582  void
2583  load_user_pointers_line(const std::vector<void *> &v);
2584 
2590  void
2591  save_user_pointers_quad(std::vector<void *> &v) const;
2592 
2597  void
2598  load_user_pointers_quad(const std::vector<void *> &v);
2599 
2605  void
2606  save_user_pointers_hex(std::vector<void *> &v) const;
2607 
2612  void
2613  load_user_pointers_hex(const std::vector<void *> &v);
2614 
2615  /*
2616  * @}
2617  */
2618 
2642  begin(const unsigned int level = 0) const;
2643 
2675  begin_active(const unsigned int level = 0) const;
2676 
2682  end() const;
2683 
2703  end(const unsigned int level) const;
2704 
2725  end_active(const unsigned int level) const;
2726 
2727 
2732  last() const;
2733 
2738  last_active() const;
2739 
2755  cell_iterators() const;
2756 
2793  active_cell_iterators() const;
2794 
2811  cell_iterators_on_level(const unsigned int level) const;
2812 
2829  active_cell_iterators_on_level(const unsigned int level) const;
2830 
2831  /*
2832  * @}
2833  */
2834 
2835  /*-------------------------------------------------------------------------*/
2836 
2846  begin_face() const;
2847 
2852  begin_active_face() const;
2853 
2859  end_face() const;
2860 
2880  active_face_iterators() const;
2881 
2882  /*
2883  * @}
2884  */
2885 
2886  /*-------------------------------------------------------------------------*/
2887 
2898  begin_vertex() const;
2899 
2906  begin_active_vertex() const;
2907 
2914  end_vertex() const;
2915 
2916  /*
2917  * @}
2918  */
2919 
2937  unsigned int
2938  n_lines() const;
2939 
2943  unsigned int
2944  n_lines(const unsigned int level) const;
2945 
2949  unsigned int
2950  n_active_lines() const;
2951 
2955  unsigned int
2956  n_active_lines(const unsigned int level) const;
2957 
2961  unsigned int
2962  n_quads() const;
2963 
2967  unsigned int
2968  n_quads(const unsigned int level) const;
2969 
2973  unsigned int
2974  n_active_quads() const;
2975 
2979  unsigned int
2980  n_active_quads(const unsigned int level) const;
2981 
2985  unsigned int
2986  n_hexs() const;
2987 
2992  unsigned int
2993  n_hexs(const unsigned int level) const;
2994 
2998  unsigned int
2999  n_active_hexs() const;
3000 
3005  unsigned int
3006  n_active_hexs(const unsigned int level) const;
3007 
3012  unsigned int
3013  n_cells() const;
3014 
3019  unsigned int
3020  n_cells(const unsigned int level) const;
3021 
3026  unsigned int
3027  n_active_cells() const;
3028 
3036  virtual types::global_cell_index
3037  n_global_active_cells() const;
3038 
3039 
3044  unsigned int
3045  n_active_cells(const unsigned int level) const;
3046 
3052  unsigned int
3053  n_faces() const;
3054 
3060  unsigned int
3061  n_active_faces() const;
3062 
3080  unsigned int
3081  n_levels() const;
3082 
3089  virtual unsigned int
3090  n_global_levels() const;
3091 
3101  virtual bool
3102  has_hanging_nodes() const;
3103 
3111  unsigned int
3112  n_vertices() const;
3113 
3122  const std::vector<Point<spacedim>> &
3123  get_vertices() const;
3124 
3129  unsigned int
3130  n_used_vertices() const;
3131 
3135  bool
3136  vertex_used(const unsigned int index) const;
3137 
3142  const std::vector<bool> &
3143  get_used_vertices() const;
3144 
3156  unsigned int
3157  max_adjacent_cells() const;
3158 
3165  virtual types::subdomain_id
3166  locally_owned_subdomain() const;
3167 
3178  get_triangulation();
3179 
3185  get_triangulation() const;
3186 
3187 
3188  /*
3189  * @}
3190  */
3191 
3206  unsigned int
3207  n_raw_lines() const;
3208 
3218  unsigned int
3219  n_raw_lines(const unsigned int level) const;
3220 
3230  unsigned int
3231  n_raw_quads() const;
3232 
3242  unsigned int
3243  n_raw_quads(const unsigned int level) const;
3244 
3254  unsigned int
3255  n_raw_hexs(const unsigned int level) const;
3256 
3266  unsigned int
3267  n_raw_cells(const unsigned int level) const;
3268 
3280  unsigned int
3281  n_raw_faces() const;
3282 
3283  /*
3284  * @}
3285  */
3286 
3295  virtual std::size_t
3296  memory_consumption() const;
3297 
3306  template <class Archive>
3307  void
3308  save(Archive &ar, const unsigned int version) const;
3309 
3325  template <class Archive>
3326  void
3327  load(Archive &ar, const unsigned int version);
3328 
3329 
3345  virtual void
3346  add_periodicity(
3347  const std::vector<GridTools::PeriodicFacePair<cell_iterator>> &);
3348 
3352  const std::map<
3353  std::pair<cell_iterator, unsigned int>,
3354  std::pair<std::pair<cell_iterator, unsigned int>, std::bitset<3>>> &
3355  get_periodic_face_map() const;
3356 
3357 #ifdef DOXYGEN
3358 
3362  template <class Archive>
3363  void
3364  serialize(Archive &archive, const unsigned int version);
3365 #else
3366  // This macro defines the serialize() method that is compatible with
3367  // the templated save() and load() method that have been implemented.
3368  BOOST_SERIALIZATION_SPLIT_MEMBER()
3369 #endif
3370 
3381  DeclException2(ExcInvalidLevel,
3382  int,
3383  int,
3384  << "You are requesting information from refinement level "
3385  << arg1
3386  << " of a triangulation, but this triangulation only has "
3387  << arg2 << " refinement levels. The given level " << arg1
3388  << " must be *less* than " << arg2 << ".");
3396  ExcTriangulationNotEmpty,
3397  int,
3398  int,
3399  << "You are trying to perform an operation on a triangulation "
3400  << "that is only allowed if the triangulation is currently empty. "
3401  << "However, it currently stores " << arg1 << " vertices and has "
3402  << "cells on " << arg2 << " levels.");
3408  DeclException0(ExcGridReadError);
3419  DeclException1(ExcEmptyLevel,
3420  int,
3421  << "You tried to do something on level " << arg1
3422  << ", but this level is empty.");
3428  DeclException0(ExcNonOrientableTriangulation);
3429 
3437  DeclException1(ExcBoundaryIdNotFound,
3439  << "The given boundary_id " << arg1
3440  << " is not defined in this Triangulation!");
3441 
3448  ExcInconsistentCoarseningFlags,
3449  "A cell is flagged for coarsening, but either not all of its siblings "
3450  "are active or flagged for coarsening as well. Please clean up all "
3451  "coarsen flags on your triangulation via "
3452  "Triangulation::prepare_coarsening_and_refinement() beforehand!");
3453 
3454  /*
3455  * @}
3456  */
3457 
3458 protected:
3464 
3478  static void
3479  write_bool_vector(const unsigned int magic_number1,
3480  const std::vector<bool> &v,
3481  const unsigned int magic_number2,
3482  std::ostream & out);
3483 
3488  static void
3489  read_bool_vector(const unsigned int magic_number1,
3490  std::vector<bool> &v,
3491  const unsigned int magic_number2,
3492  std::istream & in);
3493 
3498  void
3499  update_periodic_face_map();
3500 
3501 
3502 private:
3509  std::vector<GridTools::PeriodicFacePair<cell_iterator>>
3511 
3516  std::map<std::pair<cell_iterator, unsigned int>,
3517  std::pair<std::pair<cell_iterator, unsigned int>, std::bitset<3>>>
3519 
3534  using raw_face_iterator =
3535  TriaRawIterator<TriaAccessor<dim - 1, dim, spacedim>>;
3536  using raw_vertex_iterator =
3538  using raw_line_iterator = typename IteratorSelector::raw_line_iterator;
3539  using raw_quad_iterator = typename IteratorSelector::raw_quad_iterator;
3540  using raw_hex_iterator = typename IteratorSelector::raw_hex_iterator;
3541 
3547  begin_raw(const unsigned int level = 0) const;
3548 
3554  end_raw(const unsigned int level) const;
3555 
3556  /*
3557  * @}
3558  */
3559 
3572  begin_raw_line(const unsigned int level = 0) const;
3573 
3592  begin_line(const unsigned int level = 0) const;
3593 
3612  begin_active_line(const unsigned int level = 0) const;
3613 
3619  end_line() const;
3620 
3621  /*
3622  * @}
3623  */
3624 
3650  begin_raw_quad(const unsigned int level = 0) const;
3651 
3670  begin_quad(const unsigned int level = 0) const;
3671 
3690  begin_active_quad(const unsigned int level = 0) const;
3691 
3697  end_quad() const;
3698 
3699  /*
3700  * @}
3701  */
3702 
3727  begin_raw_hex(const unsigned int level = 0) const;
3728 
3746  hex_iterator
3747  begin_hex(const unsigned int level = 0) const;
3748 
3767  begin_active_hex(const unsigned int level = 0) const;
3768 
3773  hex_iterator
3774  end_hex() const;
3775 
3776  /*
3777  * @}
3778  */
3779 
3780 
3794  void
3795  clear_despite_subscriptions();
3796 
3803  void
3804  reset_active_cell_indices();
3805 
3819  DistortedCellList
3820  execute_refinement();
3821 
3828  void
3829  execute_coarsening();
3830 
3835  void
3836  fix_coarsen_flags();
3837 
3851  virtual unsigned int
3852  coarse_cell_id_to_coarse_cell_index(
3854 
3855 
3868  virtual types::coarse_cell_id
3869  coarse_cell_index_to_coarse_cell_id(
3870  const unsigned int coarse_cell_index) const;
3871 
3876  std::vector<
3877  std::unique_ptr<::internal::TriangulationImplementation::TriaLevel>>
3879 
3885  std::unique_ptr<::internal::TriangulationImplementation::TriaFaces>
3887 
3888 
3892  std::vector<Point<spacedim>> vertices;
3893 
3897  std::vector<bool> vertices_used;
3898 
3903  std::map<types::manifold_id, std::unique_ptr<const Manifold<dim, spacedim>>>
3905 
3910 
3911 
3917 
3928 
3943  std::unique_ptr<std::map<unsigned int, types::boundary_id>>
3945 
3946 
3966  std::unique_ptr<std::map<unsigned int, types::manifold_id>>
3968 
3969  // make a couple of classes friends
3970  template <int, int, int>
3971  friend class TriaAccessorBase;
3972  template <int, int, int>
3973  friend class TriaAccessor;
3974  friend class TriaAccessor<0, 1, spacedim>;
3975 
3976  friend class CellAccessor<dim, spacedim>;
3977 
3978  friend struct ::internal::TriaAccessorImplementation::Implementation;
3979 
3980  friend class hp::DoFHandler<dim, spacedim>;
3981 
3982  friend struct ::internal::TriangulationImplementation::Implementation;
3983 
3984  friend class ::internal::TriangulationImplementation::TriaObjects;
3985 
3986  friend class CellId;
3987 
3988  // explicitly check for sensible template arguments, but not on windows
3989  // because MSVC creates bogus warnings during normal compilation
3990 #ifndef DEAL_II_MSVC
3991  static_assert(dim <= spacedim,
3992  "The dimension <dim> of a Triangulation must be less than or "
3993  "equal to the space dimension <spacedim> in which it lives.");
3994 #endif
3995 };
3996 
3997 
3998 #ifndef DOXYGEN
3999 
4000 
4001 
4002 namespace internal
4003 {
4004  namespace TriangulationImplementation
4005  {
4006  template <class Archive>
4007  void
4008  NumberCache<1>::serialize(Archive &ar, const unsigned int)
4009  {
4010  ar &n_levels;
4011  ar &n_lines &n_lines_level;
4012  ar &n_active_lines &n_active_lines_level;
4013  }
4014 
4015 
4016  template <class Archive>
4017  void
4018  NumberCache<2>::serialize(Archive &ar, const unsigned int version)
4019  {
4020  this->NumberCache<1>::serialize(ar, version);
4021 
4022  ar &n_quads &n_quads_level;
4023  ar &n_active_quads &n_active_quads_level;
4024  }
4025 
4026 
4027  template <class Archive>
4028  void
4029  NumberCache<3>::serialize(Archive &ar, const unsigned int version)
4030  {
4031  this->NumberCache<2>::serialize(ar, version);
4032 
4033  ar &n_hexes &n_hexes_level;
4034  ar &n_active_hexes &n_active_hexes_level;
4035  }
4036 
4037  } // namespace TriangulationImplementation
4038 } // namespace internal
4039 
4040 
4041 template <int dim, int spacedim>
4042 inline bool
4043 Triangulation<dim, spacedim>::vertex_used(const unsigned int index) const
4044 {
4045  AssertIndexRange(index, vertices_used.size());
4046  return vertices_used[index];
4047 }
4048 
4049 
4050 
4051 template <int dim, int spacedim>
4052 inline unsigned int
4054 {
4055  return number_cache.n_levels;
4056 }
4057 
4058 template <int dim, int spacedim>
4059 inline unsigned int
4061 {
4062  return number_cache.n_levels;
4063 }
4064 
4065 
4066 template <int dim, int spacedim>
4067 inline unsigned int
4069 {
4070  return vertices.size();
4071 }
4072 
4073 
4074 
4075 template <int dim, int spacedim>
4076 inline const std::vector<Point<spacedim>> &
4078 {
4079  return vertices;
4080 }
4081 
4082 
4083 template <int dim, int spacedim>
4084 template <class Archive>
4085 void
4086 Triangulation<dim, spacedim>::save(Archive &ar, const unsigned int) const
4087 {
4088  // as discussed in the documentation, do not store the signals as
4089  // well as boundary and manifold description but everything else
4090  ar &smooth_grid;
4091 
4092  unsigned int n_levels = levels.size();
4093  ar & n_levels;
4094  for (const auto &level : levels)
4095  ar &level;
4096 
4097  // boost dereferences a nullptr when serializing a nullptr
4098  // at least up to 1.65.1. This causes problems with clang-5.
4099  // Therefore, work around it.
4100  bool faces_is_nullptr = (faces.get() == nullptr);
4101  ar & faces_is_nullptr;
4102  if (!faces_is_nullptr)
4103  ar &faces;
4104 
4105  ar &vertices;
4106  ar &vertices_used;
4107 
4108  ar &anisotropic_refinement;
4109  ar &number_cache;
4110 
4111  ar &check_for_distorted_cells;
4112 
4113  if (dim == 1)
4114  {
4115  ar &vertex_to_boundary_id_map_1d;
4116  ar &vertex_to_manifold_id_map_1d;
4117  }
4118 }
4119 
4120 
4121 
4122 template <int dim, int spacedim>
4123 template <class Archive>
4124 void
4125 Triangulation<dim, spacedim>::load(Archive &ar, const unsigned int)
4126 {
4127  // clear previous content. this also calls the respective signal
4128  clear();
4129 
4130  // as discussed in the documentation, do not store the signals as
4131  // well as boundary and manifold description but everything else
4132  ar &smooth_grid;
4133 
4134  unsigned int size;
4135  ar & size;
4136  levels.resize(size);
4137  for (auto &level_ : levels)
4138  {
4139  std::unique_ptr<internal::TriangulationImplementation::TriaLevel> level;
4140  ar & level;
4141  level_ = std::move(level);
4142  }
4143 
4144  // Workaround for nullptr, see in save().
4145  bool faces_is_nullptr = true;
4146  ar & faces_is_nullptr;
4147  if (!faces_is_nullptr)
4148  ar &faces;
4149 
4150  ar &vertices;
4151  ar &vertices_used;
4152 
4153  ar &anisotropic_refinement;
4154  ar &number_cache;
4155 
4156  // the levels do not serialize the active_cell_indices because
4157  // they are easy enough to rebuild upon re-loading data. do
4158  // this here. don't forget to first resize the fields appropriately
4159  {
4160  for (auto &level : levels)
4161  level->active_cell_indices.resize(level->refine_flags.size());
4162  reset_active_cell_indices();
4163  }
4164 
4165 
4166  bool my_check_for_distorted_cells;
4167  ar & my_check_for_distorted_cells;
4168 
4169  Assert(my_check_for_distorted_cells == check_for_distorted_cells,
4170  ExcMessage("The triangulation loaded into here must have the "
4171  "same setting with regard to reporting distorted "
4172  "cell as the one previously stored."));
4173 
4174  if (dim == 1)
4175  {
4176  ar &vertex_to_boundary_id_map_1d;
4177  ar &vertex_to_manifold_id_map_1d;
4178  }
4179 
4180  // trigger the create signal to indicate
4181  // that new content has been imported into
4182  // the triangulation
4183  signals.create();
4184 }
4185 
4186 
4187 
4188 template <int dim, int spacedim>
4189 inline unsigned int
4192 {
4193  return coarse_cell_id;
4194 }
4195 
4196 
4197 
4198 template <int dim, int spacedim>
4199 inline types::coarse_cell_id
4201  const unsigned int coarse_cell_index) const
4202 {
4203  return coarse_cell_index;
4204 }
4205 
4206 
4207 
4208 /* -------------- declaration of explicit specializations ------------- */
4209 
4210 template <>
4211 unsigned int
4213 template <>
4214 unsigned int
4215 Triangulation<1, 1>::n_quads(const unsigned int level) const;
4216 template <>
4217 unsigned int
4218 Triangulation<1, 1>::n_raw_quads(const unsigned int level) const;
4219 template <>
4220 unsigned int
4221 Triangulation<2, 2>::n_raw_quads(const unsigned int level) const;
4222 template <>
4223 unsigned int
4224 Triangulation<1, 1>::n_raw_hexs(const unsigned int level) const;
4225 template <>
4226 unsigned int
4227 Triangulation<1, 1>::n_active_quads(const unsigned int level) const;
4228 template <>
4229 unsigned int
4231 template <>
4232 unsigned int
4234 
4235 
4236 // -------------------------------------------------------------------
4237 // -- Explicit specializations for codimension one grids
4238 
4239 
4240 template <>
4241 unsigned int
4243 template <>
4244 unsigned int
4245 Triangulation<1, 2>::n_quads(const unsigned int level) const;
4246 template <>
4247 unsigned int
4248 Triangulation<1, 2>::n_raw_quads(const unsigned int level) const;
4249 template <>
4250 unsigned int
4251 Triangulation<2, 3>::n_raw_quads(const unsigned int level) const;
4252 template <>
4253 unsigned int
4254 Triangulation<1, 2>::n_raw_hexs(const unsigned int level) const;
4255 template <>
4256 unsigned int
4257 Triangulation<1, 2>::n_active_quads(const unsigned int level) const;
4258 template <>
4259 unsigned int
4261 template <>
4262 unsigned int
4264 
4265 // -------------------------------------------------------------------
4266 // -- Explicit specializations for codimension two grids
4267 
4268 
4269 template <>
4270 unsigned int
4272 template <>
4273 unsigned int
4274 Triangulation<1, 3>::n_quads(const unsigned int level) const;
4275 template <>
4276 unsigned int
4277 Triangulation<1, 3>::n_raw_quads(const unsigned int level) const;
4278 template <>
4279 unsigned int
4280 Triangulation<2, 3>::n_raw_quads(const unsigned int level) const;
4281 template <>
4282 unsigned int
4283 Triangulation<1, 3>::n_raw_hexs(const unsigned int level) const;
4284 template <>
4285 unsigned int
4286 Triangulation<1, 3>::n_active_quads(const unsigned int level) const;
4287 template <>
4288 unsigned int
4290 template <>
4291 unsigned int
4293 
4294 
4295 #endif // DOXYGEN
4296 
4298 
4299 // Include tria_accessor.h here, so that it is possible for an end
4300 // user to use the iterators of Triangulation<dim> directly without
4301 // the need to include tria_accessor.h separately. (Otherwise the
4302 // iterators are an 'opaque' or 'incomplete' type.)
4304 
4305 #endif
boost::signals2::signal< void(const Triangulation< dim, spacedim > &destination_tria)> copy
Definition: tria.h:2132
::internal::TriangulationImplementation::NumberCache< dim > number_cache
Definition: tria.h:3927
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:2084
unsigned int n_vertices() const
boost::signals2::signal< void(const typename Triangulation< dim, spacedim >::cell_iterator &cell)> pre_coarsening_on_cell
Definition: tria.h:2112
#define DeclException2(Exception2, type1, type2, outsequence)
Definition: exceptions.h:538
boost::signals2::signal< void()> post_distributed_repartition
Definition: tria.h:2230
typename IteratorSelector::line_iterator line_iterator
Definition: tria.h:1438
T operator()(InputIterator first, InputIterator last) const
Definition: tria.h:2044
MeshSmoothing smooth_grid
Definition: tria.h:3463
typename IteratorSelector::raw_line_iterator raw_line_iterator
Definition: tria.h:3538
std::vector< Point< spacedim > > vertices
Definition: tria.h:3892
std::map< types::manifold_id, std::unique_ptr< const Manifold< dim, spacedim > > > manifold
Definition: tria.h:3904
typename IteratorSelector::hex_iterator hex_iterator
Definition: tria.h:1486
typename IteratorSelector::active_line_iterator active_line_iterator
Definition: tria.h:1453
boost::signals2::signal< void()> pre_distributed_refinement
Definition: tria.h:2201
bool anisotropic_refinement
Definition: tria.h:3909
#define AssertIndexRange(index, range)
Definition: exceptions.h:1648
std::vector< GridTools::PeriodicFacePair< cell_iterator > > periodic_face_pairs_level_0
Definition: tria.h:3510
static ::ExceptionBase & ExcFacesHaveNoLevel()
unsigned int n_levels() const
void create_triangulation(Triangulation< dim, dim > &tria, const AdditionalData &additional_data=AdditionalData())
static ::ExceptionBase & ExcMessage(std::string arg1)
boost::signals2::signal< void()> pre_refinement
Definition: tria.h:2077
const bool check_for_distorted_cells
Definition: tria.h:3916
#define DeclException1(Exception1, type1, outsequence)
Definition: exceptions.h:515
static const char T
unsigned int n_raw_quads() const
Definition: tria.cc:12221
#define Assert(cond, exc)
Definition: exceptions.h:1423
Signals signals
Definition: tria.h:2266
std::vector< std::unique_ptr<::internal::TriangulationImplementation::TriaLevel > > levels
Definition: tria.h:3878
boost::signals2::signal< void()> clear
Definition: tria.h:2147
unsigned int n_raw_hexs(const unsigned int level) const
Definition: tria.cc:12277
unsigned int max_adjacent_cells() const
Definition: tria.cc:12394
void load(Archive &ar, const unsigned int version)
std::list< typename Triangulation< dim, spacedim >::cell_iterator > distorted_cells
Definition: tria.h:1532
unsigned int n_quads() const
Definition: tria.cc:12173
#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:3967
std::vector< bool > vertices_used
Definition: tria.h:3897
#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:2122
typename IteratorSelector::active_quad_iterator active_quad_iterator
Definition: tria.h:1477
const std::vector< Point< spacedim > > & get_vertices() const
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:369
boost::signals2::signal< void()> mesh_movement
Definition: tria.h:2101
unsigned int level
Definition: grid_out.cc:4338
typename IteratorSelector::raw_quad_iterator raw_quad_iterator
Definition: tria.h:3539
VectorType::value_type * end(VectorType &V)
std::unique_ptr<::internal::TriangulationImplementation::TriaFaces > faces
Definition: tria.h:3886
Point< 3 > vertices[4]
boost::signals2::signal< void()> pre_distributed_save
Definition: tria.h:2238
void save(Archive &ar, const unsigned int version) const
unsigned int n_active_cells(const internal::TriangulationImplementation::NumberCache< 1 > &c)
Definition: tria.cc:11766
typename IteratorSelector::quad_iterator quad_iterator
Definition: tria.h:1462
TriangulationBase< dim, spacedim > Triangulation
Definition: tria_base.h:302
boost::signals2::signal< void()> create
Definition: tria.h:2068
std::unique_ptr< std::map< unsigned int, types::boundary_id > > vertex_to_boundary_id_map_1d
Definition: tria.h:3944
Definition: hp.h:117
unsigned int n_active_quads() const
Definition: tria.cc:12240
unsigned int n_cells(const internal::TriangulationImplementation::NumberCache< 1 > &c)
Definition: tria.cc:11759
Definition: cell_id.h:69
Point< 2 > first
Definition: grid_out.cc:4335
boost::signals2::signal< void()> pre_partition
Definition: tria.h:2092
typename IteratorSelector::active_hex_iterator active_hex_iterator
Definition: tria.h:1497
boost::signals2::signal< void()> post_distributed_save
Definition: tria.h:2245
std::vector< unsigned int > n_active_hexes_level
Definition: tria.h:293
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:3518
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:368
virtual unsigned int n_global_levels() const
VectorType::value_type * begin(VectorType &V)
typename IteratorSelector::raw_hex_iterator raw_hex_iterator
Definition: tria.h:3540
boost::signals2::signal< unsigned int(const cell_iterator &, const CellStatus), CellWeightSum< unsigned int > > cell_weight
Definition: tria.h:2188
boost::signals2::signal< void()> pre_distributed_load
Definition: tria.h:2253
std::vector< unsigned int > n_active_lines_level
Definition: tria.h:178
std::vector< unsigned int > n_active_quads_level
Definition: tria.h:235
boost::signals2::signal< void()> post_distributed_load
Definition: tria.h:2260
global_cell_index coarse_cell_id
Definition: types.h:114
boost::signals2::signal< void()> pre_distributed_repartition
Definition: tria.h:2223
bool vertex_used(const unsigned int index) const
boost::signals2::signal< void()> any_change
Definition: tria.h:2158
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:2211