Reference documentation for deal.II version Git 81120c2 2018-01-16 17:31:12 +0100
tria.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 1998 - 2017 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 at
12 // the top level of the deal.II distribution.
13 //
14 // ---------------------------------------------------------------------
15 
16 #ifndef dealii_tria_h
17 #define dealii_tria_h
18 
19 
20 #include <deal.II/base/config.h>
21 #include <deal.II/base/point.h>
22 #include <deal.II/base/subscriptor.h>
23 #include <deal.II/base/smartpointer.h>
24 #include <deal.II/base/geometry_info.h>
25 #include <deal.II/base/iterator_range.h>
26 #include <deal.II/grid/tria_iterator_selector.h>
27 
28 // Ignore deprecation warnings for auto_ptr.
29 DEAL_II_DISABLE_EXTRA_DIAGNOSTICS
30 #include <boost/signals2.hpp>
31 #include <boost/serialization/vector.hpp>
32 #include <boost/serialization/map.hpp>
33 #include <boost/serialization/unique_ptr.hpp>
34 #include <boost/serialization/split_member.hpp>
35 DEAL_II_ENABLE_EXTRA_DIAGNOSTICS
36 
37 #include <vector>
38 #include <list>
39 #include <map>
40 #include <numeric>
41 #include <bitset>
42 #include <functional>
43 #include <memory>
44 
45 
46 DEAL_II_NAMESPACE_OPEN
47 
48 template <int dim, int spacedim> class Boundary;
49 template <int dim, int spacedim> class StraightBoundary;
50 template <int dim, int spacedim> class Manifold;
51 
52 namespace GridTools
53 {
54  template <typename CellIterator> struct PeriodicFacePair;
55 }
56 
57 template <int, int, int> class TriaAccessor;
58 template <int spacedim> class TriaAccessor<0,1,spacedim>;
59 template <int, int, int> class TriaAccessorBase;
60 
61 namespace internal
62 {
63  namespace Triangulation
64  {
65  template <int dim> class TriaLevel;
66  template <int dim> class TriaFaces;
67 
68  template <typename> class TriaObjects;
69 
75  struct Implementation;
76  }
77 
78  namespace TriaAccessor
79  {
80  struct Implementation;
81  }
82 }
83 
84 namespace hp
85 {
86  template <int dim, int spacedim> class DoFHandler;
87 }
88 
89 
90 /*------------------------------------------------------------------------*/
91 
127 template <int structdim>
128 struct CellData
129 {
136 
144  union
145  {
155 
166  };
167 
177 
185  CellData ();
186 };
187 
188 
189 
245 {
252  std::vector<CellData<1> > boundary_lines;
253 
260  std::vector<CellData<2> > boundary_quads;
261 
269  bool check_consistency (const unsigned int dim) const;
270 };
271 
272 
273 /*------------------------------------------------------------------------*/
274 
275 
276 namespace internal
277 {
282  namespace Triangulation
283  {
284 
298  template <int dim>
299  struct NumberCache
300  {
301  };
302 
316  template <>
317  struct NumberCache<1>
318  {
322  unsigned int n_levels;
323 
327  unsigned int n_lines;
328 
332  std::vector<unsigned int> n_lines_level;
333 
337  unsigned int n_active_lines;
338 
342  std::vector<unsigned int> n_active_lines_level;
343 
347  NumberCache ();
348 
353  std::size_t memory_consumption () const;
354 
359  template <class Archive>
360  void serialize (Archive &ar,
361  const unsigned int version);
362  };
363 
364 
379  template <>
380  struct NumberCache<2> : public NumberCache<1>
381  {
385  unsigned int n_quads;
386 
390  std::vector<unsigned int> n_quads_level;
391 
395  unsigned int n_active_quads;
396 
400  std::vector<unsigned int> n_active_quads_level;
401 
405  NumberCache ();
406 
411  std::size_t memory_consumption () const;
412 
417  template <class Archive>
418  void serialize (Archive &ar,
419  const unsigned int version);
420  };
421 
422 
438  template <>
439  struct NumberCache<3> : public NumberCache<2>
440  {
444  unsigned int n_hexes;
445 
449  std::vector<unsigned int> n_hexes_level;
450 
454  unsigned int n_active_hexes;
455 
459  std::vector<unsigned int> n_active_hexes_level;
460 
464  NumberCache ();
465 
470  std::size_t memory_consumption () const;
471 
476  template <class Archive>
477  void serialize (Archive &ar,
478  const unsigned int version);
479  };
480  }
481 }
482 
483 
484 /*------------------------------------------------------------------------*/
485 
486 
1243 template <int dim, int spacedim=dim>
1244 class Triangulation : public Subscriptor
1245 {
1246 private:
1247 
1252  typedef ::internal::Triangulation::Iterators<dim, spacedim> IteratorSelector;
1253 
1254 public:
1262  DEAL_II_DEPRECATED
1264 
1270  {
1275  none = 0x0,
1446 
1460 
1467  };
1468 
1485 
1503 
1517  typedef TriaIterator <TriaAccessor<dim-1, dim, spacedim> > face_iterator;
1518 
1530  typedef TriaActiveIterator<TriaAccessor<dim-1, dim, spacedim> > active_face_iterator;
1531 
1541 
1555 
1556  typedef typename IteratorSelector::line_iterator line_iterator;
1557  typedef typename IteratorSelector::active_line_iterator active_line_iterator;
1558 
1559  typedef typename IteratorSelector::quad_iterator quad_iterator;
1560  typedef typename IteratorSelector::active_quad_iterator active_quad_iterator;
1561 
1562  typedef typename IteratorSelector::hex_iterator hex_iterator;
1563  typedef typename IteratorSelector::active_hex_iterator active_hex_iterator;
1564 
1584  {
1591  virtual ~DistortedCellList () noexcept;
1592 
1597  std::list<typename Triangulation<dim,spacedim>::cell_iterator>
1599  };
1600 
1604  static const unsigned int dimension = dim;
1605 
1609  static const unsigned int space_dimension = spacedim;
1610 
1626  const bool check_for_distorted_cells = false);
1627 
1643  Triangulation (const Triangulation<dim, spacedim> &) = delete;
1644 
1652 
1657 
1661  virtual ~Triangulation ();
1662 
1669  virtual void clear ();
1670 
1676  virtual void set_mesh_smoothing (const MeshSmoothing mesh_smoothing);
1677 
1681  virtual const MeshSmoothing &get_mesh_smoothing() const;
1682 
1723  DEAL_II_DEPRECATED
1724  void set_boundary (const types::manifold_id number,
1725  const Boundary<dim,spacedim> &boundary_object);
1726 
1727 
1742  DEAL_II_DEPRECATED
1743  void set_boundary (const types::manifold_id number);
1744 
1769  void set_manifold (const types::manifold_id number,
1770  const Manifold<dim,spacedim> &manifold_object);
1771 
1772 
1784  void set_manifold (const types::manifold_id number);
1785 
1794  void set_all_manifold_ids (const types::manifold_id number);
1795 
1805 
1816  const types::manifold_id number);
1817 
1818 
1831  DEAL_II_DEPRECATED
1832  const Boundary<dim,spacedim> &get_boundary (const types::manifold_id number) const;
1833 
1843  const Manifold<dim,spacedim> &get_manifold (const types::manifold_id number) const;
1844 
1856  std::vector<types::boundary_id> get_boundary_ids() const;
1857 
1869  std::vector<types::manifold_id> get_manifold_ids() const;
1870 
1897  virtual void copy_triangulation (const Triangulation<dim, spacedim> &other_tria);
1898 
1942  virtual void create_triangulation (const std::vector<Point<spacedim> > &vertices,
1943  const std::vector<CellData<dim> > &cells,
1944  const SubCellData &subcelldata);
1945 
1954  virtual void create_triangulation_compatibility (
1955  const std::vector<Point<spacedim> > &vertices,
1956  const std::vector<CellData<dim> > &cells,
1957  const SubCellData &subcelldata);
1958 
1965  void flip_all_direction_flags();
1966 
1978  void set_all_refine_flags ();
1979 
1994  void refine_global (const unsigned int times = 1);
1995 
2027  virtual void execute_coarsening_and_refinement ();
2028 
2058  virtual bool prepare_coarsening_and_refinement ();
2059 
2060  /*
2061  * @}
2062  */
2063 
2078  {
2096  };
2097 
2103  template <typename T>
2105  {
2106  typedef T result_type;
2107 
2108  template <typename InputIterator>
2109  T operator()(InputIterator first, InputIterator last) const
2110  {
2111  return std::accumulate (first, last, T());
2112  }
2113  };
2114 
2124  struct Signals
2125  {
2133  boost::signals2::signal<void ()> create;
2134 
2142  boost::signals2::signal<void ()> pre_refinement;
2143 
2149  boost::signals2::signal<void ()> post_refinement;
2150 
2158  boost::signals2::signal<void ()> mesh_movement;
2159 
2167  boost::signals2::signal<void (const typename Triangulation<dim, spacedim>::cell_iterator &cell)> pre_coarsening_on_cell;
2168 
2175  boost::signals2::signal<void (const typename Triangulation<dim, spacedim>::cell_iterator &cell)> post_refinement_on_cell;
2176 
2183  boost::signals2::signal<void (const Triangulation<dim, spacedim> &destination_tria)> copy;
2184 
2198  boost::signals2::signal<void ()> clear;
2199 
2209  boost::signals2::signal<void ()> any_change;
2210 
2234  boost::signals2::signal<unsigned int (const cell_iterator &,
2235  const CellStatus),
2237 
2249  boost::signals2::signal<void ()> pre_distributed_refinement;
2250 
2259  boost::signals2::signal<void ()> post_distributed_refinement;
2260 
2267  boost::signals2::signal<void ()> pre_distributed_save;
2268 
2274  boost::signals2::signal<void ()> post_distributed_load;
2275  };
2276 
2280  mutable Signals signals;
2281 
2282  /*
2283  * @}
2284  */
2285 
2295  void save_refine_flags (std::ostream &out) const;
2296 
2300  void save_refine_flags (std::vector<bool> &v) const;
2301 
2305  void load_refine_flags (std::istream &in);
2306 
2310  void load_refine_flags (const std::vector<bool> &v);
2311 
2315  void save_coarsen_flags (std::ostream &out) const;
2316 
2320  void save_coarsen_flags (std::vector<bool> &v) const;
2321 
2325  void load_coarsen_flags (std::istream &out);
2326 
2330  void load_coarsen_flags (const std::vector<bool> &v);
2331 
2336  bool get_anisotropic_refinement_flag() const;
2337 
2338  /*
2339  * @}
2340  */
2341 
2351  void clear_user_flags ();
2352 
2358  void save_user_flags (std::ostream &out) const;
2359 
2365  void save_user_flags (std::vector<bool> &v) const;
2366 
2371  void load_user_flags (std::istream &in);
2372 
2377  void load_user_flags (const std::vector<bool> &v);
2378 
2383  void clear_user_flags_line ();
2384 
2389  void save_user_flags_line (std::ostream &out) const;
2390 
2396  void save_user_flags_line (std::vector<bool> &v) const;
2397 
2402  void load_user_flags_line (std::istream &in);
2403 
2408  void load_user_flags_line (const std::vector<bool> &v);
2409 
2414  void clear_user_flags_quad ();
2415 
2420  void save_user_flags_quad (std::ostream &out) const;
2421 
2427  void save_user_flags_quad (std::vector<bool> &v) const;
2428 
2433  void load_user_flags_quad (std::istream &in);
2434 
2439  void load_user_flags_quad (const std::vector<bool> &v);
2440 
2441 
2446  void clear_user_flags_hex ();
2447 
2452  void save_user_flags_hex (std::ostream &out) const;
2453 
2459  void save_user_flags_hex (std::vector<bool> &v) const;
2460 
2465  void load_user_flags_hex (std::istream &in);
2466 
2471  void load_user_flags_hex (const std::vector<bool> &v);
2472 
2478  void clear_user_data ();
2479 
2485  void save_user_indices (std::vector<unsigned int> &v) const;
2486 
2491  void load_user_indices (const std::vector<unsigned int> &v);
2492 
2498  void save_user_pointers (std::vector<void *> &v) const;
2499 
2504  void load_user_pointers (const std::vector<void *> &v);
2505 
2511  void save_user_indices_line (std::vector<unsigned int> &v) const;
2512 
2517  void load_user_indices_line (const std::vector<unsigned int> &v);
2518 
2524  void save_user_indices_quad (std::vector<unsigned int> &v) const;
2525 
2530  void load_user_indices_quad (const std::vector<unsigned int> &v);
2531 
2537  void save_user_indices_hex (std::vector<unsigned int> &v) const;
2538 
2543  void load_user_indices_hex (const std::vector<unsigned int> &v);
2549  void save_user_pointers_line (std::vector<void *> &v) const;
2550 
2555  void load_user_pointers_line (const std::vector<void *> &v);
2556 
2562  void save_user_pointers_quad (std::vector<void *> &v) const;
2563 
2568  void load_user_pointers_quad (const std::vector<void *> &v);
2569 
2575  void save_user_pointers_hex (std::vector<void *> &v) const;
2576 
2581  void load_user_pointers_hex (const std::vector<void *> &v);
2582 
2583  /*
2584  * @}
2585  */
2586 
2595  cell_iterator begin (const unsigned int level = 0) const;
2596 
2609  active_cell_iterator begin_active(const unsigned int level = 0) const;
2610 
2615  cell_iterator end () const;
2616 
2621  cell_iterator end (const unsigned int level) const;
2622 
2628  active_cell_iterator end_active (const unsigned int level) const;
2629 
2630 
2634  cell_iterator last () const;
2635 
2639  active_cell_iterator last_active () const;
2640 
2656 
2694 
2710  IteratorRange<cell_iterator> cell_iterators_on_level (const unsigned int level) const;
2711 
2728 
2729  /*
2730  * @}
2731  */
2732 
2733  /*---------------------------------------*/
2734  /*---------------------------------------*/
2735 
2744  face_iterator begin_face () const;
2745 
2749  active_face_iterator begin_active_face() const;
2750 
2755  face_iterator end_face () const;
2756 
2757  /*
2758  * @}
2759  */
2760 
2761  /*---------------------------------------*/
2762  /*---------------------------------------*/
2763 
2773  vertex_iterator begin_vertex() const;
2774 
2780  active_vertex_iterator begin_active_vertex() const;
2781 
2787  vertex_iterator end_vertex() const;
2788 
2789  /*
2790  * @}
2791  */
2792 
2810  unsigned int n_lines () const;
2811 
2815  unsigned int n_lines (const unsigned int level) const;
2816 
2820  unsigned int n_active_lines () const;
2821 
2825  unsigned int n_active_lines (const unsigned int level) const;
2826 
2830  unsigned int n_quads () const;
2831 
2835  unsigned int n_quads (const unsigned int level) const;
2836 
2840  unsigned int n_active_quads () const;
2841 
2845  unsigned int n_active_quads (const unsigned int level) const;
2846 
2850  unsigned int n_hexs() const;
2851 
2856  unsigned int n_hexs(const unsigned int level) const;
2857 
2861  unsigned int n_active_hexs() const;
2862 
2867  unsigned int n_active_hexs(const unsigned int level) const;
2868 
2873  unsigned int n_cells () const;
2874 
2879  unsigned int n_cells (const unsigned int level) const;
2880 
2885  unsigned int n_active_cells () const;
2886 
2895 
2896 
2901  unsigned int n_active_cells (const unsigned int level) const;
2902 
2908  unsigned int n_faces () const;
2909 
2915  unsigned int n_active_faces () const;
2916 
2934  unsigned int n_levels () const;
2935 
2942  virtual
2943  unsigned int n_global_levels () const;
2944 
2954  virtual
2955  bool has_hanging_nodes() const;
2956 
2964  unsigned int n_vertices () const;
2965 
2974  const std::vector<Point<spacedim> > &
2975  get_vertices () const;
2976 
2981  unsigned int n_used_vertices () const;
2982 
2986  bool vertex_used (const unsigned int index) const;
2987 
2992  const std::vector<bool> &
2993  get_used_vertices () const;
2994 
3006  unsigned int max_adjacent_cells () const;
3007 
3015 
3026  get_triangulation ();
3027 
3033  get_triangulation () const;
3034 
3035 
3036  /*
3037  * @}
3038  */
3039 
3054  unsigned int n_raw_lines () const;
3055 
3065  unsigned int n_raw_lines (const unsigned int level) const;
3066 
3076  unsigned int n_raw_quads () const;
3077 
3087  unsigned int n_raw_quads (const unsigned int level) const;
3088 
3098  unsigned int n_raw_hexs (const unsigned int level) const;
3099 
3109  unsigned int n_raw_cells (const unsigned int level) const;
3110 
3121  unsigned int n_raw_faces () const;
3122 
3123  /*
3124  * @}
3125  */
3126 
3135  virtual std::size_t memory_consumption () const;
3136 
3145  template <class Archive>
3146  void save (Archive &ar,
3147  const unsigned int version) const;
3148 
3164  template <class Archive>
3165  void load (Archive &ar,
3166  const unsigned int version);
3167 
3168 
3184  virtual void
3186  (const std::vector<GridTools::PeriodicFacePair<cell_iterator> > &);
3187 
3191  const std::map<std::pair<cell_iterator, unsigned int>,std::pair<std::pair<cell_iterator, unsigned int>, std::bitset<3> > > &
3192  get_periodic_face_map() const;
3193 
3194 
3195  BOOST_SERIALIZATION_SPLIT_MEMBER()
3196 
3197 
3208  int,
3209  << "The given level " << arg1
3210  << " is not in the valid range!");
3218  int, int,
3219  << "You are trying to perform an operation on a triangulation "
3220  << "that is only allowed if the triangulation is currently empty. "
3221  << "However, it currently stores " << arg1 << " vertices and has "
3222  << "cells on " << arg2 << " levels.");
3240  int,
3241  << "You tried to do something on level " << arg1
3242  << ", but this level is empty.");
3249 
3258  types::boundary_id,
3259  << "The given boundary_id " << arg1
3260  << " is not defined in this Triangulation!");
3261 
3262  /*
3263  * @}
3264  */
3265 
3266 protected:
3272 
3286  static void write_bool_vector (const unsigned int magic_number1,
3287  const std::vector<bool> &v,
3288  const unsigned int magic_number2,
3289  std::ostream &out);
3290 
3295  static void read_bool_vector (const unsigned int magic_number1,
3296  std::vector<bool> &v,
3297  const unsigned int magic_number2,
3298  std::istream &in);
3299 
3303  void update_periodic_face_map ();
3304 
3305 
3306 private:
3313  std::vector<GridTools::PeriodicFacePair<cell_iterator> > periodic_face_pairs_level_0;
3314 
3318  std::map<std::pair<cell_iterator, unsigned int>, std::pair<std::pair<cell_iterator, unsigned int>, std::bitset<3> > > periodic_face_map;
3319 
3334  typedef TriaRawIterator<TriaAccessor<dim-1, dim, spacedim> > raw_face_iterator;
3335  typedef TriaRawIterator<::TriaAccessor<0, dim, spacedim> > raw_vertex_iterator;
3336  typedef typename IteratorSelector::raw_line_iterator raw_line_iterator;
3337  typedef typename IteratorSelector::raw_quad_iterator raw_quad_iterator;
3338  typedef typename IteratorSelector::raw_hex_iterator raw_hex_iterator;
3339 
3344  raw_cell_iterator begin_raw (const unsigned int level = 0) const;
3345 
3350  raw_cell_iterator end_raw (const unsigned int level) const;
3351 
3352  /*
3353  * @}
3354  */
3355 
3367  raw_line_iterator
3368  begin_raw_line (const unsigned int level = 0) const;
3369 
3373  line_iterator
3374  begin_line (const unsigned int level = 0) const;
3375 
3379  active_line_iterator
3380  begin_active_line(const unsigned int level = 0) const;
3381 
3386  line_iterator end_line () const;
3387 
3388  /*
3389  * @}
3390  */
3391 
3402  raw_quad_iterator
3403  begin_raw_quad (const unsigned int level = 0) const;
3404 
3408  quad_iterator
3409  begin_quad (const unsigned int level = 0) const;
3410 
3414  active_quad_iterator
3415  begin_active_quad (const unsigned int level = 0) const;
3416 
3421  quad_iterator
3422  end_quad () const;
3423 
3424  /*
3425  * @}
3426  */
3427 
3437  raw_hex_iterator
3438  begin_raw_hex (const unsigned int level = 0) const;
3439 
3443  hex_iterator
3444  begin_hex (const unsigned int level = 0) const;
3445 
3449  active_hex_iterator
3450  begin_active_hex (const unsigned int level = 0) const;
3451 
3456  hex_iterator
3457  end_hex () const;
3458 
3459  /*
3460  * @}
3461  */
3462 
3463 
3478 
3485  void reset_active_cell_indices ();
3486 
3500  DistortedCellList execute_refinement ();
3501 
3508  void execute_coarsening ();
3509 
3514  void fix_coarsen_flags ();
3515 
3520  std::vector<std::unique_ptr<::internal::Triangulation::TriaLevel<dim> > > levels;
3521 
3527  std::unique_ptr<::internal::Triangulation::TriaFaces<dim> > faces;
3528 
3529 
3533  std::vector<Point<spacedim> > vertices;
3534 
3538  std::vector<bool> vertices_used;
3539 
3544  std::map<types::manifold_id, SmartPointer<const Manifold<dim,spacedim>, Triangulation<dim, spacedim> > > manifold;
3545 
3546 
3551 
3552 
3558 
3568  ::internal::Triangulation::NumberCache<dim> number_cache;
3569 
3584  std::unique_ptr<std::map<unsigned int, types::boundary_id> > vertex_to_boundary_id_map_1d;
3585 
3586 
3606  std::unique_ptr<std::map<unsigned int, types::manifold_id> > vertex_to_manifold_id_map_1d;
3607 
3608  // make a couple of classes friends
3609  template <int,int,int> friend class TriaAccessorBase;
3610  template <int,int,int> friend class TriaAccessor;
3611  friend class TriaAccessor<0, 1, spacedim>;
3612 
3613  friend class CellAccessor<dim, spacedim>;
3614 
3615  friend struct ::internal::TriaAccessor::Implementation;
3616 
3617  friend class hp::DoFHandler<dim,spacedim>;
3618 
3619  friend struct ::internal::Triangulation::Implementation;
3620 
3621  template <typename>
3622  friend class ::internal::Triangulation::TriaObjects;
3623 
3624  // explicitly check for sensible template arguments, but not on windows
3625  // because MSVC creates bogus warnings during normal compilation
3626 #ifndef DEAL_II_MSVC
3627  static_assert (dim<=spacedim,
3628  "The dimension <dim> of a Triangulation must be less than or "
3629  "equal to the space dimension <spacedim> in which it lives.");
3630 #endif
3631 
3632 };
3633 
3634 
3635 #ifndef DOXYGEN
3636 
3637 
3638 template <int structdim>
3639 inline
3641 {
3642  for (unsigned int i=0; i<GeometryInfo<structdim>::vertices_per_cell; ++i)
3643  vertices[i] = numbers::invalid_unsigned_int;
3644 
3645  material_id = 0;
3646 
3647  // And the manifold to be invalid
3648  manifold_id = numbers::invalid_manifold_id;
3649 }
3650 
3651 
3652 
3653 namespace internal
3654 {
3655  namespace Triangulation
3656  {
3657  template <class Archive>
3658  void NumberCache<1>::serialize (Archive &ar,
3659  const unsigned int)
3660  {
3661  ar &n_levels;
3662  ar &n_lines &n_lines_level;
3663  ar &n_active_lines &n_active_lines_level;
3664  }
3665 
3666 
3667  template <class Archive>
3668  void NumberCache<2>::serialize (Archive &ar,
3669  const unsigned int version)
3670  {
3671  this->NumberCache<1>::serialize (ar, version);
3672 
3673  ar &n_quads &n_quads_level;
3674  ar &n_active_quads &n_active_quads_level;
3675  }
3676 
3677 
3678  template <class Archive>
3679  void NumberCache<3>::serialize (Archive &ar,
3680  const unsigned int version)
3681  {
3682  this->NumberCache<2>::serialize (ar, version);
3683 
3684  ar &n_hexes &n_hexes_level;
3685  ar &n_active_hexes &n_active_hexes_level;
3686  }
3687 
3688  }
3689 }
3690 
3691 
3692 template <int dim, int spacedim>
3693 inline
3694 bool
3695 Triangulation<dim,spacedim>::vertex_used(const unsigned int index) const
3696 {
3697  Assert (index < vertices_used.size(),
3698  ExcIndexRange(index, 0, vertices_used.size()));
3699  return vertices_used[index];
3700 }
3701 
3702 
3703 
3704 template <int dim, int spacedim>
3705 inline
3706 unsigned int Triangulation<dim, spacedim>::n_levels () const
3707 {
3708  return number_cache.n_levels;
3709 }
3710 
3711 template <int dim, int spacedim>
3712 inline
3714 {
3715  return number_cache.n_levels;
3716 }
3717 
3718 
3719 template <int dim, int spacedim>
3720 inline
3721 unsigned int
3723 {
3724  return vertices.size();
3725 }
3726 
3727 
3728 
3729 template <int dim, int spacedim>
3730 inline
3731 const std::vector<Point<spacedim> > &
3733 {
3734  return vertices;
3735 }
3736 
3737 
3738 template <int dim, int spacedim>
3739 template <class Archive>
3740 void
3742  const unsigned int) const
3743 {
3744  // as discussed in the documentation, do not store the signals as
3745  // well as boundary and manifold description but everything else
3746  ar &smooth_grid;
3747 
3748  unsigned int n_levels = levels.size();
3749  ar &n_levels;
3750  for (unsigned int i = 0; i < levels.size(); ++i)
3751  ar &levels[i];
3752 
3753  // boost dereferences a nullptr when serializing a nullptr
3754  // at least up to 1.65.1. This causes problems with clang-5.
3755  // Therefore, work around it.
3756  bool faces_is_nullptr = (faces.get()==nullptr);
3757  ar &faces_is_nullptr;
3758  if (!faces_is_nullptr)
3759  ar &faces;
3760 
3761  ar &vertices;
3762  ar &vertices_used;
3763 
3764  ar &anisotropic_refinement;
3765  ar &number_cache;
3766 
3767  ar &check_for_distorted_cells;
3768 
3769  if (dim == 1)
3770  {
3771  ar &vertex_to_boundary_id_map_1d;
3772  ar &vertex_to_manifold_id_map_1d;
3773  }
3774 }
3775 
3776 
3777 
3778 template <int dim, int spacedim>
3779 template <class Archive>
3780 void
3782  const unsigned int)
3783 {
3784  // clear previous content. this also calls the respective signal
3785  clear ();
3786 
3787  // as discussed in the documentation, do not store the signals as
3788  // well as boundary and manifold description but everything else
3789  ar &smooth_grid;
3790 
3791  unsigned int size;
3792  ar &size;
3793  levels.resize(size);
3794  for (unsigned int i = 0; i < levels.size(); ++i)
3795  {
3796  std::unique_ptr<internal::Triangulation::TriaLevel<dim>> level;
3797  ar &level;
3798  levels[i] = std::move(level);
3799  }
3800 
3801  //Workaround for nullptr, see in save().
3802  bool faces_is_nullptr = true;
3803  ar &faces_is_nullptr;
3804  if (!faces_is_nullptr)
3805  ar &faces;
3806 
3807  ar &vertices;
3808  ar &vertices_used;
3809 
3810  ar &anisotropic_refinement;
3811  ar &number_cache;
3812 
3813  // the levels do not serialize the active_cell_indices because
3814  // they are easy enough to rebuild upon re-loading data. do
3815  // this here. don't forget to first resize the fields appropriately
3816  {
3817  for (unsigned int l=0; l<levels.size(); ++l)
3818  levels[l]->active_cell_indices.resize (levels[l]->refine_flags.size());
3819  reset_active_cell_indices ();
3820  }
3821 
3822 
3823  bool my_check_for_distorted_cells;
3824  ar &my_check_for_distorted_cells;
3825 
3826  Assert (my_check_for_distorted_cells == check_for_distorted_cells,
3827  ExcMessage ("The triangulation loaded into here must have the "
3828  "same setting with regard to reporting distorted "
3829  "cell as the one previously stored."));
3830 
3831  if (dim == 1)
3832  {
3833  ar &vertex_to_boundary_id_map_1d;
3834  ar &vertex_to_manifold_id_map_1d;
3835  }
3836 
3837  // trigger the create signal to indicate
3838  // that new content has been imported into
3839  // the triangulation
3840  signals.create();
3841 }
3842 
3843 
3844 /* -------------- declaration of explicit specializations ------------- */
3845 
3846 template <> unsigned int Triangulation<1,1>::n_raw_lines (const unsigned int level) const;
3847 template <> unsigned int Triangulation<1,1>::n_quads () const;
3848 template <> unsigned int Triangulation<1,1>::n_quads (const unsigned int level) const;
3849 template <> unsigned int Triangulation<1,1>::n_raw_quads (const unsigned int level) const;
3850 template <> unsigned int Triangulation<2,2>::n_raw_quads (const unsigned int level) const;
3851 template <> unsigned int Triangulation<1,1>::n_raw_hexs (const unsigned int level) const;
3852 template <> unsigned int Triangulation<1,1>::n_active_quads (const unsigned int level) const;
3853 template <> unsigned int Triangulation<1,1>::n_active_quads () const;
3854 template <> unsigned int Triangulation<1,1>::max_adjacent_cells () const;
3855 
3856 
3857 // -------------------------------------------------------------------
3858 // -- Explicit specializations for codimension one grids
3859 
3860 
3861 template <> unsigned int Triangulation<1,2>::n_raw_lines (const unsigned int level) const;
3862 template <> unsigned int Triangulation<1,2>::n_quads () const;
3863 template <> unsigned int Triangulation<1,2>::n_quads (const unsigned int level) const;
3864 template <> unsigned int Triangulation<1,2>::n_raw_quads (const unsigned int level) const;
3865 template <> unsigned int Triangulation<2,3>::n_raw_quads (const unsigned int level) const;
3866 template <> unsigned int Triangulation<1,2>::n_raw_hexs (const unsigned int level) const;
3867 template <> unsigned int Triangulation<1,2>::n_active_quads (const unsigned int level) const;
3868 template <> unsigned int Triangulation<1,2>::n_active_quads () const;
3869 template <> unsigned int Triangulation<1,2>::max_adjacent_cells () const;
3870 
3871 // -------------------------------------------------------------------
3872 // -- Explicit specializations for codimension two grids
3873 
3874 
3875 template <> unsigned int Triangulation<1,3>::n_raw_lines (const unsigned int level) const;
3876 template <> unsigned int Triangulation<1,3>::n_quads () const;
3877 template <> unsigned int Triangulation<1,3>::n_quads (const unsigned int level) const;
3878 template <> unsigned int Triangulation<1,3>::n_raw_quads (const unsigned int level) const;
3879 template <> unsigned int Triangulation<2,3>::n_raw_quads (const unsigned int level) const;
3880 template <> unsigned int Triangulation<1,3>::n_raw_hexs (const unsigned int level) const;
3881 template <> unsigned int Triangulation<1,3>::n_active_quads (const unsigned int level) const;
3882 template <> unsigned int Triangulation<1,3>::n_active_quads () const;
3883 template <> unsigned int Triangulation<1,3>::max_adjacent_cells () const;
3884 
3885 
3886 #endif // DOXYGEN
3887 
3888 DEAL_II_NAMESPACE_CLOSE
3889 
3890 // Include tria_accessor.h here, so that it is possible for an end
3891 // user to use the iterators of Triangulation<dim> directly without
3892 // the need to include tria_accessor.h separately. (Otherwise the
3893 // iterators are an 'opaque' or 'incomplete' type.)
3894 #include <deal.II/grid/tria_accessor.h>
3895 
3896 #endif
std::vector< CellData< 1 > > boundary_lines
Definition: tria.h:252
TriaActiveIterator< CellAccessor< dim, spacedim > > active_cell_iterator
Definition: tria.h:1502
boost::signals2::signal< void()> any_change
Definition: tria.h:2209
unsigned int n_raw_faces() const
Definition: tria.cc:11108
void set_boundary(const types::manifold_id number, const Boundary< dim, spacedim > &boundary_object)
Definition: tria.cc:8950
active_line_iterator begin_active_line(const unsigned int level=0) const
Definition: tria.cc:10824
static const unsigned int space_dimension
Definition: tria.h:1609
virtual void copy_triangulation(const Triangulation< dim, spacedim > &other_tria)
Definition: tria.cc:9148
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:9856
#define DeclException2(Exception2, type1, type2, outsequence)
Definition: exceptions.h:605
Iterator points to a valid object.
virtual ~DistortedCellList() noexcept
Definition: tria.cc:13403
void clear_user_flags()
Definition: tria.cc:9721
line_iterator begin_line(const unsigned int level=0) const
Definition: tria.cc:10808
const std::vector< Point< spacedim > > & get_vertices() const
::internal::Triangulation::NumberCache< dim > number_cache
Definition: tria.h:3568
cell_iterator end() const
Definition: tria.cc:10568
virtual unsigned int n_global_levels() const
void save_user_flags_hex(std::ostream &out) const
Definition: tria.cc:10018
unsigned int n_active_lines() const
Definition: tria.cc:11291
active_face_iterator begin_active_face() const
Definition: tria.cc:10680
unsigned int n_used_vertices() const
Definition: tria.cc:11604
std::vector< GridTools::PeriodicFacePair< cell_iterator > > periodic_face_pairs_level_0
Definition: tria.h:3313
std::list< typename Triangulation< dim, spacedim >::cell_iterator > distorted_cells
Definition: tria.h:1598
bool check_consistency(const unsigned int dim) const
Definition: tria.cc:47
unsigned int n_faces() const
Definition: tria.cc:11090
IteratorRange< active_cell_iterator > active_cell_iterators() const
Definition: tria.cc:10624
std::vector< Point< spacedim > > vertices
Definition: tria.h:3533
boost::signals2::signal< void()> clear
Definition: tria.h:2198
TriaActiveIterator< TriaAccessor< dim-1, dim, spacedim > > active_face_iterator
Definition: tria.h:1530
void set_all_refine_flags()
Definition: tria.cc:9424
void load_user_flags(std::istream &in)
Definition: tria.cc:9778
TriaActiveIterator<::TriaAccessor< 0, dim, spacedim > > active_vertex_iterator
Definition: tria.h:1554
unsigned int boundary_id
Definition: types.h:110
bool anisotropic_refinement
Definition: tria.h:3550
boost::signals2::signal< unsigned int(const cell_iterator &, const CellStatus), CellWeightSum< unsigned int > > cell_weight
Definition: tria.h:2236
std::vector< unsigned int > n_active_lines_level
Definition: tria.h:342
std::vector< unsigned int > n_hexes_level
Definition: tria.h:449
boost::signals2::signal< void(const typename Triangulation< dim, spacedim >::cell_iterator &cell)> pre_coarsening_on_cell
Definition: tria.h:2167
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:13343
boost::signals2::signal< void()> mesh_movement
Definition: tria.h:2158
static::ExceptionBase & ExcGridReadError()
void clear_user_flags_quad()
Definition: tria.cc:9681
face_iterator begin_face() const
Definition: tria.cc:10659
std::vector< unsigned int > n_quads_level
Definition: tria.h:390
void save_user_pointers_quad(std::vector< void * > &v) const
Definition: tria.cc:10389
void flip_all_direction_flags()
Definition: tria.cc:9413
raw_hex_iterator begin_raw_hex(const unsigned int level=0) const
Definition: tria.cc:10938
STL namespace.
const std::vector< bool > & get_used_vertices() const
Definition: tria.cc:11614
cell_iterator last() const
Definition: tria.cc:10520
line_iterator end_line() const
Definition: tria.cc:10840
types::boundary_id boundary_id
Definition: tria.h:165
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:13311
unsigned int material_id
Definition: types.h:133
static::ExceptionBase & ExcIndexRange(int arg1, int arg2, int arg3)
std::vector< unsigned int > n_active_quads_level
Definition: tria.h:400
cell_iterator begin(const unsigned int level=0) const
Definition: tria.cc:10480
void execute_coarsening()
Definition: tria.cc:11892
void load_user_flags_quad(std::istream &in)
Definition: tria.cc:9966
void save_user_flags_line(std::ostream &out) const
Definition: tria.cc:9845
unsigned int n_active_cells() const
Definition: tria.cc:11076
void load_user_pointers_line(const std::vector< void * > &v)
Definition: tria.cc:10375
void serialize(Archive &ar, const unsigned int version)
unsigned int n_levels() const
void set_manifold(const types::manifold_id number, const Manifold< dim, spacedim > &manifold_object)
Definition: tria.cc:8958
IteratorRange< cell_iterator > cell_iterators() const
Definition: tria.cc:10614
static::ExceptionBase & ExcFacesHaveNoLevel()
bool get_anisotropic_refinement_flag() const
Definition: tria.cc:9578
vertex_iterator end_vertex() const
Definition: tria.cc:10761
TriaIterator< TriaAccessor< dim-1, dim, spacedim > > face_iterator
Definition: tria.h:1517
void load_coarsen_flags(std::istream &out)
Definition: tria.cc:9549
void load_user_flags_hex(std::istream &in)
Definition: tria.cc:10029
virtual void execute_coarsening_and_refinement()
Definition: tria.cc:11731
Definition: tria.h:75
void save_user_indices_hex(std::vector< unsigned int > &v) const
Definition: tria.cc:10223
unsigned int n_active_quads() const
Definition: tria.cc:11501
void save_coarsen_flags(std::ostream &out) const
Definition: tria.cc:9538
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:11722
Definition: tria.h:48
void save_user_indices(std::vector< unsigned int > &v) const
Definition: tria.cc:10062
virtual bool prepare_coarsening_and_refinement()
Definition: tria.cc:12418
static::ExceptionBase & ExcMessage(std::string arg1)
unsigned int n_raw_hexs(const unsigned int level) const
Definition: tria.cc:11535
boost::signals2::signal< void()> pre_distributed_save
Definition: tria.h:2267
unsigned int n_raw_lines() const
Definition: tria.cc:11274
static::ExceptionBase & ExcTriangulationNotEmpty(int arg1, int arg2)
void reset_active_cell_indices()
Definition: tria.cc:11775
DistortedCellList execute_refinement()
Definition: tria.cc:11858
const Boundary< dim, spacedim > & get_boundary(const types::manifold_id number) const
Definition: tria.cc:9058
const bool check_for_distorted_cells
Definition: tria.h:3557
boost::signals2::signal< void()> pre_refinement
Definition: tria.h:2142
quad_iterator end_quad() const
Definition: tria.cc:10925
static const unsigned int dimension
Definition: tria.h:1604
static::ExceptionBase & ExcNonOrientableTriangulation()
Triangulation(const MeshSmoothing smooth_grid=none, const bool check_for_distorted_cells=false)
Definition: tria.cc:8814
unsigned int n_cells() const
Definition: tria.cc:11069
#define DeclException1(Exception1, type1, outsequence)
Definition: exceptions.h:593
TriaIterator< CellAccessor< dim, spacedim > > cell_iterator
Definition: tria.h:1484
Triangulation & operator=(Triangulation< dim, spacedim > &&tria)
Definition: tria.cc:8863
void clear_user_flags_hex()
Definition: tria.cc:9713
void load_user_indices_line(const std::vector< unsigned int > &v)
Definition: tria.cc:10177
Definition: types.h:30
unsigned int global_dof_index
Definition: types.h:88
active_cell_iterator end_active(const unsigned int level) const
Definition: tria.cc:10602
IteratorRange< cell_iterator > cell_iterators_on_level(const unsigned int level) const
Definition: tria.cc:10635
#define Assert(cond, exc)
Definition: exceptions.h:337
std::unique_ptr<::internal::Triangulation::TriaFaces< dim > > faces
Definition: tria.h:3527
std::vector< types::manifold_id > get_manifold_ids() const
Definition: tria.cc:9126
void save_user_flags(std::ostream &out) const
Definition: tria.cc:9731
hex_iterator end_hex() const
Definition: tria.cc:11000
unsigned int n_raw_quads() const
Definition: tria.cc:11484
unsigned int n_hexs() const
Definition: tria.cc:11519
void set_all_manifold_ids(const types::manifold_id number)
Definition: tria.cc:8989
void load_user_pointers_quad(const std::vector< void * > &v)
Definition: tria.cc:10406
active_vertex_iterator begin_active_vertex() const
Definition: tria.cc:10752
boost::signals2::signal< void()> create
Definition: tria.h:2133
static const StraightBoundary< dim, spacedim > straight_boundary
Definition: tria.h:1263
void load(Archive &ar, const unsigned int version)
std::unique_ptr< std::map< unsigned int, types::manifold_id > > vertex_to_manifold_id_map_1d
Definition: tria.h:3606
std::vector< bool > vertices_used
Definition: tria.h:3538
#define DeclException0(Exception0)
Definition: exceptions.h:570
virtual bool has_hanging_nodes() const
Definition: tria.cc:11198
virtual void create_triangulation(const std::vector< Point< spacedim > > &vertices, const std::vector< CellData< dim > > &cells, const SubCellData &subcelldata)
Definition: tria.cc:9232
types::material_id material_id
Definition: tria.h:154
void load_user_indices(const std::vector< unsigned int > &v)
Definition: tria.cc:10092
void save_user_pointers(std::vector< void * > &v) const
Definition: tria.cc:10297
raw_line_iterator begin_raw_line(const unsigned int level=0) const
Definition: tria.cc:10783
void clear_despite_subscriptions()
Definition: tria.cc:11842
std::map< types::manifold_id, SmartPointer< const Manifold< dim, spacedim >, Triangulation< dim, spacedim > > > manifold
Definition: tria.h:3544
const Manifold< dim, spacedim > & get_manifold(const types::manifold_id number) const
Definition: tria.cc:9071
hex_iterator begin_hex(const unsigned int level=0) const
Definition: tria.cc:10968
raw_cell_iterator begin_raw(const unsigned int level=0) const
Definition: tria.cc:10460
void save_refine_flags(std::ostream &out) const
Definition: tria.cc:9473
virtual ~Triangulation()
Definition: tria.cc:8888
unsigned int n_lines() const
Definition: tria.cc:11209
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:3318
boost::signals2::signal< void()> post_distributed_refinement
Definition: tria.h:2259
vertex_iterator begin_vertex() const
Definition: tria.cc:10724
::internal::Triangulation::Iterators< dim, spacedim > IteratorSelector
Definition: tria.h:1252
std::vector< std::unique_ptr<::internal::Triangulation::TriaLevel< dim > > > levels
Definition: tria.h:3520
void save_user_indices_line(std::vector< unsigned int > &v) const
Definition: tria.cc:10164
virtual void set_mesh_smoothing(const MeshSmoothing mesh_smoothing)
Definition: tria.cc:8930
unsigned int subdomain_id
Definition: types.h:42
virtual types::subdomain_id locally_owned_subdomain() const
Definition: tria.cc:11678
boost::signals2::signal< void(const typename Triangulation< dim, spacedim >::cell_iterator &cell)> post_refinement_on_cell
Definition: tria.h:2175
boost::signals2::signal< void()> post_refinement
Definition: tria.h:2149
std::unique_ptr< std::map< unsigned int, types::boundary_id > > vertex_to_boundary_id_map_1d
Definition: tria.h:3584
active_cell_iterator last_active() const
Definition: tria.cc:10547
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:10646
void save_user_pointers_line(std::vector< void * > &v) const
Definition: tria.cc:10362
types::manifold_id manifold_id
Definition: tria.h:176
active_quad_iterator begin_active_quad(const unsigned int level=0) const
Definition: tria.cc:10909
virtual types::global_dof_index n_global_active_cells() const
Definition: tria.cc:11082
virtual const MeshSmoothing & get_mesh_smoothing() const
Definition: tria.cc:8941
void load_user_indices_hex(const std::vector< unsigned int > &v)
Definition: tria.cc:10240
void save_user_indices_quad(std::vector< unsigned int > &v) const
Definition: tria.cc:10190
unsigned int n_raw_cells(const unsigned int level) const
Definition: tria.cc:11142
const types::manifold_id invalid_manifold_id
Definition: types.h:229
unsigned int n_active_faces() const
Definition: tria.cc:11124
std::vector< unsigned int > n_active_hexes_level
Definition: tria.h:459
unsigned int manifold_id
Definition: types.h:122
void fix_coarsen_flags()
Definition: tria.cc:11964
void serialize(Archive &ar, const unsigned int version)
void save_user_pointers_hex(std::vector< void * > &v) const
Definition: tria.cc:10422
void update_periodic_face_map()
Definition: tria.cc:11793
void save(Archive &ar, const unsigned int version) const
face_iterator end_face() const
Definition: tria.cc:10701
Signals signals
Definition: tria.h:2280
virtual void add_periodicity(const std::vector< GridTools::PeriodicFacePair< cell_iterator > > &)
Definition: tria.cc:11706
raw_cell_iterator end_raw(const unsigned int level) const
Definition: tria.cc:10579
std::vector< CellData< 2 > > boundary_quads
Definition: tria.h:260
void serialize(Archive &ar, const unsigned int version)
MeshSmoothing smooth_grid
Definition: tria.h:3271
quad_iterator begin_quad(const unsigned int level=0) const
Definition: tria.cc:10893
unsigned int n_quads() const
Definition: tria.cc:11438
active_hex_iterator begin_active_hex(const unsigned int level=0) const
Definition: tria.cc:10984
void refine_global(const unsigned int times=1)
Definition: tria.cc:9440
static::ExceptionBase & ExcEmptyLevel(int arg1)
void load_user_pointers_hex(const std::vector< void * > &v)
Definition: tria.cc:10439
void set_all_manifold_ids_on_boundary(const types::manifold_id number)
Definition: tria.cc:9004
void load_user_pointers(const std::vector< void * > &v)
Definition: tria.cc:10327
active_cell_iterator begin_active(const unsigned int level=0) const
Definition: tria.cc:10500
std::vector< types::boundary_id > get_boundary_ids() const
Definition: tria.cc:9094
void clear_user_flags_line()
Definition: tria.cc:9649
static::ExceptionBase & ExcBoundaryIdNotFound(types::boundary_id arg1)
boost::signals2::signal< void()> post_distributed_load
Definition: tria.h:2274
unsigned int max_adjacent_cells() const
Definition: tria.cc:11645
unsigned int n_vertices() const
void clear_user_data()
Definition: tria.cc:9621
unsigned int n_active_hexs() const
Definition: tria.cc:11542
raw_quad_iterator begin_raw_quad(const unsigned int level=0) const
Definition: tria.cc:10854
virtual void create_triangulation_compatibility(const std::vector< Point< spacedim > > &vertices, const std::vector< CellData< dim > > &cells, const SubCellData &subcelldata)
Definition: tria.cc:9212
void load_user_indices_quad(const std::vector< unsigned int > &v)
Definition: tria.cc:10207
virtual void clear()
Definition: tria.cc:8915
boost::signals2::signal< void(const Triangulation< dim, spacedim > &destination_tria)> copy
Definition: tria.h:2183
void save_user_flags_quad(std::ostream &out) const
Definition: tria.cc:9955
void load_refine_flags(std::istream &in)
Definition: tria.cc:9484
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:135
std::vector< unsigned int > n_lines_level
Definition: tria.h:332
Triangulation< dim, spacedim > & get_triangulation()
Definition: tria.cc:11687
boost::signals2::signal< void()> pre_distributed_refinement
Definition: tria.h:2249
TriaIterator<::TriaAccessor< 0, dim, spacedim > > vertex_iterator
Definition: tria.h:1540
virtual std::size_t memory_consumption() const
Definition: tria.cc:13381