Reference documentation for deal.II version Git 2ec7f2a 2018-07-19 19:43:15 -0400
tria.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 1998 - 2018 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE.md at
12 // the top level directory of deal.II.
13 //
14 // ---------------------------------------------------------------------
15 
16 #ifndef dealii_tria_h
17 #define dealii_tria_h
18 
19 
20 #include <deal.II/base/config.h>
21 
22 #include <deal.II/base/geometry_info.h>
23 #include <deal.II/base/iterator_range.h>
24 #include <deal.II/base/point.h>
25 #include <deal.II/base/smartpointer.h>
26 #include <deal.II/base/subscriptor.h>
27 
28 #include <deal.II/grid/tria_iterator_selector.h>
29 
30 #include <boost/serialization/map.hpp>
31 #include <boost/serialization/split_member.hpp>
32 #include <boost/serialization/unique_ptr.hpp>
33 #include <boost/serialization/vector.hpp>
34 #include <boost/signals2.hpp>
35 
36 #include <bitset>
37 #include <functional>
38 #include <list>
39 #include <map>
40 #include <memory>
41 #include <numeric>
42 #include <vector>
43 
44 
45 DEAL_II_NAMESPACE_OPEN
46 
47 template <int dim, int spacedim>
48 class Manifold;
49 
50 namespace GridTools
51 {
52  template <typename CellIterator>
53  struct PeriodicFacePair;
54 }
55 
56 template <int, int, int>
58 template <int spacedim>
59 class TriaAccessor<0, 1, spacedim>;
60 template <int, int, int>
62 
63 namespace internal
64 {
65  namespace TriangulationImplementation
66  {
67  template <int dim>
68  class TriaLevel;
69  template <int dim>
70  class TriaFaces;
71 
72  template <typename>
73  class TriaObjects;
74 
80  struct Implementation;
81  } // namespace TriangulationImplementation
82 
83  namespace TriaAccessorImplementation
84  {
85  struct Implementation;
86  }
87 } // namespace internal
88 
89 namespace hp
90 {
91  template <int dim, int spacedim>
92  class DoFHandler;
93 }
94 
95 
96 /*------------------------------------------------------------------------*/
97 
133 template <int structdim>
134 struct CellData
135 {
142 
150  union
151  {
161 
172  };
173 
183 
191  CellData();
192 };
193 
194 
195 
251 {
258  std::vector<CellData<1>> boundary_lines;
259 
266  std::vector<CellData<2>> boundary_quads;
267 
276  bool
277  check_consistency(const unsigned int dim) const;
278 };
279 
280 
281 /*------------------------------------------------------------------------*/
282 
283 
284 namespace internal
285 {
290  namespace TriangulationImplementation
291  {
305  template <int dim>
306  struct NumberCache
307  {};
308 
322  template <>
323  struct NumberCache<1>
324  {
328  unsigned int n_levels;
329 
333  unsigned int n_lines;
334 
338  std::vector<unsigned int> n_lines_level;
339 
343  unsigned int n_active_lines;
344 
348  std::vector<unsigned int> n_active_lines_level;
349 
353  NumberCache();
354 
359  std::size_t
360  memory_consumption() const;
361 
366  template <class Archive>
367  void
368  serialize(Archive &ar, const unsigned int version);
369  };
370 
371 
386  template <>
387  struct NumberCache<2> : public NumberCache<1>
388  {
392  unsigned int n_quads;
393 
397  std::vector<unsigned int> n_quads_level;
398 
402  unsigned int n_active_quads;
403 
407  std::vector<unsigned int> n_active_quads_level;
408 
412  NumberCache();
413 
418  std::size_t
419  memory_consumption() const;
420 
425  template <class Archive>
426  void
427  serialize(Archive &ar, const unsigned int version);
428  };
429 
430 
446  template <>
447  struct NumberCache<3> : public NumberCache<2>
448  {
452  unsigned int n_hexes;
453 
457  std::vector<unsigned int> n_hexes_level;
458 
462  unsigned int n_active_hexes;
463 
467  std::vector<unsigned int> n_active_hexes_level;
468 
472  NumberCache();
473 
478  std::size_t
479  memory_consumption() const;
480 
485  template <class Archive>
486  void
487  serialize(Archive &ar, const unsigned int version);
488  };
489  } // namespace TriangulationImplementation
490 } // namespace internal
491 
492 
493 /*------------------------------------------------------------------------*/
494 
495 
1274 template <int dim, int spacedim = dim>
1275 class Triangulation : public Subscriptor
1276 {
1277 private:
1282  using IteratorSelector =
1283  ::internal::TriangulationImplementation::Iterators<dim, spacedim>;
1284 
1285 public:
1291  {
1296  none = 0x0,
1467 
1481 
1488  };
1489 
1506 
1524 
1538  using face_iterator = TriaIterator<TriaAccessor<dim - 1, dim, spacedim>>;
1539 
1551  using active_face_iterator =
1552  TriaActiveIterator<TriaAccessor<dim - 1, dim, spacedim>>;
1553 
1563 
1576  using active_vertex_iterator =
1578 
1579  using line_iterator = typename IteratorSelector::line_iterator;
1580  using active_line_iterator = typename IteratorSelector::active_line_iterator;
1581 
1582  using quad_iterator = typename IteratorSelector::quad_iterator;
1583  using active_quad_iterator = typename IteratorSelector::active_quad_iterator;
1584 
1585  using hex_iterator = typename IteratorSelector::hex_iterator;
1586  using active_hex_iterator = typename IteratorSelector::active_hex_iterator;
1587 
1607  {
1614  virtual ~DistortedCellList() noexcept override;
1615 
1620  std::list<typename Triangulation<dim, spacedim>::cell_iterator>
1622  };
1623 
1627  static const unsigned int dimension = dim;
1628 
1632  static const unsigned int space_dimension = spacedim;
1633 
1649  const bool check_for_distorted_cells = false);
1650 
1666  Triangulation(const Triangulation<dim, spacedim> &) = delete;
1667 
1675 
1679  Triangulation &
1680  operator=(Triangulation<dim, spacedim> &&tria) noexcept;
1681 
1685  virtual ~Triangulation() override;
1686 
1693  virtual void
1694  clear();
1695 
1701  virtual void
1702  set_mesh_smoothing(const MeshSmoothing mesh_smoothing);
1703 
1707  virtual const MeshSmoothing &
1708  get_mesh_smoothing() const;
1709 
1733  void
1734  set_manifold(const types::manifold_id number,
1735  const Manifold<dim, spacedim> &manifold_object);
1736 
1737 
1752  DEAL_II_DEPRECATED
1753  void
1754  set_manifold(const types::manifold_id number);
1755 
1768  void
1769  reset_manifold(const types::manifold_id manifold_number);
1770 
1782  void
1784 
1793  void
1794  set_all_manifold_ids(const types::manifold_id number);
1795 
1804  void
1805  set_all_manifold_ids_on_boundary(const types::manifold_id number);
1806 
1816  void
1817  set_all_manifold_ids_on_boundary(const types::boundary_id b_id,
1818  const types::manifold_id number);
1819 
1829  const Manifold<dim, spacedim> &
1830  get_manifold(const types::manifold_id number) const;
1831 
1843  std::vector<types::boundary_id>
1844  get_boundary_ids() const;
1845 
1857  std::vector<types::manifold_id>
1858  get_manifold_ids() const;
1859 
1886  virtual void
1887  copy_triangulation(const Triangulation<dim, spacedim> &other_tria);
1888 
1932  virtual void
1933  create_triangulation(const std::vector<Point<spacedim>> &vertices,
1934  const std::vector<CellData<dim>> & cells,
1935  const SubCellData & subcelldata);
1936 
1945  virtual void
1947  const std::vector<Point<spacedim>> &vertices,
1948  const std::vector<CellData<dim>> & cells,
1949  const SubCellData & subcelldata);
1950 
1957  void
1959 
1971  void
1973 
1988  void
1989  refine_global(const unsigned int times = 1);
1990 
2022  virtual void
2024 
2054  virtual bool
2056 
2057  /*
2058  * @}
2059  */
2060 
2075  {
2093  };
2094 
2100  template <typename T>
2102  {
2103  using result_type = T;
2104 
2105  template <typename InputIterator>
2106  T
2107  operator()(InputIterator first, InputIterator last) const
2108  {
2109  return std::accumulate(first, last, T());
2110  }
2111  };
2112 
2122  struct Signals
2123  {
2131  boost::signals2::signal<void()> create;
2132 
2140  boost::signals2::signal<void()> pre_refinement;
2141 
2147  boost::signals2::signal<void()> post_refinement;
2148 
2156  boost::signals2::signal<void()> mesh_movement;
2157 
2165  boost::signals2::signal<void(
2166  const typename Triangulation<dim, spacedim>::cell_iterator &cell)>
2168 
2175  boost::signals2::signal<void(
2176  const typename Triangulation<dim, spacedim>::cell_iterator &cell)>
2178 
2185  boost::signals2::signal<void(
2186  const Triangulation<dim, spacedim> &destination_tria)>
2188 
2202  boost::signals2::signal<void()> clear;
2203 
2213  boost::signals2::signal<void()> any_change;
2214 
2238  boost::signals2::signal<unsigned int(const cell_iterator &,
2239  const CellStatus),
2242 
2254  boost::signals2::signal<void()> pre_distributed_refinement;
2255 
2264  boost::signals2::signal<void()> post_distributed_refinement;
2265 
2272  boost::signals2::signal<void()> pre_distributed_save;
2273 
2279  boost::signals2::signal<void()> post_distributed_load;
2280  };
2281 
2285  mutable Signals signals;
2286 
2287  /*
2288  * @}
2289  */
2290 
2300  void
2301  save_refine_flags(std::ostream &out) const;
2302 
2306  void
2307  save_refine_flags(std::vector<bool> &v) const;
2308 
2312  void
2313  load_refine_flags(std::istream &in);
2314 
2318  void
2319  load_refine_flags(const std::vector<bool> &v);
2320 
2324  void
2325  save_coarsen_flags(std::ostream &out) const;
2326 
2330  void
2331  save_coarsen_flags(std::vector<bool> &v) const;
2332 
2336  void
2337  load_coarsen_flags(std::istream &out);
2338 
2342  void
2343  load_coarsen_flags(const std::vector<bool> &v);
2344 
2349  bool
2351 
2352  /*
2353  * @}
2354  */
2355 
2365  void
2366  clear_user_flags();
2367 
2373  void
2374  save_user_flags(std::ostream &out) const;
2375 
2381  void
2382  save_user_flags(std::vector<bool> &v) const;
2383 
2388  void
2389  load_user_flags(std::istream &in);
2390 
2395  void
2396  load_user_flags(const std::vector<bool> &v);
2397 
2402  void
2404 
2409  void
2410  save_user_flags_line(std::ostream &out) const;
2411 
2417  void
2418  save_user_flags_line(std::vector<bool> &v) const;
2419 
2424  void
2425  load_user_flags_line(std::istream &in);
2426 
2431  void
2432  load_user_flags_line(const std::vector<bool> &v);
2433 
2438  void
2440 
2445  void
2446  save_user_flags_quad(std::ostream &out) const;
2447 
2453  void
2454  save_user_flags_quad(std::vector<bool> &v) const;
2455 
2460  void
2461  load_user_flags_quad(std::istream &in);
2462 
2467  void
2468  load_user_flags_quad(const std::vector<bool> &v);
2469 
2470 
2475  void
2477 
2482  void
2483  save_user_flags_hex(std::ostream &out) const;
2484 
2490  void
2491  save_user_flags_hex(std::vector<bool> &v) const;
2492 
2497  void
2498  load_user_flags_hex(std::istream &in);
2499 
2504  void
2505  load_user_flags_hex(const std::vector<bool> &v);
2506 
2512  void
2513  clear_user_data();
2514 
2520  void
2521  save_user_indices(std::vector<unsigned int> &v) const;
2522 
2527  void
2528  load_user_indices(const std::vector<unsigned int> &v);
2529 
2535  void
2536  save_user_pointers(std::vector<void *> &v) const;
2537 
2542  void
2543  load_user_pointers(const std::vector<void *> &v);
2544 
2550  void
2551  save_user_indices_line(std::vector<unsigned int> &v) const;
2552 
2557  void
2558  load_user_indices_line(const std::vector<unsigned int> &v);
2559 
2565  void
2566  save_user_indices_quad(std::vector<unsigned int> &v) const;
2567 
2572  void
2573  load_user_indices_quad(const std::vector<unsigned int> &v);
2574 
2580  void
2581  save_user_indices_hex(std::vector<unsigned int> &v) const;
2582 
2587  void
2588  load_user_indices_hex(const std::vector<unsigned int> &v);
2594  void
2595  save_user_pointers_line(std::vector<void *> &v) const;
2596 
2601  void
2602  load_user_pointers_line(const std::vector<void *> &v);
2603 
2609  void
2610  save_user_pointers_quad(std::vector<void *> &v) const;
2611 
2616  void
2617  load_user_pointers_quad(const std::vector<void *> &v);
2618 
2624  void
2625  save_user_pointers_hex(std::vector<void *> &v) const;
2626 
2631  void
2632  load_user_pointers_hex(const std::vector<void *> &v);
2633 
2634  /*
2635  * @}
2636  */
2637 
2647  begin(const unsigned int level = 0) const;
2648 
2666  begin_active(const unsigned int level = 0) const;
2667 
2673  end() const;
2674 
2680  end(const unsigned int level) const;
2681 
2688  end_active(const unsigned int level) const;
2689 
2690 
2695  last() const;
2696 
2701  last_active() const;
2702 
2718  cell_iterators() const;
2719 
2756  active_cell_iterators() const;
2757 
2774  cell_iterators_on_level(const unsigned int level) const;
2775 
2792  active_cell_iterators_on_level(const unsigned int level) const;
2793 
2794  /*
2795  * @}
2796  */
2797 
2798  /*-------------------------------------------------------------------------*/
2799 
2809  begin_face() const;
2810 
2815  begin_active_face() const;
2816 
2822  end_face() const;
2823 
2824  /*
2825  * @}
2826  */
2827 
2828  /*-------------------------------------------------------------------------*/
2829 
2840  begin_vertex() const;
2841 
2848  begin_active_vertex() const;
2849 
2856  end_vertex() const;
2857 
2858  /*
2859  * @}
2860  */
2861 
2879  unsigned int
2880  n_lines() const;
2881 
2885  unsigned int
2886  n_lines(const unsigned int level) const;
2887 
2891  unsigned int
2892  n_active_lines() const;
2893 
2897  unsigned int
2898  n_active_lines(const unsigned int level) const;
2899 
2903  unsigned int
2904  n_quads() const;
2905 
2909  unsigned int
2910  n_quads(const unsigned int level) const;
2911 
2915  unsigned int
2916  n_active_quads() const;
2917 
2921  unsigned int
2922  n_active_quads(const unsigned int level) const;
2923 
2927  unsigned int
2928  n_hexs() const;
2929 
2934  unsigned int
2935  n_hexs(const unsigned int level) const;
2936 
2940  unsigned int
2941  n_active_hexs() const;
2942 
2947  unsigned int
2948  n_active_hexs(const unsigned int level) const;
2949 
2954  unsigned int
2955  n_cells() const;
2956 
2961  unsigned int
2962  n_cells(const unsigned int level) const;
2963 
2968  unsigned int
2969  n_active_cells() const;
2970 
2978  virtual types::global_dof_index
2979  n_global_active_cells() const;
2980 
2981 
2986  unsigned int
2987  n_active_cells(const unsigned int level) const;
2988 
2994  unsigned int
2995  n_faces() const;
2996 
3002  unsigned int
3003  n_active_faces() const;
3004 
3022  unsigned int
3023  n_levels() const;
3024 
3031  virtual unsigned int
3032  n_global_levels() const;
3033 
3043  virtual bool
3044  has_hanging_nodes() const;
3045 
3053  unsigned int
3054  n_vertices() const;
3055 
3064  const std::vector<Point<spacedim>> &
3065  get_vertices() const;
3066 
3071  unsigned int
3072  n_used_vertices() const;
3073 
3077  bool
3078  vertex_used(const unsigned int index) const;
3079 
3084  const std::vector<bool> &
3085  get_used_vertices() const;
3086 
3098  unsigned int
3099  max_adjacent_cells() const;
3100 
3107  virtual types::subdomain_id
3108  locally_owned_subdomain() const;
3109 
3121 
3127  get_triangulation() const;
3128 
3129 
3130  /*
3131  * @}
3132  */
3133 
3148  unsigned int
3149  n_raw_lines() const;
3150 
3160  unsigned int
3161  n_raw_lines(const unsigned int level) const;
3162 
3172  unsigned int
3173  n_raw_quads() const;
3174 
3184  unsigned int
3185  n_raw_quads(const unsigned int level) const;
3186 
3196  unsigned int
3197  n_raw_hexs(const unsigned int level) const;
3198 
3208  unsigned int
3209  n_raw_cells(const unsigned int level) const;
3210 
3221  unsigned int
3222  n_raw_faces() const;
3223 
3224  /*
3225  * @}
3226  */
3227 
3236  virtual std::size_t
3237  memory_consumption() const;
3238 
3247  template <class Archive>
3248  void
3249  save(Archive &ar, const unsigned int version) const;
3250 
3266  template <class Archive>
3267  void
3268  load(Archive &ar, const unsigned int version);
3269 
3270 
3286  virtual void
3288  const std::vector<GridTools::PeriodicFacePair<cell_iterator>> &);
3289 
3293  const std::map<
3294  std::pair<cell_iterator, unsigned int>,
3295  std::pair<std::pair<cell_iterator, unsigned int>, std::bitset<3>>> &
3296  get_periodic_face_map() const;
3297 
3298 
3299  BOOST_SERIALIZATION_SPLIT_MEMBER()
3300 
3301 
3312  int,
3313  << "The given level " << arg1
3314  << " is not in the valid range!");
3323  int,
3324  int,
3325  << "You are trying to perform an operation on a triangulation "
3326  << "that is only allowed if the triangulation is currently empty. "
3327  << "However, it currently stores " << arg1 << " vertices and has "
3328  << "cells on " << arg2 << " levels.");
3346  int,
3347  << "You tried to do something on level " << arg1
3348  << ", but this level is empty.");
3355 
3364  types::boundary_id,
3365  << "The given boundary_id " << arg1
3366  << " is not defined in this Triangulation!");
3367 
3368  /*
3369  * @}
3370  */
3371 
3372 protected:
3378 
3392  static void
3393  write_bool_vector(const unsigned int magic_number1,
3394  const std::vector<bool> &v,
3395  const unsigned int magic_number2,
3396  std::ostream & out);
3397 
3402  static void
3403  read_bool_vector(const unsigned int magic_number1,
3404  std::vector<bool> &v,
3405  const unsigned int magic_number2,
3406  std::istream & in);
3407 
3412  void
3414 
3415 
3416 private:
3423  std::vector<GridTools::PeriodicFacePair<cell_iterator>>
3425 
3430  std::map<std::pair<cell_iterator, unsigned int>,
3431  std::pair<std::pair<cell_iterator, unsigned int>, std::bitset<3>>>
3433 
3448  using raw_face_iterator =
3449  TriaRawIterator<TriaAccessor<dim - 1, dim, spacedim>>;
3450  using raw_vertex_iterator =
3451  TriaRawIterator<::TriaAccessor<0, dim, spacedim>>;
3452  using raw_line_iterator = typename IteratorSelector::raw_line_iterator;
3453  using raw_quad_iterator = typename IteratorSelector::raw_quad_iterator;
3454  using raw_hex_iterator = typename IteratorSelector::raw_hex_iterator;
3455 
3461  begin_raw(const unsigned int level = 0) const;
3462 
3468  end_raw(const unsigned int level) const;
3469 
3470  /*
3471  * @}
3472  */
3473 
3485  raw_line_iterator
3486  begin_raw_line(const unsigned int level = 0) const;
3487 
3491  line_iterator
3492  begin_line(const unsigned int level = 0) const;
3493 
3497  active_line_iterator
3498  begin_active_line(const unsigned int level = 0) const;
3499 
3504  line_iterator
3505  end_line() const;
3506 
3507  /*
3508  * @}
3509  */
3510 
3521  raw_quad_iterator
3522  begin_raw_quad(const unsigned int level = 0) const;
3523 
3527  quad_iterator
3528  begin_quad(const unsigned int level = 0) const;
3529 
3533  active_quad_iterator
3534  begin_active_quad(const unsigned int level = 0) const;
3535 
3540  quad_iterator
3541  end_quad() const;
3542 
3543  /*
3544  * @}
3545  */
3546 
3556  raw_hex_iterator
3557  begin_raw_hex(const unsigned int level = 0) const;
3558 
3562  hex_iterator
3563  begin_hex(const unsigned int level = 0) const;
3564 
3568  active_hex_iterator
3569  begin_active_hex(const unsigned int level = 0) const;
3570 
3575  hex_iterator
3576  end_hex() const;
3577 
3578  /*
3579  * @}
3580  */
3581 
3582 
3596  void
3598 
3605  void
3607 
3621  DistortedCellList
3623 
3630  void
3632 
3637  void
3639 
3644  std::vector<std::unique_ptr<
3645  ::internal::TriangulationImplementation::TriaLevel<dim>>>
3646  levels;
3647 
3653  std::unique_ptr<::internal::TriangulationImplementation::TriaFaces<dim>>
3655 
3656 
3660  std::vector<Point<spacedim>> vertices;
3661 
3665  std::vector<bool> vertices_used;
3666 
3671  std::map<types::manifold_id, std::unique_ptr<const Manifold<dim, spacedim>>>
3673 
3678 
3679 
3685 
3695  ::internal::TriangulationImplementation::NumberCache<dim> number_cache;
3696 
3711  std::unique_ptr<std::map<unsigned int, types::boundary_id>>
3713 
3714 
3734  std::unique_ptr<std::map<unsigned int, types::manifold_id>>
3736 
3737  // make a couple of classes friends
3738  template <int, int, int>
3739  friend class TriaAccessorBase;
3740  template <int, int, int>
3741  friend class TriaAccessor;
3742  friend class TriaAccessor<0, 1, spacedim>;
3743 
3744  friend class CellAccessor<dim, spacedim>;
3745 
3746  friend struct ::internal::TriaAccessorImplementation::Implementation;
3747 
3748  friend class hp::DoFHandler<dim, spacedim>;
3749 
3750  friend struct ::internal::TriangulationImplementation::Implementation;
3751 
3752  template <typename>
3753  friend class ::internal::TriangulationImplementation::TriaObjects;
3754 
3755  // explicitly check for sensible template arguments, but not on windows
3756  // because MSVC creates bogus warnings during normal compilation
3757 #ifndef DEAL_II_MSVC
3758  static_assert(dim <= spacedim,
3759  "The dimension <dim> of a Triangulation must be less than or "
3760  "equal to the space dimension <spacedim> in which it lives.");
3761 #endif
3762 };
3763 
3764 
3765 #ifndef DOXYGEN
3766 
3767 
3768 template <int structdim>
3770 {
3771  for (unsigned int i = 0; i < GeometryInfo<structdim>::vertices_per_cell; ++i)
3772  vertices[i] = numbers::invalid_unsigned_int;
3773 
3774  material_id = 0;
3775 
3776  // And the manifold to be invalid
3777  manifold_id = numbers::invalid_manifold_id;
3778 }
3779 
3780 
3781 
3782 namespace internal
3783 {
3784  namespace TriangulationImplementation
3785  {
3786  template <class Archive>
3787  void
3788  NumberCache<1>::serialize(Archive &ar, const unsigned int)
3789  {
3790  ar &n_levels;
3791  ar &n_lines &n_lines_level;
3792  ar &n_active_lines &n_active_lines_level;
3793  }
3794 
3795 
3796  template <class Archive>
3797  void
3798  NumberCache<2>::serialize(Archive &ar, const unsigned int version)
3799  {
3800  this->NumberCache<1>::serialize(ar, version);
3801 
3802  ar &n_quads &n_quads_level;
3803  ar &n_active_quads &n_active_quads_level;
3804  }
3805 
3806 
3807  template <class Archive>
3808  void
3809  NumberCache<3>::serialize(Archive &ar, const unsigned int version)
3810  {
3811  this->NumberCache<2>::serialize(ar, version);
3812 
3813  ar &n_hexes &n_hexes_level;
3814  ar &n_active_hexes &n_active_hexes_level;
3815  }
3816 
3817  } // namespace TriangulationImplementation
3818 } // namespace internal
3819 
3820 
3821 template <int dim, int spacedim>
3822 inline bool
3823 Triangulation<dim, spacedim>::vertex_used(const unsigned int index) const
3824 {
3825  Assert(index < vertices_used.size(),
3826  ExcIndexRange(index, 0, vertices_used.size()));
3827  return vertices_used[index];
3828 }
3829 
3830 
3831 
3832 template <int dim, int spacedim>
3833 inline unsigned int
3835 {
3836  return number_cache.n_levels;
3837 }
3838 
3839 template <int dim, int spacedim>
3840 inline unsigned int
3842 {
3843  return number_cache.n_levels;
3844 }
3845 
3846 
3847 template <int dim, int spacedim>
3848 inline unsigned int
3850 {
3851  return vertices.size();
3852 }
3853 
3854 
3855 
3856 template <int dim, int spacedim>
3857 inline const std::vector<Point<spacedim>> &
3859 {
3860  return vertices;
3861 }
3862 
3863 
3864 template <int dim, int spacedim>
3865 template <class Archive>
3866 void
3867 Triangulation<dim, spacedim>::save(Archive &ar, const unsigned int) const
3868 {
3869  // as discussed in the documentation, do not store the signals as
3870  // well as boundary and manifold description but everything else
3871  ar &smooth_grid;
3872 
3873  unsigned int n_levels = levels.size();
3874  ar & n_levels;
3875  for (unsigned int i = 0; i < levels.size(); ++i)
3876  ar &levels[i];
3877 
3878  // boost dereferences a nullptr when serializing a nullptr
3879  // at least up to 1.65.1. This causes problems with clang-5.
3880  // Therefore, work around it.
3881  bool faces_is_nullptr = (faces.get() == nullptr);
3882  ar & faces_is_nullptr;
3883  if (!faces_is_nullptr)
3884  ar &faces;
3885 
3886  ar &vertices;
3887  ar &vertices_used;
3888 
3889  ar &anisotropic_refinement;
3890  ar &number_cache;
3891 
3892  ar &check_for_distorted_cells;
3893 
3894  if (dim == 1)
3895  {
3896  ar &vertex_to_boundary_id_map_1d;
3897  ar &vertex_to_manifold_id_map_1d;
3898  }
3899 }
3900 
3901 
3902 
3903 template <int dim, int spacedim>
3904 template <class Archive>
3905 void
3906 Triangulation<dim, spacedim>::load(Archive &ar, const unsigned int)
3907 {
3908  // clear previous content. this also calls the respective signal
3909  clear();
3910 
3911  // as discussed in the documentation, do not store the signals as
3912  // well as boundary and manifold description but everything else
3913  ar &smooth_grid;
3914 
3915  unsigned int size;
3916  ar & size;
3917  levels.resize(size);
3918  for (unsigned int i = 0; i < levels.size(); ++i)
3919  {
3920  std::unique_ptr<internal::TriangulationImplementation::TriaLevel<dim>>
3921  level;
3922  ar &level;
3923  levels[i] = std::move(level);
3924  }
3925 
3926  // Workaround for nullptr, see in save().
3927  bool faces_is_nullptr = true;
3928  ar & faces_is_nullptr;
3929  if (!faces_is_nullptr)
3930  ar &faces;
3931 
3932  ar &vertices;
3933  ar &vertices_used;
3934 
3935  ar &anisotropic_refinement;
3936  ar &number_cache;
3937 
3938  // the levels do not serialize the active_cell_indices because
3939  // they are easy enough to rebuild upon re-loading data. do
3940  // this here. don't forget to first resize the fields appropriately
3941  {
3942  for (unsigned int l = 0; l < levels.size(); ++l)
3943  levels[l]->active_cell_indices.resize(levels[l]->refine_flags.size());
3944  reset_active_cell_indices();
3945  }
3946 
3947 
3948  bool my_check_for_distorted_cells;
3949  ar & my_check_for_distorted_cells;
3950 
3951  Assert(my_check_for_distorted_cells == check_for_distorted_cells,
3952  ExcMessage("The triangulation loaded into here must have the "
3953  "same setting with regard to reporting distorted "
3954  "cell as the one previously stored."));
3955 
3956  if (dim == 1)
3957  {
3958  ar &vertex_to_boundary_id_map_1d;
3959  ar &vertex_to_manifold_id_map_1d;
3960  }
3961 
3962  // trigger the create signal to indicate
3963  // that new content has been imported into
3964  // the triangulation
3965  signals.create();
3966 }
3967 
3968 
3969 /* -------------- declaration of explicit specializations ------------- */
3970 
3971 template <>
3972 unsigned int
3973 Triangulation<1, 1>::n_raw_lines(const unsigned int level) const;
3974 template <>
3975 unsigned int
3977 template <>
3978 unsigned int
3979 Triangulation<1, 1>::n_quads(const unsigned int level) const;
3980 template <>
3981 unsigned int
3982 Triangulation<1, 1>::n_raw_quads(const unsigned int level) const;
3983 template <>
3984 unsigned int
3985 Triangulation<2, 2>::n_raw_quads(const unsigned int level) const;
3986 template <>
3987 unsigned int
3988 Triangulation<1, 1>::n_raw_hexs(const unsigned int level) const;
3989 template <>
3990 unsigned int
3991 Triangulation<1, 1>::n_active_quads(const unsigned int level) const;
3992 template <>
3993 unsigned int
3995 template <>
3996 unsigned int
3998 
3999 
4000 // -------------------------------------------------------------------
4001 // -- Explicit specializations for codimension one grids
4002 
4003 
4004 template <>
4005 unsigned int
4006 Triangulation<1, 2>::n_raw_lines(const unsigned int level) const;
4007 template <>
4008 unsigned int
4010 template <>
4011 unsigned int
4012 Triangulation<1, 2>::n_quads(const unsigned int level) const;
4013 template <>
4014 unsigned int
4015 Triangulation<1, 2>::n_raw_quads(const unsigned int level) const;
4016 template <>
4017 unsigned int
4018 Triangulation<2, 3>::n_raw_quads(const unsigned int level) const;
4019 template <>
4020 unsigned int
4021 Triangulation<1, 2>::n_raw_hexs(const unsigned int level) const;
4022 template <>
4023 unsigned int
4024 Triangulation<1, 2>::n_active_quads(const unsigned int level) const;
4025 template <>
4026 unsigned int
4028 template <>
4029 unsigned int
4031 
4032 // -------------------------------------------------------------------
4033 // -- Explicit specializations for codimension two grids
4034 
4035 
4036 template <>
4037 unsigned int
4038 Triangulation<1, 3>::n_raw_lines(const unsigned int level) const;
4039 template <>
4040 unsigned int
4042 template <>
4043 unsigned int
4044 Triangulation<1, 3>::n_quads(const unsigned int level) const;
4045 template <>
4046 unsigned int
4047 Triangulation<1, 3>::n_raw_quads(const unsigned int level) const;
4048 template <>
4049 unsigned int
4050 Triangulation<2, 3>::n_raw_quads(const unsigned int level) const;
4051 template <>
4052 unsigned int
4053 Triangulation<1, 3>::n_raw_hexs(const unsigned int level) const;
4054 template <>
4055 unsigned int
4056 Triangulation<1, 3>::n_active_quads(const unsigned int level) const;
4057 template <>
4058 unsigned int
4060 template <>
4061 unsigned int
4063 
4064 
4065 #endif // DOXYGEN
4066 
4067 DEAL_II_NAMESPACE_CLOSE
4068 
4069 // Include tria_accessor.h here, so that it is possible for an end
4070 // user to use the iterators of Triangulation<dim> directly without
4071 // the need to include tria_accessor.h separately. (Otherwise the
4072 // iterators are an 'opaque' or 'incomplete' type.)
4073 #include <deal.II/grid/tria_accessor.h>
4074 
4075 #endif
std::vector< CellData< 1 > > boundary_lines
Definition: tria.h:258
boost::signals2::signal< void(const Triangulation< dim, spacedim > &destination_tria)> copy
Definition: tria.h:2187
::internal::TriangulationImplementation::NumberCache< dim > number_cache
Definition: tria.h:3695
unsigned int n_raw_faces() const
Definition: tria.cc:12544
boost::signals2::signal< void()> post_refinement
Definition: tria.h:2147
active_line_iterator begin_active_line(const unsigned int level=0) const
Definition: tria.cc:12260
static const unsigned int space_dimension
Definition: tria.h:1632
virtual void copy_triangulation(const Triangulation< dim, spacedim > &other_tria)
Definition: tria.cc:10473
static const unsigned int invalid_unsigned_int
Definition: types.h:173
static::ExceptionBase & ExcInvalidLevel(int arg1)
void load_user_flags_line(std::istream &in)
Definition: tria.cc:11240
unsigned int manifold_id
Definition: types.h:123
boost::signals2::signal< void(const typename Triangulation< dim, spacedim >::cell_iterator &cell)> pre_coarsening_on_cell
Definition: tria.h:2167
#define DeclException2(Exception2, type1, type2, outsequence)
Definition: exceptions.h:420
Iterator points to a valid object.
void clear_user_flags()
Definition: tria.cc:11096
line_iterator begin_line(const unsigned int level=0) const
Definition: tria.cc:12244
const std::vector< Point< spacedim > > & get_vertices() const
virtual void create_triangulation_compatibility(const std::vector< Point< spacedim >> &vertices, const std::vector< CellData< dim >> &cells, const SubCellData &subcelldata)
Definition: tria.cc:10536
cell_iterator end() const
Definition: tria.cc:12004
virtual unsigned int n_global_levels() const
void save_user_flags_hex(std::ostream &out) const
Definition: tria.cc:11418
unsigned int n_active_lines() const
Definition: tria.cc:12743
active_face_iterator begin_active_face() const
Definition: tria.cc:12117
unsigned int n_used_vertices() const
Definition: tria.cc:13091
std::vector< GridTools::PeriodicFacePair< cell_iterator > > periodic_face_pairs_level_0
Definition: tria.h:3424
bool check_consistency(const unsigned int dim) const
Definition: tria.cc:48
unsigned int n_faces() const
Definition: tria.cc:12525
IteratorRange< active_cell_iterator > active_cell_iterators() const
Definition: tria.cc:12060
std::vector< Point< spacedim > > vertices
Definition: tria.h:3660
std::map< types::manifold_id, std::unique_ptr< const Manifold< dim, spacedim > > > manifold
Definition: tria.h:3672
void set_all_refine_flags()
Definition: tria.cc:10756
void load_user_flags(std::istream &in)
Definition: tria.cc:11156
boost::signals2::signal< void()> pre_distributed_refinement
Definition: tria.h:2254
bool anisotropic_refinement
Definition: tria.h:3677
static void read_bool_vector(const unsigned int magic_number1, std::vector< bool > &v, const unsigned int magic_number2, std::istream &in)
Definition: tria.cc:14934
static::ExceptionBase & ExcGridReadError()
void clear_user_flags_quad()
Definition: tria.cc:11047
face_iterator begin_face() const
Definition: tria.cc:12096
void save_user_pointers_quad(std::vector< void * > &v) const
Definition: tria.cc:11821
void serialize(Archive &ar, const unsigned int version)
void flip_all_direction_flags()
Definition: tria.cc:10744
raw_hex_iterator begin_raw_hex(const unsigned int level=0) const
Definition: tria.cc:12373
unsigned int material_id
Definition: types.h:134
STL namespace.
const std::vector< bool > & get_used_vertices() const
Definition: tria.cc:13104
cell_iterator last() const
Definition: tria.cc:11955
line_iterator end_line() const
Definition: tria.cc:12276
types::boundary_id boundary_id
Definition: tria.h:171
static void write_bool_vector(const unsigned int magic_number1, const std::vector< bool > &v, const unsigned int magic_number2, std::ostream &out)
Definition: tria.cc:14899
static::ExceptionBase & ExcIndexRange(int arg1, int arg2, int arg3)
cell_iterator begin(const unsigned int level=0) const
Definition: tria.cc:11915
void execute_coarsening()
Definition: tria.cc:13399
void load_user_flags_quad(std::istream &in)
Definition: tria.cc:11363
void save_user_flags_line(std::ostream &out) const
Definition: tria.cc:11226
unsigned int n_active_cells() const
Definition: tria.cc:12509
Definition: point.h:106
void load_user_pointers_line(const std::vector< void * > &v)
Definition: tria.cc:11806
unsigned int n_levels() const
void set_manifold(const types::manifold_id number, const Manifold< dim, spacedim > &manifold_object)
Definition: tria.cc:10268
IteratorRange< cell_iterator > cell_iterators() const
Definition: tria.cc:12051
virtual ~DistortedCellList() noexceptoverride
Definition: tria.cc:14993
static::ExceptionBase & ExcFacesHaveNoLevel()
std::unique_ptr<::internal::TriangulationImplementation::TriaFaces< dim > > faces
Definition: tria.h:3654
bool get_anisotropic_refinement_flag() const
Definition: tria.cc:10921
vertex_iterator end_vertex() const
Definition: tria.cc:12199
virtual void add_periodicity(const std::vector< GridTools::PeriodicFacePair< cell_iterator >> &)
Definition: tria.cc:13200
void load_coarsen_flags(std::istream &out)
Definition: tria.cc:10889
void load_user_flags_hex(std::istream &in)
Definition: tria.cc:11432
virtual void execute_coarsening_and_refinement()
Definition: tria.cc:13229
Definition: tria.h:81
void save_user_indices_hex(std::vector< unsigned int > &v) const
Definition: tria.cc:11643
unsigned int n_active_quads() const
Definition: tria.cc:12977
void save_coarsen_flags(std::ostream &out) const
Definition: tria.cc:10875
const std::map< std::pair< cell_iterator, unsigned int >, std::pair< std::pair< cell_iterator, unsigned int >, std::bitset< 3 > > > & get_periodic_face_map() const
Definition: tria.cc:13220
void save_user_indices(std::vector< unsigned int > &v) const
Definition: tria.cc:11468
virtual bool prepare_coarsening_and_refinement()
Definition: tria.cc:13935
static::ExceptionBase & ExcMessage(std::string arg1)
unsigned int n_raw_hexs(const unsigned int level) const
Definition: tria.cc:13015
boost::signals2::signal< void()> pre_refinement
Definition: tria.h:2140
unsigned int n_raw_lines() const
Definition: tria.cc:12724
static::ExceptionBase & ExcTriangulationNotEmpty(int arg1, int arg2)
void reset_active_cell_indices()
Definition: tria.cc:13270
DistortedCellList execute_refinement()
Definition: tria.cc:13367
const bool check_for_distorted_cells
Definition: tria.h:3684
unsigned int subdomain_id
Definition: types.h:43
quad_iterator end_quad() const
Definition: tria.cc:12360
static const unsigned int dimension
Definition: tria.h:1627
static::ExceptionBase & ExcNonOrientableTriangulation()
Triangulation(const MeshSmoothing smooth_grid=none, const bool check_for_distorted_cells=false)
Definition: tria.cc:10129
unsigned int n_cells() const
Definition: tria.cc:12501
#define DeclException1(Exception1, type1, outsequence)
Definition: exceptions.h:408
void clear_user_flags_hex()
Definition: tria.cc:11087
void load_user_indices_line(const std::vector< unsigned int > &v)
Definition: tria.cc:11594
Definition: types.h:31
virtual void create_triangulation(const std::vector< Point< spacedim >> &vertices, const std::vector< CellData< dim >> &cells, const SubCellData &subcelldata)
Definition: tria.cc:10556
active_cell_iterator end_active(const unsigned int level) const
Definition: tria.cc:12039
IteratorRange< cell_iterator > cell_iterators_on_level(const unsigned int level) const
Definition: tria.cc:12071
#define Assert(cond, exc)
Definition: exceptions.h:1227
std::vector< types::manifold_id > get_manifold_ids() const
Definition: tria.cc:10450
void save_user_flags(std::ostream &out) const
Definition: tria.cc:11107
hex_iterator end_hex() const
Definition: tria.cc:12435
unsigned int n_raw_quads() const
Definition: tria.cc:12958
boost::signals2::signal< void()> clear
Definition: tria.h:2202
unsigned int n_hexs() const
Definition: tria.cc:12997
void set_all_manifold_ids(const types::manifold_id number)
Definition: tria.cc:10310
void load_user_pointers_quad(const std::vector< void * > &v)
Definition: tria.cc:11839
::internal::TriangulationImplementation::Iterators< dim, spacedim > IteratorSelector
Definition: tria.h:1283
active_vertex_iterator begin_active_vertex() const
Definition: tria.cc:12190
void load(Archive &ar, const unsigned int version)
std::list< typename Triangulation< dim, spacedim >::cell_iterator > distorted_cells
Definition: tria.h:1621
std::unique_ptr< std::map< unsigned int, types::manifold_id > > vertex_to_manifold_id_map_1d
Definition: tria.h:3735
std::vector< bool > vertices_used
Definition: tria.h:3665
#define DeclException0(Exception0)
Definition: exceptions.h:385
virtual bool has_hanging_nodes() const
Definition: tria.cc:12639
boost::signals2::signal< void(const typename Triangulation< dim, spacedim >::cell_iterator &cell)> post_refinement_on_cell
Definition: tria.h:2177
void reset_all_manifolds()
Definition: tria.cc:10302
types::material_id material_id
Definition: tria.h:160
boost::signals2::signal< void()> mesh_movement
Definition: tria.h:2156
void load_user_indices(const std::vector< unsigned int > &v)
Definition: tria.cc:11500
void save_user_pointers(std::vector< void * > &v) const
Definition: tria.cc:11724
raw_line_iterator begin_raw_line(const unsigned int level=0) const
Definition: tria.cc:12220
void clear_despite_subscriptions()
Definition: tria.cc:13351
const Manifold< dim, spacedim > & get_manifold(const types::manifold_id number) const
Definition: tria.cc:10394
boost::signals2::signal< void()> pre_distributed_save
Definition: tria.h:2272
std::vector< types::boundary_id > get_boundary_ids() const
Definition: tria.cc:10417
hex_iterator begin_hex(const unsigned int level=0) const
Definition: tria.cc:12403
raw_cell_iterator begin_raw(const unsigned int level=0) const
Definition: tria.cc:11895
void save_refine_flags(std::ostream &out) const
Definition: tria.cc:10807
unsigned int n_lines() const
Definition: tria.cc:12651
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:3432
vertex_iterator begin_vertex() const
Definition: tria.cc:12161
void serialize(Archive &ar, const unsigned int version)
void save_user_indices_line(std::vector< unsigned int > &v) const
Definition: tria.cc:11580
virtual void set_mesh_smoothing(const MeshSmoothing mesh_smoothing)
Definition: tria.cc:10247
virtual types::subdomain_id locally_owned_subdomain() const
Definition: tria.cc:13173
boost::signals2::signal< void()> create
Definition: tria.h:2131
std::unique_ptr< std::map< unsigned int, types::boundary_id > > vertex_to_boundary_id_map_1d
Definition: tria.h:3712
active_cell_iterator last_active() const
Definition: tria.cc:11983
std::vector< std::unique_ptr< ::internal::TriangulationImplementation::TriaLevel< dim > > > levels
Definition: tria.h:3646
bool vertex_used(const unsigned int index) const
Definition: hp.h:102
IteratorRange< active_cell_iterator > active_cell_iterators_on_level(const unsigned int level) const
Definition: tria.cc:12082
void save_user_pointers_line(std::vector< void * > &v) const
Definition: tria.cc:11792
types::manifold_id manifold_id
Definition: tria.h:182
active_quad_iterator begin_active_quad(const unsigned int level=0) const
Definition: tria.cc:12344
virtual types::global_dof_index n_global_active_cells() const
Definition: tria.cc:12516
virtual const MeshSmoothing & get_mesh_smoothing() const
Definition: tria.cc:10259
void load_user_indices_hex(const std::vector< unsigned int > &v)
Definition: tria.cc:11661
void reset_manifold(const types::manifold_id manifold_number)
Definition: tria.cc:10290
void save_user_indices_quad(std::vector< unsigned int > &v) const
Definition: tria.cc:11608
unsigned int global_dof_index
Definition: types.h:89
unsigned int n_raw_cells(const unsigned int level) const
Definition: tria.cc:12580
const types::manifold_id invalid_manifold_id
Definition: types.h:234
unsigned int n_active_faces() const
Definition: tria.cc:12561
void fix_coarsen_flags()
Definition: tria.cc:13474
void save_user_pointers_hex(std::vector< void * > &v) const
Definition: tria.cc:11856
void update_periodic_face_map()
Definition: tria.cc:13288
std::vector< unsigned int > n_active_hexes_level
Definition: tria.h:467
void save(Archive &ar, const unsigned int version) const
face_iterator end_face() const
Definition: tria.cc:12138
Signals signals
Definition: tria.h:2285
raw_cell_iterator end_raw(const unsigned int level) const
Definition: tria.cc:12015
std::vector< CellData< 2 > > boundary_quads
Definition: tria.h:266
MeshSmoothing smooth_grid
Definition: tria.h:3377
boost::signals2::signal< unsigned int(const cell_iterator &, const CellStatus), CellWeightSum< unsigned int > > cell_weight
Definition: tria.h:2241
quad_iterator begin_quad(const unsigned int level=0) const
Definition: tria.cc:12328
unsigned int n_quads() const
Definition: tria.cc:12909
std::vector< unsigned int > n_active_lines_level
Definition: tria.h:348
active_hex_iterator begin_active_hex(const unsigned int level=0) const
Definition: tria.cc:12419
void refine_global(const unsigned int times=1)
Definition: tria.cc:10773
static::ExceptionBase & ExcEmptyLevel(int arg1)
void load_user_pointers_hex(const std::vector< void * > &v)
Definition: tria.cc:11874
void set_all_manifold_ids_on_boundary(const types::manifold_id number)
Definition: tria.cc:10329
void load_user_pointers(const std::vector< void * > &v)
Definition: tria.cc:11755
active_cell_iterator begin_active(const unsigned int level=0) const
Definition: tria.cc:11935
std::vector< unsigned int > n_active_quads_level
Definition: tria.h:407
void clear_user_flags_line()
Definition: tria.cc:11006
static::ExceptionBase & ExcBoundaryIdNotFound(types::boundary_id arg1)
void serialize(Archive &ar, const unsigned int version)
unsigned int max_adjacent_cells() const
Definition: tria.cc:13138
boost::signals2::signal< void()> post_distributed_load
Definition: tria.h:2279
unsigned int n_vertices() const
unsigned int boundary_id
Definition: types.h:111
void clear_user_data()
Definition: tria.cc:10971
unsigned int n_active_hexs() const
Definition: tria.cc:13023
raw_quad_iterator begin_raw_quad(const unsigned int level=0) const
Definition: tria.cc:12290
void load_user_indices_quad(const std::vector< unsigned int > &v)
Definition: tria.cc:11626
boost::signals2::signal< void()> any_change
Definition: tria.h:2213
virtual void clear()
Definition: tria.cc:10232
void save_user_flags_quad(std::ostream &out) const
Definition: tria.cc:11349
void load_refine_flags(std::istream &in)
Definition: tria.cc:10821
Tensor< 2, dim, Number > l(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
unsigned int vertices[GeometryInfo< structdim >::vertices_per_cell]
Definition: tria.h:141
Triangulation< dim, spacedim > & get_triangulation()
Definition: tria.cc:13182
boost::signals2::signal< void()> post_distributed_refinement
Definition: tria.h:2264
virtual std::size_t memory_consumption() const
Definition: tria.cc:14972