Reference documentation for deal.II version Git ca6ed5c 2017-11-20 14:53:00 +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 
1246 template <int dim, int spacedim=dim>
1247 class Triangulation : public Subscriptor
1248 {
1249 private:
1250 
1255  typedef ::internal::Triangulation::Iterators<dim, spacedim> IteratorSelector;
1256 
1257 public:
1265  DEAL_II_DEPRECATED
1267 
1273  {
1278  none = 0x0,
1449 
1463 
1470  };
1471 
1488 
1506 
1520  typedef TriaIterator <TriaAccessor<dim-1, dim, spacedim> > face_iterator;
1521 
1533  typedef TriaActiveIterator<TriaAccessor<dim-1, dim, spacedim> > active_face_iterator;
1534 
1544 
1558 
1559  typedef typename IteratorSelector::line_iterator line_iterator;
1560  typedef typename IteratorSelector::active_line_iterator active_line_iterator;
1561 
1562  typedef typename IteratorSelector::quad_iterator quad_iterator;
1563  typedef typename IteratorSelector::active_quad_iterator active_quad_iterator;
1564 
1565  typedef typename IteratorSelector::hex_iterator hex_iterator;
1566  typedef typename IteratorSelector::active_hex_iterator active_hex_iterator;
1567 
1587  {
1594  virtual ~DistortedCellList () noexcept;
1595 
1600  std::list<typename Triangulation<dim,spacedim>::cell_iterator>
1602  };
1603 
1607  static const unsigned int dimension = dim;
1608 
1612  static const unsigned int space_dimension = spacedim;
1613 
1629  const bool check_for_distorted_cells = false);
1630 
1646  Triangulation (const Triangulation<dim, spacedim> &) = delete;
1647 
1655 
1660 
1664  virtual ~Triangulation ();
1665 
1672  virtual void clear ();
1673 
1679  virtual void set_mesh_smoothing (const MeshSmoothing mesh_smoothing);
1680 
1684  virtual const MeshSmoothing &get_mesh_smoothing() const;
1685 
1726  DEAL_II_DEPRECATED
1727  void set_boundary (const types::manifold_id number,
1728  const Boundary<dim,spacedim> &boundary_object);
1729 
1730 
1745  DEAL_II_DEPRECATED
1746  void set_boundary (const types::manifold_id number);
1747 
1772  void set_manifold (const types::manifold_id number,
1773  const Manifold<dim,spacedim> &manifold_object);
1774 
1775 
1787  void set_manifold (const types::manifold_id number);
1788 
1797  void set_all_manifold_ids (const types::manifold_id number);
1798 
1808 
1819  const types::manifold_id number);
1820 
1821 
1834  DEAL_II_DEPRECATED
1835  const Boundary<dim,spacedim> &get_boundary (const types::manifold_id number) const;
1836 
1846  const Manifold<dim,spacedim> &get_manifold (const types::manifold_id number) const;
1847 
1859  std::vector<types::boundary_id> get_boundary_ids() const;
1860 
1872  std::vector<types::manifold_id> get_manifold_ids() const;
1873 
1901  virtual void copy_triangulation (const Triangulation<dim, spacedim> &other_tria);
1902 
1946  virtual void create_triangulation (const std::vector<Point<spacedim> > &vertices,
1947  const std::vector<CellData<dim> > &cells,
1948  const SubCellData &subcelldata);
1949 
1958  virtual void create_triangulation_compatibility (
1959  const std::vector<Point<spacedim> > &vertices,
1960  const std::vector<CellData<dim> > &cells,
1961  const SubCellData &subcelldata);
1962 
1969  void flip_all_direction_flags();
1970 
1982  void set_all_refine_flags ();
1983 
1998  void refine_global (const unsigned int times = 1);
1999 
2031  virtual void execute_coarsening_and_refinement ();
2032 
2062  virtual bool prepare_coarsening_and_refinement ();
2063 
2064  /*
2065  * @}
2066  */
2067 
2082  {
2100  };
2101 
2107  template <typename T>
2109  {
2110  typedef T result_type;
2111 
2112  template <typename InputIterator>
2113  T operator()(InputIterator first, InputIterator last) const
2114  {
2115  return std::accumulate (first, last, T());
2116  }
2117  };
2118 
2128  struct Signals
2129  {
2137  boost::signals2::signal<void ()> create;
2138 
2146  boost::signals2::signal<void ()> pre_refinement;
2147 
2153  boost::signals2::signal<void ()> post_refinement;
2154 
2162  boost::signals2::signal<void ()> mesh_movement;
2163 
2171  boost::signals2::signal<void (const typename Triangulation<dim, spacedim>::cell_iterator &cell)> pre_coarsening_on_cell;
2172 
2179  boost::signals2::signal<void (const typename Triangulation<dim, spacedim>::cell_iterator &cell)> post_refinement_on_cell;
2180 
2187  boost::signals2::signal<void (const Triangulation<dim, spacedim> &destination_tria)> copy;
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),
2241 
2253  boost::signals2::signal<void ()> pre_distributed_refinement;
2254 
2263  boost::signals2::signal<void ()> post_distributed_refinement;
2264 
2271  boost::signals2::signal<void ()> pre_distributed_save;
2272 
2278  boost::signals2::signal<void ()> post_distributed_load;
2279  };
2280 
2284  mutable Signals signals;
2285 
2286  /*
2287  * @}
2288  */
2289 
2299  void save_refine_flags (std::ostream &out) const;
2300 
2304  void save_refine_flags (std::vector<bool> &v) const;
2305 
2309  void load_refine_flags (std::istream &in);
2310 
2314  void load_refine_flags (const std::vector<bool> &v);
2315 
2319  void save_coarsen_flags (std::ostream &out) const;
2320 
2324  void save_coarsen_flags (std::vector<bool> &v) const;
2325 
2329  void load_coarsen_flags (std::istream &out);
2330 
2334  void load_coarsen_flags (const std::vector<bool> &v);
2335 
2340  bool get_anisotropic_refinement_flag() const;
2341 
2342  /*
2343  * @}
2344  */
2345 
2355  void clear_user_flags ();
2356 
2362  void save_user_flags (std::ostream &out) const;
2363 
2369  void save_user_flags (std::vector<bool> &v) const;
2370 
2375  void load_user_flags (std::istream &in);
2376 
2381  void load_user_flags (const std::vector<bool> &v);
2382 
2387  void clear_user_flags_line ();
2388 
2393  void save_user_flags_line (std::ostream &out) const;
2394 
2400  void save_user_flags_line (std::vector<bool> &v) const;
2401 
2406  void load_user_flags_line (std::istream &in);
2407 
2412  void load_user_flags_line (const std::vector<bool> &v);
2413 
2418  void clear_user_flags_quad ();
2419 
2424  void save_user_flags_quad (std::ostream &out) const;
2425 
2431  void save_user_flags_quad (std::vector<bool> &v) const;
2432 
2437  void load_user_flags_quad (std::istream &in);
2438 
2443  void load_user_flags_quad (const std::vector<bool> &v);
2444 
2445 
2450  void clear_user_flags_hex ();
2451 
2456  void save_user_flags_hex (std::ostream &out) const;
2457 
2463  void save_user_flags_hex (std::vector<bool> &v) const;
2464 
2469  void load_user_flags_hex (std::istream &in);
2470 
2475  void load_user_flags_hex (const std::vector<bool> &v);
2476 
2482  void clear_user_data ();
2483 
2489  void save_user_indices (std::vector<unsigned int> &v) const;
2490 
2495  void load_user_indices (const std::vector<unsigned int> &v);
2496 
2502  void save_user_pointers (std::vector<void *> &v) const;
2503 
2508  void load_user_pointers (const std::vector<void *> &v);
2509 
2515  void save_user_indices_line (std::vector<unsigned int> &v) const;
2516 
2521  void load_user_indices_line (const std::vector<unsigned int> &v);
2522 
2528  void save_user_indices_quad (std::vector<unsigned int> &v) const;
2529 
2534  void load_user_indices_quad (const std::vector<unsigned int> &v);
2535 
2541  void save_user_indices_hex (std::vector<unsigned int> &v) const;
2542 
2547  void load_user_indices_hex (const std::vector<unsigned int> &v);
2553  void save_user_pointers_line (std::vector<void *> &v) const;
2554 
2559  void load_user_pointers_line (const std::vector<void *> &v);
2560 
2566  void save_user_pointers_quad (std::vector<void *> &v) const;
2567 
2572  void load_user_pointers_quad (const std::vector<void *> &v);
2573 
2579  void save_user_pointers_hex (std::vector<void *> &v) const;
2580 
2585  void load_user_pointers_hex (const std::vector<void *> &v);
2586 
2587  /*
2588  * @}
2589  */
2590 
2599  cell_iterator begin (const unsigned int level = 0) const;
2600 
2613  active_cell_iterator begin_active(const unsigned int level = 0) const;
2614 
2619  cell_iterator end () const;
2620 
2625  cell_iterator end (const unsigned int level) const;
2626 
2632  active_cell_iterator end_active (const unsigned int level) const;
2633 
2634 
2638  cell_iterator last () const;
2639 
2643  active_cell_iterator last_active () const;
2644 
2660 
2698 
2714  IteratorRange<cell_iterator> cell_iterators_on_level (const unsigned int level) const;
2715 
2732 
2733  /*
2734  * @}
2735  */
2736 
2737  /*---------------------------------------*/
2738  /*---------------------------------------*/
2739 
2748  face_iterator begin_face () const;
2749 
2753  active_face_iterator begin_active_face() const;
2754 
2759  face_iterator end_face () const;
2760 
2761  /*
2762  * @}
2763  */
2764 
2765  /*---------------------------------------*/
2766  /*---------------------------------------*/
2767 
2777  vertex_iterator begin_vertex() const;
2778 
2784  active_vertex_iterator begin_active_vertex() const;
2785 
2791  vertex_iterator end_vertex() const;
2792 
2793  /*
2794  * @}
2795  */
2796 
2814  unsigned int n_lines () const;
2815 
2819  unsigned int n_lines (const unsigned int level) const;
2820 
2824  unsigned int n_active_lines () const;
2825 
2829  unsigned int n_active_lines (const unsigned int level) const;
2830 
2834  unsigned int n_quads () const;
2835 
2839  unsigned int n_quads (const unsigned int level) const;
2840 
2844  unsigned int n_active_quads () const;
2845 
2849  unsigned int n_active_quads (const unsigned int level) const;
2850 
2854  unsigned int n_hexs() const;
2855 
2860  unsigned int n_hexs(const unsigned int level) const;
2861 
2865  unsigned int n_active_hexs() const;
2866 
2871  unsigned int n_active_hexs(const unsigned int level) const;
2872 
2877  unsigned int n_cells () const;
2878 
2883  unsigned int n_cells (const unsigned int level) const;
2884 
2889  unsigned int n_active_cells () const;
2890 
2899 
2900 
2905  unsigned int n_active_cells (const unsigned int level) const;
2906 
2912  unsigned int n_faces () const;
2913 
2919  unsigned int n_active_faces () const;
2920 
2938  unsigned int n_levels () const;
2939 
2946  virtual
2947  unsigned int n_global_levels () const;
2948 
2958  virtual
2959  bool has_hanging_nodes() const;
2960 
2968  unsigned int n_vertices () const;
2969 
2978  const std::vector<Point<spacedim> > &
2979  get_vertices () const;
2980 
2985  unsigned int n_used_vertices () const;
2986 
2990  bool vertex_used (const unsigned int index) const;
2991 
2996  const std::vector<bool> &
2997  get_used_vertices () const;
2998 
3010  unsigned int max_adjacent_cells () const;
3011 
3019 
3030  get_triangulation ();
3031 
3037  get_triangulation () const;
3038 
3039 
3040  /*
3041  * @}
3042  */
3043 
3058  unsigned int n_raw_lines () const;
3059 
3069  unsigned int n_raw_lines (const unsigned int level) const;
3070 
3080  unsigned int n_raw_quads () const;
3081 
3091  unsigned int n_raw_quads (const unsigned int level) const;
3092 
3102  unsigned int n_raw_hexs (const unsigned int level) const;
3103 
3113  unsigned int n_raw_cells (const unsigned int level) const;
3114 
3125  unsigned int n_raw_faces () const;
3126 
3127  /*
3128  * @}
3129  */
3130 
3139  virtual std::size_t memory_consumption () const;
3140 
3149  template <class Archive>
3150  void save (Archive &ar,
3151  const unsigned int version) const;
3152 
3168  template <class Archive>
3169  void load (Archive &ar,
3170  const unsigned int version);
3171 
3172 
3188  virtual void
3190  (const std::vector<GridTools::PeriodicFacePair<cell_iterator> > &);
3191 
3195  const std::map<std::pair<cell_iterator, unsigned int>,std::pair<std::pair<cell_iterator, unsigned int>, std::bitset<3> > > &
3196  get_periodic_face_map() const;
3197 
3198 
3199  BOOST_SERIALIZATION_SPLIT_MEMBER()
3200 
3201 
3212  int,
3213  << "The given level " << arg1
3214  << " is not in the valid range!");
3222  int, int,
3223  << "You are trying to perform an operation on a triangulation "
3224  << "that is only allowed if the triangulation is currently empty. "
3225  << "However, it currently stores " << arg1 << " vertices and has "
3226  << "cells on " << arg2 << " levels.");
3244  int,
3245  << "You tried to do something on level " << arg1
3246  << ", but this level is empty.");
3253 
3262  types::boundary_id,
3263  << "The given boundary_id " << arg1
3264  << " is not defined in this Triangulation!");
3265 
3266  /*
3267  * @}
3268  */
3269 
3270 protected:
3276 
3290  static void write_bool_vector (const unsigned int magic_number1,
3291  const std::vector<bool> &v,
3292  const unsigned int magic_number2,
3293  std::ostream &out);
3294 
3299  static void read_bool_vector (const unsigned int magic_number1,
3300  std::vector<bool> &v,
3301  const unsigned int magic_number2,
3302  std::istream &in);
3303 
3307  void update_periodic_face_map ();
3308 
3309 
3310 private:
3317  std::vector<GridTools::PeriodicFacePair<cell_iterator> > periodic_face_pairs_level_0;
3318 
3322  std::map<std::pair<cell_iterator, unsigned int>, std::pair<std::pair<cell_iterator, unsigned int>, std::bitset<3> > > periodic_face_map;
3323 
3338  typedef TriaRawIterator<TriaAccessor<dim-1, dim, spacedim> > raw_face_iterator;
3339  typedef TriaRawIterator<::TriaAccessor<0, dim, spacedim> > raw_vertex_iterator;
3340  typedef typename IteratorSelector::raw_line_iterator raw_line_iterator;
3341  typedef typename IteratorSelector::raw_quad_iterator raw_quad_iterator;
3342  typedef typename IteratorSelector::raw_hex_iterator raw_hex_iterator;
3343 
3348  raw_cell_iterator begin_raw (const unsigned int level = 0) const;
3349 
3354  raw_cell_iterator end_raw (const unsigned int level) const;
3355 
3356  /*
3357  * @}
3358  */
3359 
3371  raw_line_iterator
3372  begin_raw_line (const unsigned int level = 0) const;
3373 
3377  line_iterator
3378  begin_line (const unsigned int level = 0) const;
3379 
3383  active_line_iterator
3384  begin_active_line(const unsigned int level = 0) const;
3385 
3390  line_iterator end_line () const;
3391 
3392  /*
3393  * @}
3394  */
3395 
3406  raw_quad_iterator
3407  begin_raw_quad (const unsigned int level = 0) const;
3408 
3412  quad_iterator
3413  begin_quad (const unsigned int level = 0) const;
3414 
3418  active_quad_iterator
3419  begin_active_quad (const unsigned int level = 0) const;
3420 
3425  quad_iterator
3426  end_quad () const;
3427 
3428  /*
3429  * @}
3430  */
3431 
3441  raw_hex_iterator
3442  begin_raw_hex (const unsigned int level = 0) const;
3443 
3447  hex_iterator
3448  begin_hex (const unsigned int level = 0) const;
3449 
3453  active_hex_iterator
3454  begin_active_hex (const unsigned int level = 0) const;
3455 
3460  hex_iterator
3461  end_hex () const;
3462 
3463  /*
3464  * @}
3465  */
3466 
3467 
3482 
3489  void reset_active_cell_indices ();
3490 
3504  DistortedCellList execute_refinement ();
3505 
3512  void execute_coarsening ();
3513 
3518  void fix_coarsen_flags ();
3519 
3524  std::vector<std::unique_ptr<::internal::Triangulation::TriaLevel<dim> > > levels;
3525 
3531  std::unique_ptr<::internal::Triangulation::TriaFaces<dim> > faces;
3532 
3533 
3537  std::vector<Point<spacedim> > vertices;
3538 
3542  std::vector<bool> vertices_used;
3543 
3548  std::map<types::manifold_id, SmartPointer<const Manifold<dim,spacedim>, Triangulation<dim, spacedim> > > manifold;
3549 
3550 
3555 
3556 
3562 
3572  ::internal::Triangulation::NumberCache<dim> number_cache;
3573 
3588  std::unique_ptr<std::map<unsigned int, types::boundary_id> > vertex_to_boundary_id_map_1d;
3589 
3590 
3610  std::unique_ptr<std::map<unsigned int, types::manifold_id> > vertex_to_manifold_id_map_1d;
3611 
3612  // make a couple of classes friends
3613  template <int,int,int> friend class TriaAccessorBase;
3614  template <int,int,int> friend class TriaAccessor;
3615  friend class TriaAccessor<0, 1, spacedim>;
3616 
3617  friend class CellAccessor<dim, spacedim>;
3618 
3619  friend struct ::internal::TriaAccessor::Implementation;
3620 
3621  friend class hp::DoFHandler<dim,spacedim>;
3622 
3623  friend struct ::internal::Triangulation::Implementation;
3624 
3625  template <typename>
3626  friend class ::internal::Triangulation::TriaObjects;
3627 
3628  // explicitly check for sensible template arguments, but not on windows
3629  // because MSVC creates bogus warnings during normal compilation
3630 #ifndef DEAL_II_MSVC
3631  static_assert (dim<=spacedim,
3632  "The dimension <dim> of a Triangulation must be less than or "
3633  "equal to the space dimension <spacedim> in which it lives.");
3634 #endif
3635 
3636 };
3637 
3638 
3639 #ifndef DOXYGEN
3640 
3641 
3642 template <int structdim>
3643 inline
3645 {
3646  for (unsigned int i=0; i<GeometryInfo<structdim>::vertices_per_cell; ++i)
3647  vertices[i] = numbers::invalid_unsigned_int;
3648 
3649  material_id = 0;
3650 
3651  // And the manifold to be invalid
3652  manifold_id = numbers::invalid_manifold_id;
3653 }
3654 
3655 
3656 
3657 namespace internal
3658 {
3659  namespace Triangulation
3660  {
3661  template <class Archive>
3662  void NumberCache<1>::serialize (Archive &ar,
3663  const unsigned int)
3664  {
3665  ar &n_levels;
3666  ar &n_lines &n_lines_level;
3667  ar &n_active_lines &n_active_lines_level;
3668  }
3669 
3670 
3671  template <class Archive>
3672  void NumberCache<2>::serialize (Archive &ar,
3673  const unsigned int version)
3674  {
3675  this->NumberCache<1>::serialize (ar, version);
3676 
3677  ar &n_quads &n_quads_level;
3678  ar &n_active_quads &n_active_quads_level;
3679  }
3680 
3681 
3682  template <class Archive>
3683  void NumberCache<3>::serialize (Archive &ar,
3684  const unsigned int version)
3685  {
3686  this->NumberCache<2>::serialize (ar, version);
3687 
3688  ar &n_hexes &n_hexes_level;
3689  ar &n_active_hexes &n_active_hexes_level;
3690  }
3691 
3692  }
3693 }
3694 
3695 
3696 template <int dim, int spacedim>
3697 inline
3698 bool
3699 Triangulation<dim,spacedim>::vertex_used(const unsigned int index) const
3700 {
3701  Assert (index < vertices_used.size(),
3702  ExcIndexRange(index, 0, vertices_used.size()));
3703  return vertices_used[index];
3704 }
3705 
3706 
3707 
3708 template <int dim, int spacedim>
3709 inline
3710 unsigned int Triangulation<dim, spacedim>::n_levels () const
3711 {
3712  return number_cache.n_levels;
3713 }
3714 
3715 template <int dim, int spacedim>
3716 inline
3718 {
3719  return number_cache.n_levels;
3720 }
3721 
3722 
3723 template <int dim, int spacedim>
3724 inline
3725 unsigned int
3727 {
3728  return vertices.size();
3729 }
3730 
3731 
3732 
3733 template <int dim, int spacedim>
3734 inline
3735 const std::vector<Point<spacedim> > &
3737 {
3738  return vertices;
3739 }
3740 
3741 
3742 template <int dim, int spacedim>
3743 template <class Archive>
3744 void
3746  const unsigned int) const
3747 {
3748  // as discussed in the documentation, do not store the signals as
3749  // well as boundary and manifold description but everything else
3750  ar &smooth_grid;
3751 
3752  unsigned int n_levels = levels.size();
3753  ar &n_levels;
3754  for (unsigned int i = 0; i < levels.size(); ++i)
3755  ar &levels[i];
3756 
3757  // boost dereferences a nullptr when serializing a nullptr
3758  // at least up to 1.65.1. This causes problems with clang-5.
3759  // Therefore, work around it.
3760  bool faces_is_nullptr = (faces.get()==nullptr);
3761  ar &faces_is_nullptr;
3762  if (!faces_is_nullptr)
3763  ar &faces;
3764 
3765  ar &vertices;
3766  ar &vertices_used;
3767 
3768  ar &anisotropic_refinement;
3769  ar &number_cache;
3770 
3771  ar &check_for_distorted_cells;
3772 
3773  if (dim == 1)
3774  {
3775  ar &vertex_to_boundary_id_map_1d;
3776  ar &vertex_to_manifold_id_map_1d;
3777  }
3778 }
3779 
3780 
3781 
3782 template <int dim, int spacedim>
3783 template <class Archive>
3784 void
3786  const unsigned int)
3787 {
3788  // clear previous content. this also calls the respective signal
3789  clear ();
3790 
3791  // as discussed in the documentation, do not store the signals as
3792  // well as boundary and manifold description but everything else
3793  ar &smooth_grid;
3794 
3795  unsigned int size;
3796  ar &size;
3797  levels.resize(size);
3798  for (unsigned int i = 0; i < levels.size(); ++i)
3799  {
3800  std::unique_ptr<internal::Triangulation::TriaLevel<dim>> level;
3801  ar &level;
3802  levels[i] = std::move(level);
3803  }
3804 
3805  //Workaround for nullptr, see in save().
3806  bool faces_is_nullptr = true;
3807  ar &faces_is_nullptr;
3808  if (!faces_is_nullptr)
3809  ar &faces;
3810 
3811  ar &vertices;
3812  ar &vertices_used;
3813 
3814  ar &anisotropic_refinement;
3815  ar &number_cache;
3816 
3817  // the levels do not serialize the active_cell_indices because
3818  // they are easy enough to rebuild upon re-loading data. do
3819  // this here. don't forget to first resize the fields appropriately
3820  {
3821  for (unsigned int l=0; l<levels.size(); ++l)
3822  levels[l]->active_cell_indices.resize (levels[l]->refine_flags.size());
3823  reset_active_cell_indices ();
3824  }
3825 
3826 
3827  bool my_check_for_distorted_cells;
3828  ar &my_check_for_distorted_cells;
3829 
3830  Assert (my_check_for_distorted_cells == check_for_distorted_cells,
3831  ExcMessage ("The triangulation loaded into here must have the "
3832  "same setting with regard to reporting distorted "
3833  "cell as the one previously stored."));
3834 
3835  if (dim == 1)
3836  {
3837  ar &vertex_to_boundary_id_map_1d;
3838  ar &vertex_to_manifold_id_map_1d;
3839  }
3840 
3841  // trigger the create signal to indicate
3842  // that new content has been imported into
3843  // the triangulation
3844  signals.create();
3845 }
3846 
3847 
3848 /* -------------- declaration of explicit specializations ------------- */
3849 
3850 template <> unsigned int Triangulation<1,1>::n_raw_lines (const unsigned int level) const;
3851 template <> unsigned int Triangulation<1,1>::n_quads () const;
3852 template <> unsigned int Triangulation<1,1>::n_quads (const unsigned int level) const;
3853 template <> unsigned int Triangulation<1,1>::n_raw_quads (const unsigned int level) const;
3854 template <> unsigned int Triangulation<2,2>::n_raw_quads (const unsigned int level) const;
3855 template <> unsigned int Triangulation<1,1>::n_raw_hexs (const unsigned int level) const;
3856 template <> unsigned int Triangulation<1,1>::n_active_quads (const unsigned int level) const;
3857 template <> unsigned int Triangulation<1,1>::n_active_quads () const;
3858 template <> unsigned int Triangulation<1,1>::max_adjacent_cells () const;
3859 
3860 
3861 // -------------------------------------------------------------------
3862 // -- Explicit specializations for codimension one grids
3863 
3864 
3865 template <> unsigned int Triangulation<1,2>::n_raw_lines (const unsigned int level) const;
3866 template <> unsigned int Triangulation<1,2>::n_quads () const;
3867 template <> unsigned int Triangulation<1,2>::n_quads (const unsigned int level) const;
3868 template <> unsigned int Triangulation<1,2>::n_raw_quads (const unsigned int level) const;
3869 template <> unsigned int Triangulation<2,3>::n_raw_quads (const unsigned int level) const;
3870 template <> unsigned int Triangulation<1,2>::n_raw_hexs (const unsigned int level) const;
3871 template <> unsigned int Triangulation<1,2>::n_active_quads (const unsigned int level) const;
3872 template <> unsigned int Triangulation<1,2>::n_active_quads () const;
3873 template <> unsigned int Triangulation<1,2>::max_adjacent_cells () const;
3874 
3875 // -------------------------------------------------------------------
3876 // -- Explicit specializations for codimension two grids
3877 
3878 
3879 template <> unsigned int Triangulation<1,3>::n_raw_lines (const unsigned int level) const;
3880 template <> unsigned int Triangulation<1,3>::n_quads () const;
3881 template <> unsigned int Triangulation<1,3>::n_quads (const unsigned int level) const;
3882 template <> unsigned int Triangulation<1,3>::n_raw_quads (const unsigned int level) const;
3883 template <> unsigned int Triangulation<2,3>::n_raw_quads (const unsigned int level) const;
3884 template <> unsigned int Triangulation<1,3>::n_raw_hexs (const unsigned int level) const;
3885 template <> unsigned int Triangulation<1,3>::n_active_quads (const unsigned int level) const;
3886 template <> unsigned int Triangulation<1,3>::n_active_quads () const;
3887 template <> unsigned int Triangulation<1,3>::max_adjacent_cells () const;
3888 
3889 
3890 #endif // DOXYGEN
3891 
3892 DEAL_II_NAMESPACE_CLOSE
3893 
3894 // Include tria_accessor.h here, so that it is possible for an end
3895 // user to use the iterators of Triangulation<dim> directly without
3896 // the need to include tria_accessor.h separately. (Otherwise the
3897 // iterators are an 'opaque' or 'incomplete' type.)
3898 #include <deal.II/grid/tria_accessor.h>
3899 
3900 #endif
std::vector< CellData< 1 > > boundary_lines
Definition: tria.h:252
TriaActiveIterator< CellAccessor< dim, spacedim > > active_cell_iterator
Definition: tria.h:1505
boost::signals2::signal< void()> any_change
Definition: tria.h:2213
unsigned int n_raw_faces() const
Definition: tria.cc:11166
void set_boundary(const types::manifold_id number, const Boundary< dim, spacedim > &boundary_object)
Definition: tria.cc:9009
active_line_iterator begin_active_line(const unsigned int level=0) const
Definition: tria.cc:10882
static const unsigned int space_dimension
Definition: tria.h:1612
virtual void copy_triangulation(const Triangulation< dim, spacedim > &other_tria)
Definition: tria.cc:9207
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:9914
#define DeclException2(Exception2, type1, type2, outsequence)
Definition: exceptions.h:605
Iterator points to a valid object.
virtual ~DistortedCellList() noexcept
Definition: tria.cc:13461
void clear_user_flags()
Definition: tria.cc:9779
line_iterator begin_line(const unsigned int level=0) const
Definition: tria.cc:10866
const std::vector< Point< spacedim > > & get_vertices() const
::internal::Triangulation::NumberCache< dim > number_cache
Definition: tria.h:3572
cell_iterator end() const
Definition: tria.cc:10626
virtual unsigned int n_global_levels() const
void save_user_flags_hex(std::ostream &out) const
Definition: tria.cc:10076
unsigned int n_active_lines() const
Definition: tria.cc:11349
active_face_iterator begin_active_face() const
Definition: tria.cc:10738
unsigned int n_used_vertices() const
Definition: tria.cc:11662
std::vector< GridTools::PeriodicFacePair< cell_iterator > > periodic_face_pairs_level_0
Definition: tria.h:3317
std::list< typename Triangulation< dim, spacedim >::cell_iterator > distorted_cells
Definition: tria.h:1601
bool check_consistency(const unsigned int dim) const
Definition: tria.cc:47
unsigned int n_faces() const
Definition: tria.cc:11148
IteratorRange< active_cell_iterator > active_cell_iterators() const
Definition: tria.cc:10682
std::vector< Point< spacedim > > vertices
Definition: tria.h:3537
boost::signals2::signal< void()> clear
Definition: tria.h:2202
TriaActiveIterator< TriaAccessor< dim-1, dim, spacedim > > active_face_iterator
Definition: tria.h:1533
void set_all_refine_flags()
Definition: tria.cc:9482
void load_user_flags(std::istream &in)
Definition: tria.cc:9836
TriaActiveIterator<::TriaAccessor< 0, dim, spacedim > > active_vertex_iterator
Definition: tria.h:1557
unsigned int boundary_id
Definition: types.h:110
bool anisotropic_refinement
Definition: tria.h:3554
boost::signals2::signal< unsigned int(const cell_iterator &, const CellStatus), CellWeightSum< unsigned int > > cell_weight
Definition: tria.h:2240
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:2171
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:13401
boost::signals2::signal< void()> mesh_movement
Definition: tria.h:2162
static::ExceptionBase & ExcGridReadError()
void clear_user_flags_quad()
Definition: tria.cc:9739
face_iterator begin_face() const
Definition: tria.cc:10717
std::vector< unsigned int > n_quads_level
Definition: tria.h:390
void save_user_pointers_quad(std::vector< void * > &v) const
Definition: tria.cc:10447
void flip_all_direction_flags()
Definition: tria.cc:9471
raw_hex_iterator begin_raw_hex(const unsigned int level=0) const
Definition: tria.cc:10996
STL namespace.
const std::vector< bool > & get_used_vertices() const
Definition: tria.cc:11672
cell_iterator last() const
Definition: tria.cc:10578
line_iterator end_line() const
Definition: tria.cc:10898
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:13369
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:10538
void execute_coarsening()
Definition: tria.cc:11950
void load_user_flags_quad(std::istream &in)
Definition: tria.cc:10024
void save_user_flags_line(std::ostream &out) const
Definition: tria.cc:9903
unsigned int n_active_cells() const
Definition: tria.cc:11134
void load_user_pointers_line(const std::vector< void * > &v)
Definition: tria.cc:10433
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:9017
IteratorRange< cell_iterator > cell_iterators() const
Definition: tria.cc:10672
static::ExceptionBase & ExcFacesHaveNoLevel()
bool get_anisotropic_refinement_flag() const
Definition: tria.cc:9636
vertex_iterator end_vertex() const
Definition: tria.cc:10819
TriaIterator< TriaAccessor< dim-1, dim, spacedim > > face_iterator
Definition: tria.h:1520
void load_coarsen_flags(std::istream &out)
Definition: tria.cc:9607
void load_user_flags_hex(std::istream &in)
Definition: tria.cc:10087
virtual void execute_coarsening_and_refinement()
Definition: tria.cc:11789
Definition: tria.h:75
void save_user_indices_hex(std::vector< unsigned int > &v) const
Definition: tria.cc:10281
unsigned int n_active_quads() const
Definition: tria.cc:11559
void save_coarsen_flags(std::ostream &out) const
Definition: tria.cc:9596
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:11780
Definition: tria.h:48
void save_user_indices(std::vector< unsigned int > &v) const
Definition: tria.cc:10120
virtual bool prepare_coarsening_and_refinement()
Definition: tria.cc:12476
static::ExceptionBase & ExcMessage(std::string arg1)
unsigned int n_raw_hexs(const unsigned int level) const
Definition: tria.cc:11593
boost::signals2::signal< void()> pre_distributed_save
Definition: tria.h:2271
unsigned int n_raw_lines() const
Definition: tria.cc:11332
static::ExceptionBase & ExcTriangulationNotEmpty(int arg1, int arg2)
void reset_active_cell_indices()
Definition: tria.cc:11833
DistortedCellList execute_refinement()
Definition: tria.cc:11916
const Boundary< dim, spacedim > & get_boundary(const types::manifold_id number) const
Definition: tria.cc:9117
const bool check_for_distorted_cells
Definition: tria.h:3561
boost::signals2::signal< void()> pre_refinement
Definition: tria.h:2146
quad_iterator end_quad() const
Definition: tria.cc:10983
static const unsigned int dimension
Definition: tria.h:1607
static::ExceptionBase & ExcNonOrientableTriangulation()
Triangulation(const MeshSmoothing smooth_grid=none, const bool check_for_distorted_cells=false)
Definition: tria.cc:8873
unsigned int n_cells() const
Definition: tria.cc:11127
#define DeclException1(Exception1, type1, outsequence)
Definition: exceptions.h:593
TriaIterator< CellAccessor< dim, spacedim > > cell_iterator
Definition: tria.h:1487
Triangulation & operator=(Triangulation< dim, spacedim > &&tria)
Definition: tria.cc:8922
void clear_user_flags_hex()
Definition: tria.cc:9771
void load_user_indices_line(const std::vector< unsigned int > &v)
Definition: tria.cc:10235
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:10660
IteratorRange< cell_iterator > cell_iterators_on_level(const unsigned int level) const
Definition: tria.cc:10693
#define Assert(cond, exc)
Definition: exceptions.h:337
std::unique_ptr<::internal::Triangulation::TriaFaces< dim > > faces
Definition: tria.h:3531
std::vector< types::manifold_id > get_manifold_ids() const
Definition: tria.cc:9185
void save_user_flags(std::ostream &out) const
Definition: tria.cc:9789
hex_iterator end_hex() const
Definition: tria.cc:11058
unsigned int n_raw_quads() const
Definition: tria.cc:11542
unsigned int n_hexs() const
Definition: tria.cc:11577
void set_all_manifold_ids(const types::manifold_id number)
Definition: tria.cc:9048
void load_user_pointers_quad(const std::vector< void * > &v)
Definition: tria.cc:10464
active_vertex_iterator begin_active_vertex() const
Definition: tria.cc:10810
boost::signals2::signal< void()> create
Definition: tria.h:2137
static const StraightBoundary< dim, spacedim > straight_boundary
Definition: tria.h:1266
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:3610
std::vector< bool > vertices_used
Definition: tria.h:3542
#define DeclException0(Exception0)
Definition: exceptions.h:570
virtual bool has_hanging_nodes() const
Definition: tria.cc:11256
virtual void create_triangulation(const std::vector< Point< spacedim > > &vertices, const std::vector< CellData< dim > > &cells, const SubCellData &subcelldata)
Definition: tria.cc:9291
types::material_id material_id
Definition: tria.h:154
void load_user_indices(const std::vector< unsigned int > &v)
Definition: tria.cc:10150
void save_user_pointers(std::vector< void * > &v) const
Definition: tria.cc:10355
raw_line_iterator begin_raw_line(const unsigned int level=0) const
Definition: tria.cc:10841
void clear_despite_subscriptions()
Definition: tria.cc:11900
std::map< types::manifold_id, SmartPointer< const Manifold< dim, spacedim >, Triangulation< dim, spacedim > > > manifold
Definition: tria.h:3548
const Manifold< dim, spacedim > & get_manifold(const types::manifold_id number) const
Definition: tria.cc:9130
hex_iterator begin_hex(const unsigned int level=0) const
Definition: tria.cc:11026
raw_cell_iterator begin_raw(const unsigned int level=0) const
Definition: tria.cc:10518
void save_refine_flags(std::ostream &out) const
Definition: tria.cc:9531
virtual ~Triangulation()
Definition: tria.cc:8947
unsigned int n_lines() const
Definition: tria.cc:11267
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:3322
boost::signals2::signal< void()> post_distributed_refinement
Definition: tria.h:2263
vertex_iterator begin_vertex() const
Definition: tria.cc:10782
::internal::Triangulation::Iterators< dim, spacedim > IteratorSelector
Definition: tria.h:1255
std::vector< std::unique_ptr<::internal::Triangulation::TriaLevel< dim > > > levels
Definition: tria.h:3524
void save_user_indices_line(std::vector< unsigned int > &v) const
Definition: tria.cc:10222
virtual void set_mesh_smoothing(const MeshSmoothing mesh_smoothing)
Definition: tria.cc:8989
unsigned int subdomain_id
Definition: types.h:42
virtual types::subdomain_id locally_owned_subdomain() const
Definition: tria.cc:11736
boost::signals2::signal< void(const typename Triangulation< dim, spacedim >::cell_iterator &cell)> post_refinement_on_cell
Definition: tria.h:2179
boost::signals2::signal< void()> post_refinement
Definition: tria.h:2153
std::unique_ptr< std::map< unsigned int, types::boundary_id > > vertex_to_boundary_id_map_1d
Definition: tria.h:3588
active_cell_iterator last_active() const
Definition: tria.cc:10605
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:10704
void save_user_pointers_line(std::vector< void * > &v) const
Definition: tria.cc:10420
types::manifold_id manifold_id
Definition: tria.h:176
active_quad_iterator begin_active_quad(const unsigned int level=0) const
Definition: tria.cc:10967
virtual types::global_dof_index n_global_active_cells() const
Definition: tria.cc:11140
virtual const MeshSmoothing & get_mesh_smoothing() const
Definition: tria.cc:9000
void load_user_indices_hex(const std::vector< unsigned int > &v)
Definition: tria.cc:10298
void save_user_indices_quad(std::vector< unsigned int > &v) const
Definition: tria.cc:10248
unsigned int n_raw_cells(const unsigned int level) const
Definition: tria.cc:11200
const types::manifold_id invalid_manifold_id
Definition: types.h:229
unsigned int n_active_faces() const
Definition: tria.cc:11182
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:12022
void serialize(Archive &ar, const unsigned int version)
void save_user_pointers_hex(std::vector< void * > &v) const
Definition: tria.cc:10480
void update_periodic_face_map()
Definition: tria.cc:11851
void save(Archive &ar, const unsigned int version) const
face_iterator end_face() const
Definition: tria.cc:10759
Signals signals
Definition: tria.h:2284
virtual void add_periodicity(const std::vector< GridTools::PeriodicFacePair< cell_iterator > > &)
Definition: tria.cc:11764
raw_cell_iterator end_raw(const unsigned int level) const
Definition: tria.cc:10637
std::vector< CellData< 2 > > boundary_quads
Definition: tria.h:260
void serialize(Archive &ar, const unsigned int version)
MeshSmoothing smooth_grid
Definition: tria.h:3275
quad_iterator begin_quad(const unsigned int level=0) const
Definition: tria.cc:10951
unsigned int n_quads() const
Definition: tria.cc:11496
active_hex_iterator begin_active_hex(const unsigned int level=0) const
Definition: tria.cc:11042
void refine_global(const unsigned int times=1)
Definition: tria.cc:9498
static::ExceptionBase & ExcEmptyLevel(int arg1)
void load_user_pointers_hex(const std::vector< void * > &v)
Definition: tria.cc:10497
void set_all_manifold_ids_on_boundary(const types::manifold_id number)
Definition: tria.cc:9063
void load_user_pointers(const std::vector< void * > &v)
Definition: tria.cc:10385
active_cell_iterator begin_active(const unsigned int level=0) const
Definition: tria.cc:10558
std::vector< types::boundary_id > get_boundary_ids() const
Definition: tria.cc:9153
void clear_user_flags_line()
Definition: tria.cc:9707
static::ExceptionBase & ExcBoundaryIdNotFound(types::boundary_id arg1)
boost::signals2::signal< void()> post_distributed_load
Definition: tria.h:2278
unsigned int max_adjacent_cells() const
Definition: tria.cc:11703
unsigned int n_vertices() const
void clear_user_data()
Definition: tria.cc:9679
unsigned int n_active_hexs() const
Definition: tria.cc:11600
raw_quad_iterator begin_raw_quad(const unsigned int level=0) const
Definition: tria.cc:10912
virtual void create_triangulation_compatibility(const std::vector< Point< spacedim > > &vertices, const std::vector< CellData< dim > > &cells, const SubCellData &subcelldata)
Definition: tria.cc:9271
void load_user_indices_quad(const std::vector< unsigned int > &v)
Definition: tria.cc:10265
virtual void clear()
Definition: tria.cc:8974
boost::signals2::signal< void(const Triangulation< dim, spacedim > &destination_tria)> copy
Definition: tria.h:2187
void save_user_flags_quad(std::ostream &out) const
Definition: tria.cc:10013
void load_refine_flags(std::istream &in)
Definition: tria.cc:9542
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:11745
boost::signals2::signal< void()> pre_distributed_refinement
Definition: tria.h:2253
TriaIterator<::TriaAccessor< 0, dim, spacedim > > vertex_iterator
Definition: tria.h:1543
virtual std::size_t memory_consumption() const
Definition: tria.cc:13439