Reference documentation for deal.II version Git 040c6ad7d4 2020-09-26 18:01:03 +0200
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
tria.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 
1103 template <int dim, int spacedim = dim>
1105 {
1106 private:
1111  using IteratorSelector =
1113 
1114 public:
1120  {
1125  none = 0x0,
1169  limit_level_difference_at_vertices = 0x1,
1190  eliminate_unrefined_islands = 0x2,
1206  patch_level_1 = 0x4,
1230  coarsest_level_1 = 0x8,
1255  allow_anisotropic_smoothing = 0x10,
1288  eliminate_refined_inner_islands = 0x100,
1293  eliminate_refined_boundary_islands = 0x200,
1299  do_not_produce_unrefined_islands = 0x400,
1300 
1305  smoothing_on_refinement =
1306  (limit_level_difference_at_vertices | eliminate_unrefined_islands),
1311  smoothing_on_coarsening =
1312  (eliminate_refined_inner_islands | eliminate_refined_boundary_islands |
1313  do_not_produce_unrefined_islands),
1314 
1320  maximum_smoothing = 0xffff ^ allow_anisotropic_smoothing
1321  };
1322 
1339 
1345 
1363 
1377  using face_iterator = TriaIterator<TriaAccessor<dim - 1, dim, spacedim>>;
1378 
1390  using active_face_iterator =
1391  TriaActiveIterator<TriaAccessor<dim - 1, dim, spacedim>>;
1392 
1402 
1415  using active_vertex_iterator =
1417 
1425  using line_iterator = typename IteratorSelector::line_iterator;
1426 
1440  using active_line_iterator = typename IteratorSelector::active_line_iterator;
1441 
1449  using quad_iterator = typename IteratorSelector::quad_iterator;
1450 
1464  using active_quad_iterator = typename IteratorSelector::active_quad_iterator;
1465 
1473  using hex_iterator = typename IteratorSelector::hex_iterator;
1474 
1484  using active_hex_iterator = typename IteratorSelector::active_hex_iterator;
1485 
1505  {
1512  virtual ~DistortedCellList() noexcept override = default;
1513 
1518  std::list<typename Triangulation<dim, spacedim>::cell_iterator>
1520  };
1521 
1525  static const unsigned int dimension = dim;
1526 
1530  static const unsigned int space_dimension = spacedim;
1531 
1546  Triangulation(const MeshSmoothing smooth_grid = none,
1547  const bool check_for_distorted_cells = false);
1548 
1564  Triangulation(const Triangulation<dim, spacedim> &) = delete;
1565 
1573 
1577  Triangulation &
1578  operator=(Triangulation<dim, spacedim> &&tria) noexcept;
1579 
1583  virtual ~Triangulation() override;
1584 
1591  virtual void
1592  clear();
1593 
1599  virtual void
1600  set_mesh_smoothing(const MeshSmoothing mesh_smoothing);
1601 
1605  virtual const MeshSmoothing &
1606  get_mesh_smoothing() const;
1607 
1630  void
1631  set_manifold(const types::manifold_id number,
1632  const Manifold<dim, spacedim> &manifold_object);
1633 
1646  void
1647  reset_manifold(const types::manifold_id manifold_number);
1648 
1660  void
1661  reset_all_manifolds();
1662 
1671  void
1672  set_all_manifold_ids(const types::manifold_id number);
1673 
1682  void
1683  set_all_manifold_ids_on_boundary(const types::manifold_id number);
1684 
1694  void
1695  set_all_manifold_ids_on_boundary(const types::boundary_id b_id,
1696  const types::manifold_id number);
1697 
1709  const Manifold<dim, spacedim> &
1710  get_manifold(const types::manifold_id number) const;
1711 
1724  virtual std::vector<types::boundary_id>
1725  get_boundary_ids() const;
1726 
1739  virtual std::vector<types::manifold_id>
1740  get_manifold_ids() const;
1741 
1768  virtual void
1769  copy_triangulation(const Triangulation<dim, spacedim> &other_tria);
1770 
1816  virtual void
1817  create_triangulation(const std::vector<Point<spacedim>> &vertices,
1818  const std::vector<CellData<dim>> & cells,
1819  const SubCellData & subcelldata);
1820 
1833  virtual void
1836  &construction_data);
1837 
1846  virtual void
1847  create_triangulation_compatibility(
1848  const std::vector<Point<spacedim>> &vertices,
1849  const std::vector<CellData<dim>> & cells,
1850  const SubCellData & subcelldata);
1851 
1858  void
1859  flip_all_direction_flags();
1860 
1872  void
1873  set_all_refine_flags();
1874 
1897  void
1898  refine_global(const unsigned int times = 1);
1899 
1931  virtual void
1932  execute_coarsening_and_refinement();
1933 
1963  virtual bool
1964  prepare_coarsening_and_refinement();
1965 
1966  /*
1967  * @}
1968  */
1969 
1984  {
2001  CELL_INVALID
2002  };
2003 
2009  template <typename T>
2011  {
2012  using result_type = T;
2013 
2014  template <typename InputIterator>
2015  T
2016  operator()(InputIterator first, InputIterator last) const
2017  {
2018  return std::accumulate(first, last, T());
2019  }
2020  };
2021 
2031  struct Signals
2032  {
2040  boost::signals2::signal<void()> create;
2041 
2049  boost::signals2::signal<void()> pre_refinement;
2050 
2056  boost::signals2::signal<void()> post_refinement;
2057 
2064  boost::signals2::signal<void()> pre_partition;
2065 
2073  boost::signals2::signal<void()> mesh_movement;
2074 
2082  boost::signals2::signal<void(
2083  const typename Triangulation<dim, spacedim>::cell_iterator &cell)>
2085 
2092  boost::signals2::signal<void(
2093  const typename Triangulation<dim, spacedim>::cell_iterator &cell)>
2095 
2102  boost::signals2::signal<void(
2103  const Triangulation<dim, spacedim> &destination_tria)>
2105 
2119  boost::signals2::signal<void()> clear;
2120 
2130  boost::signals2::signal<void()> any_change;
2131 
2157  boost::signals2::signal<unsigned int(const cell_iterator &,
2158  const CellStatus),
2161 
2173  boost::signals2::signal<void()> pre_distributed_refinement;
2174 
2183  boost::signals2::signal<void()> post_distributed_refinement;
2184 
2195  boost::signals2::signal<void()> pre_distributed_repartition;
2196 
2202  boost::signals2::signal<void()> post_distributed_repartition;
2203 
2210  boost::signals2::signal<void()> pre_distributed_save;
2211 
2217  boost::signals2::signal<void()> post_distributed_save;
2218 
2225  boost::signals2::signal<void()> pre_distributed_load;
2226 
2232  boost::signals2::signal<void()> post_distributed_load;
2233  };
2234 
2238  mutable Signals signals;
2239 
2240  /*
2241  * @}
2242  */
2243 
2253  void
2254  save_refine_flags(std::ostream &out) const;
2255 
2259  void
2260  save_refine_flags(std::vector<bool> &v) const;
2261 
2265  void
2266  load_refine_flags(std::istream &in);
2267 
2271  void
2272  load_refine_flags(const std::vector<bool> &v);
2273 
2277  void
2278  save_coarsen_flags(std::ostream &out) const;
2279 
2283  void
2284  save_coarsen_flags(std::vector<bool> &v) const;
2285 
2289  void
2290  load_coarsen_flags(std::istream &out);
2291 
2295  void
2296  load_coarsen_flags(const std::vector<bool> &v);
2297 
2302  bool
2303  get_anisotropic_refinement_flag() const;
2304 
2305  /*
2306  * @}
2307  */
2308 
2318  void
2319  clear_user_flags();
2320 
2326  void
2327  save_user_flags(std::ostream &out) const;
2328 
2334  void
2335  save_user_flags(std::vector<bool> &v) const;
2336 
2341  void
2342  load_user_flags(std::istream &in);
2343 
2348  void
2349  load_user_flags(const std::vector<bool> &v);
2350 
2355  void
2356  clear_user_flags_line();
2357 
2362  void
2363  save_user_flags_line(std::ostream &out) const;
2364 
2370  void
2371  save_user_flags_line(std::vector<bool> &v) const;
2372 
2377  void
2378  load_user_flags_line(std::istream &in);
2379 
2384  void
2385  load_user_flags_line(const std::vector<bool> &v);
2386 
2391  void
2392  clear_user_flags_quad();
2393 
2398  void
2399  save_user_flags_quad(std::ostream &out) const;
2400 
2406  void
2407  save_user_flags_quad(std::vector<bool> &v) const;
2408 
2413  void
2414  load_user_flags_quad(std::istream &in);
2415 
2420  void
2421  load_user_flags_quad(const std::vector<bool> &v);
2422 
2423 
2428  void
2429  clear_user_flags_hex();
2430 
2435  void
2436  save_user_flags_hex(std::ostream &out) const;
2437 
2443  void
2444  save_user_flags_hex(std::vector<bool> &v) const;
2445 
2450  void
2451  load_user_flags_hex(std::istream &in);
2452 
2457  void
2458  load_user_flags_hex(const std::vector<bool> &v);
2459 
2465  void
2466  clear_user_data();
2467 
2473  void
2474  save_user_indices(std::vector<unsigned int> &v) const;
2475 
2480  void
2481  load_user_indices(const std::vector<unsigned int> &v);
2482 
2488  void
2489  save_user_pointers(std::vector<void *> &v) const;
2490 
2495  void
2496  load_user_pointers(const std::vector<void *> &v);
2497 
2503  void
2504  save_user_indices_line(std::vector<unsigned int> &v) const;
2505 
2510  void
2511  load_user_indices_line(const std::vector<unsigned int> &v);
2512 
2518  void
2519  save_user_indices_quad(std::vector<unsigned int> &v) const;
2520 
2525  void
2526  load_user_indices_quad(const std::vector<unsigned int> &v);
2527 
2533  void
2534  save_user_indices_hex(std::vector<unsigned int> &v) const;
2535 
2540  void
2541  load_user_indices_hex(const std::vector<unsigned int> &v);
2547  void
2548  save_user_pointers_line(std::vector<void *> &v) const;
2549 
2554  void
2555  load_user_pointers_line(const std::vector<void *> &v);
2556 
2562  void
2563  save_user_pointers_quad(std::vector<void *> &v) const;
2564 
2569  void
2570  load_user_pointers_quad(const std::vector<void *> &v);
2571 
2577  void
2578  save_user_pointers_hex(std::vector<void *> &v) const;
2579 
2584  void
2585  load_user_pointers_hex(const std::vector<void *> &v);
2586 
2587  /*
2588  * @}
2589  */
2590 
2614  begin(const unsigned int level = 0) const;
2615 
2647  begin_active(const unsigned int level = 0) const;
2648 
2654  end() const;
2655 
2675  end(const unsigned int level) const;
2676 
2697  end_active(const unsigned int level) const;
2698 
2699 
2704  last() const;
2705 
2710  last_active() const;
2711 
2727  cell_iterators() const;
2728 
2765  active_cell_iterators() const;
2766 
2783  cell_iterators_on_level(const unsigned int level) const;
2784 
2801  active_cell_iterators_on_level(const unsigned int level) const;
2802 
2803  /*
2804  * @}
2805  */
2806 
2807  /*-------------------------------------------------------------------------*/
2808 
2818  begin_face() const;
2819 
2824  begin_active_face() const;
2825 
2831  end_face() const;
2832 
2852  active_face_iterators() const;
2853 
2854  /*
2855  * @}
2856  */
2857 
2858  /*-------------------------------------------------------------------------*/
2859 
2870  begin_vertex() const;
2871 
2878  begin_active_vertex() const;
2879 
2886  end_vertex() const;
2887 
2888  /*
2889  * @}
2890  */
2891 
2909  unsigned int
2910  n_lines() const;
2911 
2915  unsigned int
2916  n_lines(const unsigned int level) const;
2917 
2921  unsigned int
2922  n_active_lines() const;
2923 
2927  unsigned int
2928  n_active_lines(const unsigned int level) const;
2929 
2933  unsigned int
2934  n_quads() const;
2935 
2939  unsigned int
2940  n_quads(const unsigned int level) const;
2941 
2945  unsigned int
2946  n_active_quads() const;
2947 
2951  unsigned int
2952  n_active_quads(const unsigned int level) const;
2953 
2957  unsigned int
2958  n_hexs() const;
2959 
2964  unsigned int
2965  n_hexs(const unsigned int level) const;
2966 
2970  unsigned int
2971  n_active_hexs() const;
2972 
2977  unsigned int
2978  n_active_hexs(const unsigned int level) const;
2979 
2984  unsigned int
2985  n_cells() const;
2986 
2991  unsigned int
2992  n_cells(const unsigned int level) const;
2993 
2998  unsigned int
2999  n_active_cells() const;
3000 
3008  virtual types::global_cell_index
3009  n_global_active_cells() const;
3010 
3011 
3016  unsigned int
3017  n_active_cells(const unsigned int level) const;
3018 
3024  unsigned int
3025  n_faces() const;
3026 
3032  unsigned int
3033  n_active_faces() const;
3034 
3052  unsigned int
3053  n_levels() const;
3054 
3061  virtual unsigned int
3062  n_global_levels() const;
3063 
3073  virtual bool
3074  has_hanging_nodes() const;
3075 
3083  unsigned int
3084  n_vertices() const;
3085 
3094  const std::vector<Point<spacedim>> &
3095  get_vertices() const;
3096 
3101  unsigned int
3102  n_used_vertices() const;
3103 
3107  bool
3108  vertex_used(const unsigned int index) const;
3109 
3114  const std::vector<bool> &
3115  get_used_vertices() const;
3116 
3128  unsigned int
3129  max_adjacent_cells() const;
3130 
3137  virtual types::subdomain_id
3138  locally_owned_subdomain() const;
3139 
3150  get_triangulation();
3151 
3157  get_triangulation() const;
3158 
3159 
3160  /*
3161  * @}
3162  */
3163 
3178  unsigned int
3179  n_raw_lines() const;
3180 
3190  unsigned int
3191  n_raw_lines(const unsigned int level) const;
3192 
3202  unsigned int
3203  n_raw_quads() const;
3204 
3214  unsigned int
3215  n_raw_quads(const unsigned int level) const;
3216 
3226  unsigned int
3227  n_raw_hexs(const unsigned int level) const;
3228 
3238  unsigned int
3239  n_raw_cells(const unsigned int level) const;
3240 
3252  unsigned int
3253  n_raw_faces() const;
3254 
3255  /*
3256  * @}
3257  */
3258 
3267  virtual std::size_t
3268  memory_consumption() const;
3269 
3278  template <class Archive>
3279  void
3280  save(Archive &ar, const unsigned int version) const;
3281 
3297  template <class Archive>
3298  void
3299  load(Archive &ar, const unsigned int version);
3300 
3301 
3317  virtual void
3318  add_periodicity(
3319  const std::vector<GridTools::PeriodicFacePair<cell_iterator>> &);
3320 
3324  const std::map<
3325  std::pair<cell_iterator, unsigned int>,
3326  std::pair<std::pair<cell_iterator, unsigned int>, std::bitset<3>>> &
3327  get_periodic_face_map() const;
3328 
3329 #ifdef DOXYGEN
3330 
3334  template <class Archive>
3335  void
3336  serialize(Archive &archive, const unsigned int version);
3337 #else
3338  // This macro defines the serialize() method that is compatible with
3339  // the templated save() and load() method that have been implemented.
3340  BOOST_SERIALIZATION_SPLIT_MEMBER()
3341 #endif
3342 
3353  DeclException2(ExcInvalidLevel,
3354  int,
3355  int,
3356  << "You are requesting information from refinement level "
3357  << arg1
3358  << " of a triangulation, but this triangulation only has "
3359  << arg2 << " refinement levels. The given level " << arg1
3360  << " must be *less* than " << arg2 << ".");
3368  ExcTriangulationNotEmpty,
3369  int,
3370  int,
3371  << "You are trying to perform an operation on a triangulation "
3372  << "that is only allowed if the triangulation is currently empty. "
3373  << "However, it currently stores " << arg1 << " vertices and has "
3374  << "cells on " << arg2 << " levels.");
3380  DeclException0(ExcGridReadError);
3391  DeclException1(ExcEmptyLevel,
3392  int,
3393  << "You tried to do something on level " << arg1
3394  << ", but this level is empty.");
3400  DeclException0(ExcNonOrientableTriangulation);
3401 
3409  DeclException1(ExcBoundaryIdNotFound,
3411  << "The given boundary_id " << arg1
3412  << " is not defined in this Triangulation!");
3413 
3420  ExcInconsistentCoarseningFlags,
3421  "A cell is flagged for coarsening, but either not all of its siblings "
3422  "are active or flagged for coarsening as well. Please clean up all "
3423  "coarsen flags on your triangulation via "
3424  "Triangulation::prepare_coarsening_and_refinement() beforehand!");
3425 
3426  /*
3427  * @}
3428  */
3429 
3430 protected:
3436 
3450  static void
3451  write_bool_vector(const unsigned int magic_number1,
3452  const std::vector<bool> &v,
3453  const unsigned int magic_number2,
3454  std::ostream & out);
3455 
3460  static void
3461  read_bool_vector(const unsigned int magic_number1,
3462  std::vector<bool> &v,
3463  const unsigned int magic_number2,
3464  std::istream & in);
3465 
3470  void
3471  update_periodic_face_map();
3472 
3473 
3474 private:
3481  std::vector<GridTools::PeriodicFacePair<cell_iterator>>
3483 
3488  std::map<std::pair<cell_iterator, unsigned int>,
3489  std::pair<std::pair<cell_iterator, unsigned int>, std::bitset<3>>>
3491 
3506  using raw_face_iterator =
3507  TriaRawIterator<TriaAccessor<dim - 1, dim, spacedim>>;
3508  using raw_vertex_iterator =
3510  using raw_line_iterator = typename IteratorSelector::raw_line_iterator;
3511  using raw_quad_iterator = typename IteratorSelector::raw_quad_iterator;
3512  using raw_hex_iterator = typename IteratorSelector::raw_hex_iterator;
3513 
3519  begin_raw(const unsigned int level = 0) const;
3520 
3526  end_raw(const unsigned int level) const;
3527 
3528  /*
3529  * @}
3530  */
3531 
3544  begin_raw_line(const unsigned int level = 0) const;
3545 
3564  begin_line(const unsigned int level = 0) const;
3565 
3584  begin_active_line(const unsigned int level = 0) const;
3585 
3591  end_line() const;
3592 
3593  /*
3594  * @}
3595  */
3596 
3622  begin_raw_quad(const unsigned int level = 0) const;
3623 
3642  begin_quad(const unsigned int level = 0) const;
3643 
3662  begin_active_quad(const unsigned int level = 0) const;
3663 
3669  end_quad() const;
3670 
3671  /*
3672  * @}
3673  */
3674 
3699  begin_raw_hex(const unsigned int level = 0) const;
3700 
3718  hex_iterator
3719  begin_hex(const unsigned int level = 0) const;
3720 
3739  begin_active_hex(const unsigned int level = 0) const;
3740 
3745  hex_iterator
3746  end_hex() const;
3747 
3748  /*
3749  * @}
3750  */
3751 
3752 
3766  void
3767  clear_despite_subscriptions();
3768 
3775  void
3776  reset_active_cell_indices();
3777 
3791  DistortedCellList
3792  execute_refinement();
3793 
3800  void
3801  execute_coarsening();
3802 
3807  void
3808  fix_coarsen_flags();
3809 
3823  virtual unsigned int
3824  coarse_cell_id_to_coarse_cell_index(
3826 
3827 
3840  virtual types::coarse_cell_id
3841  coarse_cell_index_to_coarse_cell_id(
3842  const unsigned int coarse_cell_index) const;
3843 
3848  std::vector<
3849  std::unique_ptr<::internal::TriangulationImplementation::TriaLevel>>
3851 
3857  std::unique_ptr<::internal::TriangulationImplementation::TriaFaces>
3859 
3860 
3864  std::vector<Point<spacedim>> vertices;
3865 
3869  std::vector<bool> vertices_used;
3870 
3875  std::map<types::manifold_id, std::unique_ptr<const Manifold<dim, spacedim>>>
3877 
3882 
3883 
3889 
3900 
3915  std::unique_ptr<std::map<unsigned int, types::boundary_id>>
3917 
3918 
3938  std::unique_ptr<std::map<unsigned int, types::manifold_id>>
3940 
3941  // make a couple of classes friends
3942  template <int, int, int>
3943  friend class TriaAccessorBase;
3944  template <int, int, int>
3945  friend class TriaAccessor;
3946  friend class TriaAccessor<0, 1, spacedim>;
3947 
3948  friend class CellAccessor<dim, spacedim>;
3949 
3950  friend struct ::internal::TriaAccessorImplementation::Implementation;
3951 
3952  friend class hp::DoFHandler<dim, spacedim>;
3953 
3954  friend struct ::internal::TriangulationImplementation::Implementation;
3955 
3956  friend class ::internal::TriangulationImplementation::TriaObjects;
3957 
3958  friend class CellId;
3959 
3960  // explicitly check for sensible template arguments, but not on windows
3961  // because MSVC creates bogus warnings during normal compilation
3962 #ifndef DEAL_II_MSVC
3963  static_assert(dim <= spacedim,
3964  "The dimension <dim> of a Triangulation must be less than or "
3965  "equal to the space dimension <spacedim> in which it lives.");
3966 #endif
3967 };
3968 
3969 
3970 #ifndef DOXYGEN
3971 
3972 
3973 
3974 namespace internal
3975 {
3976  namespace TriangulationImplementation
3977  {
3978  template <class Archive>
3979  void
3980  NumberCache<1>::serialize(Archive &ar, const unsigned int)
3981  {
3982  ar &n_levels;
3983  ar &n_lines &n_lines_level;
3984  ar &n_active_lines &n_active_lines_level;
3985  }
3986 
3987 
3988  template <class Archive>
3989  void
3990  NumberCache<2>::serialize(Archive &ar, const unsigned int version)
3991  {
3992  this->NumberCache<1>::serialize(ar, version);
3993 
3994  ar &n_quads &n_quads_level;
3995  ar &n_active_quads &n_active_quads_level;
3996  }
3997 
3998 
3999  template <class Archive>
4000  void
4001  NumberCache<3>::serialize(Archive &ar, const unsigned int version)
4002  {
4003  this->NumberCache<2>::serialize(ar, version);
4004 
4005  ar &n_hexes &n_hexes_level;
4006  ar &n_active_hexes &n_active_hexes_level;
4007  }
4008 
4009  } // namespace TriangulationImplementation
4010 } // namespace internal
4011 
4012 
4013 template <int dim, int spacedim>
4014 inline bool
4015 Triangulation<dim, spacedim>::vertex_used(const unsigned int index) const
4016 {
4017  AssertIndexRange(index, vertices_used.size());
4018  return vertices_used[index];
4019 }
4020 
4021 
4022 
4023 template <int dim, int spacedim>
4024 inline unsigned int
4026 {
4027  return number_cache.n_levels;
4028 }
4029 
4030 template <int dim, int spacedim>
4031 inline unsigned int
4033 {
4034  return number_cache.n_levels;
4035 }
4036 
4037 
4038 template <int dim, int spacedim>
4039 inline unsigned int
4041 {
4042  return vertices.size();
4043 }
4044 
4045 
4046 
4047 template <int dim, int spacedim>
4048 inline const std::vector<Point<spacedim>> &
4050 {
4051  return vertices;
4052 }
4053 
4054 
4055 template <int dim, int spacedim>
4056 template <class Archive>
4057 void
4058 Triangulation<dim, spacedim>::save(Archive &ar, const unsigned int) const
4059 {
4060  // as discussed in the documentation, do not store the signals as
4061  // well as boundary and manifold description but everything else
4062  ar &smooth_grid;
4063 
4064  unsigned int n_levels = levels.size();
4065  ar & n_levels;
4066  for (const auto &level : levels)
4067  ar &level;
4068 
4069  // boost dereferences a nullptr when serializing a nullptr
4070  // at least up to 1.65.1. This causes problems with clang-5.
4071  // Therefore, work around it.
4072  bool faces_is_nullptr = (faces.get() == nullptr);
4073  ar & faces_is_nullptr;
4074  if (!faces_is_nullptr)
4075  ar &faces;
4076 
4077  ar &vertices;
4078  ar &vertices_used;
4079 
4080  ar &anisotropic_refinement;
4081  ar &number_cache;
4082 
4083  ar &check_for_distorted_cells;
4084 
4085  if (dim == 1)
4086  {
4087  ar &vertex_to_boundary_id_map_1d;
4088  ar &vertex_to_manifold_id_map_1d;
4089  }
4090 }
4091 
4092 
4093 
4094 template <int dim, int spacedim>
4095 template <class Archive>
4096 void
4097 Triangulation<dim, spacedim>::load(Archive &ar, const unsigned int)
4098 {
4099  // clear previous content. this also calls the respective signal
4100  clear();
4101 
4102  // as discussed in the documentation, do not store the signals as
4103  // well as boundary and manifold description but everything else
4104  ar &smooth_grid;
4105 
4106  unsigned int size;
4107  ar & size;
4108  levels.resize(size);
4109  for (auto &level_ : levels)
4110  {
4111  std::unique_ptr<internal::TriangulationImplementation::TriaLevel> level;
4112  ar & level;
4113  level_ = std::move(level);
4114  }
4115 
4116  // Workaround for nullptr, see in save().
4117  bool faces_is_nullptr = true;
4118  ar & faces_is_nullptr;
4119  if (!faces_is_nullptr)
4120  ar &faces;
4121 
4122  ar &vertices;
4123  ar &vertices_used;
4124 
4125  ar &anisotropic_refinement;
4126  ar &number_cache;
4127 
4128  // the levels do not serialize the active_cell_indices because
4129  // they are easy enough to rebuild upon re-loading data. do
4130  // this here. don't forget to first resize the fields appropriately
4131  {
4132  for (auto &level : levels)
4133  level->active_cell_indices.resize(level->refine_flags.size());
4134  reset_active_cell_indices();
4135  }
4136 
4137 
4138  bool my_check_for_distorted_cells;
4139  ar & my_check_for_distorted_cells;
4140 
4141  Assert(my_check_for_distorted_cells == check_for_distorted_cells,
4142  ExcMessage("The triangulation loaded into here must have the "
4143  "same setting with regard to reporting distorted "
4144  "cell as the one previously stored."));
4145 
4146  if (dim == 1)
4147  {
4148  ar &vertex_to_boundary_id_map_1d;
4149  ar &vertex_to_manifold_id_map_1d;
4150  }
4151 
4152  // trigger the create signal to indicate
4153  // that new content has been imported into
4154  // the triangulation
4155  signals.create();
4156 }
4157 
4158 
4159 
4160 template <int dim, int spacedim>
4161 inline unsigned int
4164 {
4165  return coarse_cell_id;
4166 }
4167 
4168 
4169 
4170 template <int dim, int spacedim>
4171 inline types::coarse_cell_id
4173  const unsigned int coarse_cell_index) const
4174 {
4175  return coarse_cell_index;
4176 }
4177 
4178 
4179 
4180 /* -------------- declaration of explicit specializations ------------- */
4181 
4182 template <>
4183 unsigned int
4185 template <>
4186 unsigned int
4187 Triangulation<1, 1>::n_quads(const unsigned int level) const;
4188 template <>
4189 unsigned int
4190 Triangulation<1, 1>::n_raw_quads(const unsigned int level) const;
4191 template <>
4192 unsigned int
4193 Triangulation<2, 2>::n_raw_quads(const unsigned int level) const;
4194 template <>
4195 unsigned int
4196 Triangulation<1, 1>::n_raw_hexs(const unsigned int level) const;
4197 template <>
4198 unsigned int
4199 Triangulation<1, 1>::n_active_quads(const unsigned int level) const;
4200 template <>
4201 unsigned int
4203 template <>
4204 unsigned int
4206 
4207 
4208 // -------------------------------------------------------------------
4209 // -- Explicit specializations for codimension one grids
4210 
4211 
4212 template <>
4213 unsigned int
4215 template <>
4216 unsigned int
4217 Triangulation<1, 2>::n_quads(const unsigned int level) const;
4218 template <>
4219 unsigned int
4220 Triangulation<1, 2>::n_raw_quads(const unsigned int level) const;
4221 template <>
4222 unsigned int
4223 Triangulation<2, 3>::n_raw_quads(const unsigned int level) const;
4224 template <>
4225 unsigned int
4226 Triangulation<1, 2>::n_raw_hexs(const unsigned int level) const;
4227 template <>
4228 unsigned int
4229 Triangulation<1, 2>::n_active_quads(const unsigned int level) const;
4230 template <>
4231 unsigned int
4233 template <>
4234 unsigned int
4236 
4237 // -------------------------------------------------------------------
4238 // -- Explicit specializations for codimension two grids
4239 
4240 
4241 template <>
4242 unsigned int
4244 template <>
4245 unsigned int
4246 Triangulation<1, 3>::n_quads(const unsigned int level) const;
4247 template <>
4248 unsigned int
4249 Triangulation<1, 3>::n_raw_quads(const unsigned int level) const;
4250 template <>
4251 unsigned int
4252 Triangulation<2, 3>::n_raw_quads(const unsigned int level) const;
4253 template <>
4254 unsigned int
4255 Triangulation<1, 3>::n_raw_hexs(const unsigned int level) const;
4256 template <>
4257 unsigned int
4258 Triangulation<1, 3>::n_active_quads(const unsigned int level) const;
4259 template <>
4260 unsigned int
4262 template <>
4263 unsigned int
4265 
4266 
4267 #endif // DOXYGEN
4268 
4270 
4271 // Include tria_accessor.h here, so that it is possible for an end
4272 // user to use the iterators of Triangulation<dim> directly without
4273 // the need to include tria_accessor.h separately. (Otherwise the
4274 // iterators are an 'opaque' or 'incomplete' type.)
4276 
4277 #endif
boost::signals2::signal< void(const Triangulation< dim, spacedim > &destination_tria)> copy
Definition: tria.h:2104
::internal::TriangulationImplementation::NumberCache< dim > number_cache
Definition: tria.h:3899
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:2056
unsigned int n_vertices() const
boost::signals2::signal< void(const typename Triangulation< dim, spacedim >::cell_iterator &cell)> pre_coarsening_on_cell
Definition: tria.h:2084
#define DeclException2(Exception2, type1, type2, outsequence)
Definition: exceptions.h:538
boost::signals2::signal< void()> post_distributed_repartition
Definition: tria.h:2202
typename IteratorSelector::line_iterator line_iterator
Definition: tria.h:1425
T operator()(InputIterator first, InputIterator last) const
Definition: tria.h:2016
MeshSmoothing smooth_grid
Definition: tria.h:3435
typename IteratorSelector::raw_line_iterator raw_line_iterator
Definition: tria.h:3510
std::vector< Point< spacedim > > vertices
Definition: tria.h:3864
std::map< types::manifold_id, std::unique_ptr< const Manifold< dim, spacedim > > > manifold
Definition: tria.h:3876
typename IteratorSelector::hex_iterator hex_iterator
Definition: tria.h:1473
typename IteratorSelector::active_line_iterator active_line_iterator
Definition: tria.h:1440
boost::signals2::signal< void()> pre_distributed_refinement
Definition: tria.h:2173
bool anisotropic_refinement
Definition: tria.h:3881
#define AssertIndexRange(index, range)
Definition: exceptions.h:1636
std::vector< GridTools::PeriodicFacePair< cell_iterator > > periodic_face_pairs_level_0
Definition: tria.h:3482
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:2049
const bool check_for_distorted_cells
Definition: tria.h:3888
#define DeclException1(Exception1, type1, outsequence)
Definition: exceptions.h:515
static const char T
unsigned int n_raw_quads() const
Definition: tria.cc:12205
#define Assert(cond, exc)
Definition: exceptions.h:1411
Signals signals
Definition: tria.h:2238
std::vector< std::unique_ptr<::internal::TriangulationImplementation::TriaLevel > > levels
Definition: tria.h:3850
boost::signals2::signal< void()> clear
Definition: tria.h:2119
unsigned int n_raw_hexs(const unsigned int level) const
Definition: tria.cc:12261
unsigned int max_adjacent_cells() const
Definition: tria.cc:12378
void load(Archive &ar, const unsigned int version)
std::list< typename Triangulation< dim, spacedim >::cell_iterator > distorted_cells
Definition: tria.h:1519
unsigned int n_quads() const
Definition: tria.cc:12157
#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:3939
std::vector< bool > vertices_used
Definition: tria.h:3869
#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:2094
typename IteratorSelector::active_quad_iterator active_quad_iterator
Definition: tria.h:1464
const std::vector< Point< spacedim > > & get_vertices() const
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:363
boost::signals2::signal< void()> mesh_movement
Definition: tria.h:2073
unsigned int level
Definition: grid_out.cc:4338
typename IteratorSelector::raw_quad_iterator raw_quad_iterator
Definition: tria.h:3511
VectorType::value_type * end(VectorType &V)
std::unique_ptr<::internal::TriangulationImplementation::TriaFaces > faces
Definition: tria.h:3858
Point< 3 > vertices[4]
boost::signals2::signal< void()> pre_distributed_save
Definition: tria.h:2210
void save(Archive &ar, const unsigned int version) const
unsigned int n_active_cells(const internal::TriangulationImplementation::NumberCache< 1 > &c)
Definition: tria.cc:11750
typename IteratorSelector::quad_iterator quad_iterator
Definition: tria.h:1449
TriangulationBase< dim, spacedim > Triangulation
Definition: tria_base.h:302
boost::signals2::signal< void()> create
Definition: tria.h:2040
std::unique_ptr< std::map< unsigned int, types::boundary_id > > vertex_to_boundary_id_map_1d
Definition: tria.h:3916
Definition: hp.h:117
unsigned int n_active_quads() const
Definition: tria.cc:12224
unsigned int n_cells(const internal::TriangulationImplementation::NumberCache< 1 > &c)
Definition: tria.cc:11743
Definition: cell_id.h:69
Point< 2 > first
Definition: grid_out.cc:4335
boost::signals2::signal< void()> pre_partition
Definition: tria.h:2064
typename IteratorSelector::active_hex_iterator active_hex_iterator
Definition: tria.h:1484
boost::signals2::signal< void()> post_distributed_save
Definition: tria.h:2217
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:3490
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:362
virtual unsigned int n_global_levels() const
VectorType::value_type * begin(VectorType &V)
typename IteratorSelector::raw_hex_iterator raw_hex_iterator
Definition: tria.h:3512
boost::signals2::signal< unsigned int(const cell_iterator &, const CellStatus), CellWeightSum< unsigned int > > cell_weight
Definition: tria.h:2160
boost::signals2::signal< void()> pre_distributed_load
Definition: tria.h:2225
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:2232
global_cell_index coarse_cell_id
Definition: types.h:114
boost::signals2::signal< void()> pre_distributed_repartition
Definition: tria.h:2195
bool vertex_used(const unsigned int index) const
boost::signals2::signal< void()> any_change
Definition: tria.h:2130
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:2183