Reference documentation for deal.II version Git 4e68a80cad 2021-10-22 15:50:12 -0600
\(\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 - 2021 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 #endif
112 
113 
114 /*------------------------------------------------------------------------*/
115 
116 
117 namespace internal
118 {
123  namespace TriangulationImplementation
124  {
136  template <int dim>
137  struct NumberCache
138  {};
139 
151  template <>
152  struct NumberCache<1>
153  {
157  unsigned int n_levels;
158 
162  unsigned int n_lines;
163 
167  std::vector<unsigned int> n_lines_level;
168 
172  unsigned int n_active_lines;
173 
177  std::vector<unsigned int> n_active_lines_level;
178 
182  NumberCache();
183 
188  std::size_t
189  memory_consumption() const;
190 
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 
254  template <class Archive>
255  void
256  serialize(Archive &ar, const unsigned int version);
257  };
258 
259 
273  template <>
274  struct NumberCache<3> : public NumberCache<2>
275  {
279  unsigned int n_hexes;
280 
284  std::vector<unsigned int> n_hexes_level;
285 
289  unsigned int n_active_hexes;
290 
294  std::vector<unsigned int> n_active_hexes_level;
295 
299  NumberCache();
300 
305  std::size_t
306  memory_consumption() const;
307 
313  template <class Archive>
314  void
315  serialize(Archive &ar, const unsigned int version);
316  };
317  } // namespace TriangulationImplementation
318 } // namespace internal
319 
320 
321 /*------------------------------------------------------------------------*/
322 
323 
1120 template <int dim, int spacedim = dim>
1122 {
1123 private:
1128  using IteratorSelector =
1130 
1131 public:
1137  {
1142  none = 0x0,
1186  limit_level_difference_at_vertices = 0x1,
1207  eliminate_unrefined_islands = 0x2,
1223  patch_level_1 = 0x4,
1247  coarsest_level_1 = 0x8,
1272  allow_anisotropic_smoothing = 0x10,
1305  eliminate_refined_inner_islands = 0x100,
1310  eliminate_refined_boundary_islands = 0x200,
1316  do_not_produce_unrefined_islands = 0x400,
1317 
1322  smoothing_on_refinement =
1323  (limit_level_difference_at_vertices | eliminate_unrefined_islands),
1328  smoothing_on_coarsening =
1329  (eliminate_refined_inner_islands | eliminate_refined_boundary_islands |
1330  do_not_produce_unrefined_islands),
1331 
1337  maximum_smoothing = 0xffff ^ allow_anisotropic_smoothing
1338  };
1339 
1356 
1362 
1380 
1394  using face_iterator = TriaIterator<TriaAccessor<dim - 1, dim, spacedim>>;
1395 
1407  using active_face_iterator =
1408  TriaActiveIterator<TriaAccessor<dim - 1, dim, spacedim>>;
1409 
1419 
1432  using active_vertex_iterator =
1434 
1442  using line_iterator = typename IteratorSelector::line_iterator;
1443 
1457  using active_line_iterator = typename IteratorSelector::active_line_iterator;
1458 
1466  using quad_iterator = typename IteratorSelector::quad_iterator;
1467 
1481  using active_quad_iterator = typename IteratorSelector::active_quad_iterator;
1482 
1490  using hex_iterator = typename IteratorSelector::hex_iterator;
1491 
1501  using active_hex_iterator = typename IteratorSelector::active_hex_iterator;
1502 
1522  {
1529  virtual ~DistortedCellList() noexcept override;
1530 
1535  std::list<typename Triangulation<dim, spacedim>::cell_iterator>
1537  };
1538 
1542  static const unsigned int dimension = dim;
1543 
1547  static const unsigned int space_dimension = spacedim;
1548 
1563  Triangulation(const MeshSmoothing smooth_grid = none,
1564  const bool check_for_distorted_cells = false);
1565 
1581  Triangulation(const Triangulation<dim, spacedim> &) = delete;
1582 
1590 
1594  Triangulation &
1595  operator=(Triangulation<dim, spacedim> &&tria) noexcept;
1596 
1600  virtual ~Triangulation() override;
1601 
1608  virtual void
1609  clear();
1610 
1615  virtual MPI_Comm
1616  get_communicator() const;
1617 
1623  virtual void
1624  set_mesh_smoothing(const MeshSmoothing mesh_smoothing);
1625 
1629  virtual const MeshSmoothing &
1630  get_mesh_smoothing() const;
1631 
1654  void
1655  set_manifold(const types::manifold_id number,
1656  const Manifold<dim, spacedim> &manifold_object);
1657 
1670  void
1671  reset_manifold(const types::manifold_id manifold_number);
1672 
1684  void
1685  reset_all_manifolds();
1686 
1695  void
1696  set_all_manifold_ids(const types::manifold_id number);
1697 
1706  void
1707  set_all_manifold_ids_on_boundary(const types::manifold_id number);
1708 
1718  void
1719  set_all_manifold_ids_on_boundary(const types::boundary_id b_id,
1720  const types::manifold_id number);
1721 
1733  const Manifold<dim, spacedim> &
1734  get_manifold(const types::manifold_id number) const;
1735 
1748  virtual std::vector<types::boundary_id>
1749  get_boundary_ids() const;
1750 
1763  virtual std::vector<types::manifold_id>
1764  get_manifold_ids() const;
1765 
1792  virtual void
1793  copy_triangulation(const Triangulation<dim, spacedim> &other_tria);
1794 
1842  virtual void
1843  create_triangulation(const std::vector<Point<spacedim>> &vertices,
1844  const std::vector<CellData<dim>> & cells,
1845  const SubCellData & subcelldata);
1846 
1859  virtual void
1862  &construction_data);
1863 
1873  virtual void
1874  create_triangulation_compatibility(
1875  const std::vector<Point<spacedim>> &vertices,
1876  const std::vector<CellData<dim>> & cells,
1877  const SubCellData & subcelldata);
1878 
1885  void
1886  flip_all_direction_flags();
1887 
1899  void
1900  set_all_refine_flags();
1901 
1924  void
1925  refine_global(const unsigned int times = 1);
1926 
1939  void
1940  coarsen_global(const unsigned int times = 1);
1941 
1973  virtual void
1974  execute_coarsening_and_refinement();
1975 
2005  virtual bool
2006  prepare_coarsening_and_refinement();
2007 
2008  /*
2009  * @}
2010  */
2011 
2026  {
2043  CELL_INVALID
2044  };
2045 
2051  template <typename T>
2053  {
2054  using result_type = T;
2055 
2056  template <typename InputIterator>
2057  T
2058  operator()(InputIterator first, InputIterator last) const
2059  {
2060  return std::accumulate(first, last, T());
2061  }
2062  };
2063 
2073  struct Signals
2074  {
2082  boost::signals2::signal<void()> create;
2083 
2091  boost::signals2::signal<void()> pre_refinement;
2092 
2098  boost::signals2::signal<void()> post_refinement;
2099 
2106  boost::signals2::signal<void()> pre_partition;
2107 
2115  boost::signals2::signal<void()> mesh_movement;
2116 
2124  boost::signals2::signal<void(
2125  const typename Triangulation<dim, spacedim>::cell_iterator &cell)>
2127 
2134  boost::signals2::signal<void(
2135  const typename Triangulation<dim, spacedim>::cell_iterator &cell)>
2137 
2144  boost::signals2::signal<void(
2145  const Triangulation<dim, spacedim> &destination_tria)>
2147 
2161  boost::signals2::signal<void()> clear;
2162 
2172  boost::signals2::signal<void()> any_change;
2173 
2199  boost::signals2::signal<unsigned int(const cell_iterator &,
2200  const CellStatus),
2203 
2215  boost::signals2::signal<void()> pre_distributed_refinement;
2216 
2224  boost::signals2::signal<void()> post_p4est_refinement;
2225 
2234  boost::signals2::signal<void()> post_distributed_refinement;
2235 
2246  boost::signals2::signal<void()> pre_distributed_repartition;
2247 
2253  boost::signals2::signal<void()> post_distributed_repartition;
2254 
2261  boost::signals2::signal<void()> pre_distributed_save;
2262 
2268  boost::signals2::signal<void()> post_distributed_save;
2269 
2276  boost::signals2::signal<void()> pre_distributed_load;
2277 
2283  boost::signals2::signal<void()> post_distributed_load;
2284  };
2285 
2289  mutable Signals signals;
2290 
2291  /*
2292  * @}
2293  */
2294 
2304  void
2305  save_refine_flags(std::ostream &out) const;
2306 
2310  void
2311  save_refine_flags(std::vector<bool> &v) const;
2312 
2316  void
2317  load_refine_flags(std::istream &in);
2318 
2322  void
2323  load_refine_flags(const std::vector<bool> &v);
2324 
2328  void
2329  save_coarsen_flags(std::ostream &out) const;
2330 
2334  void
2335  save_coarsen_flags(std::vector<bool> &v) const;
2336 
2340  void
2341  load_coarsen_flags(std::istream &out);
2342 
2346  void
2347  load_coarsen_flags(const std::vector<bool> &v);
2348 
2353  bool
2354  get_anisotropic_refinement_flag() const;
2355 
2356  /*
2357  * @}
2358  */
2359 
2369  void
2370  clear_user_flags();
2371 
2377  void
2378  save_user_flags(std::ostream &out) const;
2379 
2385  void
2386  save_user_flags(std::vector<bool> &v) const;
2387 
2392  void
2393  load_user_flags(std::istream &in);
2394 
2399  void
2400  load_user_flags(const std::vector<bool> &v);
2401 
2406  void
2407  clear_user_flags_line();
2408 
2413  void
2414  save_user_flags_line(std::ostream &out) const;
2415 
2421  void
2422  save_user_flags_line(std::vector<bool> &v) const;
2423 
2428  void
2429  load_user_flags_line(std::istream &in);
2430 
2435  void
2436  load_user_flags_line(const std::vector<bool> &v);
2437 
2442  void
2443  clear_user_flags_quad();
2444 
2449  void
2450  save_user_flags_quad(std::ostream &out) const;
2451 
2457  void
2458  save_user_flags_quad(std::vector<bool> &v) const;
2459 
2464  void
2465  load_user_flags_quad(std::istream &in);
2466 
2471  void
2472  load_user_flags_quad(const std::vector<bool> &v);
2473 
2474 
2479  void
2480  clear_user_flags_hex();
2481 
2486  void
2487  save_user_flags_hex(std::ostream &out) const;
2488 
2494  void
2495  save_user_flags_hex(std::vector<bool> &v) const;
2496 
2501  void
2502  load_user_flags_hex(std::istream &in);
2503 
2508  void
2509  load_user_flags_hex(const std::vector<bool> &v);
2510 
2516  void
2517  clear_user_data();
2518 
2524  void
2525  save_user_indices(std::vector<unsigned int> &v) const;
2526 
2531  void
2532  load_user_indices(const std::vector<unsigned int> &v);
2533 
2539  void
2540  save_user_pointers(std::vector<void *> &v) const;
2541 
2546  void
2547  load_user_pointers(const std::vector<void *> &v);
2548 
2554  void
2555  save_user_indices_line(std::vector<unsigned int> &v) const;
2556 
2561  void
2562  load_user_indices_line(const std::vector<unsigned int> &v);
2563 
2569  void
2570  save_user_indices_quad(std::vector<unsigned int> &v) const;
2571 
2576  void
2577  load_user_indices_quad(const std::vector<unsigned int> &v);
2578 
2584  void
2585  save_user_indices_hex(std::vector<unsigned int> &v) const;
2586 
2591  void
2592  load_user_indices_hex(const std::vector<unsigned int> &v);
2598  void
2599  save_user_pointers_line(std::vector<void *> &v) const;
2600 
2605  void
2606  load_user_pointers_line(const std::vector<void *> &v);
2607 
2613  void
2614  save_user_pointers_quad(std::vector<void *> &v) const;
2615 
2620  void
2621  load_user_pointers_quad(const std::vector<void *> &v);
2622 
2628  void
2629  save_user_pointers_hex(std::vector<void *> &v) const;
2630 
2635  void
2636  load_user_pointers_hex(const std::vector<void *> &v);
2637 
2638  /*
2639  * @}
2640  */
2641 
2665  begin(const unsigned int level = 0) const;
2666 
2698  begin_active(const unsigned int level = 0) const;
2699 
2705  end() const;
2706 
2726  end(const unsigned int level) const;
2727 
2748  end_active(const unsigned int level) const;
2749 
2750 
2755  last() const;
2756 
2761  last_active() const;
2762 
2776  create_cell_iterator(const CellId &cell_id) const;
2777 
2793  cell_iterators() const;
2794 
2831  active_cell_iterators() const;
2832 
2849  cell_iterators_on_level(const unsigned int level) const;
2850 
2867  active_cell_iterators_on_level(const unsigned int level) const;
2868 
2869  /*
2870  * @}
2871  */
2872 
2873  /*-------------------------------------------------------------------------*/
2874 
2884  begin_face() const;
2885 
2890  begin_active_face() const;
2891 
2897  end_face() const;
2898 
2918  active_face_iterators() const;
2919 
2920  /*
2921  * @}
2922  */
2923 
2924  /*-------------------------------------------------------------------------*/
2925 
2936  begin_vertex() const;
2937 
2944  begin_active_vertex() const;
2945 
2952  end_vertex() const;
2953 
2954  /*
2955  * @}
2956  */
2957 
2975  unsigned int
2976  n_lines() const;
2977 
2981  unsigned int
2982  n_lines(const unsigned int level) const;
2983 
2987  unsigned int
2988  n_active_lines() const;
2989 
2993  unsigned int
2994  n_active_lines(const unsigned int level) const;
2995 
2999  unsigned int
3000  n_quads() const;
3001 
3005  unsigned int
3006  n_quads(const unsigned int level) const;
3007 
3011  unsigned int
3012  n_active_quads() const;
3013 
3017  unsigned int
3018  n_active_quads(const unsigned int level) const;
3019 
3023  unsigned int
3024  n_hexs() const;
3025 
3030  unsigned int
3031  n_hexs(const unsigned int level) const;
3032 
3036  unsigned int
3037  n_active_hexs() const;
3038 
3043  unsigned int
3044  n_active_hexs(const unsigned int level) const;
3045 
3050  unsigned int
3051  n_cells() const;
3052 
3057  unsigned int
3058  n_cells(const unsigned int level) const;
3059 
3064  unsigned int
3065  n_active_cells() const;
3066 
3074  virtual types::global_cell_index
3075  n_global_active_cells() const;
3076 
3077 
3082  unsigned int
3083  n_active_cells(const unsigned int level) const;
3084 
3089  virtual types::coarse_cell_id
3090  n_global_coarse_cells() const;
3091 
3097  unsigned int
3098  n_faces() const;
3099 
3105  unsigned int
3106  n_active_faces() const;
3107 
3125  unsigned int
3126  n_levels() const;
3127 
3134  virtual unsigned int
3135  n_global_levels() const;
3136 
3146  virtual bool
3147  has_hanging_nodes() const;
3148 
3156  unsigned int
3157  n_vertices() const;
3158 
3167  const std::vector<Point<spacedim>> &
3168  get_vertices() const;
3169 
3174  unsigned int
3175  n_used_vertices() const;
3176 
3180  bool
3181  vertex_used(const unsigned int index) const;
3182 
3187  const std::vector<bool> &
3188  get_used_vertices() const;
3189 
3201  unsigned int
3202  max_adjacent_cells() const;
3203 
3210  virtual types::subdomain_id
3211  locally_owned_subdomain() const;
3212 
3223  get_triangulation();
3224 
3230  get_triangulation() const;
3231 
3232 
3233  /*
3234  * @}
3235  */
3236 
3251  unsigned int
3252  n_raw_lines() const;
3253 
3263  unsigned int
3264  n_raw_lines(const unsigned int level) const;
3265 
3275  unsigned int
3276  n_raw_quads() const;
3277 
3287  unsigned int
3288  n_raw_quads(const unsigned int level) const;
3289 
3299  unsigned int
3300  n_raw_hexs(const unsigned int level) const;
3301 
3311  unsigned int
3312  n_raw_cells(const unsigned int level) const;
3313 
3325  unsigned int
3326  n_raw_faces() const;
3327 
3328  /*
3329  * @}
3330  */
3331 
3340  virtual std::size_t
3341  memory_consumption() const;
3342 
3352  template <class Archive>
3353  void
3354  save(Archive &ar, const unsigned int version) const;
3355 
3373  template <class Archive>
3374  void
3375  load(Archive &ar, const unsigned int version);
3376 
3377 
3393  virtual void
3394  add_periodicity(
3395  const std::vector<GridTools::PeriodicFacePair<cell_iterator>> &);
3396 
3400  const std::map<
3401  std::pair<cell_iterator, unsigned int>,
3402  std::pair<std::pair<cell_iterator, unsigned int>, std::bitset<3>>> &
3403  get_periodic_face_map() const;
3404 
3409  const std::vector<ReferenceCell> &
3410  get_reference_cells() const;
3411 
3416  bool
3417  all_reference_cells_are_hyper_cube() const;
3418 
3419 #ifdef DOXYGEN
3420 
3425  template <class Archive>
3426  void
3427  serialize(Archive &archive, const unsigned int version);
3428 #else
3429  // This macro defines the serialize() method that is compatible with
3430  // the templated save() and load() method that have been implemented.
3431  BOOST_SERIALIZATION_SPLIT_MEMBER()
3432 #endif
3433 
3444  DeclException2(ExcInvalidLevel,
3445  int,
3446  int,
3447  << "You are requesting information from refinement level "
3448  << arg1
3449  << " of a triangulation, but this triangulation only has "
3450  << arg2 << " refinement levels. The given level " << arg1
3451  << " must be *less* than " << arg2 << ".");
3459  ExcTriangulationNotEmpty,
3460  int,
3461  int,
3462  << "You are trying to perform an operation on a triangulation "
3463  << "that is only allowed if the triangulation is currently empty. "
3464  << "However, it currently stores " << arg1 << " vertices and has "
3465  << "cells on " << arg2 << " levels.");
3471  DeclException0(ExcGridReadError);
3482  DeclException1(ExcEmptyLevel,
3483  int,
3484  << "You tried to do something on level " << arg1
3485  << ", but this level is empty.");
3491  DeclException0(ExcNonOrientableTriangulation);
3492 
3500  DeclException1(ExcBoundaryIdNotFound,
3502  << "The given boundary_id " << arg1
3503  << " is not defined in this Triangulation!");
3504 
3511  ExcInconsistentCoarseningFlags,
3512  "A cell is flagged for coarsening, but either not all of its siblings "
3513  "are active or flagged for coarsening as well. Please clean up all "
3514  "coarsen flags on your triangulation via "
3515  "Triangulation::prepare_coarsening_and_refinement() beforehand!");
3516 
3517  /*
3518  * @}
3519  */
3520 
3521 protected:
3527 
3532  std::vector<ReferenceCell> reference_cells;
3533 
3547  static void
3548  write_bool_vector(const unsigned int magic_number1,
3549  const std::vector<bool> &v,
3550  const unsigned int magic_number2,
3551  std::ostream & out);
3552 
3557  static void
3558  read_bool_vector(const unsigned int magic_number1,
3559  std::vector<bool> &v,
3560  const unsigned int magic_number2,
3561  std::istream & in);
3562 
3567  void
3568  update_periodic_face_map();
3569 
3573  virtual void
3574  update_reference_cells();
3575 
3576 
3577 private:
3582  std::unique_ptr<
3585 
3592  std::vector<GridTools::PeriodicFacePair<cell_iterator>>
3594 
3599  std::map<std::pair<cell_iterator, unsigned int>,
3600  std::pair<std::pair<cell_iterator, unsigned int>, std::bitset<3>>>
3602 
3617  using raw_face_iterator =
3618  TriaRawIterator<TriaAccessor<dim - 1, dim, spacedim>>;
3619  using raw_vertex_iterator =
3621  using raw_line_iterator = typename IteratorSelector::raw_line_iterator;
3622  using raw_quad_iterator = typename IteratorSelector::raw_quad_iterator;
3623  using raw_hex_iterator = typename IteratorSelector::raw_hex_iterator;
3624 
3630  begin_raw(const unsigned int level = 0) const;
3631 
3637  end_raw(const unsigned int level) const;
3638 
3639  /*
3640  * @}
3641  */
3642 
3655  begin_raw_line(const unsigned int level = 0) const;
3656 
3675  begin_line(const unsigned int level = 0) const;
3676 
3695  begin_active_line(const unsigned int level = 0) const;
3696 
3702  end_line() const;
3703 
3704  /*
3705  * @}
3706  */
3707 
3733  begin_raw_quad(const unsigned int level = 0) const;
3734 
3753  begin_quad(const unsigned int level = 0) const;
3754 
3773  begin_active_quad(const unsigned int level = 0) const;
3774 
3780  end_quad() const;
3781 
3782  /*
3783  * @}
3784  */
3785 
3810  begin_raw_hex(const unsigned int level = 0) const;
3811 
3829  hex_iterator
3830  begin_hex(const unsigned int level = 0) const;
3831 
3850  begin_active_hex(const unsigned int level = 0) const;
3851 
3856  hex_iterator
3857  end_hex() const;
3858 
3859  /*
3860  * @}
3861  */
3862 
3863 
3877  void
3878  clear_despite_subscriptions();
3879 
3883  void
3884  reset_policy();
3885 
3892  void
3893  reset_active_cell_indices();
3894 
3898  void
3899  reset_global_cell_indices();
3900 
3904  void
3905  reset_cell_vertex_indices_cache();
3906 
3920  DistortedCellList
3921  execute_refinement();
3922 
3929  void
3930  execute_coarsening();
3931 
3936  void
3937  fix_coarsen_flags();
3938 
3952  virtual unsigned int
3953  coarse_cell_id_to_coarse_cell_index(
3955 
3956 
3969  virtual types::coarse_cell_id
3971  const unsigned int coarse_cell_index) const;
3972 
3977  std::vector<
3978  std::unique_ptr<::internal::TriangulationImplementation::TriaLevel>>
3980 
3986  std::unique_ptr<::internal::TriangulationImplementation::TriaFaces>
3988 
3989 
3993  std::vector<Point<spacedim>> vertices;
3994 
3998  std::vector<bool> vertices_used;
3999 
4004  std::map<types::manifold_id, std::unique_ptr<const Manifold<dim, spacedim>>>
4006 
4011 
4012 
4018 
4029 
4044  std::unique_ptr<std::map<unsigned int, types::boundary_id>>
4046 
4047 
4067  std::unique_ptr<std::map<unsigned int, types::manifold_id>>
4069 
4070  // make a couple of classes friends
4071  template <int, int, int>
4072  friend class TriaAccessorBase;
4073  template <int, int, int>
4074  friend class TriaAccessor;
4075  friend class TriaAccessor<0, 1, spacedim>;
4076 
4077  friend class CellAccessor<dim, spacedim>;
4078 
4079  friend struct ::internal::TriaAccessorImplementation::Implementation;
4080 
4081  friend struct ::internal::TriangulationImplementation::Implementation;
4082  friend struct ::internal::TriangulationImplementation::
4083  ImplementationMixedMesh;
4084 
4085  friend class ::internal::TriangulationImplementation::TriaObjects;
4086 
4087  // explicitly check for sensible template arguments, but not on windows
4088  // because MSVC creates bogus warnings during normal compilation
4089 #ifndef DEAL_II_MSVC
4090  static_assert(dim <= spacedim,
4091  "The dimension <dim> of a Triangulation must be less than or "
4092  "equal to the space dimension <spacedim> in which it lives.");
4093 #endif
4094 };
4095 
4096 
4097 #ifndef DOXYGEN
4098 
4099 
4100 
4101 namespace internal
4102 {
4103  namespace TriangulationImplementation
4104  {
4105  template <class Archive>
4106  void
4107  NumberCache<1>::serialize(Archive &ar, const unsigned int)
4108  {
4109  ar &n_levels;
4110  ar &n_lines &n_lines_level;
4111  ar &n_active_lines &n_active_lines_level;
4112  }
4113 
4114 
4115  template <class Archive>
4116  void
4117  NumberCache<2>::serialize(Archive &ar, const unsigned int version)
4118  {
4119  this->NumberCache<1>::serialize(ar, version);
4120 
4121  ar &n_quads &n_quads_level;
4122  ar &n_active_quads &n_active_quads_level;
4123  }
4124 
4125 
4126  template <class Archive>
4127  void
4128  NumberCache<3>::serialize(Archive &ar, const unsigned int version)
4129  {
4130  this->NumberCache<2>::serialize(ar, version);
4131 
4132  ar &n_hexes &n_hexes_level;
4133  ar &n_active_hexes &n_active_hexes_level;
4134  }
4135 
4136  } // namespace TriangulationImplementation
4137 } // namespace internal
4138 
4139 
4140 template <int dim, int spacedim>
4141 inline bool
4142 Triangulation<dim, spacedim>::vertex_used(const unsigned int index) const
4143 {
4144  AssertIndexRange(index, vertices_used.size());
4145  return vertices_used[index];
4146 }
4147 
4148 
4149 
4150 template <int dim, int spacedim>
4151 inline unsigned int
4153 {
4154  return number_cache.n_levels;
4155 }
4156 
4157 template <int dim, int spacedim>
4158 inline unsigned int
4160 {
4161  return number_cache.n_levels;
4162 }
4163 
4164 
4165 template <int dim, int spacedim>
4166 inline unsigned int
4168 {
4169  return vertices.size();
4170 }
4171 
4172 
4173 
4174 template <int dim, int spacedim>
4175 inline const std::vector<Point<spacedim>> &
4177 {
4178  return vertices;
4179 }
4180 
4181 
4182 template <int dim, int spacedim>
4183 template <class Archive>
4184 void
4185 Triangulation<dim, spacedim>::save(Archive &ar, const unsigned int) const
4186 {
4187  // as discussed in the documentation, do not store the signals as
4188  // well as boundary and manifold description but everything else
4189  ar &smooth_grid;
4190 
4191  unsigned int n_levels = levels.size();
4192  ar & n_levels;
4193  for (const auto &level : levels)
4194  ar &level;
4195 
4196  // boost dereferences a nullptr when serializing a nullptr
4197  // at least up to 1.65.1. This causes problems with clang-5.
4198  // Therefore, work around it.
4199  bool faces_is_nullptr = (faces.get() == nullptr);
4200  ar & faces_is_nullptr;
4201  if (!faces_is_nullptr)
4202  ar &faces;
4203 
4204  ar &vertices;
4205  ar &vertices_used;
4206 
4207  ar &anisotropic_refinement;
4208  ar &number_cache;
4209 
4210  ar &check_for_distorted_cells;
4211 
4212  if (dim == 1)
4213  {
4214  ar &vertex_to_boundary_id_map_1d;
4215  ar &vertex_to_manifold_id_map_1d;
4216  }
4217 }
4218 
4219 
4220 
4221 template <int dim, int spacedim>
4222 template <class Archive>
4223 void
4224 Triangulation<dim, spacedim>::load(Archive &ar, const unsigned int)
4225 {
4226  // clear previous content. this also calls the respective signal
4227  clear();
4228 
4229  // as discussed in the documentation, do not store the signals as
4230  // well as boundary and manifold description but everything else
4231  ar &smooth_grid;
4232 
4233  unsigned int size;
4234  ar & size;
4235  levels.resize(size);
4236  for (auto &level_ : levels)
4237  {
4238  std::unique_ptr<internal::TriangulationImplementation::TriaLevel> level;
4239  ar & level;
4240  level_ = std::move(level);
4241  }
4242 
4243  // Workaround for nullptr, see in save().
4244  bool faces_is_nullptr = true;
4245  ar & faces_is_nullptr;
4246  if (!faces_is_nullptr)
4247  ar &faces;
4248 
4249  ar &vertices;
4250  ar &vertices_used;
4251 
4252  ar &anisotropic_refinement;
4253  ar &number_cache;
4254 
4255  // the levels do not serialize the active_cell_indices because
4256  // they are easy enough to rebuild upon re-loading data. do
4257  // this here. don't forget to first resize the fields appropriately
4258  {
4259  for (auto &level : levels)
4260  {
4261  level->active_cell_indices.resize(level->refine_flags.size());
4262  level->global_active_cell_indices.resize(level->refine_flags.size());
4263  level->global_level_cell_indices.resize(level->refine_flags.size());
4264  }
4265  reset_cell_vertex_indices_cache();
4266  reset_active_cell_indices();
4267  reset_global_cell_indices();
4268  }
4269 
4270  reset_policy();
4271 
4272  bool my_check_for_distorted_cells;
4273  ar & my_check_for_distorted_cells;
4274 
4275  Assert(my_check_for_distorted_cells == check_for_distorted_cells,
4276  ExcMessage("The triangulation loaded into here must have the "
4277  "same setting with regard to reporting distorted "
4278  "cell as the one previously stored."));
4279 
4280  if (dim == 1)
4281  {
4282  ar &vertex_to_boundary_id_map_1d;
4283  ar &vertex_to_manifold_id_map_1d;
4284  }
4285 
4286  // trigger the create signal to indicate
4287  // that new content has been imported into
4288  // the triangulation
4289  signals.create();
4290 }
4291 
4292 
4293 
4294 template <int dim, int spacedim>
4295 inline unsigned int
4298 {
4299  return coarse_cell_id;
4300 }
4301 
4302 
4303 
4304 template <int dim, int spacedim>
4305 inline types::coarse_cell_id
4307  const unsigned int coarse_cell_index) const
4308 {
4309  return coarse_cell_index;
4310 }
4311 
4312 
4313 
4314 /* -------------- declaration of explicit specializations ------------- */
4315 
4316 template <>
4317 unsigned int
4319 template <>
4320 unsigned int
4321 Triangulation<1, 1>::n_quads(const unsigned int level) const;
4322 template <>
4323 unsigned int
4324 Triangulation<1, 1>::n_raw_quads(const unsigned int level) const;
4325 template <>
4326 unsigned int
4327 Triangulation<2, 2>::n_raw_quads(const unsigned int level) const;
4328 template <>
4329 unsigned int
4330 Triangulation<3, 3>::n_raw_quads(const unsigned int level) const;
4331 template <>
4332 unsigned int
4334 template <>
4335 unsigned int
4336 Triangulation<1, 1>::n_active_quads(const unsigned int level) const;
4337 template <>
4338 unsigned int
4340 template <>
4341 unsigned int
4342 Triangulation<1, 1>::n_raw_hexs(const unsigned int level) const;
4343 template <>
4344 unsigned int
4345 Triangulation<3, 3>::n_raw_hexs(const unsigned int level) const;
4346 template <>
4347 unsigned int
4349 template <>
4350 unsigned int
4352 template <>
4353 unsigned int
4354 Triangulation<3, 3>::n_active_hexs(const unsigned int) const;
4355 template <>
4356 unsigned int
4357 Triangulation<3, 3>::n_hexs(const unsigned int level) const;
4358 
4359 template <>
4360 unsigned int
4362 
4363 
4364 // -------------------------------------------------------------------
4365 // -- Explicit specializations for codimension one grids
4366 
4367 
4368 template <>
4369 unsigned int
4371 template <>
4372 unsigned int
4373 Triangulation<1, 2>::n_quads(const unsigned int level) const;
4374 template <>
4375 unsigned int
4376 Triangulation<1, 2>::n_raw_quads(const unsigned int level) const;
4377 template <>
4378 unsigned int
4379 Triangulation<2, 3>::n_raw_quads(const unsigned int level) const;
4380 template <>
4381 unsigned int
4382 Triangulation<1, 2>::n_raw_hexs(const unsigned int level) const;
4383 template <>
4384 unsigned int
4385 Triangulation<1, 2>::n_active_quads(const unsigned int level) const;
4386 template <>
4387 unsigned int
4389 template <>
4390 unsigned int
4392 
4393 // -------------------------------------------------------------------
4394 // -- Explicit specializations for codimension two grids
4395 
4396 template <>
4397 unsigned int
4399 template <>
4400 unsigned int
4401 Triangulation<1, 3>::n_quads(const unsigned int level) const;
4402 template <>
4403 unsigned int
4404 Triangulation<1, 3>::n_raw_quads(const unsigned int level) const;
4405 template <>
4406 unsigned int
4407 Triangulation<2, 3>::n_raw_quads(const unsigned int level) const;
4408 template <>
4409 unsigned int
4410 Triangulation<1, 3>::n_raw_hexs(const unsigned int level) const;
4411 template <>
4412 unsigned int
4413 Triangulation<1, 3>::n_active_quads(const unsigned int level) const;
4414 template <>
4415 unsigned int
4417 template <>
4418 unsigned int
4420 
4421 template <>
4422 bool
4424 template <>
4425 bool
4427 template <>
4428 bool
4430 
4431 
4432 extern template class Triangulation<1, 1>;
4433 extern template class Triangulation<1, 2>;
4434 extern template class Triangulation<1, 3>;
4435 extern template class Triangulation<2, 2>;
4436 extern template class Triangulation<2, 3>;
4437 extern template class Triangulation<3, 3>;
4438 
4439 #endif // DOXYGEN
4440 
4442 
4443 // Include tria_accessor.h here, so that it is possible for an end
4444 // user to use the iterators of Triangulation<dim> directly without
4445 // the need to include tria_accessor.h separately. (Otherwise the
4446 // iterators are an 'opaque' or 'incomplete' type.)
4448 
4449 #endif
boost::signals2::signal< void(const Triangulation< dim, spacedim > &destination_tria)> copy
Definition: tria.h:2146
::internal::TriangulationImplementation::NumberCache< dim > number_cache
Definition: tria.h:4028
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:2098
unsigned int n_vertices() const
boost::signals2::signal< void(const typename Triangulation< dim, spacedim >::cell_iterator &cell)> pre_coarsening_on_cell
Definition: tria.h:2126
#define DeclException2(Exception2, type1, type2, outsequence)
Definition: exceptions.h:532
boost::signals2::signal< void()> post_distributed_repartition
Definition: tria.h:2253
typename IteratorSelector::line_iterator line_iterator
Definition: tria.h:1442
T operator()(InputIterator first, InputIterator last) const
Definition: tria.h:2058
MeshSmoothing smooth_grid
Definition: tria.h:3526
typename IteratorSelector::raw_line_iterator raw_line_iterator
Definition: tria.h:3621
std::vector< Point< spacedim > > vertices
Definition: tria.h:3993
boost::signals2::signal< void()> post_p4est_refinement
Definition: tria.h:2224
std::map< types::manifold_id, std::unique_ptr< const Manifold< dim, spacedim > > > manifold
Definition: tria.h:4005
typename IteratorSelector::hex_iterator hex_iterator
Definition: tria.h:1490
const ::Triangulation< dim, spacedim > & tria
typename IteratorSelector::active_line_iterator active_line_iterator
Definition: tria.h:1457
boost::signals2::signal< void()> pre_distributed_refinement
Definition: tria.h:2215
bool anisotropic_refinement
Definition: tria.h:4010
#define AssertIndexRange(index, range)
Definition: exceptions.h:1720
std::unique_ptr< ::internal::TriangulationImplementation::Policy< dim, spacedim > > policy
Definition: tria.h:3584
std::vector< GridTools::PeriodicFacePair< cell_iterator > > periodic_face_pairs_level_0
Definition: tria.h:3593
std::vector< ReferenceCell > reference_cells
Definition: tria.h:3532
std::vector< types::coarse_cell_id > coarse_cell_index_to_coarse_cell_id
unsigned int n_active_hexs() const
Definition: tria.cc:14228
static ::ExceptionBase & ExcFacesHaveNoLevel()
unsigned int n_levels() const
void create_triangulation(Triangulation< dim, dim > &tria, const AdditionalData &additional_data=AdditionalData())
virtual bool prepare_coarsening_and_refinement()
Definition: tria.cc:15216
static ::ExceptionBase & ExcMessage(std::string arg1)
boost::signals2::signal< void()> pre_refinement
Definition: tria.h:2091
const bool check_for_distorted_cells
Definition: tria.h:4017
#define DeclException1(Exception1, type1, outsequence)
Definition: exceptions.h:509
static const char T
unsigned int n_raw_quads() const
Definition: tria.cc:14164
#define Assert(cond, exc)
Definition: exceptions.h:1461
Signals signals
Definition: tria.h:2289
std::vector< std::unique_ptr<::internal::TriangulationImplementation::TriaLevel > > levels
Definition: tria.h:3979
boost::signals2::signal< void()> clear
Definition: tria.h:2161
unsigned int n_raw_hexs(const unsigned int level) const
Definition: tria.cc:14220
unsigned int max_adjacent_cells() const
Definition: tria.cc:14337
void load(Archive &ar, const unsigned int version)
std::list< typename Triangulation< dim, spacedim >::cell_iterator > distorted_cells
Definition: tria.h:1536
unsigned int n_quads() const
Definition: tria.cc:14116
#define DeclExceptionMsg(Exception, defaulttext)
Definition: exceptions.h:487
std::unique_ptr< std::map< unsigned int, types::manifold_id > > vertex_to_manifold_id_map_1d
Definition: tria.h:4068
std::vector< bool > vertices_used
Definition: tria.h:3998
#define DeclException0(Exception0)
Definition: exceptions.h:464
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:2136
typename IteratorSelector::active_quad_iterator active_quad_iterator
Definition: tria.h:1481
const std::vector< Point< spacedim > > & get_vertices() const
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:401
boost::signals2::signal< void()> mesh_movement
Definition: tria.h:2115
unsigned int level
Definition: grid_out.cc:4589
typename IteratorSelector::raw_quad_iterator raw_quad_iterator
Definition: tria.h:3622
VectorType::value_type * end(VectorType &V)
std::unique_ptr<::internal::TriangulationImplementation::TriaFaces > faces
Definition: tria.h:3987
Point< 3 > vertices[4]
boost::signals2::signal< void()> pre_distributed_save
Definition: tria.h:2261
void save(Archive &ar, const unsigned int version) const
unsigned int n_active_cells(const internal::TriangulationImplementation::NumberCache< 1 > &c)
Definition: tria.cc:13704
typename IteratorSelector::quad_iterator quad_iterator
Definition: tria.h:1466
boost::signals2::signal< void()> create
Definition: tria.h:2082
std::unique_ptr< std::map< unsigned int, types::boundary_id > > vertex_to_boundary_id_map_1d
Definition: tria.h:4045
unsigned int n_hexs() const
Definition: tria.cc:14202
unsigned int n_active_quads() const
Definition: tria.cc:14183
unsigned int n_cells(const internal::TriangulationImplementation::NumberCache< 1 > &c)
Definition: tria.cc:13697
Definition: cell_id.h:70
Point< 2 > first
Definition: grid_out.cc:4586
boost::signals2::signal< void()> pre_partition
Definition: tria.h:2106
typename IteratorSelector::active_hex_iterator active_hex_iterator
Definition: tria.h:1501
boost::signals2::signal< void()> post_distributed_save
Definition: tria.h:2268
std::vector< unsigned int > n_active_hexes_level
Definition: tria.h:294
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:3601
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:400
virtual unsigned int n_global_levels() const
VectorType::value_type * begin(VectorType &V)
typename IteratorSelector::raw_hex_iterator raw_hex_iterator
Definition: tria.h:3623
boost::signals2::signal< unsigned int(const cell_iterator &, const CellStatus), CellWeightSum< unsigned int > > cell_weight
Definition: tria.h:2202
boost::signals2::signal< void()> pre_distributed_load
Definition: tria.h:2276
std::vector< unsigned int > n_active_lines_level
Definition: tria.h:177
std::vector< unsigned int > n_active_quads_level
Definition: tria.h:235
boost::signals2::signal< void()> post_distributed_load
Definition: tria.h:2283
global_cell_index coarse_cell_id
Definition: types.h:114
#define DEAL_II_DEPRECATED
Definition: config.h:160
boost::signals2::signal< void()> pre_distributed_repartition
Definition: tria.h:2246
bool vertex_used(const unsigned int index) const
boost::signals2::signal< void()> any_change
Definition: tria.h:2172
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:2234