Reference documentation for deal.II version 9.2.0
\(\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 
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 
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 =
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 
1721  virtual std::vector<types::boundary_id>
1722  get_boundary_ids() const;
1723 
1736  virtual std::vector<types::manifold_id>
1737  get_manifold_ids() const;
1738 
1765  virtual void
1766  copy_triangulation(const Triangulation<dim, spacedim> &other_tria);
1767 
1813  virtual void
1814  create_triangulation(const std::vector<Point<spacedim>> &vertices,
1815  const std::vector<CellData<dim>> & cells,
1816  const SubCellData & subcelldata);
1817 
1827  virtual void
1830  &construction_data);
1831 
1840  virtual void
1841  create_triangulation_compatibility(
1842  const std::vector<Point<spacedim>> &vertices,
1843  const std::vector<CellData<dim>> & cells,
1844  const SubCellData & subcelldata);
1845 
1852  void
1853  flip_all_direction_flags();
1854 
1866  void
1867  set_all_refine_flags();
1868 
1883  void
1884  refine_global(const unsigned int times = 1);
1885 
1917  virtual void
1918  execute_coarsening_and_refinement();
1919 
1949  virtual bool
1950  prepare_coarsening_and_refinement();
1951 
1952  /*
1953  * @}
1954  */
1955 
1970  {
1987  CELL_INVALID
1988  };
1989 
1995  template <typename T>
1997  {
1998  using result_type = T;
1999 
2000  template <typename InputIterator>
2001  T
2002  operator()(InputIterator first, InputIterator last) const
2003  {
2004  return std::accumulate(first, last, T());
2005  }
2006  };
2007 
2017  struct Signals
2018  {
2026  boost::signals2::signal<void()> create;
2027 
2035  boost::signals2::signal<void()> pre_refinement;
2036 
2042  boost::signals2::signal<void()> post_refinement;
2043 
2050  boost::signals2::signal<void()> pre_partition;
2051 
2059  boost::signals2::signal<void()> mesh_movement;
2060 
2068  boost::signals2::signal<void(
2069  const typename Triangulation<dim, spacedim>::cell_iterator &cell)>
2071 
2078  boost::signals2::signal<void(
2079  const typename Triangulation<dim, spacedim>::cell_iterator &cell)>
2081 
2088  boost::signals2::signal<void(
2089  const Triangulation<dim, spacedim> &destination_tria)>
2091 
2105  boost::signals2::signal<void()> clear;
2106 
2116  boost::signals2::signal<void()> any_change;
2117 
2141  boost::signals2::signal<unsigned int(const cell_iterator &,
2142  const CellStatus),
2145 
2157  boost::signals2::signal<void()> pre_distributed_refinement;
2158 
2167  boost::signals2::signal<void()> post_distributed_refinement;
2168 
2179  boost::signals2::signal<void()> pre_distributed_repartition;
2180 
2186  boost::signals2::signal<void()> post_distributed_repartition;
2187 
2194  boost::signals2::signal<void()> pre_distributed_save;
2195 
2201  boost::signals2::signal<void()> post_distributed_save;
2202 
2209  boost::signals2::signal<void()> pre_distributed_load;
2210 
2216  boost::signals2::signal<void()> post_distributed_load;
2217  };
2218 
2222  mutable Signals signals;
2223 
2224  /*
2225  * @}
2226  */
2227 
2237  void
2238  save_refine_flags(std::ostream &out) const;
2239 
2243  void
2244  save_refine_flags(std::vector<bool> &v) const;
2245 
2249  void
2250  load_refine_flags(std::istream &in);
2251 
2255  void
2256  load_refine_flags(const std::vector<bool> &v);
2257 
2261  void
2262  save_coarsen_flags(std::ostream &out) const;
2263 
2267  void
2268  save_coarsen_flags(std::vector<bool> &v) const;
2269 
2273  void
2274  load_coarsen_flags(std::istream &out);
2275 
2279  void
2280  load_coarsen_flags(const std::vector<bool> &v);
2281 
2286  bool
2287  get_anisotropic_refinement_flag() const;
2288 
2289  /*
2290  * @}
2291  */
2292 
2302  void
2303  clear_user_flags();
2304 
2310  void
2311  save_user_flags(std::ostream &out) const;
2312 
2318  void
2319  save_user_flags(std::vector<bool> &v) const;
2320 
2325  void
2326  load_user_flags(std::istream &in);
2327 
2332  void
2333  load_user_flags(const std::vector<bool> &v);
2334 
2339  void
2340  clear_user_flags_line();
2341 
2346  void
2347  save_user_flags_line(std::ostream &out) const;
2348 
2354  void
2355  save_user_flags_line(std::vector<bool> &v) const;
2356 
2361  void
2362  load_user_flags_line(std::istream &in);
2363 
2368  void
2369  load_user_flags_line(const std::vector<bool> &v);
2370 
2375  void
2376  clear_user_flags_quad();
2377 
2382  void
2383  save_user_flags_quad(std::ostream &out) const;
2384 
2390  void
2391  save_user_flags_quad(std::vector<bool> &v) const;
2392 
2397  void
2398  load_user_flags_quad(std::istream &in);
2399 
2404  void
2405  load_user_flags_quad(const std::vector<bool> &v);
2406 
2407 
2412  void
2413  clear_user_flags_hex();
2414 
2419  void
2420  save_user_flags_hex(std::ostream &out) const;
2421 
2427  void
2428  save_user_flags_hex(std::vector<bool> &v) const;
2429 
2434  void
2435  load_user_flags_hex(std::istream &in);
2436 
2441  void
2442  load_user_flags_hex(const std::vector<bool> &v);
2443 
2449  void
2450  clear_user_data();
2451 
2457  void
2458  save_user_indices(std::vector<unsigned int> &v) const;
2459 
2464  void
2465  load_user_indices(const std::vector<unsigned int> &v);
2466 
2472  void
2473  save_user_pointers(std::vector<void *> &v) const;
2474 
2479  void
2480  load_user_pointers(const std::vector<void *> &v);
2481 
2487  void
2488  save_user_indices_line(std::vector<unsigned int> &v) const;
2489 
2494  void
2495  load_user_indices_line(const std::vector<unsigned int> &v);
2496 
2502  void
2503  save_user_indices_quad(std::vector<unsigned int> &v) const;
2504 
2509  void
2510  load_user_indices_quad(const std::vector<unsigned int> &v);
2511 
2517  void
2518  save_user_indices_hex(std::vector<unsigned int> &v) const;
2519 
2524  void
2525  load_user_indices_hex(const std::vector<unsigned int> &v);
2531  void
2532  save_user_pointers_line(std::vector<void *> &v) const;
2533 
2538  void
2539  load_user_pointers_line(const std::vector<void *> &v);
2540 
2546  void
2547  save_user_pointers_quad(std::vector<void *> &v) const;
2548 
2553  void
2554  load_user_pointers_quad(const std::vector<void *> &v);
2555 
2561  void
2562  save_user_pointers_hex(std::vector<void *> &v) const;
2563 
2568  void
2569  load_user_pointers_hex(const std::vector<void *> &v);
2570 
2571  /*
2572  * @}
2573  */
2574 
2598  begin(const unsigned int level = 0) const;
2599 
2631  begin_active(const unsigned int level = 0) const;
2632 
2638  end() const;
2639 
2659  end(const unsigned int level) const;
2660 
2681  end_active(const unsigned int level) const;
2682 
2683 
2688  last() const;
2689 
2694  last_active() const;
2695 
2711  cell_iterators() const;
2712 
2749  active_cell_iterators() const;
2750 
2767  cell_iterators_on_level(const unsigned int level) const;
2768 
2785  active_cell_iterators_on_level(const unsigned int level) const;
2786 
2787  /*
2788  * @}
2789  */
2790 
2791  /*-------------------------------------------------------------------------*/
2792 
2802  begin_face() const;
2803 
2808  begin_active_face() const;
2809 
2815  end_face() const;
2816 
2836  active_face_iterators() const;
2837 
2838  /*
2839  * @}
2840  */
2841 
2842  /*-------------------------------------------------------------------------*/
2843 
2854  begin_vertex() const;
2855 
2862  begin_active_vertex() const;
2863 
2870  end_vertex() const;
2871 
2872  /*
2873  * @}
2874  */
2875 
2893  unsigned int
2894  n_lines() const;
2895 
2899  unsigned int
2900  n_lines(const unsigned int level) const;
2901 
2905  unsigned int
2906  n_active_lines() const;
2907 
2911  unsigned int
2912  n_active_lines(const unsigned int level) const;
2913 
2917  unsigned int
2918  n_quads() const;
2919 
2923  unsigned int
2924  n_quads(const unsigned int level) const;
2925 
2929  unsigned int
2930  n_active_quads() const;
2931 
2935  unsigned int
2936  n_active_quads(const unsigned int level) const;
2937 
2941  unsigned int
2942  n_hexs() const;
2943 
2948  unsigned int
2949  n_hexs(const unsigned int level) const;
2950 
2954  unsigned int
2955  n_active_hexs() const;
2956 
2961  unsigned int
2962  n_active_hexs(const unsigned int level) const;
2963 
2968  unsigned int
2969  n_cells() const;
2970 
2975  unsigned int
2976  n_cells(const unsigned int level) const;
2977 
2982  unsigned int
2983  n_active_cells() const;
2984 
2992  virtual types::global_cell_index
2993  n_global_active_cells() const;
2994 
2995 
3000  unsigned int
3001  n_active_cells(const unsigned int level) const;
3002 
3008  unsigned int
3009  n_faces() const;
3010 
3016  unsigned int
3017  n_active_faces() const;
3018 
3036  unsigned int
3037  n_levels() const;
3038 
3045  virtual unsigned int
3046  n_global_levels() const;
3047 
3057  virtual bool
3058  has_hanging_nodes() const;
3059 
3067  unsigned int
3068  n_vertices() const;
3069 
3078  const std::vector<Point<spacedim>> &
3079  get_vertices() const;
3080 
3085  unsigned int
3086  n_used_vertices() const;
3087 
3091  bool
3092  vertex_used(const unsigned int index) const;
3093 
3098  const std::vector<bool> &
3099  get_used_vertices() const;
3100 
3112  unsigned int
3113  max_adjacent_cells() const;
3114 
3121  virtual types::subdomain_id
3122  locally_owned_subdomain() const;
3123 
3134  get_triangulation();
3135 
3141  get_triangulation() const;
3142 
3143 
3144  /*
3145  * @}
3146  */
3147 
3162  unsigned int
3163  n_raw_lines() const;
3164 
3174  unsigned int
3175  n_raw_lines(const unsigned int level) const;
3176 
3186  unsigned int
3187  n_raw_quads() const;
3188 
3198  unsigned int
3199  n_raw_quads(const unsigned int level) const;
3200 
3210  unsigned int
3211  n_raw_hexs(const unsigned int level) const;
3212 
3222  unsigned int
3223  n_raw_cells(const unsigned int level) const;
3224 
3236  unsigned int
3237  n_raw_faces() const;
3238 
3239  /*
3240  * @}
3241  */
3242 
3251  virtual std::size_t
3252  memory_consumption() const;
3253 
3262  template <class Archive>
3263  void
3264  save(Archive &ar, const unsigned int version) const;
3265 
3281  template <class Archive>
3282  void
3283  load(Archive &ar, const unsigned int version);
3284 
3285 
3301  virtual void
3302  add_periodicity(
3303  const std::vector<GridTools::PeriodicFacePair<cell_iterator>> &);
3304 
3308  const std::map<
3309  std::pair<cell_iterator, unsigned int>,
3310  std::pair<std::pair<cell_iterator, unsigned int>, std::bitset<3>>> &
3311  get_periodic_face_map() const;
3312 
3313 #ifdef DOXYGEN
3314 
3318  template <class Archive>
3319  void
3320  serialize(Archive &archive, const unsigned int version);
3321 #else
3322  // This macro defines the serialize() method that is compatible with
3323  // the templated save() and load() method that have been implemented.
3324  BOOST_SERIALIZATION_SPLIT_MEMBER()
3325 #endif
3326 
3337  DeclException2(ExcInvalidLevel,
3338  int,
3339  int,
3340  << "You are requesting information from refinement level "
3341  << arg1
3342  << " of a triangulation, but this triangulation only has "
3343  << arg2 << " refinement levels. The given level " << arg1
3344  << " must be *less* than " << arg2 << ".");
3352  ExcTriangulationNotEmpty,
3353  int,
3354  int,
3355  << "You are trying to perform an operation on a triangulation "
3356  << "that is only allowed if the triangulation is currently empty. "
3357  << "However, it currently stores " << arg1 << " vertices and has "
3358  << "cells on " << arg2 << " levels.");
3364  DeclException0(ExcGridReadError);
3375  DeclException1(ExcEmptyLevel,
3376  int,
3377  << "You tried to do something on level " << arg1
3378  << ", but this level is empty.");
3384  DeclException0(ExcNonOrientableTriangulation);
3385 
3393  DeclException1(ExcBoundaryIdNotFound,
3395  << "The given boundary_id " << arg1
3396  << " is not defined in this Triangulation!");
3397 
3404  ExcInconsistentCoarseningFlags,
3405  "A cell is flagged for coarsening, but either not all of its siblings "
3406  "are active or flagged for coarsening as well. Please clean up all "
3407  "coarsen flags on your triangulation via "
3408  "Triangulation::prepare_coarsening_and_refinement() beforehand!");
3409 
3410  /*
3411  * @}
3412  */
3413 
3414 protected:
3420 
3434  static void
3435  write_bool_vector(const unsigned int magic_number1,
3436  const std::vector<bool> &v,
3437  const unsigned int magic_number2,
3438  std::ostream & out);
3439 
3444  static void
3445  read_bool_vector(const unsigned int magic_number1,
3446  std::vector<bool> &v,
3447  const unsigned int magic_number2,
3448  std::istream & in);
3449 
3454  void
3455  update_periodic_face_map();
3456 
3457 
3458 private:
3465  std::vector<GridTools::PeriodicFacePair<cell_iterator>>
3467 
3472  std::map<std::pair<cell_iterator, unsigned int>,
3473  std::pair<std::pair<cell_iterator, unsigned int>, std::bitset<3>>>
3475 
3490  using raw_face_iterator =
3491  TriaRawIterator<TriaAccessor<dim - 1, dim, spacedim>>;
3492  using raw_vertex_iterator =
3494  using raw_line_iterator = typename IteratorSelector::raw_line_iterator;
3495  using raw_quad_iterator = typename IteratorSelector::raw_quad_iterator;
3496  using raw_hex_iterator = typename IteratorSelector::raw_hex_iterator;
3497 
3503  begin_raw(const unsigned int level = 0) const;
3504 
3510  end_raw(const unsigned int level) const;
3511 
3512  /*
3513  * @}
3514  */
3515 
3528  begin_raw_line(const unsigned int level = 0) const;
3529 
3548  begin_line(const unsigned int level = 0) const;
3549 
3568  begin_active_line(const unsigned int level = 0) const;
3569 
3575  end_line() const;
3576 
3577  /*
3578  * @}
3579  */
3580 
3606  begin_raw_quad(const unsigned int level = 0) const;
3607 
3626  begin_quad(const unsigned int level = 0) const;
3627 
3646  begin_active_quad(const unsigned int level = 0) const;
3647 
3653  end_quad() const;
3654 
3655  /*
3656  * @}
3657  */
3658 
3683  begin_raw_hex(const unsigned int level = 0) const;
3684 
3702  hex_iterator
3703  begin_hex(const unsigned int level = 0) const;
3704 
3723  begin_active_hex(const unsigned int level = 0) const;
3724 
3729  hex_iterator
3730  end_hex() const;
3731 
3732  /*
3733  * @}
3734  */
3735 
3736 
3750  void
3751  clear_despite_subscriptions();
3752 
3759  void
3760  reset_active_cell_indices();
3761 
3775  DistortedCellList
3776  execute_refinement();
3777 
3784  void
3785  execute_coarsening();
3786 
3791  void
3792  fix_coarsen_flags();
3793 
3807  virtual unsigned int
3808  coarse_cell_id_to_coarse_cell_index(
3810 
3811 
3824  virtual types::coarse_cell_id
3825  coarse_cell_index_to_coarse_cell_id(
3826  const unsigned int coarse_cell_index) const;
3827 
3832  std::vector<std::unique_ptr<
3835 
3841  std::unique_ptr<::internal::TriangulationImplementation::TriaFaces<dim>>
3843 
3844 
3848  std::vector<Point<spacedim>> vertices;
3849 
3853  std::vector<bool> vertices_used;
3854 
3859  std::map<types::manifold_id, std::unique_ptr<const Manifold<dim, spacedim>>>
3861 
3866 
3867 
3873 
3884 
3899  std::unique_ptr<std::map<unsigned int, types::boundary_id>>
3901 
3902 
3922  std::unique_ptr<std::map<unsigned int, types::manifold_id>>
3924 
3925  // make a couple of classes friends
3926  template <int, int, int>
3927  friend class TriaAccessorBase;
3928  template <int, int, int>
3929  friend class TriaAccessor;
3930  friend class TriaAccessor<0, 1, spacedim>;
3931 
3932  friend class CellAccessor<dim, spacedim>;
3933 
3934  friend struct ::internal::TriaAccessorImplementation::Implementation;
3935 
3936  friend class hp::DoFHandler<dim, spacedim>;
3937 
3938  friend struct ::internal::TriangulationImplementation::Implementation;
3939 
3940  template <typename>
3941  friend class ::internal::TriangulationImplementation::TriaObjects;
3942 
3943  friend class CellId;
3944 
3945  // explicitly check for sensible template arguments, but not on windows
3946  // because MSVC creates bogus warnings during normal compilation
3947 #ifndef DEAL_II_MSVC
3948  static_assert(dim <= spacedim,
3949  "The dimension <dim> of a Triangulation must be less than or "
3950  "equal to the space dimension <spacedim> in which it lives.");
3951 #endif
3952 };
3953 
3954 
3955 #ifndef DOXYGEN
3956 
3957 
3958 
3959 namespace internal
3960 {
3961  namespace TriangulationImplementation
3962  {
3963  template <class Archive>
3964  void
3965  NumberCache<1>::serialize(Archive &ar, const unsigned int)
3966  {
3967  ar &n_levels;
3968  ar &n_lines &n_lines_level;
3969  ar &n_active_lines &n_active_lines_level;
3970  }
3971 
3972 
3973  template <class Archive>
3974  void
3975  NumberCache<2>::serialize(Archive &ar, const unsigned int version)
3976  {
3977  this->NumberCache<1>::serialize(ar, version);
3978 
3979  ar &n_quads &n_quads_level;
3980  ar &n_active_quads &n_active_quads_level;
3981  }
3982 
3983 
3984  template <class Archive>
3985  void
3986  NumberCache<3>::serialize(Archive &ar, const unsigned int version)
3987  {
3988  this->NumberCache<2>::serialize(ar, version);
3989 
3990  ar &n_hexes &n_hexes_level;
3991  ar &n_active_hexes &n_active_hexes_level;
3992  }
3993 
3994  } // namespace TriangulationImplementation
3995 } // namespace internal
3996 
3997 
3998 template <int dim, int spacedim>
3999 inline bool
4000 Triangulation<dim, spacedim>::vertex_used(const unsigned int index) const
4001 {
4002  AssertIndexRange(index, vertices_used.size());
4003  return vertices_used[index];
4004 }
4005 
4006 
4007 
4008 template <int dim, int spacedim>
4009 inline unsigned int
4011 {
4012  return number_cache.n_levels;
4013 }
4014 
4015 template <int dim, int spacedim>
4016 inline unsigned int
4018 {
4019  return number_cache.n_levels;
4020 }
4021 
4022 
4023 template <int dim, int spacedim>
4024 inline unsigned int
4026 {
4027  return vertices.size();
4028 }
4029 
4030 
4031 
4032 template <int dim, int spacedim>
4033 inline const std::vector<Point<spacedim>> &
4035 {
4036  return vertices;
4037 }
4038 
4039 
4040 template <int dim, int spacedim>
4041 template <class Archive>
4042 void
4043 Triangulation<dim, spacedim>::save(Archive &ar, const unsigned int) const
4044 {
4045  // as discussed in the documentation, do not store the signals as
4046  // well as boundary and manifold description but everything else
4047  ar &smooth_grid;
4048 
4049  unsigned int n_levels = levels.size();
4050  ar & n_levels;
4051  for (unsigned int i = 0; i < levels.size(); ++i)
4052  ar &levels[i];
4053 
4054  // boost dereferences a nullptr when serializing a nullptr
4055  // at least up to 1.65.1. This causes problems with clang-5.
4056  // Therefore, work around it.
4057  bool faces_is_nullptr = (faces.get() == nullptr);
4058  ar & faces_is_nullptr;
4059  if (!faces_is_nullptr)
4060  ar &faces;
4061 
4062  ar &vertices;
4063  ar &vertices_used;
4064 
4065  ar &anisotropic_refinement;
4066  ar &number_cache;
4067 
4068  ar &check_for_distorted_cells;
4069 
4070  if (dim == 1)
4071  {
4072  ar &vertex_to_boundary_id_map_1d;
4073  ar &vertex_to_manifold_id_map_1d;
4074  }
4075 }
4076 
4077 
4078 
4079 template <int dim, int spacedim>
4080 template <class Archive>
4081 void
4082 Triangulation<dim, spacedim>::load(Archive &ar, const unsigned int)
4083 {
4084  // clear previous content. this also calls the respective signal
4085  clear();
4086 
4087  // as discussed in the documentation, do not store the signals as
4088  // well as boundary and manifold description but everything else
4089  ar &smooth_grid;
4090 
4091  unsigned int size;
4092  ar & size;
4093  levels.resize(size);
4094  for (unsigned int i = 0; i < levels.size(); ++i)
4095  {
4096  std::unique_ptr<internal::TriangulationImplementation::TriaLevel<dim>>
4097  level;
4098  ar &level;
4099  levels[i] = std::move(level);
4100  }
4101 
4102  // Workaround for nullptr, see in save().
4103  bool faces_is_nullptr = true;
4104  ar & faces_is_nullptr;
4105  if (!faces_is_nullptr)
4106  ar &faces;
4107 
4108  ar &vertices;
4109  ar &vertices_used;
4110 
4111  ar &anisotropic_refinement;
4112  ar &number_cache;
4113 
4114  // the levels do not serialize the active_cell_indices because
4115  // they are easy enough to rebuild upon re-loading data. do
4116  // this here. don't forget to first resize the fields appropriately
4117  {
4118  for (unsigned int l = 0; l < levels.size(); ++l)
4119  levels[l]->active_cell_indices.resize(levels[l]->refine_flags.size());
4120  reset_active_cell_indices();
4121  }
4122 
4123 
4124  bool my_check_for_distorted_cells;
4125  ar & my_check_for_distorted_cells;
4126 
4127  Assert(my_check_for_distorted_cells == check_for_distorted_cells,
4128  ExcMessage("The triangulation loaded into here must have the "
4129  "same setting with regard to reporting distorted "
4130  "cell as the one previously stored."));
4131 
4132  if (dim == 1)
4133  {
4134  ar &vertex_to_boundary_id_map_1d;
4135  ar &vertex_to_manifold_id_map_1d;
4136  }
4137 
4138  // trigger the create signal to indicate
4139  // that new content has been imported into
4140  // the triangulation
4141  signals.create();
4142 }
4143 
4144 
4145 
4146 template <int dim, int spacedim>
4147 inline unsigned int
4150 {
4151  return coarse_cell_id;
4152 }
4153 
4154 
4155 
4156 template <int dim, int spacedim>
4157 inline types::coarse_cell_id
4159  const unsigned int coarse_cell_index) const
4160 {
4161  return coarse_cell_index;
4162 }
4163 
4164 
4165 
4166 /* -------------- declaration of explicit specializations ------------- */
4167 
4168 template <>
4169 unsigned int
4170 Triangulation<1, 1>::n_raw_lines(const unsigned int level) const;
4171 template <>
4172 unsigned int
4174 template <>
4175 unsigned int
4176 Triangulation<1, 1>::n_quads(const unsigned int level) const;
4177 template <>
4178 unsigned int
4179 Triangulation<1, 1>::n_raw_quads(const unsigned int level) const;
4180 template <>
4181 unsigned int
4182 Triangulation<2, 2>::n_raw_quads(const unsigned int level) const;
4183 template <>
4184 unsigned int
4185 Triangulation<1, 1>::n_raw_hexs(const unsigned int level) const;
4186 template <>
4187 unsigned int
4188 Triangulation<1, 1>::n_active_quads(const unsigned int level) const;
4189 template <>
4190 unsigned int
4192 template <>
4193 unsigned int
4195 
4196 
4197 // -------------------------------------------------------------------
4198 // -- Explicit specializations for codimension one grids
4199 
4200 
4201 template <>
4202 unsigned int
4203 Triangulation<1, 2>::n_raw_lines(const unsigned int level) const;
4204 template <>
4205 unsigned int
4207 template <>
4208 unsigned int
4209 Triangulation<1, 2>::n_quads(const unsigned int level) const;
4210 template <>
4211 unsigned int
4212 Triangulation<1, 2>::n_raw_quads(const unsigned int level) const;
4213 template <>
4214 unsigned int
4215 Triangulation<2, 3>::n_raw_quads(const unsigned int level) const;
4216 template <>
4217 unsigned int
4218 Triangulation<1, 2>::n_raw_hexs(const unsigned int level) const;
4219 template <>
4220 unsigned int
4221 Triangulation<1, 2>::n_active_quads(const unsigned int level) const;
4222 template <>
4223 unsigned int
4225 template <>
4226 unsigned int
4228 
4229 // -------------------------------------------------------------------
4230 // -- Explicit specializations for codimension two grids
4231 
4232 
4233 template <>
4234 unsigned int
4235 Triangulation<1, 3>::n_raw_lines(const unsigned int level) const;
4236 template <>
4237 unsigned int
4239 template <>
4240 unsigned int
4241 Triangulation<1, 3>::n_quads(const unsigned int level) const;
4242 template <>
4243 unsigned int
4244 Triangulation<1, 3>::n_raw_quads(const unsigned int level) const;
4245 template <>
4246 unsigned int
4247 Triangulation<2, 3>::n_raw_quads(const unsigned int level) const;
4248 template <>
4249 unsigned int
4250 Triangulation<1, 3>::n_raw_hexs(const unsigned int level) const;
4251 template <>
4252 unsigned int
4253 Triangulation<1, 3>::n_active_quads(const unsigned int level) const;
4254 template <>
4255 unsigned int
4257 template <>
4258 unsigned int
4260 
4261 
4262 #endif // DOXYGEN
4263 
4265 
4266 // Include tria_accessor.h here, so that it is possible for an end
4267 // user to use the iterators of Triangulation<dim> directly without
4268 // the need to include tria_accessor.h separately. (Otherwise the
4269 // iterators are an 'opaque' or 'incomplete' type.)
4271 
4272 #endif
boost::signals2::signal< void(const Triangulation< dim, spacedim > &destination_tria)> copy
Definition: tria.h:2090
::internal::TriangulationImplementation::NumberCache< dim > number_cache
Definition: tria.h:3883
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:2042
unsigned int n_vertices() const
boost::signals2::signal< void(const typename Triangulation< dim, spacedim >::cell_iterator &cell)> pre_coarsening_on_cell
Definition: tria.h:2070
#define DeclException2(Exception2, type1, type2, outsequence)
Definition: exceptions.h:541
boost::signals2::signal< void()> post_distributed_repartition
Definition: tria.h:2186
typename IteratorSelector::line_iterator line_iterator
Definition: tria.h:1424
T operator()(InputIterator first, InputIterator last) const
Definition: tria.h:2002
std::vector< GridTools::PeriodicFacePair< cell_iterator > > periodic_face_pairs_level_0
Definition: tria.h:3466
typename IteratorSelector::raw_line_iterator raw_line_iterator
Definition: tria.h:3494
std::vector< Point< spacedim > > vertices
Definition: tria.h:3848
std::map< types::manifold_id, std::unique_ptr< const Manifold< dim, spacedim > > > manifold
Definition: tria.h:3860
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:2157
bool anisotropic_refinement
Definition: tria.h:3865
#define AssertIndexRange(index, range)
Definition: exceptions.h:1649
static ::ExceptionBase & ExcFacesHaveNoLevel()
unsigned int n_levels() const
void create_triangulation(Triangulation< dim, dim > &tria, const AdditionalData &additional_data=AdditionalData())
std::unique_ptr<::internal::TriangulationImplementation::TriaFaces< dim > > faces
Definition: tria.h:3842
static ::ExceptionBase & ExcMessage(std::string arg1)
boost::signals2::signal< void()> pre_refinement
Definition: tria.h:2035
const bool check_for_distorted_cells
Definition: tria.h:3872
#define DeclException1(Exception1, type1, outsequence)
Definition: exceptions.h:518
static const char T
unsigned int n_raw_quads() const
Definition: tria.cc:13123
#define Assert(cond, exc)
Definition: exceptions.h:1419
Signals signals
Definition: tria.h:2222
boost::signals2::signal< void()> clear
Definition: tria.h:2105
unsigned int n_raw_hexs(const unsigned int level) const
Definition: tria.cc:13179
unsigned int max_adjacent_cells() const
Definition: tria.cc:13296
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:13075
#define DeclExceptionMsg(Exception, defaulttext)
Definition: exceptions.h:496
std::unique_ptr< std::map< unsigned int, types::manifold_id > > vertex_to_manifold_id_map_1d
Definition: tria.h:3923
std::vector< bool > vertices_used
Definition: tria.h:3853
#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:2080
typename IteratorSelector::active_quad_iterator active_quad_iterator
Definition: tria.h:1463
const std::vector< Point< spacedim > > & get_vertices() const
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:359
boost::signals2::signal< void()> mesh_movement
Definition: tria.h:2059
unsigned int level
Definition: grid_out.cc:4355
typename IteratorSelector::raw_quad_iterator raw_quad_iterator
Definition: tria.h:3495
VectorType::value_type * end(VectorType &V)
Point< 3 > vertices[4]
unsigned int n_raw_lines() const
Definition: tria.cc:12892
boost::signals2::signal< void()> pre_distributed_save
Definition: tria.h:2194
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:3474
void save(Archive &ar, const unsigned int version) const
unsigned int n_active_cells(const internal::TriangulationImplementation::NumberCache< 1 > &c)
Definition: tria.cc:12625
typename IteratorSelector::quad_iterator quad_iterator
Definition: tria.h:1448
TriangulationBase< dim, spacedim > Triangulation
Definition: tria_base.h:302
boost::signals2::signal< void()> create
Definition: tria.h:2026
std::unique_ptr< std::map< unsigned int, types::boundary_id > > vertex_to_boundary_id_map_1d
Definition: tria.h:3900
std::vector< std::unique_ptr< ::internal::TriangulationImplementation::TriaLevel< dim > > > levels
Definition: tria.h:3834
Definition: hp.h:117
unsigned int n_active_quads() const
Definition: tria.cc:13142
unsigned int n_cells(const internal::TriangulationImplementation::NumberCache< 1 > &c)
Definition: tria.cc:12618
Definition: cell_id.h:69
Point< 2 > first
Definition: grid_out.cc:4352
boost::signals2::signal< void()> pre_partition
Definition: tria.h:2050
typename IteratorSelector::active_hex_iterator active_hex_iterator
Definition: tria.h:1483
boost::signals2::signal< void()> post_distributed_save
Definition: tria.h:2201
std::vector< unsigned int > n_active_hexes_level
Definition: tria.h:297
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:358
virtual unsigned int n_global_levels() const
VectorType::value_type * begin(VectorType &V)
typename IteratorSelector::raw_hex_iterator raw_hex_iterator
Definition: tria.h:3496
MeshSmoothing smooth_grid
Definition: tria.h:3419
boost::signals2::signal< unsigned int(const cell_iterator &, const CellStatus), CellWeightSum< unsigned int > > cell_weight
Definition: tria.h:2144
boost::signals2::signal< void()> pre_distributed_load
Definition: tria.h:2209
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:2216
global_cell_index coarse_cell_id
Definition: types.h:114
boost::signals2::signal< void()> pre_distributed_repartition
Definition: tria.h:2179
bool vertex_used(const unsigned int index) const
boost::signals2::signal< void()> any_change
Definition: tria.h:2116
std::enable_if< std::is_fundamental< T >::value, std::size_t >::type memory_consumption(const T &t)
Tensor< 2, dim, Number > l(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
boost::signals2::signal< void()> post_distributed_refinement
Definition: tria.h:2167