Reference documentation for deal.II version Git 1d6f7faded 2020-04-08 17:58:29 +0200
\(\newcommand{\vcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\vcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
tria.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 1998 - 2019 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 
22 #include <deal.II/base/geometry_info.h>
23 #include <deal.II/base/iterator_range.h>
24 #include <deal.II/base/point.h>
25 #include <deal.II/base/smartpointer.h>
26 #include <deal.II/base/subscriptor.h>
27 
28 #include <deal.II/grid/tria_description.h>
29 #include <deal.II/grid/tria_iterator_selector.h>
30 
31 #include <boost/serialization/map.hpp>
32 #include <boost/serialization/split_member.hpp>
33 #include <boost/serialization/unique_ptr.hpp>
34 #include <boost/serialization/vector.hpp>
35 #include <boost/signals2.hpp>
36 
37 #include <bitset>
38 #include <functional>
39 #include <list>
40 #include <map>
41 #include <memory>
42 #include <numeric>
43 #include <vector>
44 
45 
46 DEAL_II_NAMESPACE_OPEN
47 
48 // Forward declarations
49 #ifndef DOXYGEN
50 template <int dim, int spacedim>
51 class Manifold;
52 
53 template <int dim>
54 struct CellData;
55 
56 struct SubCellData;
57 
59 {
60  template <int, int>
61  struct Description;
62 }
63 
64 namespace GridTools
65 {
66  template <typename CellIterator>
67  struct PeriodicFacePair;
68 }
69 
70 template <int, int, int>
71 class TriaAccessor;
72 template <int spacedim>
73 class TriaAccessor<0, 1, spacedim>;
74 template <int, int, int>
75 class TriaAccessorBase;
76 
77 namespace internal
78 {
79  namespace TriangulationImplementation
80  {
81  template <int dim>
82  class TriaLevel;
83  template <int dim>
84  class TriaFaces;
85 
86  template <typename>
87  class TriaObjects;
88 
94  struct Implementation;
95  } // namespace TriangulationImplementation
96 
97  namespace TriaAccessorImplementation
98  {
99  struct Implementation;
100  }
101 } // namespace internal
102 
103 namespace hp
104 {
105  template <int dim, int spacedim>
106  class DoFHandler;
107 }
108 #endif
109 
110 
111 /*------------------------------------------------------------------------*/
112 
113 
114 namespace internal
115 {
120  namespace TriangulationImplementation
121  {
135  template <int dim>
136  struct NumberCache
137  {};
138 
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 
216  template <>
217  struct NumberCache<2> : public NumberCache<1>
218  {
222  unsigned int n_quads;
223 
227  std::vector<unsigned int> n_quads_level;
228 
232  unsigned int n_active_quads;
233 
237  std::vector<unsigned int> n_active_quads_level;
238 
242  NumberCache();
243 
248  std::size_t
249  memory_consumption() const;
250 
255  template <class Archive>
256  void
257  serialize(Archive &ar, const unsigned int version);
258  };
259 
260 
276  template <>
277  struct NumberCache<3> : public NumberCache<2>
278  {
282  unsigned int n_hexes;
283 
287  std::vector<unsigned int> n_hexes_level;
288 
292  unsigned int n_active_hexes;
293 
297  std::vector<unsigned int> n_active_hexes_level;
298 
302  NumberCache();
303 
308  std::size_t
309  memory_consumption() const;
310 
315  template <class Archive>
316  void
317  serialize(Archive &ar, const unsigned int version);
318  };
319  } // namespace TriangulationImplementation
320 } // namespace internal
321 
322 
323 /*------------------------------------------------------------------------*/
324 
325 
1108 template <int dim, int spacedim = dim>
1110 {
1111 private:
1116  using IteratorSelector =
1117  ::internal::TriangulationImplementation::Iterators<dim, spacedim>;
1118 
1119 public:
1125  {
1130  none = 0x0,
1174  limit_level_difference_at_vertices = 0x1,
1195  eliminate_unrefined_islands = 0x2,
1211  patch_level_1 = 0x4,
1235  coarsest_level_1 = 0x8,
1260  allow_anisotropic_smoothing = 0x10,
1293  eliminate_refined_inner_islands = 0x100,
1298  eliminate_refined_boundary_islands = 0x200,
1304  do_not_produce_unrefined_islands = 0x400,
1305 
1310  smoothing_on_refinement =
1311  (limit_level_difference_at_vertices | eliminate_unrefined_islands),
1316  smoothing_on_coarsening =
1317  (eliminate_refined_inner_islands | eliminate_refined_boundary_islands |
1318  do_not_produce_unrefined_islands),
1319 
1325  maximum_smoothing = 0xffff ^ allow_anisotropic_smoothing
1326  };
1327 
1344 
1362 
1376  using face_iterator = TriaIterator<TriaAccessor<dim - 1, dim, spacedim>>;
1377 
1389  using active_face_iterator =
1390  TriaActiveIterator<TriaAccessor<dim - 1, dim, spacedim>>;
1391 
1401 
1414  using active_vertex_iterator =
1416 
1424  using line_iterator = typename IteratorSelector::line_iterator;
1425 
1439  using active_line_iterator = typename IteratorSelector::active_line_iterator;
1440 
1448  using quad_iterator = typename IteratorSelector::quad_iterator;
1449 
1463  using active_quad_iterator = typename IteratorSelector::active_quad_iterator;
1464 
1472  using hex_iterator = typename IteratorSelector::hex_iterator;
1473 
1483  using active_hex_iterator = typename IteratorSelector::active_hex_iterator;
1484 
1504  {
1511  virtual ~DistortedCellList() noexcept override = default;
1512 
1517  std::list<typename Triangulation<dim, spacedim>::cell_iterator>
1519  };
1520 
1524  static const unsigned int dimension = dim;
1525 
1529  static const unsigned int space_dimension = spacedim;
1530 
1545  Triangulation(const MeshSmoothing smooth_grid = none,
1546  const bool check_for_distorted_cells = false);
1547 
1563  Triangulation(const Triangulation<dim, spacedim> &) = delete;
1564 
1572 
1576  Triangulation &
1577  operator=(Triangulation<dim, spacedim> &&tria) noexcept;
1578 
1582  virtual ~Triangulation() override;
1583 
1590  virtual void
1591  clear();
1592 
1598  virtual void
1599  set_mesh_smoothing(const MeshSmoothing mesh_smoothing);
1600 
1604  virtual const MeshSmoothing &
1605  get_mesh_smoothing() const;
1606 
1629  void
1630  set_manifold(const types::manifold_id number,
1631  const Manifold<dim, spacedim> &manifold_object);
1632 
1645  void
1646  reset_manifold(const types::manifold_id manifold_number);
1647 
1659  void
1660  reset_all_manifolds();
1661 
1670  void
1671  set_all_manifold_ids(const types::manifold_id number);
1672 
1681  void
1682  set_all_manifold_ids_on_boundary(const types::manifold_id number);
1683 
1693  void
1694  set_all_manifold_ids_on_boundary(const types::boundary_id b_id,
1695  const types::manifold_id number);
1696 
1706  const Manifold<dim, spacedim> &
1707  get_manifold(const types::manifold_id number) const;
1708 
1720  std::vector<types::boundary_id>
1721  get_boundary_ids() const;
1722 
1734  std::vector<types::manifold_id>
1735  get_manifold_ids() const;
1736 
1763  virtual void
1764  copy_triangulation(const Triangulation<dim, spacedim> &other_tria);
1765 
1811  virtual void
1812  create_triangulation(const std::vector<Point<spacedim>> &vertices,
1813  const std::vector<CellData<dim>> & cells,
1814  const SubCellData & subcelldata);
1815 
1825  virtual void
1826  create_triangulation(
1828  &construction_data);
1829 
1838  virtual void
1839  create_triangulation_compatibility(
1840  const std::vector<Point<spacedim>> &vertices,
1841  const std::vector<CellData<dim>> & cells,
1842  const SubCellData & subcelldata);
1843 
1850  void
1851  flip_all_direction_flags();
1852 
1864  void
1865  set_all_refine_flags();
1866 
1881  void
1882  refine_global(const unsigned int times = 1);
1883 
1915  virtual void
1916  execute_coarsening_and_refinement();
1917 
1947  virtual bool
1948  prepare_coarsening_and_refinement();
1949 
1950  /*
1951  * @}
1952  */
1953 
1968  {
1985  CELL_INVALID
1986  };
1987 
1993  template <typename T>
1995  {
1996  using result_type = T;
1997 
1998  template <typename InputIterator>
1999  T
2000  operator()(InputIterator first, InputIterator last) const
2001  {
2002  return std::accumulate(first, last, T());
2003  }
2004  };
2005 
2015  struct Signals
2016  {
2024  boost::signals2::signal<void()> create;
2025 
2033  boost::signals2::signal<void()> pre_refinement;
2034 
2040  boost::signals2::signal<void()> post_refinement;
2041 
2048  boost::signals2::signal<void()> pre_partition;
2049 
2057  boost::signals2::signal<void()> mesh_movement;
2058 
2066  boost::signals2::signal<void(
2067  const typename Triangulation<dim, spacedim>::cell_iterator &cell)>
2069 
2076  boost::signals2::signal<void(
2077  const typename Triangulation<dim, spacedim>::cell_iterator &cell)>
2079 
2086  boost::signals2::signal<void(
2087  const Triangulation<dim, spacedim> &destination_tria)>
2089 
2103  boost::signals2::signal<void()> clear;
2104 
2114  boost::signals2::signal<void()> any_change;
2115 
2139  boost::signals2::signal<unsigned int(const cell_iterator &,
2140  const CellStatus),
2143 
2155  boost::signals2::signal<void()> pre_distributed_refinement;
2156 
2165  boost::signals2::signal<void()> post_distributed_refinement;
2166 
2177  boost::signals2::signal<void()> pre_distributed_repartition;
2178 
2184  boost::signals2::signal<void()> post_distributed_repartition;
2185 
2192  boost::signals2::signal<void()> pre_distributed_save;
2193 
2199  boost::signals2::signal<void()> post_distributed_save;
2200 
2207  boost::signals2::signal<void()> pre_distributed_load;
2208 
2214  boost::signals2::signal<void()> post_distributed_load;
2215  };
2216 
2220  mutable Signals signals;
2221 
2222  /*
2223  * @}
2224  */
2225 
2235  void
2236  save_refine_flags(std::ostream &out) const;
2237 
2241  void
2242  save_refine_flags(std::vector<bool> &v) const;
2243 
2247  void
2248  load_refine_flags(std::istream &in);
2249 
2253  void
2254  load_refine_flags(const std::vector<bool> &v);
2255 
2259  void
2260  save_coarsen_flags(std::ostream &out) const;
2261 
2265  void
2266  save_coarsen_flags(std::vector<bool> &v) const;
2267 
2271  void
2272  load_coarsen_flags(std::istream &out);
2273 
2277  void
2278  load_coarsen_flags(const std::vector<bool> &v);
2279 
2284  bool
2285  get_anisotropic_refinement_flag() const;
2286 
2287  /*
2288  * @}
2289  */
2290 
2300  void
2301  clear_user_flags();
2302 
2308  void
2309  save_user_flags(std::ostream &out) const;
2310 
2316  void
2317  save_user_flags(std::vector<bool> &v) const;
2318 
2323  void
2324  load_user_flags(std::istream &in);
2325 
2330  void
2331  load_user_flags(const std::vector<bool> &v);
2332 
2337  void
2338  clear_user_flags_line();
2339 
2344  void
2345  save_user_flags_line(std::ostream &out) const;
2346 
2352  void
2353  save_user_flags_line(std::vector<bool> &v) const;
2354 
2359  void
2360  load_user_flags_line(std::istream &in);
2361 
2366  void
2367  load_user_flags_line(const std::vector<bool> &v);
2368 
2373  void
2374  clear_user_flags_quad();
2375 
2380  void
2381  save_user_flags_quad(std::ostream &out) const;
2382 
2388  void
2389  save_user_flags_quad(std::vector<bool> &v) const;
2390 
2395  void
2396  load_user_flags_quad(std::istream &in);
2397 
2402  void
2403  load_user_flags_quad(const std::vector<bool> &v);
2404 
2405 
2410  void
2411  clear_user_flags_hex();
2412 
2417  void
2418  save_user_flags_hex(std::ostream &out) const;
2419 
2425  void
2426  save_user_flags_hex(std::vector<bool> &v) const;
2427 
2432  void
2433  load_user_flags_hex(std::istream &in);
2434 
2439  void
2440  load_user_flags_hex(const std::vector<bool> &v);
2441 
2447  void
2448  clear_user_data();
2449 
2455  void
2456  save_user_indices(std::vector<unsigned int> &v) const;
2457 
2462  void
2463  load_user_indices(const std::vector<unsigned int> &v);
2464 
2470  void
2471  save_user_pointers(std::vector<void *> &v) const;
2472 
2477  void
2478  load_user_pointers(const std::vector<void *> &v);
2479 
2485  void
2486  save_user_indices_line(std::vector<unsigned int> &v) const;
2487 
2492  void
2493  load_user_indices_line(const std::vector<unsigned int> &v);
2494 
2500  void
2501  save_user_indices_quad(std::vector<unsigned int> &v) const;
2502 
2507  void
2508  load_user_indices_quad(const std::vector<unsigned int> &v);
2509 
2515  void
2516  save_user_indices_hex(std::vector<unsigned int> &v) const;
2517 
2522  void
2523  load_user_indices_hex(const std::vector<unsigned int> &v);
2529  void
2530  save_user_pointers_line(std::vector<void *> &v) const;
2531 
2536  void
2537  load_user_pointers_line(const std::vector<void *> &v);
2538 
2544  void
2545  save_user_pointers_quad(std::vector<void *> &v) const;
2546 
2551  void
2552  load_user_pointers_quad(const std::vector<void *> &v);
2553 
2559  void
2560  save_user_pointers_hex(std::vector<void *> &v) const;
2561 
2566  void
2567  load_user_pointers_hex(const std::vector<void *> &v);
2568 
2569  /*
2570  * @}
2571  */
2572 
2596  begin(const unsigned int level = 0) const;
2597 
2629  begin_active(const unsigned int level = 0) const;
2630 
2636  end() const;
2637 
2657  end(const unsigned int level) const;
2658 
2679  end_active(const unsigned int level) const;
2680 
2681 
2686  last() const;
2687 
2692  last_active() const;
2693 
2709  cell_iterators() const;
2710 
2747  active_cell_iterators() const;
2748 
2765  cell_iterators_on_level(const unsigned int level) const;
2766 
2783  active_cell_iterators_on_level(const unsigned int level) const;
2784 
2785  /*
2786  * @}
2787  */
2788 
2789  /*-------------------------------------------------------------------------*/
2790 
2800  begin_face() const;
2801 
2806  begin_active_face() const;
2807 
2813  end_face() const;
2814 
2834  active_face_iterators() const;
2835 
2836  /*
2837  * @}
2838  */
2839 
2840  /*-------------------------------------------------------------------------*/
2841 
2852  begin_vertex() const;
2853 
2860  begin_active_vertex() const;
2861 
2868  end_vertex() const;
2869 
2870  /*
2871  * @}
2872  */
2873 
2891  unsigned int
2892  n_lines() const;
2893 
2897  unsigned int
2898  n_lines(const unsigned int level) const;
2899 
2903  unsigned int
2904  n_active_lines() const;
2905 
2909  unsigned int
2910  n_active_lines(const unsigned int level) const;
2911 
2915  unsigned int
2916  n_quads() const;
2917 
2921  unsigned int
2922  n_quads(const unsigned int level) const;
2923 
2927  unsigned int
2928  n_active_quads() const;
2929 
2933  unsigned int
2934  n_active_quads(const unsigned int level) const;
2935 
2939  unsigned int
2940  n_hexs() const;
2941 
2946  unsigned int
2947  n_hexs(const unsigned int level) const;
2948 
2952  unsigned int
2953  n_active_hexs() const;
2954 
2959  unsigned int
2960  n_active_hexs(const unsigned int level) const;
2961 
2966  unsigned int
2967  n_cells() const;
2968 
2973  unsigned int
2974  n_cells(const unsigned int level) const;
2975 
2980  unsigned int
2981  n_active_cells() const;
2982 
2990  virtual types::global_cell_index
2991  n_global_active_cells() const;
2992 
2993 
2998  unsigned int
2999  n_active_cells(const unsigned int level) const;
3000 
3006  unsigned int
3007  n_faces() const;
3008 
3014  unsigned int
3015  n_active_faces() const;
3016 
3034  unsigned int
3035  n_levels() const;
3036 
3043  virtual unsigned int
3044  n_global_levels() const;
3045 
3055  virtual bool
3056  has_hanging_nodes() const;
3057 
3065  unsigned int
3066  n_vertices() const;
3067 
3076  const std::vector<Point<spacedim>> &
3077  get_vertices() const;
3078 
3083  unsigned int
3084  n_used_vertices() const;
3085 
3089  bool
3090  vertex_used(const unsigned int index) const;
3091 
3096  const std::vector<bool> &
3097  get_used_vertices() const;
3098 
3110  unsigned int
3111  max_adjacent_cells() const;
3112 
3119  virtual types::subdomain_id
3120  locally_owned_subdomain() const;
3121 
3132  get_triangulation();
3133 
3139  get_triangulation() const;
3140 
3141 
3142  /*
3143  * @}
3144  */
3145 
3160  unsigned int
3161  n_raw_lines() const;
3162 
3172  unsigned int
3173  n_raw_lines(const unsigned int level) const;
3174 
3184  unsigned int
3185  n_raw_quads() const;
3186 
3196  unsigned int
3197  n_raw_quads(const unsigned int level) const;
3198 
3208  unsigned int
3209  n_raw_hexs(const unsigned int level) const;
3210 
3220  unsigned int
3221  n_raw_cells(const unsigned int level) const;
3222 
3234  unsigned int
3235  n_raw_faces() const;
3236 
3237  /*
3238  * @}
3239  */
3240 
3249  virtual std::size_t
3250  memory_consumption() const;
3251 
3260  template <class Archive>
3261  void
3262  save(Archive &ar, const unsigned int version) const;
3263 
3279  template <class Archive>
3280  void
3281  load(Archive &ar, const unsigned int version);
3282 
3283 
3299  virtual void
3300  add_periodicity(
3301  const std::vector<GridTools::PeriodicFacePair<cell_iterator>> &);
3302 
3306  const std::map<
3307  std::pair<cell_iterator, unsigned int>,
3308  std::pair<std::pair<cell_iterator, unsigned int>, std::bitset<3>>> &
3309  get_periodic_face_map() const;
3310 
3322  virtual unsigned int
3323  coarse_cell_id_to_coarse_cell_index(
3324  const types::coarse_cell_id coarse_cell_id) const;
3325 
3326 
3337  virtual types::coarse_cell_id
3338  coarse_cell_index_to_coarse_cell_id(
3339  const unsigned int coarse_cell_index) const;
3340 
3341 
3342  BOOST_SERIALIZATION_SPLIT_MEMBER()
3343 
3344 
3354  DeclException2(ExcInvalidLevel,
3355  int,
3356  int,
3357  << "You are requesting information from refinement level "
3358  << arg1
3359  << " of a triangulation, but this triangulation only has "
3360  << arg2 << " refinement levels. The given level " << arg1
3361  << " must be *less* than " << arg2 << ".");
3369  ExcTriangulationNotEmpty,
3370  int,
3371  int,
3372  << "You are trying to perform an operation on a triangulation "
3373  << "that is only allowed if the triangulation is currently empty. "
3374  << "However, it currently stores " << arg1 << " vertices and has "
3375  << "cells on " << arg2 << " levels.");
3381  DeclException0(ExcGridReadError);
3392  DeclException1(ExcEmptyLevel,
3393  int,
3394  << "You tried to do something on level " << arg1
3395  << ", but this level is empty.");
3401  DeclException0(ExcNonOrientableTriangulation);
3402 
3410  DeclException1(ExcBoundaryIdNotFound,
3411  types::boundary_id,
3412  << "The given boundary_id " << arg1
3413  << " is not defined in this Triangulation!");
3414 
3421  ExcInconsistentCoarseningFlags,
3422  "A cell is flagged for coarsening, but either not all of its siblings "
3423  "are active or flagged for coarsening as well. Please clean up all "
3424  "coarsen flags on your triangulation via "
3425  "Triangulation::prepare_coarsening_and_refinement() beforehand!");
3426 
3427  /*
3428  * @}
3429  */
3430 
3431 protected:
3436  MeshSmoothing smooth_grid;
3437 
3451  static void
3452  write_bool_vector(const unsigned int magic_number1,
3453  const std::vector<bool> &v,
3454  const unsigned int magic_number2,
3455  std::ostream & out);
3456 
3461  static void
3462  read_bool_vector(const unsigned int magic_number1,
3463  std::vector<bool> &v,
3464  const unsigned int magic_number2,
3465  std::istream & in);
3466 
3471  void
3472  update_periodic_face_map();
3473 
3474 
3475 private:
3482  std::vector<GridTools::PeriodicFacePair<cell_iterator>>
3483  periodic_face_pairs_level_0;
3484 
3489  std::map<std::pair<cell_iterator, unsigned int>,
3490  std::pair<std::pair<cell_iterator, unsigned int>, std::bitset<3>>>
3491  periodic_face_map;
3492 
3507  using raw_face_iterator =
3508  TriaRawIterator<TriaAccessor<dim - 1, dim, spacedim>>;
3509  using raw_vertex_iterator =
3510  TriaRawIterator<::TriaAccessor<0, dim, spacedim>>;
3511  using raw_line_iterator = typename IteratorSelector::raw_line_iterator;
3512  using raw_quad_iterator = typename IteratorSelector::raw_quad_iterator;
3513  using raw_hex_iterator = typename IteratorSelector::raw_hex_iterator;
3514 
3520  begin_raw(const unsigned int level = 0) const;
3521 
3527  end_raw(const unsigned int level) const;
3528 
3529  /*
3530  * @}
3531  */
3532 
3544  raw_line_iterator
3545  begin_raw_line(const unsigned int level = 0) const;
3546 
3565  begin_line(const unsigned int level = 0) const;
3566 
3585  begin_active_line(const unsigned int level = 0) const;
3586 
3592  end_line() const;
3593 
3594  /*
3595  * @}
3596  */
3597 
3622  raw_quad_iterator
3623  begin_raw_quad(const unsigned int level = 0) const;
3624 
3643  begin_quad(const unsigned int level = 0) const;
3644 
3663  begin_active_quad(const unsigned int level = 0) const;
3664 
3670  end_quad() const;
3671 
3672  /*
3673  * @}
3674  */
3675 
3699  raw_hex_iterator
3700  begin_raw_hex(const unsigned int level = 0) const;
3701 
3719  hex_iterator
3720  begin_hex(const unsigned int level = 0) const;
3721 
3740  begin_active_hex(const unsigned int level = 0) const;
3741 
3746  hex_iterator
3747  end_hex() const;
3748 
3749  /*
3750  * @}
3751  */
3752 
3753 
3767  void
3768  clear_despite_subscriptions();
3769 
3776  void
3777  reset_active_cell_indices();
3778 
3792  DistortedCellList
3793  execute_refinement();
3794 
3801  void
3802  execute_coarsening();
3803 
3808  void
3809  fix_coarsen_flags();
3810 
3815  std::vector<std::unique_ptr<
3816  ::internal::TriangulationImplementation::TriaLevel<dim>>>
3817  levels;
3818 
3824  std::unique_ptr<::internal::TriangulationImplementation::TriaFaces<dim>>
3825  faces;
3826 
3827 
3831  std::vector<Point<spacedim>> vertices;
3832 
3836  std::vector<bool> vertices_used;
3837 
3842  std::map<types::manifold_id, std::unique_ptr<const Manifold<dim, spacedim>>>
3843  manifold;
3844 
3848  bool anisotropic_refinement;
3849 
3850 
3855  const bool check_for_distorted_cells;
3856 
3866  ::internal::TriangulationImplementation::NumberCache<dim> number_cache;
3867 
3882  std::unique_ptr<std::map<unsigned int, types::boundary_id>>
3883  vertex_to_boundary_id_map_1d;
3884 
3885 
3905  std::unique_ptr<std::map<unsigned int, types::manifold_id>>
3906  vertex_to_manifold_id_map_1d;
3907 
3908  // make a couple of classes friends
3909  template <int, int, int>
3910  friend class TriaAccessorBase;
3911  template <int, int, int>
3912  friend class TriaAccessor;
3913  friend class TriaAccessor<0, 1, spacedim>;
3914 
3915  friend class CellAccessor<dim, spacedim>;
3916 
3917  friend struct ::internal::TriaAccessorImplementation::Implementation;
3918 
3919  friend class hp::DoFHandler<dim, spacedim>;
3920 
3921  friend struct ::internal::TriangulationImplementation::Implementation;
3922 
3923  template <typename>
3924  friend class ::internal::TriangulationImplementation::TriaObjects;
3925 
3926  // explicitly check for sensible template arguments, but not on windows
3927  // because MSVC creates bogus warnings during normal compilation
3928 #ifndef DEAL_II_MSVC
3929  static_assert(dim <= spacedim,
3930  "The dimension <dim> of a Triangulation must be less than or "
3931  "equal to the space dimension <spacedim> in which it lives.");
3932 #endif
3933 };
3934 
3935 
3936 #ifndef DOXYGEN
3937 
3938 
3939 
3940 namespace internal
3941 {
3942  namespace TriangulationImplementation
3943  {
3944  template <class Archive>
3945  void
3946  NumberCache<1>::serialize(Archive &ar, const unsigned int)
3947  {
3948  ar &n_levels;
3949  ar &n_lines &n_lines_level;
3950  ar &n_active_lines &n_active_lines_level;
3951  }
3952 
3953 
3954  template <class Archive>
3955  void
3956  NumberCache<2>::serialize(Archive &ar, const unsigned int version)
3957  {
3958  this->NumberCache<1>::serialize(ar, version);
3959 
3960  ar &n_quads &n_quads_level;
3961  ar &n_active_quads &n_active_quads_level;
3962  }
3963 
3964 
3965  template <class Archive>
3966  void
3967  NumberCache<3>::serialize(Archive &ar, const unsigned int version)
3968  {
3969  this->NumberCache<2>::serialize(ar, version);
3970 
3971  ar &n_hexes &n_hexes_level;
3972  ar &n_active_hexes &n_active_hexes_level;
3973  }
3974 
3975  } // namespace TriangulationImplementation
3976 } // namespace internal
3977 
3978 
3979 template <int dim, int spacedim>
3980 inline bool
3981 Triangulation<dim, spacedim>::vertex_used(const unsigned int index) const
3982 {
3983  AssertIndexRange(index, vertices_used.size());
3984  return vertices_used[index];
3985 }
3986 
3987 
3988 
3989 template <int dim, int spacedim>
3990 inline unsigned int
3992 {
3993  return number_cache.n_levels;
3994 }
3995 
3996 template <int dim, int spacedim>
3997 inline unsigned int
3999 {
4000  return number_cache.n_levels;
4001 }
4002 
4003 
4004 template <int dim, int spacedim>
4005 inline unsigned int
4007 {
4008  return vertices.size();
4009 }
4010 
4011 
4012 
4013 template <int dim, int spacedim>
4014 inline const std::vector<Point<spacedim>> &
4016 {
4017  return vertices;
4018 }
4019 
4020 
4021 template <int dim, int spacedim>
4022 template <class Archive>
4023 void
4024 Triangulation<dim, spacedim>::save(Archive &ar, const unsigned int) const
4025 {
4026  // as discussed in the documentation, do not store the signals as
4027  // well as boundary and manifold description but everything else
4028  ar &smooth_grid;
4029 
4030  unsigned int n_levels = levels.size();
4031  ar & n_levels;
4032  for (unsigned int i = 0; i < levels.size(); ++i)
4033  ar &levels[i];
4034 
4035  // boost dereferences a nullptr when serializing a nullptr
4036  // at least up to 1.65.1. This causes problems with clang-5.
4037  // Therefore, work around it.
4038  bool faces_is_nullptr = (faces.get() == nullptr);
4039  ar & faces_is_nullptr;
4040  if (!faces_is_nullptr)
4041  ar &faces;
4042 
4043  ar &vertices;
4044  ar &vertices_used;
4045 
4046  ar &anisotropic_refinement;
4047  ar &number_cache;
4048 
4049  ar &check_for_distorted_cells;
4050 
4051  if (dim == 1)
4052  {
4053  ar &vertex_to_boundary_id_map_1d;
4054  ar &vertex_to_manifold_id_map_1d;
4055  }
4056 }
4057 
4058 
4059 
4060 template <int dim, int spacedim>
4061 template <class Archive>
4062 void
4063 Triangulation<dim, spacedim>::load(Archive &ar, const unsigned int)
4064 {
4065  // clear previous content. this also calls the respective signal
4066  clear();
4067 
4068  // as discussed in the documentation, do not store the signals as
4069  // well as boundary and manifold description but everything else
4070  ar &smooth_grid;
4071 
4072  unsigned int size;
4073  ar & size;
4074  levels.resize(size);
4075  for (unsigned int i = 0; i < levels.size(); ++i)
4076  {
4077  std::unique_ptr<internal::TriangulationImplementation::TriaLevel<dim>>
4078  level;
4079  ar &level;
4080  levels[i] = std::move(level);
4081  }
4082 
4083  // Workaround for nullptr, see in save().
4084  bool faces_is_nullptr = true;
4085  ar & faces_is_nullptr;
4086  if (!faces_is_nullptr)
4087  ar &faces;
4088 
4089  ar &vertices;
4090  ar &vertices_used;
4091 
4092  ar &anisotropic_refinement;
4093  ar &number_cache;
4094 
4095  // the levels do not serialize the active_cell_indices because
4096  // they are easy enough to rebuild upon re-loading data. do
4097  // this here. don't forget to first resize the fields appropriately
4098  {
4099  for (unsigned int l = 0; l < levels.size(); ++l)
4100  levels[l]->active_cell_indices.resize(levels[l]->refine_flags.size());
4101  reset_active_cell_indices();
4102  }
4103 
4104 
4105  bool my_check_for_distorted_cells;
4106  ar & my_check_for_distorted_cells;
4107 
4108  Assert(my_check_for_distorted_cells == check_for_distorted_cells,
4109  ExcMessage("The triangulation loaded into here must have the "
4110  "same setting with regard to reporting distorted "
4111  "cell as the one previously stored."));
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  // trigger the create signal to indicate
4120  // that new content has been imported into
4121  // the triangulation
4122  signals.create();
4123 }
4124 
4125 
4126 
4127 template <int dim, int spacedim>
4128 inline unsigned int
4130  const types::coarse_cell_id coarse_cell_id) const
4131 {
4132  return coarse_cell_id;
4133 }
4134 
4135 
4136 
4137 template <int dim, int spacedim>
4138 inline types::coarse_cell_id
4140  const unsigned int coarse_cell_index) const
4141 {
4142  return coarse_cell_index;
4143 }
4144 
4145 
4146 
4147 /* -------------- declaration of explicit specializations ------------- */
4148 
4149 template <>
4150 unsigned int
4151 Triangulation<1, 1>::n_raw_lines(const unsigned int level) const;
4152 template <>
4153 unsigned int
4155 template <>
4156 unsigned int
4157 Triangulation<1, 1>::n_quads(const unsigned int level) const;
4158 template <>
4159 unsigned int
4160 Triangulation<1, 1>::n_raw_quads(const unsigned int level) const;
4161 template <>
4162 unsigned int
4163 Triangulation<2, 2>::n_raw_quads(const unsigned int level) const;
4164 template <>
4165 unsigned int
4166 Triangulation<1, 1>::n_raw_hexs(const unsigned int level) const;
4167 template <>
4168 unsigned int
4169 Triangulation<1, 1>::n_active_quads(const unsigned int level) const;
4170 template <>
4171 unsigned int
4173 template <>
4174 unsigned int
4176 
4177 
4178 // -------------------------------------------------------------------
4179 // -- Explicit specializations for codimension one grids
4180 
4181 
4182 template <>
4183 unsigned int
4184 Triangulation<1, 2>::n_raw_lines(const unsigned int level) const;
4185 template <>
4186 unsigned int
4188 template <>
4189 unsigned int
4190 Triangulation<1, 2>::n_quads(const unsigned int level) const;
4191 template <>
4192 unsigned int
4193 Triangulation<1, 2>::n_raw_quads(const unsigned int level) const;
4194 template <>
4195 unsigned int
4196 Triangulation<2, 3>::n_raw_quads(const unsigned int level) const;
4197 template <>
4198 unsigned int
4199 Triangulation<1, 2>::n_raw_hexs(const unsigned int level) const;
4200 template <>
4201 unsigned int
4202 Triangulation<1, 2>::n_active_quads(const unsigned int level) const;
4203 template <>
4204 unsigned int
4206 template <>
4207 unsigned int
4209 
4210 // -------------------------------------------------------------------
4211 // -- Explicit specializations for codimension two grids
4212 
4213 
4214 template <>
4215 unsigned int
4216 Triangulation<1, 3>::n_raw_lines(const unsigned int level) const;
4217 template <>
4218 unsigned int
4220 template <>
4221 unsigned int
4222 Triangulation<1, 3>::n_quads(const unsigned int level) const;
4223 template <>
4224 unsigned int
4225 Triangulation<1, 3>::n_raw_quads(const unsigned int level) const;
4226 template <>
4227 unsigned int
4228 Triangulation<2, 3>::n_raw_quads(const unsigned int level) const;
4229 template <>
4230 unsigned int
4231 Triangulation<1, 3>::n_raw_hexs(const unsigned int level) const;
4232 template <>
4233 unsigned int
4234 Triangulation<1, 3>::n_active_quads(const unsigned int level) const;
4235 template <>
4236 unsigned int
4238 template <>
4239 unsigned int
4241 
4242 
4243 #endif // DOXYGEN
4244 
4245 DEAL_II_NAMESPACE_CLOSE
4246 
4247 // Include tria_accessor.h here, so that it is possible for an end
4248 // user to use the iterators of Triangulation<dim> directly without
4249 // the need to include tria_accessor.h separately. (Otherwise the
4250 // iterators are an 'opaque' or 'incomplete' type.)
4251 #include <deal.II/grid/tria_accessor.h>
4252 
4253 #endif
boost::signals2::signal< void(const Triangulation< dim, spacedim > &destination_tria)> copy
Definition: tria.h:2088
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:2040
unsigned int n_vertices() const
unsigned int manifold_id
Definition: types.h:140
boost::signals2::signal< void(const typename Triangulation< dim, spacedim >::cell_iterator &cell)> pre_coarsening_on_cell
Definition: tria.h:2068
#define DeclException2(Exception2, type1, type2, outsequence)
Definition: exceptions.h:541
boost::signals2::signal< void()> post_distributed_repartition
Definition: tria.h:2184
typename IteratorSelector::line_iterator line_iterator
Definition: tria.h:1424
unsigned int global_cell_index
Definition: types.h:106
typename IteratorSelector::hex_iterator hex_iterator
Definition: tria.h:1472
typename IteratorSelector::active_line_iterator active_line_iterator
Definition: tria.h:1439
boost::signals2::signal< void()> pre_distributed_refinement
Definition: tria.h:2155
#define AssertIndexRange(index, range)
Definition: exceptions.h:1649
STL namespace.
static ::ExceptionBase & ExcFacesHaveNoLevel()
unsigned int n_levels() const
static ::ExceptionBase & ExcMessage(std::string arg1)
boost::signals2::signal< void()> pre_refinement
Definition: tria.h:2033
unsigned int subdomain_id
Definition: types.h:44
#define DeclException1(Exception1, type1, outsequence)
Definition: exceptions.h:518
Definition: types.h:32
unsigned int n_raw_quads() const
Definition: tria.cc:13121
#define Assert(cond, exc)
Definition: exceptions.h:1419
Signals signals
Definition: tria.h:2220
boost::signals2::signal< void()> clear
Definition: tria.h:2103
::internal::TriangulationImplementation::Iterators< dim, spacedim > IteratorSelector
Definition: tria.h:1117
unsigned int n_raw_hexs(const unsigned int level) const
Definition: tria.cc:13177
unsigned int max_adjacent_cells() const
Definition: tria.cc:13294
void load(Archive &ar, const unsigned int version)
std::list< typename Triangulation< dim, spacedim >::cell_iterator > distorted_cells
Definition: tria.h:1518
unsigned int n_quads() const
Definition: tria.cc:13073
#define DeclExceptionMsg(Exception, defaulttext)
Definition: exceptions.h:496
#define DeclException0(Exception0)
Definition: exceptions.h:473
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:2078
typename IteratorSelector::active_quad_iterator active_quad_iterator
Definition: tria.h:1463
const std::vector< Point< spacedim > > & get_vertices() const
boost::signals2::signal< void()> mesh_movement
Definition: tria.h:2057
unsigned int n_raw_lines() const
Definition: tria.cc:12890
boost::signals2::signal< void()> pre_distributed_save
Definition: tria.h:2192
void save(Archive &ar, const unsigned int version) const
typename IteratorSelector::quad_iterator quad_iterator
Definition: tria.h:1448
boost::signals2::signal< void()> create
Definition: tria.h:2024
Definition: hp.h:117
unsigned int n_active_quads() const
Definition: tria.cc:13140
boost::signals2::signal< void()> pre_partition
Definition: tria.h:2048
typename IteratorSelector::active_hex_iterator active_hex_iterator
Definition: tria.h:1483
boost::signals2::signal< void()> post_distributed_save
Definition: tria.h:2199
std::vector< unsigned int > n_active_hexes_level
Definition: tria.h:297
virtual unsigned int n_global_levels() const
boost::signals2::signal< unsigned int(const cell_iterator &, const CellStatus), CellWeightSum< unsigned int > > cell_weight
Definition: tria.h:2142
boost::signals2::signal< void()> pre_distributed_load
Definition: tria.h:2207
std::vector< unsigned int > n_active_lines_level
Definition: tria.h:178
std::vector< unsigned int > n_active_quads_level
Definition: tria.h:237
boost::signals2::signal< void()> post_distributed_load
Definition: tria.h:2214
global_cell_index coarse_cell_id
Definition: types.h:113
unsigned int boundary_id
Definition: types.h:128
boost::signals2::signal< void()> pre_distributed_repartition
Definition: tria.h:2177
bool vertex_used(const unsigned int index) const
boost::signals2::signal< void()> any_change
Definition: tria.h:2114
boost::signals2::signal< void()> post_distributed_refinement
Definition: tria.h:2165