Reference documentation for deal.II version Git 9b341ae816 2021-01-21 15:59:19 -0700
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
tria.h
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 1998 - 2020 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE.md at
12 // the top level directory of deal.II.
13 //
14 // ---------------------------------------------------------------------
15 
16 #ifndef dealii_tria_h
17 #define dealii_tria_h
18 
19 
20 #include <deal.II/base/config.h>
21 
24 #include <deal.II/base/point.h>
27 
28 #include <deal.II/grid/cell_id.h>
32 
33 #include <boost/serialization/map.hpp>
34 #include <boost/serialization/split_member.hpp>
35 #include <boost/serialization/unique_ptr.hpp>
36 #include <boost/serialization/vector.hpp>
37 #include <boost/signals2.hpp>
38 
39 #include <bitset>
40 #include <functional>
41 #include <list>
42 #include <map>
43 #include <memory>
44 #include <numeric>
45 #include <vector>
46 
47 
49 
50 #ifdef signals
51 # error \
52  "The name 'signals' is already defined. You are most likely using the QT library \
53 and using the 'signals' keyword. You can either #include the Qt headers (or any conflicting headers) \
54 *after* the deal.II headers or you can define the 'QT_NO_KEYWORDS' macro and use the 'Q_SIGNALS' macro."
55 #endif
56 
57 // Forward declarations
58 #ifndef DOXYGEN
59 template <int dim, int spacedim>
60 class Manifold;
61 
62 template <int dim>
63 struct CellData;
64 
65 struct SubCellData;
66 
68 {
69  template <int, int>
70  struct Description;
71 }
72 
73 namespace GridTools
74 {
75  template <typename CellIterator>
76  struct PeriodicFacePair;
77 }
78 
79 template <int, int, int>
80 class TriaAccessor;
81 template <int spacedim>
82 class TriaAccessor<0, 1, spacedim>;
83 template <int, int, int>
84 class TriaAccessorBase;
85 
86 namespace internal
87 {
88  namespace TriangulationImplementation
89  {
90  class TriaFaces;
91 
92  class TriaObjects;
93 
94  template <int, int>
95  class Policy;
96 
102  struct Implementation;
103  struct ImplementationMixedMesh;
104  } // namespace TriangulationImplementation
105 
106  namespace TriaAccessorImplementation
107  {
108  struct Implementation;
109  }
110 } // namespace internal
111 
112 namespace hp
113 {
114  template <int dim, int spacedim>
115  class DoFHandler;
116 }
117 #endif
118 
119 
120 /*------------------------------------------------------------------------*/
121 
122 
123 namespace internal
124 {
129  namespace TriangulationImplementation
130  {
142  template <int dim>
143  struct NumberCache
144  {};
145 
157  template <>
158  struct NumberCache<1>
159  {
163  unsigned int n_levels;
164 
168  unsigned int n_lines;
169 
173  std::vector<unsigned int> n_lines_level;
174 
178  unsigned int n_active_lines;
179 
183  std::vector<unsigned int> n_active_lines_level;
184 
188  NumberCache();
189 
194  std::size_t
195  memory_consumption() const;
196 
202  template <class Archive>
203  void
204  serialize(Archive &ar, const unsigned int version);
205  };
206 
207 
220  template <>
221  struct NumberCache<2> : public NumberCache<1>
222  {
226  unsigned int n_quads;
227 
231  std::vector<unsigned int> n_quads_level;
232 
236  unsigned int n_active_quads;
237 
241  std::vector<unsigned int> n_active_quads_level;
242 
246  NumberCache();
247 
252  std::size_t
253  memory_consumption() const;
254 
260  template <class Archive>
261  void
262  serialize(Archive &ar, const unsigned int version);
263  };
264 
265 
279  template <>
280  struct NumberCache<3> : public NumberCache<2>
281  {
285  unsigned int n_hexes;
286 
290  std::vector<unsigned int> n_hexes_level;
291 
295  unsigned int n_active_hexes;
296 
300  std::vector<unsigned int> n_active_hexes_level;
301 
305  NumberCache();
306 
311  std::size_t
312  memory_consumption() const;
313 
319  template <class Archive>
320  void
321  serialize(Archive &ar, const unsigned int version);
322  };
323  } // namespace TriangulationImplementation
324 } // namespace internal
325 
326 
327 /*------------------------------------------------------------------------*/
328 
329 
1126 template <int dim, int spacedim = dim>
1128 {
1129 private:
1134  using IteratorSelector =
1136 
1137 public:
1143  {
1148  none = 0x0,
1192  limit_level_difference_at_vertices = 0x1,
1213  eliminate_unrefined_islands = 0x2,
1229  patch_level_1 = 0x4,
1253  coarsest_level_1 = 0x8,
1278  allow_anisotropic_smoothing = 0x10,
1311  eliminate_refined_inner_islands = 0x100,
1316  eliminate_refined_boundary_islands = 0x200,
1322  do_not_produce_unrefined_islands = 0x400,
1323 
1328  smoothing_on_refinement =
1329  (limit_level_difference_at_vertices | eliminate_unrefined_islands),
1334  smoothing_on_coarsening =
1335  (eliminate_refined_inner_islands | eliminate_refined_boundary_islands |
1336  do_not_produce_unrefined_islands),
1337 
1343  maximum_smoothing = 0xffff ^ allow_anisotropic_smoothing
1344  };
1345 
1362 
1368 
1386 
1400  using face_iterator = TriaIterator<TriaAccessor<dim - 1, dim, spacedim>>;
1401 
1413  using active_face_iterator =
1414  TriaActiveIterator<TriaAccessor<dim - 1, dim, spacedim>>;
1415 
1425 
1438  using active_vertex_iterator =
1440 
1448  using line_iterator = typename IteratorSelector::line_iterator;
1449 
1463  using active_line_iterator = typename IteratorSelector::active_line_iterator;
1464 
1472  using quad_iterator = typename IteratorSelector::quad_iterator;
1473 
1487  using active_quad_iterator = typename IteratorSelector::active_quad_iterator;
1488 
1496  using hex_iterator = typename IteratorSelector::hex_iterator;
1497 
1507  using active_hex_iterator = typename IteratorSelector::active_hex_iterator;
1508 
1528  {
1535  virtual ~DistortedCellList() noexcept override = default;
1536 
1541  std::list<typename Triangulation<dim, spacedim>::cell_iterator>
1543  };
1544 
1548  static const unsigned int dimension = dim;
1549 
1553  static const unsigned int space_dimension = spacedim;
1554 
1569  Triangulation(const MeshSmoothing smooth_grid = none,
1570  const bool check_for_distorted_cells = false);
1571 
1587  Triangulation(const Triangulation<dim, spacedim> &) = delete;
1588 
1596 
1600  Triangulation &
1601  operator=(Triangulation<dim, spacedim> &&tria) noexcept;
1602 
1606  virtual ~Triangulation() override;
1607 
1614  virtual void
1615  clear();
1616 
1622  virtual void
1623  set_mesh_smoothing(const MeshSmoothing mesh_smoothing);
1624 
1628  virtual const MeshSmoothing &
1629  get_mesh_smoothing() const;
1630 
1653  void
1654  set_manifold(const types::manifold_id number,
1655  const Manifold<dim, spacedim> &manifold_object);
1656 
1669  void
1670  reset_manifold(const types::manifold_id manifold_number);
1671 
1683  void
1684  reset_all_manifolds();
1685 
1694  void
1695  set_all_manifold_ids(const types::manifold_id number);
1696 
1705  void
1706  set_all_manifold_ids_on_boundary(const types::manifold_id number);
1707 
1717  void
1718  set_all_manifold_ids_on_boundary(const types::boundary_id b_id,
1719  const types::manifold_id number);
1720 
1732  const Manifold<dim, spacedim> &
1733  get_manifold(const types::manifold_id number) const;
1734 
1747  virtual std::vector<types::boundary_id>
1748  get_boundary_ids() const;
1749 
1762  virtual std::vector<types::manifold_id>
1763  get_manifold_ids() const;
1764 
1791  virtual void
1792  copy_triangulation(const Triangulation<dim, spacedim> &other_tria);
1793 
1839  virtual void
1840  create_triangulation(const std::vector<Point<spacedim>> &vertices,
1841  const std::vector<CellData<dim>> & cells,
1842  const SubCellData & subcelldata);
1843 
1856  virtual void
1859  &construction_data);
1860 
1869  virtual void
1870  create_triangulation_compatibility(
1871  const std::vector<Point<spacedim>> &vertices,
1872  const std::vector<CellData<dim>> & cells,
1873  const SubCellData & subcelldata);
1874 
1881  void
1882  flip_all_direction_flags();
1883 
1895  void
1896  set_all_refine_flags();
1897 
1920  void
1921  refine_global(const unsigned int times = 1);
1922 
1935  void
1936  coarsen_global(const unsigned int times = 1);
1937 
1969  virtual void
1970  execute_coarsening_and_refinement();
1971 
2001  virtual bool
2002  prepare_coarsening_and_refinement();
2003 
2004  /*
2005  * @}
2006  */
2007 
2022  {
2039  CELL_INVALID
2040  };
2041 
2047  template <typename T>
2049  {
2050  using result_type = T;
2051 
2052  template <typename InputIterator>
2053  T
2054  operator()(InputIterator first, InputIterator last) const
2055  {
2056  return std::accumulate(first, last, T());
2057  }
2058  };
2059 
2069  struct Signals
2070  {
2078  boost::signals2::signal<void()> create;
2079 
2087  boost::signals2::signal<void()> pre_refinement;
2088 
2094  boost::signals2::signal<void()> post_refinement;
2095 
2102  boost::signals2::signal<void()> pre_partition;
2103 
2111  boost::signals2::signal<void()> mesh_movement;
2112 
2120  boost::signals2::signal<void(
2121  const typename Triangulation<dim, spacedim>::cell_iterator &cell)>
2123 
2130  boost::signals2::signal<void(
2131  const typename Triangulation<dim, spacedim>::cell_iterator &cell)>
2133 
2140  boost::signals2::signal<void(
2141  const Triangulation<dim, spacedim> &destination_tria)>
2143 
2157  boost::signals2::signal<void()> clear;
2158 
2168  boost::signals2::signal<void()> any_change;
2169 
2195  boost::signals2::signal<unsigned int(const cell_iterator &,
2196  const CellStatus),
2199 
2211  boost::signals2::signal<void()> pre_distributed_refinement;
2212 
2221  boost::signals2::signal<void()> post_distributed_refinement;
2222 
2233  boost::signals2::signal<void()> pre_distributed_repartition;
2234 
2240  boost::signals2::signal<void()> post_distributed_repartition;
2241 
2248  boost::signals2::signal<void()> pre_distributed_save;
2249 
2255  boost::signals2::signal<void()> post_distributed_save;
2256 
2263  boost::signals2::signal<void()> pre_distributed_load;
2264 
2270  boost::signals2::signal<void()> post_distributed_load;
2271  };
2272 
2276  mutable Signals signals;
2277 
2278  /*
2279  * @}
2280  */
2281 
2291  void
2292  save_refine_flags(std::ostream &out) const;
2293 
2297  void
2298  save_refine_flags(std::vector<bool> &v) const;
2299 
2303  void
2304  load_refine_flags(std::istream &in);
2305 
2309  void
2310  load_refine_flags(const std::vector<bool> &v);
2311 
2315  void
2316  save_coarsen_flags(std::ostream &out) const;
2317 
2321  void
2322  save_coarsen_flags(std::vector<bool> &v) const;
2323 
2327  void
2328  load_coarsen_flags(std::istream &out);
2329 
2333  void
2334  load_coarsen_flags(const std::vector<bool> &v);
2335 
2340  bool
2341  get_anisotropic_refinement_flag() const;
2342 
2343  /*
2344  * @}
2345  */
2346 
2356  void
2357  clear_user_flags();
2358 
2364  void
2365  save_user_flags(std::ostream &out) const;
2366 
2372  void
2373  save_user_flags(std::vector<bool> &v) const;
2374 
2379  void
2380  load_user_flags(std::istream &in);
2381 
2386  void
2387  load_user_flags(const std::vector<bool> &v);
2388 
2393  void
2394  clear_user_flags_line();
2395 
2400  void
2401  save_user_flags_line(std::ostream &out) const;
2402 
2408  void
2409  save_user_flags_line(std::vector<bool> &v) const;
2410 
2415  void
2416  load_user_flags_line(std::istream &in);
2417 
2422  void
2423  load_user_flags_line(const std::vector<bool> &v);
2424 
2429  void
2430  clear_user_flags_quad();
2431 
2436  void
2437  save_user_flags_quad(std::ostream &out) const;
2438 
2444  void
2445  save_user_flags_quad(std::vector<bool> &v) const;
2446 
2451  void
2452  load_user_flags_quad(std::istream &in);
2453 
2458  void
2459  load_user_flags_quad(const std::vector<bool> &v);
2460 
2461 
2466  void
2467  clear_user_flags_hex();
2468 
2473  void
2474  save_user_flags_hex(std::ostream &out) const;
2475 
2481  void
2482  save_user_flags_hex(std::vector<bool> &v) const;
2483 
2488  void
2489  load_user_flags_hex(std::istream &in);
2490 
2495  void
2496  load_user_flags_hex(const std::vector<bool> &v);
2497 
2503  void
2504  clear_user_data();
2505 
2511  void
2512  save_user_indices(std::vector<unsigned int> &v) const;
2513 
2518  void
2519  load_user_indices(const std::vector<unsigned int> &v);
2520 
2526  void
2527  save_user_pointers(std::vector<void *> &v) const;
2528 
2533  void
2534  load_user_pointers(const std::vector<void *> &v);
2535 
2541  void
2542  save_user_indices_line(std::vector<unsigned int> &v) const;
2543 
2548  void
2549  load_user_indices_line(const std::vector<unsigned int> &v);
2550 
2556  void
2557  save_user_indices_quad(std::vector<unsigned int> &v) const;
2558 
2563  void
2564  load_user_indices_quad(const std::vector<unsigned int> &v);
2565 
2571  void
2572  save_user_indices_hex(std::vector<unsigned int> &v) const;
2573 
2578  void
2579  load_user_indices_hex(const std::vector<unsigned int> &v);
2585  void
2586  save_user_pointers_line(std::vector<void *> &v) const;
2587 
2592  void
2593  load_user_pointers_line(const std::vector<void *> &v);
2594 
2600  void
2601  save_user_pointers_quad(std::vector<void *> &v) const;
2602 
2607  void
2608  load_user_pointers_quad(const std::vector<void *> &v);
2609 
2615  void
2616  save_user_pointers_hex(std::vector<void *> &v) const;
2617 
2622  void
2623  load_user_pointers_hex(const std::vector<void *> &v);
2624 
2625  /*
2626  * @}
2627  */
2628 
2652  begin(const unsigned int level = 0) const;
2653 
2685  begin_active(const unsigned int level = 0) const;
2686 
2692  end() const;
2693 
2713  end(const unsigned int level) const;
2714 
2735  end_active(const unsigned int level) const;
2736 
2737 
2742  last() const;
2743 
2748  last_active() const;
2749 
2763  create_cell_iterator(const CellId &cell_id) const;
2764 
2780  cell_iterators() const;
2781 
2818  active_cell_iterators() const;
2819 
2836  cell_iterators_on_level(const unsigned int level) const;
2837 
2854  active_cell_iterators_on_level(const unsigned int level) const;
2855 
2856  /*
2857  * @}
2858  */
2859 
2860  /*-------------------------------------------------------------------------*/
2861 
2871  begin_face() const;
2872 
2877  begin_active_face() const;
2878 
2884  end_face() const;
2885 
2905  active_face_iterators() const;
2906 
2907  /*
2908  * @}
2909  */
2910 
2911  /*-------------------------------------------------------------------------*/
2912 
2923  begin_vertex() const;
2924 
2931  begin_active_vertex() const;
2932 
2939  end_vertex() const;
2940 
2941  /*
2942  * @}
2943  */
2944 
2962  unsigned int
2963  n_lines() const;
2964 
2968  unsigned int
2969  n_lines(const unsigned int level) const;
2970 
2974  unsigned int
2975  n_active_lines() const;
2976 
2980  unsigned int
2981  n_active_lines(const unsigned int level) const;
2982 
2986  unsigned int
2987  n_quads() const;
2988 
2992  unsigned int
2993  n_quads(const unsigned int level) const;
2994 
2998  unsigned int
2999  n_active_quads() const;
3000 
3004  unsigned int
3005  n_active_quads(const unsigned int level) const;
3006 
3010  unsigned int
3011  n_hexs() const;
3012 
3017  unsigned int
3018  n_hexs(const unsigned int level) const;
3019 
3023  unsigned int
3024  n_active_hexs() const;
3025 
3030  unsigned int
3031  n_active_hexs(const unsigned int level) const;
3032 
3037  unsigned int
3038  n_cells() const;
3039 
3044  unsigned int
3045  n_cells(const unsigned int level) const;
3046 
3051  unsigned int
3052  n_active_cells() const;
3053 
3061  virtual types::global_cell_index
3062  n_global_active_cells() const;
3063 
3064 
3069  unsigned int
3070  n_active_cells(const unsigned int level) const;
3071 
3077  unsigned int
3078  n_faces() const;
3079 
3085  unsigned int
3086  n_active_faces() const;
3087 
3105  unsigned int
3106  n_levels() const;
3107 
3114  virtual unsigned int
3115  n_global_levels() const;
3116 
3126  virtual bool
3127  has_hanging_nodes() const;
3128 
3136  unsigned int
3137  n_vertices() const;
3138 
3147  const std::vector<Point<spacedim>> &
3148  get_vertices() const;
3149 
3154  unsigned int
3155  n_used_vertices() const;
3156 
3160  bool
3161  vertex_used(const unsigned int index) const;
3162 
3167  const std::vector<bool> &
3168  get_used_vertices() const;
3169 
3181  unsigned int
3182  max_adjacent_cells() const;
3183 
3190  virtual types::subdomain_id
3191  locally_owned_subdomain() const;
3192 
3203  get_triangulation();
3204 
3210  get_triangulation() const;
3211 
3212 
3213  /*
3214  * @}
3215  */
3216 
3231  unsigned int
3232  n_raw_lines() const;
3233 
3243  unsigned int
3244  n_raw_lines(const unsigned int level) const;
3245 
3255  unsigned int
3256  n_raw_quads() const;
3257 
3267  unsigned int
3268  n_raw_quads(const unsigned int level) const;
3269 
3279  unsigned int
3280  n_raw_hexs(const unsigned int level) const;
3281 
3291  unsigned int
3292  n_raw_cells(const unsigned int level) const;
3293 
3305  unsigned int
3306  n_raw_faces() const;
3307 
3308  /*
3309  * @}
3310  */
3311 
3320  virtual std::size_t
3321  memory_consumption() const;
3322 
3332  template <class Archive>
3333  void
3334  save(Archive &ar, const unsigned int version) const;
3335 
3353  template <class Archive>
3354  void
3355  load(Archive &ar, const unsigned int version);
3356 
3357 
3373  virtual void
3374  add_periodicity(
3375  const std::vector<GridTools::PeriodicFacePair<cell_iterator>> &);
3376 
3380  const std::map<
3381  std::pair<cell_iterator, unsigned int>,
3382  std::pair<std::pair<cell_iterator, unsigned int>, std::bitset<3>>> &
3383  get_periodic_face_map() const;
3384 
3389  const std::vector<ReferenceCell::Type> &
3390  get_reference_cell_types() const;
3391 
3396  bool
3397  all_reference_cell_types_are_hyper_cube() const;
3398 
3399 #ifdef DOXYGEN
3400 
3405  template <class Archive>
3406  void
3407  serialize(Archive &archive, const unsigned int version);
3408 #else
3409  // This macro defines the serialize() method that is compatible with
3410  // the templated save() and load() method that have been implemented.
3411  BOOST_SERIALIZATION_SPLIT_MEMBER()
3412 #endif
3413 
3424  DeclException2(ExcInvalidLevel,
3425  int,
3426  int,
3427  << "You are requesting information from refinement level "
3428  << arg1
3429  << " of a triangulation, but this triangulation only has "
3430  << arg2 << " refinement levels. The given level " << arg1
3431  << " must be *less* than " << arg2 << ".");
3439  ExcTriangulationNotEmpty,
3440  int,
3441  int,
3442  << "You are trying to perform an operation on a triangulation "
3443  << "that is only allowed if the triangulation is currently empty. "
3444  << "However, it currently stores " << arg1 << " vertices and has "
3445  << "cells on " << arg2 << " levels.");
3451  DeclException0(ExcGridReadError);
3462  DeclException1(ExcEmptyLevel,
3463  int,
3464  << "You tried to do something on level " << arg1
3465  << ", but this level is empty.");
3471  DeclException0(ExcNonOrientableTriangulation);
3472 
3480  DeclException1(ExcBoundaryIdNotFound,
3482  << "The given boundary_id " << arg1
3483  << " is not defined in this Triangulation!");
3484 
3491  ExcInconsistentCoarseningFlags,
3492  "A cell is flagged for coarsening, but either not all of its siblings "
3493  "are active or flagged for coarsening as well. Please clean up all "
3494  "coarsen flags on your triangulation via "
3495  "Triangulation::prepare_coarsening_and_refinement() beforehand!");
3496 
3497  /*
3498  * @}
3499  */
3500 
3501 protected:
3507 
3512  std::vector<ReferenceCell::Type> reference_cell_types;
3513 
3527  static void
3528  write_bool_vector(const unsigned int magic_number1,
3529  const std::vector<bool> &v,
3530  const unsigned int magic_number2,
3531  std::ostream & out);
3532 
3537  static void
3538  read_bool_vector(const unsigned int magic_number1,
3539  std::vector<bool> &v,
3540  const unsigned int magic_number2,
3541  std::istream & in);
3542 
3547  void
3548  update_periodic_face_map();
3549 
3553  virtual void
3554  update_reference_cell_types();
3555 
3556 
3557 private:
3562  std::unique_ptr<
3565 
3572  std::vector<GridTools::PeriodicFacePair<cell_iterator>>
3574 
3579  std::map<std::pair<cell_iterator, unsigned int>,
3580  std::pair<std::pair<cell_iterator, unsigned int>, std::bitset<3>>>
3582 
3597  using raw_face_iterator =
3598  TriaRawIterator<TriaAccessor<dim - 1, dim, spacedim>>;
3599  using raw_vertex_iterator =
3601  using raw_line_iterator = typename IteratorSelector::raw_line_iterator;
3602  using raw_quad_iterator = typename IteratorSelector::raw_quad_iterator;
3603  using raw_hex_iterator = typename IteratorSelector::raw_hex_iterator;
3604 
3610  begin_raw(const unsigned int level = 0) const;
3611 
3617  end_raw(const unsigned int level) const;
3618 
3619  /*
3620  * @}
3621  */
3622 
3635  begin_raw_line(const unsigned int level = 0) const;
3636 
3655  begin_line(const unsigned int level = 0) const;
3656 
3675  begin_active_line(const unsigned int level = 0) const;
3676 
3682  end_line() const;
3683 
3684  /*
3685  * @}
3686  */
3687 
3713  begin_raw_quad(const unsigned int level = 0) const;
3714 
3733  begin_quad(const unsigned int level = 0) const;
3734 
3753  begin_active_quad(const unsigned int level = 0) const;
3754 
3760  end_quad() const;
3761 
3762  /*
3763  * @}
3764  */
3765 
3790  begin_raw_hex(const unsigned int level = 0) const;
3791 
3809  hex_iterator
3810  begin_hex(const unsigned int level = 0) const;
3811 
3830  begin_active_hex(const unsigned int level = 0) const;
3831 
3836  hex_iterator
3837  end_hex() const;
3838 
3839  /*
3840  * @}
3841  */
3842 
3843 
3857  void
3858  clear_despite_subscriptions();
3859 
3866  void
3867  reset_active_cell_indices();
3868 
3872  void
3873  reset_global_cell_indices();
3874 
3888  DistortedCellList
3889  execute_refinement();
3890 
3897  void
3898  execute_coarsening();
3899 
3904  void
3905  fix_coarsen_flags();
3906 
3920  virtual unsigned int
3921  coarse_cell_id_to_coarse_cell_index(
3923 
3924 
3937  virtual types::coarse_cell_id
3938  coarse_cell_index_to_coarse_cell_id(
3939  const unsigned int coarse_cell_index) const;
3940 
3945  std::vector<
3946  std::unique_ptr<::internal::TriangulationImplementation::TriaLevel>>
3948 
3954  std::unique_ptr<::internal::TriangulationImplementation::TriaFaces>
3956 
3957 
3961  std::vector<Point<spacedim>> vertices;
3962 
3966  std::vector<bool> vertices_used;
3967 
3972  std::map<types::manifold_id, std::unique_ptr<const Manifold<dim, spacedim>>>
3974 
3979 
3980 
3986 
3997 
4012  std::unique_ptr<std::map<unsigned int, types::boundary_id>>
4014 
4015 
4035  std::unique_ptr<std::map<unsigned int, types::manifold_id>>
4037 
4038  // make a couple of classes friends
4039  template <int, int, int>
4040  friend class TriaAccessorBase;
4041  template <int, int, int>
4042  friend class TriaAccessor;
4043  friend class TriaAccessor<0, 1, spacedim>;
4044 
4045  friend class CellAccessor<dim, spacedim>;
4046 
4047  friend struct ::internal::TriaAccessorImplementation::Implementation;
4048 
4049  friend struct ::internal::TriangulationImplementation::Implementation;
4050  friend struct ::internal::TriangulationImplementation::
4051  ImplementationMixedMesh;
4052 
4053  friend class ::internal::TriangulationImplementation::TriaObjects;
4054 
4055  // explicitly check for sensible template arguments, but not on windows
4056  // because MSVC creates bogus warnings during normal compilation
4057 #ifndef DEAL_II_MSVC
4058  static_assert(dim <= spacedim,
4059  "The dimension <dim> of a Triangulation must be less than or "
4060  "equal to the space dimension <spacedim> in which it lives.");
4061 #endif
4062 };
4063 
4064 
4065 #ifndef DOXYGEN
4066 
4067 
4068 
4069 namespace internal
4070 {
4071  namespace TriangulationImplementation
4072  {
4073  template <class Archive>
4074  void
4075  NumberCache<1>::serialize(Archive &ar, const unsigned int)
4076  {
4077  ar &n_levels;
4078  ar &n_lines &n_lines_level;
4079  ar &n_active_lines &n_active_lines_level;
4080  }
4081 
4082 
4083  template <class Archive>
4084  void
4085  NumberCache<2>::serialize(Archive &ar, const unsigned int version)
4086  {
4087  this->NumberCache<1>::serialize(ar, version);
4088 
4089  ar &n_quads &n_quads_level;
4090  ar &n_active_quads &n_active_quads_level;
4091  }
4092 
4093 
4094  template <class Archive>
4095  void
4096  NumberCache<3>::serialize(Archive &ar, const unsigned int version)
4097  {
4098  this->NumberCache<2>::serialize(ar, version);
4099 
4100  ar &n_hexes &n_hexes_level;
4101  ar &n_active_hexes &n_active_hexes_level;
4102  }
4103 
4104  } // namespace TriangulationImplementation
4105 } // namespace internal
4106 
4107 
4108 template <int dim, int spacedim>
4109 inline bool
4110 Triangulation<dim, spacedim>::vertex_used(const unsigned int index) const
4111 {
4112  AssertIndexRange(index, vertices_used.size());
4113  return vertices_used[index];
4114 }
4115 
4116 
4117 
4118 template <int dim, int spacedim>
4119 inline unsigned int
4121 {
4122  return number_cache.n_levels;
4123 }
4124 
4125 template <int dim, int spacedim>
4126 inline unsigned int
4128 {
4129  return number_cache.n_levels;
4130 }
4131 
4132 
4133 template <int dim, int spacedim>
4134 inline unsigned int
4136 {
4137  return vertices.size();
4138 }
4139 
4140 
4141 
4142 template <int dim, int spacedim>
4143 inline const std::vector<Point<spacedim>> &
4145 {
4146  return vertices;
4147 }
4148 
4149 
4150 template <int dim, int spacedim>
4151 template <class Archive>
4152 void
4153 Triangulation<dim, spacedim>::save(Archive &ar, const unsigned int) const
4154 {
4155  // as discussed in the documentation, do not store the signals as
4156  // well as boundary and manifold description but everything else
4157  ar &smooth_grid;
4158 
4159  unsigned int n_levels = levels.size();
4160  ar & n_levels;
4161  for (const auto &level : levels)
4162  ar &level;
4163 
4164  // boost dereferences a nullptr when serializing a nullptr
4165  // at least up to 1.65.1. This causes problems with clang-5.
4166  // Therefore, work around it.
4167  bool faces_is_nullptr = (faces.get() == nullptr);
4168  ar & faces_is_nullptr;
4169  if (!faces_is_nullptr)
4170  ar &faces;
4171 
4172  ar &vertices;
4173  ar &vertices_used;
4174 
4175  ar &anisotropic_refinement;
4176  ar &number_cache;
4177 
4178  ar &check_for_distorted_cells;
4179 
4180  if (dim == 1)
4181  {
4182  ar &vertex_to_boundary_id_map_1d;
4183  ar &vertex_to_manifold_id_map_1d;
4184  }
4185 }
4186 
4187 
4188 
4189 template <int dim, int spacedim>
4190 template <class Archive>
4191 void
4192 Triangulation<dim, spacedim>::load(Archive &ar, const unsigned int)
4193 {
4194  // clear previous content. this also calls the respective signal
4195  clear();
4196 
4197  // as discussed in the documentation, do not store the signals as
4198  // well as boundary and manifold description but everything else
4199  ar &smooth_grid;
4200 
4201  unsigned int size;
4202  ar & size;
4203  levels.resize(size);
4204  for (auto &level_ : levels)
4205  {
4206  std::unique_ptr<internal::TriangulationImplementation::TriaLevel> level;
4207  ar & level;
4208  level_ = std::move(level);
4209  }
4210 
4211  // Workaround for nullptr, see in save().
4212  bool faces_is_nullptr = true;
4213  ar & faces_is_nullptr;
4214  if (!faces_is_nullptr)
4215  ar &faces;
4216 
4217  ar &vertices;
4218  ar &vertices_used;
4219 
4220  ar &anisotropic_refinement;
4221  ar &number_cache;
4222 
4223  // the levels do not serialize the active_cell_indices because
4224  // they are easy enough to rebuild upon re-loading data. do
4225  // this here. don't forget to first resize the fields appropriately
4226  {
4227  for (auto &level : levels)
4228  level->active_cell_indices.resize(level->refine_flags.size());
4229  reset_active_cell_indices();
4230  }
4231 
4232 
4233  bool my_check_for_distorted_cells;
4234  ar & my_check_for_distorted_cells;
4235 
4236  Assert(my_check_for_distorted_cells == check_for_distorted_cells,
4237  ExcMessage("The triangulation loaded into here must have the "
4238  "same setting with regard to reporting distorted "
4239  "cell as the one previously stored."));
4240 
4241  if (dim == 1)
4242  {
4243  ar &vertex_to_boundary_id_map_1d;
4244  ar &vertex_to_manifold_id_map_1d;
4245  }
4246 
4247  // trigger the create signal to indicate
4248  // that new content has been imported into
4249  // the triangulation
4250  signals.create();
4251 }
4252 
4253 
4254 
4255 template <int dim, int spacedim>
4256 inline unsigned int
4259 {
4260  return coarse_cell_id;
4261 }
4262 
4263 
4264 
4265 template <int dim, int spacedim>
4266 inline types::coarse_cell_id
4268  const unsigned int coarse_cell_index) const
4269 {
4270  return coarse_cell_index;
4271 }
4272 
4273 
4274 
4275 /* -------------- declaration of explicit specializations ------------- */
4276 
4277 template <>
4278 unsigned int
4280 template <>
4281 unsigned int
4282 Triangulation<1, 1>::n_quads(const unsigned int level) const;
4283 template <>
4284 unsigned int
4285 Triangulation<1, 1>::n_raw_quads(const unsigned int level) const;
4286 template <>
4287 unsigned int
4288 Triangulation<2, 2>::n_raw_quads(const unsigned int level) const;
4289 template <>
4290 unsigned int
4291 Triangulation<1, 1>::n_raw_hexs(const unsigned int level) const;
4292 template <>
4293 unsigned int
4294 Triangulation<1, 1>::n_active_quads(const unsigned int level) const;
4295 template <>
4296 unsigned int
4298 template <>
4299 unsigned int
4301 
4302 
4303 // -------------------------------------------------------------------
4304 // -- Explicit specializations for codimension one grids
4305 
4306 
4307 template <>
4308 unsigned int
4310 template <>
4311 unsigned int
4312 Triangulation<1, 2>::n_quads(const unsigned int level) const;
4313 template <>
4314 unsigned int
4315 Triangulation<1, 2>::n_raw_quads(const unsigned int level) const;
4316 template <>
4317 unsigned int
4318 Triangulation<2, 3>::n_raw_quads(const unsigned int level) const;
4319 template <>
4320 unsigned int
4321 Triangulation<1, 2>::n_raw_hexs(const unsigned int level) const;
4322 template <>
4323 unsigned int
4324 Triangulation<1, 2>::n_active_quads(const unsigned int level) const;
4325 template <>
4326 unsigned int
4328 template <>
4329 unsigned int
4331 
4332 // -------------------------------------------------------------------
4333 // -- Explicit specializations for codimension two grids
4334 
4335 
4336 template <>
4337 unsigned int
4339 template <>
4340 unsigned int
4341 Triangulation<1, 3>::n_quads(const unsigned int level) const;
4342 template <>
4343 unsigned int
4344 Triangulation<1, 3>::n_raw_quads(const unsigned int level) const;
4345 template <>
4346 unsigned int
4347 Triangulation<2, 3>::n_raw_quads(const unsigned int level) const;
4348 template <>
4349 unsigned int
4350 Triangulation<1, 3>::n_raw_hexs(const unsigned int level) const;
4351 template <>
4352 unsigned int
4353 Triangulation<1, 3>::n_active_quads(const unsigned int level) const;
4354 template <>
4355 unsigned int
4357 template <>
4358 unsigned int
4360 
4361 
4362 #endif // DOXYGEN
4363 
4365 
4366 // Include tria_accessor.h here, so that it is possible for an end
4367 // user to use the iterators of Triangulation<dim> directly without
4368 // the need to include tria_accessor.h separately. (Otherwise the
4369 // iterators are an 'opaque' or 'incomplete' type.)
4371 
4372 #endif
boost::signals2::signal< void(const Triangulation< dim, spacedim > &destination_tria)> copy
Definition: tria.h:2142
::internal::TriangulationImplementation::NumberCache< dim > number_cache
Definition: tria.h:3996
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:2094
unsigned int n_vertices() const
boost::signals2::signal< void(const typename Triangulation< dim, spacedim >::cell_iterator &cell)> pre_coarsening_on_cell
Definition: tria.h:2122
#define DeclException2(Exception2, type1, type2, outsequence)
Definition: exceptions.h:538
boost::signals2::signal< void()> post_distributed_repartition
Definition: tria.h:2240
typename IteratorSelector::line_iterator line_iterator
Definition: tria.h:1448
T operator()(InputIterator first, InputIterator last) const
Definition: tria.h:2054
MeshSmoothing smooth_grid
Definition: tria.h:3506
typename IteratorSelector::raw_line_iterator raw_line_iterator
Definition: tria.h:3601
std::vector< Point< spacedim > > vertices
Definition: tria.h:3961
std::map< types::manifold_id, std::unique_ptr< const Manifold< dim, spacedim > > > manifold
Definition: tria.h:3973
typename IteratorSelector::hex_iterator hex_iterator
Definition: tria.h:1496
typename IteratorSelector::active_line_iterator active_line_iterator
Definition: tria.h:1463
boost::signals2::signal< void()> pre_distributed_refinement
Definition: tria.h:2211
bool anisotropic_refinement
Definition: tria.h:3978
#define AssertIndexRange(index, range)
Definition: exceptions.h:1691
std::unique_ptr< ::internal::TriangulationImplementation::Policy< dim, spacedim > > policy
Definition: tria.h:3564
std::vector< GridTools::PeriodicFacePair< cell_iterator > > periodic_face_pairs_level_0
Definition: tria.h:3573
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:2087
const bool check_for_distorted_cells
Definition: tria.h:3985
#define DeclException1(Exception1, type1, outsequence)
Definition: exceptions.h:515
static const char T
unsigned int n_raw_quads() const
Definition: tria.cc:13101
#define Assert(cond, exc)
Definition: exceptions.h:1466
Signals signals
Definition: tria.h:2276
std::vector< std::unique_ptr<::internal::TriangulationImplementation::TriaLevel > > levels
Definition: tria.h:3947
boost::signals2::signal< void()> clear
Definition: tria.h:2157
unsigned int n_raw_hexs(const unsigned int level) const
Definition: tria.cc:13157
unsigned int max_adjacent_cells() const
Definition: tria.cc:13274
void load(Archive &ar, const unsigned int version)
std::list< typename Triangulation< dim, spacedim >::cell_iterator > distorted_cells
Definition: tria.h:1542
unsigned int n_quads() const
Definition: tria.cc:13053
#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:4036
std::vector< bool > vertices_used
Definition: tria.h:3966
#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:2132
typename IteratorSelector::active_quad_iterator active_quad_iterator
Definition: tria.h:1487
const std::vector< Point< spacedim > > & get_vertices() const
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:380
boost::signals2::signal< void()> mesh_movement
Definition: tria.h:2111
unsigned int level
Definition: grid_out.cc:4358
typename IteratorSelector::raw_quad_iterator raw_quad_iterator
Definition: tria.h:3602
VectorType::value_type * end(VectorType &V)
std::unique_ptr<::internal::TriangulationImplementation::TriaFaces > faces
Definition: tria.h:3955
Point< 3 > vertices[4]
boost::signals2::signal< void()> pre_distributed_save
Definition: tria.h:2248
void save(Archive &ar, const unsigned int version) const
std::vector< ReferenceCell::Type > reference_cell_types
Definition: tria.h:3512
unsigned int n_active_cells(const internal::TriangulationImplementation::NumberCache< 1 > &c)
Definition: tria.cc:12646
typename IteratorSelector::quad_iterator quad_iterator
Definition: tria.h:1472
TriangulationBase< dim, spacedim > Triangulation
Definition: tria_base.h:395
boost::signals2::signal< void()> create
Definition: tria.h:2078
std::unique_ptr< std::map< unsigned int, types::boundary_id > > vertex_to_boundary_id_map_1d
Definition: tria.h:4013
Definition: hp.h:117
unsigned int n_active_quads() const
Definition: tria.cc:13120
unsigned int n_cells(const internal::TriangulationImplementation::NumberCache< 1 > &c)
Definition: tria.cc:12639
Definition: cell_id.h:70
Point< 2 > first
Definition: grid_out.cc:4355
boost::signals2::signal< void()> pre_partition
Definition: tria.h:2102
typename IteratorSelector::active_hex_iterator active_hex_iterator
Definition: tria.h:1507
boost::signals2::signal< void()> post_distributed_save
Definition: tria.h:2255
std::vector< unsigned int > n_active_hexes_level
Definition: tria.h:300
std::map< std::pair< cell_iterator, unsigned int >, std::pair< std::pair< cell_iterator, unsigned int >, std::bitset< 3 > > > periodic_face_map
Definition: tria.h:3581
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:379
virtual unsigned int n_global_levels() const
VectorType::value_type * begin(VectorType &V)
typename IteratorSelector::raw_hex_iterator raw_hex_iterator
Definition: tria.h:3603
boost::signals2::signal< unsigned int(const cell_iterator &, const CellStatus), CellWeightSum< unsigned int > > cell_weight
Definition: tria.h:2198
boost::signals2::signal< void()> pre_distributed_load
Definition: tria.h:2263
std::vector< unsigned int > n_active_lines_level
Definition: tria.h:183
std::vector< unsigned int > n_active_quads_level
Definition: tria.h:241
boost::signals2::signal< void()> post_distributed_load
Definition: tria.h:2270
global_cell_index coarse_cell_id
Definition: types.h:114
boost::signals2::signal< void()> pre_distributed_repartition
Definition: tria.h:2233
bool vertex_used(const unsigned int index) const
boost::signals2::signal< void()> any_change
Definition: tria.h:2168
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:2221