Reference documentation for deal.II version 8.5.1
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/base/std_cxx11/function.h>
27 #include <deal.II/base/std_cxx11/unique_ptr.h>
28 #include <deal.II/grid/tria_iterator_selector.h>
29 
30 // Ignore deprecation warnings for auto_ptr.
31 DEAL_II_DISABLE_EXTRA_DIAGNOSTICS
32 #include <boost/signals2.hpp>
33 #include <boost/serialization/vector.hpp>
34 #include <boost/serialization/map.hpp>
35 #ifdef DEAL_II_WITH_CXX11
36 # include <boost/serialization/unique_ptr.hpp>
37 #else
38 # include <boost/serialization/scoped_ptr.hpp>
39 #endif
40 #include <boost/serialization/split_member.hpp>
41 DEAL_II_ENABLE_EXTRA_DIAGNOSTICS
42 
43 #include <vector>
44 #include <list>
45 #include <map>
46 #include <numeric>
47 #include <bitset>
48 
49 
50 DEAL_II_NAMESPACE_OPEN
51 
52 template <int dim, int spacedim> class Boundary;
53 template <int dim, int spacedim> class StraightBoundary;
54 template <int dim, int spacedim> class Manifold;
55 
56 namespace GridTools
57 {
58  template<typename CellIterator> struct PeriodicFacePair;
59 }
60 
61 template <int, int, int> class TriaAccessor;
62 template <int spacedim> class TriaAccessor<0,1,spacedim>;
63 template <int, int, int> class TriaAccessorBase;
64 
65 namespace internal
66 {
67  namespace Triangulation
68  {
69  template <int dim> class TriaLevel;
70  template <int dim> class TriaFaces;
71 
72  template <typename> class TriaObjects;
73 
79  struct Implementation;
80  }
81 
82  namespace TriaAccessor
83  {
84  struct Implementation;
85  }
86 }
87 
88 namespace hp
89 {
90  template <int dim, int spacedim> class DoFHandler;
91 }
92 
93 
94 /*------------------------------------------------------------------------*/
95 
131 template <int structdim>
132 struct CellData
133 {
140 
148  union
149  {
159 
170  };
171 
181 
189  CellData ();
190 };
191 
192 
193 
249 {
256  std::vector<CellData<1> > boundary_lines;
257 
264  std::vector<CellData<2> > boundary_quads;
265 
273  bool check_consistency (const unsigned int dim) const;
274 };
275 
276 
277 /*------------------------------------------------------------------------*/
278 
279 
280 namespace internal
281 {
286  namespace Triangulation
287  {
288 
302  template <int dim>
303  struct NumberCache
304  {
305  };
306 
320  template <>
321  struct NumberCache<1>
322  {
326  unsigned int n_levels;
327 
331  unsigned int n_lines;
332 
336  std::vector<unsigned int> n_lines_level;
337 
341  unsigned int n_active_lines;
342 
346  std::vector<unsigned int> n_active_lines_level;
347 
351  NumberCache ();
352 
357  std::size_t memory_consumption () const;
358 
363  template <class Archive>
364  void serialize (Archive &ar,
365  const unsigned int version);
366  };
367 
368 
383  template <>
384  struct NumberCache<2> : public NumberCache<1>
385  {
389  unsigned int n_quads;
390 
394  std::vector<unsigned int> n_quads_level;
395 
399  unsigned int n_active_quads;
400 
404  std::vector<unsigned int> n_active_quads_level;
405 
409  NumberCache ();
410 
415  std::size_t memory_consumption () const;
416 
421  template <class Archive>
422  void serialize (Archive &ar,
423  const unsigned int version);
424  };
425 
426 
442  template <>
443  struct NumberCache<3> : public NumberCache<2>
444  {
448  unsigned int n_hexes;
449 
453  std::vector<unsigned int> n_hexes_level;
454 
458  unsigned int n_active_hexes;
459 
463  std::vector<unsigned int> n_active_hexes_level;
464 
468  NumberCache ();
469 
474  std::size_t memory_consumption () const;
475 
480  template <class Archive>
481  void serialize (Archive &ar,
482  const unsigned int version);
483  };
484  }
485 }
486 
487 
488 /*------------------------------------------------------------------------*/
489 
490 
1244 template <int dim, int spacedim=dim>
1245 class Triangulation : public Subscriptor
1246 {
1247 private:
1248 
1253  typedef ::internal::Triangulation::Iterators<dim, spacedim> IteratorSelector;
1254 
1255 public:
1261 
1267  {
1272  none = 0x0,
1443 
1457 
1464  };
1465 
1482 
1500 
1501  typedef TriaIterator <TriaAccessor<dim-1, dim, spacedim> > face_iterator;
1502  typedef TriaActiveIterator<TriaAccessor<dim-1, dim, spacedim> > active_face_iterator;
1503 
1504  typedef typename IteratorSelector::vertex_iterator vertex_iterator;
1505  typedef typename IteratorSelector::active_vertex_iterator active_vertex_iterator;
1506 
1507  typedef typename IteratorSelector::line_iterator line_iterator;
1508  typedef typename IteratorSelector::active_line_iterator active_line_iterator;
1509 
1510  typedef typename IteratorSelector::quad_iterator quad_iterator;
1511  typedef typename IteratorSelector::active_quad_iterator active_quad_iterator;
1512 
1513  typedef typename IteratorSelector::hex_iterator hex_iterator;
1514  typedef typename IteratorSelector::active_hex_iterator active_hex_iterator;
1515 
1535  {
1542  virtual ~DistortedCellList () DEAL_II_NOEXCEPT;
1543 
1548  std::list<typename Triangulation<dim,spacedim>::cell_iterator>
1550  };
1551 
1555  static const unsigned int dimension = dim;
1556 
1560  static const unsigned int space_dimension = spacedim;
1561 
1577  const bool check_for_distorted_cells = false);
1578 
1595 
1596 #ifdef DEAL_II_WITH_CXX11
1597 
1604 
1609 #endif
1610 
1614  virtual ~Triangulation ();
1615 
1622  virtual void clear ();
1623 
1629  virtual void set_mesh_smoothing (const MeshSmoothing mesh_smoothing);
1630 
1634  virtual const MeshSmoothing &get_mesh_smoothing() const;
1635 
1673  void set_boundary (const types::manifold_id number,
1674  const Boundary<dim,spacedim> &boundary_object);
1675 
1676 
1688  void set_boundary (const types::manifold_id number);
1689 
1714  void set_manifold (const types::manifold_id number,
1715  const Manifold<dim,spacedim> &manifold_object);
1716 
1717 
1729  void set_manifold (const types::manifold_id number);
1730 
1739  void set_all_manifold_ids (const types::manifold_id number);
1740 
1750 
1761  const types::manifold_id number);
1762 
1763 
1773  const Boundary<dim,spacedim> &get_boundary (const types::manifold_id number) const;
1774 
1784  const Manifold<dim,spacedim> &get_manifold (const types::manifold_id number) const;
1785 
1797  std::vector<types::boundary_id> get_boundary_ids() const;
1798 
1810  std::vector<types::manifold_id> get_manifold_ids() const;
1811 
1839  virtual void copy_triangulation (const Triangulation<dim, spacedim> &other_tria);
1840 
1884  virtual void create_triangulation (const std::vector<Point<spacedim> > &vertices,
1885  const std::vector<CellData<dim> > &cells,
1886  const SubCellData &subcelldata);
1887 
1896  virtual void create_triangulation_compatibility (
1897  const std::vector<Point<spacedim> > &vertices,
1898  const std::vector<CellData<dim> > &cells,
1899  const SubCellData &subcelldata);
1900 
1907  void flip_all_direction_flags();
1908 
1920  void set_all_refine_flags ();
1921 
1936  void refine_global (const unsigned int times = 1);
1937 
1969  virtual void execute_coarsening_and_refinement ();
1970 
2000  virtual bool prepare_coarsening_and_refinement ();
2001 
2002  /*
2003  * @}
2004  */
2005 
2020  {
2038  };
2039 
2045  template<typename T>
2047  {
2048  typedef T result_type;
2049 
2050  template<typename InputIterator>
2051  T operator()(InputIterator first, InputIterator last) const
2052  {
2053  return std::accumulate (first, last, T());
2054  }
2055  };
2056 
2066  struct Signals
2067  {
2075  boost::signals2::signal<void ()> create;
2076 
2084  boost::signals2::signal<void ()> pre_refinement;
2085 
2091  boost::signals2::signal<void ()> post_refinement;
2092 
2100  boost::signals2::signal<void ()> mesh_movement;
2101 
2109  boost::signals2::signal<void (const typename Triangulation<dim, spacedim>::cell_iterator &cell)> pre_coarsening_on_cell;
2110 
2117  boost::signals2::signal<void (const typename Triangulation<dim, spacedim>::cell_iterator &cell)> post_refinement_on_cell;
2118 
2125  boost::signals2::signal<void (const Triangulation<dim, spacedim> &destination_tria)> copy;
2126 
2139  boost::signals2::signal<void ()> clear;
2140 
2150  boost::signals2::signal<void ()> any_change;
2151 
2175  boost::signals2::signal<unsigned int (const cell_iterator &,
2176  const CellStatus),
2178  };
2179 
2183  mutable Signals signals;
2184 
2185  /*
2186  * @}
2187  */
2188 
2198  void save_refine_flags (std::ostream &out) const;
2199 
2203  void save_refine_flags (std::vector<bool> &v) const;
2204 
2208  void load_refine_flags (std::istream &in);
2209 
2213  void load_refine_flags (const std::vector<bool> &v);
2214 
2218  void save_coarsen_flags (std::ostream &out) const;
2219 
2223  void save_coarsen_flags (std::vector<bool> &v) const;
2224 
2228  void load_coarsen_flags (std::istream &out);
2229 
2233  void load_coarsen_flags (const std::vector<bool> &v);
2234 
2239  bool get_anisotropic_refinement_flag() const;
2240 
2241  /*
2242  * @}
2243  */
2244 
2254  void clear_user_flags ();
2255 
2261  void save_user_flags (std::ostream &out) const;
2262 
2268  void save_user_flags (std::vector<bool> &v) const;
2269 
2274  void load_user_flags (std::istream &in);
2275 
2280  void load_user_flags (const std::vector<bool> &v);
2281 
2286  void clear_user_flags_line ();
2287 
2292  void save_user_flags_line (std::ostream &out) const;
2293 
2299  void save_user_flags_line (std::vector<bool> &v) const;
2300 
2305  void load_user_flags_line (std::istream &in);
2306 
2311  void load_user_flags_line (const std::vector<bool> &v);
2312 
2317  void clear_user_flags_quad ();
2318 
2323  void save_user_flags_quad (std::ostream &out) const;
2324 
2330  void save_user_flags_quad (std::vector<bool> &v) const;
2331 
2336  void load_user_flags_quad (std::istream &in);
2337 
2342  void load_user_flags_quad (const std::vector<bool> &v);
2343 
2344 
2349  void clear_user_flags_hex ();
2350 
2355  void save_user_flags_hex (std::ostream &out) const;
2356 
2362  void save_user_flags_hex (std::vector<bool> &v) const;
2363 
2368  void load_user_flags_hex (std::istream &in);
2369 
2374  void load_user_flags_hex (const std::vector<bool> &v);
2375 
2381  void clear_user_data ();
2382 
2388  void save_user_indices (std::vector<unsigned int> &v) const;
2389 
2394  void load_user_indices (const std::vector<unsigned int> &v);
2395 
2401  void save_user_pointers (std::vector<void *> &v) const;
2402 
2407  void load_user_pointers (const std::vector<void *> &v);
2408 
2414  void save_user_indices_line (std::vector<unsigned int> &v) const;
2415 
2420  void load_user_indices_line (const std::vector<unsigned int> &v);
2421 
2427  void save_user_indices_quad (std::vector<unsigned int> &v) const;
2428 
2433  void load_user_indices_quad (const std::vector<unsigned int> &v);
2434 
2440  void save_user_indices_hex (std::vector<unsigned int> &v) const;
2441 
2446  void load_user_indices_hex (const std::vector<unsigned int> &v);
2452  void save_user_pointers_line (std::vector<void *> &v) const;
2453 
2458  void load_user_pointers_line (const std::vector<void *> &v);
2459 
2465  void save_user_pointers_quad (std::vector<void *> &v) const;
2466 
2471  void load_user_pointers_quad (const std::vector<void *> &v);
2472 
2478  void save_user_pointers_hex (std::vector<void *> &v) const;
2479 
2484  void load_user_pointers_hex (const std::vector<void *> &v);
2485 
2486  /*
2487  * @}
2488  */
2489 
2498  cell_iterator begin (const unsigned int level = 0) const;
2499 
2512  active_cell_iterator begin_active(const unsigned int level = 0) const;
2513 
2518  cell_iterator end () const;
2519 
2524  cell_iterator end (const unsigned int level) const;
2525 
2531  active_cell_iterator end_active (const unsigned int level) const;
2532 
2533 
2537  cell_iterator last () const;
2538 
2543 
2559 
2597 
2613  IteratorRange<cell_iterator> cell_iterators_on_level (const unsigned int level) const;
2614 
2631 
2632  /*
2633  * @}
2634  */
2635 
2636  /*---------------------------------------*/
2637  /*---------------------------------------*/
2638 
2647  face_iterator begin_face () const;
2648 
2653 
2658  face_iterator end_face () const;
2659 
2660  /*
2661  * @}
2662  */
2663 
2664  /*---------------------------------------*/
2665  /*---------------------------------------*/
2666 
2676  vertex_iterator begin_vertex() const;
2677 
2683  active_vertex_iterator begin_active_vertex() const;
2684 
2690  vertex_iterator end_vertex() const;
2691 
2692  /*
2693  * @}
2694  */
2695 
2713  unsigned int n_lines () const;
2714 
2718  unsigned int n_lines (const unsigned int level) const;
2719 
2723  unsigned int n_active_lines () const;
2724 
2728  unsigned int n_active_lines (const unsigned int level) const;
2729 
2733  unsigned int n_quads () const;
2734 
2738  unsigned int n_quads (const unsigned int level) const;
2739 
2743  unsigned int n_active_quads () const;
2744 
2748  unsigned int n_active_quads (const unsigned int level) const;
2749 
2753  unsigned int n_hexs() const;
2754 
2759  unsigned int n_hexs(const unsigned int level) const;
2760 
2764  unsigned int n_active_hexs() const;
2765 
2770  unsigned int n_active_hexs(const unsigned int level) const;
2771 
2776  unsigned int n_cells () const;
2777 
2782  unsigned int n_cells (const unsigned int level) const;
2783 
2788  unsigned int n_active_cells () const;
2789 
2798 
2799 
2804  unsigned int n_active_cells (const unsigned int level) const;
2805 
2811  unsigned int n_faces () const;
2812 
2818  unsigned int n_active_faces () const;
2819 
2837  unsigned int n_levels () const;
2838 
2845  virtual
2846  unsigned int n_global_levels () const;
2847 
2857  virtual
2858  bool has_hanging_nodes() const;
2859 
2867  unsigned int n_vertices () const;
2868 
2877  const std::vector<Point<spacedim> > &
2878  get_vertices () const;
2879 
2884  unsigned int n_used_vertices () const;
2885 
2889  bool vertex_used (const unsigned int index) const;
2890 
2895  const std::vector<bool> &
2896  get_used_vertices () const;
2897 
2909  unsigned int max_adjacent_cells () const;
2910 
2918 
2929  get_triangulation ();
2930 
2936  get_triangulation () const;
2937 
2938 
2939  /*
2940  * @}
2941  */
2942 
2957  unsigned int n_raw_lines () const;
2958 
2968  unsigned int n_raw_lines (const unsigned int level) const;
2969 
2979  unsigned int n_raw_quads () const;
2980 
2990  unsigned int n_raw_quads (const unsigned int level) const;
2991 
3001  unsigned int n_raw_hexs () const;
3002 
3012  unsigned int n_raw_hexs (const unsigned int level) const;
3013 
3023  unsigned int n_raw_cells (const unsigned int level) const;
3024 
3035  unsigned int n_raw_faces () const;
3036 
3037  /*
3038  * @}
3039  */
3040 
3049  virtual std::size_t memory_consumption () const;
3050 
3059  template <class Archive>
3060  void save (Archive &ar,
3061  const unsigned int version) const;
3062 
3078  template <class Archive>
3079  void load (Archive &ar,
3080  const unsigned int version);
3081 
3082 
3098  virtual void
3100  (const std::vector<GridTools::PeriodicFacePair<cell_iterator> > &);
3101 
3105  const std::map<std::pair<cell_iterator, unsigned int>,std::pair<std::pair<cell_iterator, unsigned int>, std::bitset<3> > > &
3106  get_periodic_face_map() const;
3107 
3108 
3109  BOOST_SERIALIZATION_SPLIT_MEMBER()
3110 
3111 
3122  int,
3123  << "The given level " << arg1
3124  << " is not in the valid range!");
3132  int, int,
3133  << "You are trying to perform an operation on a triangulation "
3134  << "that is only allowed if the triangulation is currently empty. "
3135  << "However, it currently stores " << arg1 << " vertices and has "
3136  << "cells on " << arg2 << " levels.");
3154  int,
3155  << "You tried to do something on level " << arg1
3156  << ", but this level is empty.");
3163 
3172  types::boundary_id,
3173  << "The given boundary_id " << arg1
3174  << " is not defined in this Triangulation!");
3175 
3176  /*
3177  * @}
3178  */
3179 
3180 protected:
3186 
3200  static void write_bool_vector (const unsigned int magic_number1,
3201  const std::vector<bool> &v,
3202  const unsigned int magic_number2,
3203  std::ostream &out);
3204 
3209  static void read_bool_vector (const unsigned int magic_number1,
3210  std::vector<bool> &v,
3211  const unsigned int magic_number2,
3212  std::istream &in);
3213 
3217  void update_periodic_face_map ();
3218 
3219 
3220 private:
3228 
3232  std::map<std::pair<cell_iterator, unsigned int>, std::pair<std::pair<cell_iterator, unsigned int>, std::bitset<3> > > periodic_face_map;
3233 
3248  typedef TriaRawIterator <TriaAccessor<dim-1, dim, spacedim> > raw_face_iterator;
3249  typedef typename IteratorSelector::raw_vertex_iterator raw_vertex_iterator;
3250  typedef typename IteratorSelector::raw_line_iterator raw_line_iterator;
3251  typedef typename IteratorSelector::raw_quad_iterator raw_quad_iterator;
3252  typedef typename IteratorSelector::raw_hex_iterator raw_hex_iterator;
3253 
3258  raw_cell_iterator begin_raw (const unsigned int level = 0) const;
3259 
3264  raw_cell_iterator end_raw (const unsigned int level) const;
3265 
3266  /*
3267  * @}
3268  */
3269 
3281  raw_line_iterator
3282  begin_raw_line (const unsigned int level = 0) const;
3283 
3287  line_iterator
3288  begin_line (const unsigned int level = 0) const;
3289 
3293  active_line_iterator
3294  begin_active_line(const unsigned int level = 0) const;
3295 
3300  line_iterator end_line () const;
3301 
3302  /*
3303  * @}
3304  */
3305 
3316  raw_quad_iterator
3317  begin_raw_quad (const unsigned int level = 0) const;
3318 
3322  quad_iterator
3323  begin_quad (const unsigned int level = 0) const;
3324 
3328  active_quad_iterator
3329  begin_active_quad (const unsigned int level = 0) const;
3330 
3335  quad_iterator
3336  end_quad () const;
3337 
3338  /*
3339  * @}
3340  */
3341 
3351  raw_hex_iterator
3352  begin_raw_hex (const unsigned int level = 0) const;
3353 
3357  hex_iterator
3358  begin_hex (const unsigned int level = 0) const;
3359 
3363  active_hex_iterator
3364  begin_active_hex (const unsigned int level = 0) const;
3365 
3370  hex_iterator
3371  end_hex () const;
3372 
3373  /*
3374  * @}
3375  */
3376 
3377 
3392 
3399  void reset_active_cell_indices ();
3400 
3414  DistortedCellList execute_refinement ();
3415 
3422  void execute_coarsening ();
3423 
3428  void fix_coarsen_flags ();
3429 
3434  std::vector<::internal::Triangulation::TriaLevel<dim>*> levels;
3435 
3441  std_cxx11::unique_ptr<::internal::Triangulation::TriaFaces<dim> > faces;
3442 
3443 
3447  std::vector<Point<spacedim> > vertices;
3448 
3452  std::vector<bool> vertices_used;
3453 
3458  std::map<types::manifold_id, SmartPointer<const Manifold<dim,spacedim> , Triangulation<dim, spacedim> > > manifold;
3459 
3460 
3465 
3466 
3472 
3482  ::internal::Triangulation::NumberCache<dim> number_cache;
3483 
3498  std_cxx11::unique_ptr<std::map<unsigned int, types::boundary_id> > vertex_to_boundary_id_map_1d;
3499 
3500 
3520  std_cxx11::unique_ptr<std::map<unsigned int, types::manifold_id> > vertex_to_manifold_id_map_1d;
3521 
3522  // make a couple of classes friends
3523  template <int,int,int> friend class TriaAccessorBase;
3524  template <int,int,int> friend class TriaAccessor;
3525  friend class TriaAccessor<0, 1, spacedim>;
3526 
3527  friend class CellAccessor<dim, spacedim>;
3528 
3529  friend struct ::internal::TriaAccessor::Implementation;
3530 
3531  friend class hp::DoFHandler<dim,spacedim>;
3532 
3533  friend struct ::internal::Triangulation::Implementation;
3534 
3535  template <typename>
3536  friend class ::internal::Triangulation::TriaObjects;
3537 
3538  // explicitly check for sensible template arguments, but not on windows
3539  // because MSVC creates bogus warnings during normal compilation
3540 #ifdef DEAL_II_WITH_CXX11
3541 #ifndef DEAL_II_MSVC
3542  static_assert (dim<=spacedim,
3543  "The dimension <dim> of a Triangulation must be less than or "
3544  "equal to the space dimension <spacedim> in which it lives.");
3545 #endif
3546 #endif
3547 
3548 };
3549 
3550 
3551 #ifndef DOXYGEN
3552 
3553 
3554 template <int structdim>
3555 inline
3557 {
3558  for (unsigned int i=0; i<GeometryInfo<structdim>::vertices_per_cell; ++i)
3559  vertices[i] = numbers::invalid_unsigned_int;
3560 
3561  material_id = 0;
3562 
3563  // And the manifold to be invalid
3564  manifold_id = numbers::invalid_manifold_id;
3565 }
3566 
3567 
3568 
3569 namespace internal
3570 {
3571  namespace Triangulation
3572  {
3573  template <class Archive>
3574  void NumberCache<1>::serialize (Archive &ar,
3575  const unsigned int)
3576  {
3577  ar &n_levels;
3578  ar &n_lines &n_lines_level;
3579  ar &n_active_lines &n_active_lines_level;
3580  }
3581 
3582 
3583  template <class Archive>
3584  void NumberCache<2>::serialize (Archive &ar,
3585  const unsigned int version)
3586  {
3587  this->NumberCache<1>::serialize (ar, version);
3588 
3589  ar &n_quads &n_quads_level;
3590  ar &n_active_quads &n_active_quads_level;
3591  }
3592 
3593 
3594  template <class Archive>
3595  void NumberCache<3>::serialize (Archive &ar,
3596  const unsigned int version)
3597  {
3598  this->NumberCache<2>::serialize (ar, version);
3599 
3600  ar &n_hexes &n_hexes_level;
3601  ar &n_active_hexes &n_active_hexes_level;
3602  }
3603 
3604  }
3605 }
3606 
3607 
3608 template <int dim, int spacedim>
3609 inline
3610 bool
3611 Triangulation<dim,spacedim>::vertex_used(const unsigned int index) const
3612 {
3613  Assert (index < vertices_used.size(),
3614  ExcIndexRange(index, 0, vertices_used.size()));
3615  return vertices_used[index];
3616 }
3617 
3618 
3619 
3620 template <int dim, int spacedim>
3621 inline
3622 unsigned int Triangulation<dim, spacedim>::n_levels () const
3623 {
3624  return number_cache.n_levels;
3625 }
3626 
3627 template <int dim, int spacedim>
3628 inline
3630 {
3631  return number_cache.n_levels;
3632 }
3633 
3634 
3635 template <int dim, int spacedim>
3636 inline
3637 unsigned int
3639 {
3640  return vertices.size();
3641 }
3642 
3643 
3644 
3645 template <int dim, int spacedim>
3646 inline
3647 const std::vector<Point<spacedim> > &
3649 {
3650  return vertices;
3651 }
3652 
3653 
3654 template <int dim, int spacedim>
3655 template <class Archive>
3656 void
3658  const unsigned int) const
3659 {
3660  // as discussed in the documentation, do not store the signals as
3661  // well as boundary and manifold description but everything else
3662  ar &smooth_grid;
3663  ar &levels;
3664  ar &faces;
3665  ar &vertices;
3666  ar &vertices_used;
3667 
3668  ar &anisotropic_refinement;
3669  ar &number_cache;
3670 
3671  ar &check_for_distorted_cells;
3672 
3673  if (dim == 1)
3674  {
3675  ar &vertex_to_boundary_id_map_1d;
3676  ar &vertex_to_manifold_id_map_1d;
3677  }
3678 }
3679 
3680 
3681 
3682 template <int dim, int spacedim>
3683 template <class Archive>
3684 void
3686  const unsigned int)
3687 {
3688  // clear previous content. this also calls the respective signal
3689  clear ();
3690 
3691  // as discussed in the documentation, do not store the signals as
3692  // well as boundary and manifold description but everything else
3693  ar &smooth_grid;
3694  ar &levels;
3695  ar &faces;
3696  ar &vertices;
3697  ar &vertices_used;
3698 
3699  ar &anisotropic_refinement;
3700  ar &number_cache;
3701 
3702  // the levels do not serialize the active_cell_indices because
3703  // they are easy enough to rebuild upon re-loading data. do
3704  // this here. don't forget to first resize the fields appropriately
3705  {
3706  for (unsigned int l=0; l<levels.size(); ++l)
3707  levels[l]->active_cell_indices.resize (levels[l]->refine_flags.size());
3708  reset_active_cell_indices ();
3709  }
3710 
3711 
3712  bool my_check_for_distorted_cells;
3713  ar &my_check_for_distorted_cells;
3714 
3715  Assert (my_check_for_distorted_cells == check_for_distorted_cells,
3716  ExcMessage ("The triangulation loaded into here must have the "
3717  "same setting with regard to reporting distorted "
3718  "cell as the one previously stored."));
3719 
3720  if (dim == 1)
3721  {
3722  ar &vertex_to_boundary_id_map_1d;
3723  ar &vertex_to_manifold_id_map_1d;
3724  }
3725 
3726  // trigger the create signal to indicate
3727  // that new content has been imported into
3728  // the triangulation
3729  signals.create();
3730 }
3731 
3732 
3733 /* -------------- declaration of explicit specializations ------------- */
3734 
3735 template <> unsigned int Triangulation<1,1>::n_raw_lines (const unsigned int level) const;
3736 template <> unsigned int Triangulation<1,1>::n_quads () const;
3737 template <> unsigned int Triangulation<1,1>::n_quads (const unsigned int level) const;
3738 template <> unsigned int Triangulation<1,1>::n_raw_quads (const unsigned int level) const;
3739 template <> unsigned int Triangulation<2,2>::n_raw_quads (const unsigned int level) const;
3740 template <> unsigned int Triangulation<1,1>::n_raw_hexs (const unsigned int level) const;
3741 template <> unsigned int Triangulation<1,1>::n_active_quads (const unsigned int level) const;
3742 template <> unsigned int Triangulation<1,1>::n_active_quads () const;
3743 template <> unsigned int Triangulation<1,1>::max_adjacent_cells () const;
3744 
3745 
3746 // -------------------------------------------------------------------
3747 // -- Explicit specializations for codimension one grids
3748 
3749 
3750 template <> unsigned int Triangulation<1,2>::n_raw_lines (const unsigned int level) const;
3751 template <> unsigned int Triangulation<1,2>::n_quads () const;
3752 template <> unsigned int Triangulation<1,2>::n_quads (const unsigned int level) const;
3753 template <> unsigned int Triangulation<1,2>::n_raw_quads (const unsigned int level) const;
3754 template <> unsigned int Triangulation<2,3>::n_raw_quads (const unsigned int level) const;
3755 template <> unsigned int Triangulation<1,2>::n_raw_hexs (const unsigned int level) const;
3756 template <> unsigned int Triangulation<1,2>::n_active_quads (const unsigned int level) const;
3757 template <> unsigned int Triangulation<1,2>::n_active_quads () const;
3758 template <> unsigned int Triangulation<1,2>::max_adjacent_cells () const;
3759 
3760 // -------------------------------------------------------------------
3761 // -- Explicit specializations for codimension two grids
3762 
3763 
3764 template <> unsigned int Triangulation<1,3>::n_raw_lines (const unsigned int level) const;
3765 template <> unsigned int Triangulation<1,3>::n_quads () const;
3766 template <> unsigned int Triangulation<1,3>::n_quads (const unsigned int level) const;
3767 template <> unsigned int Triangulation<1,3>::n_raw_quads (const unsigned int level) const;
3768 template <> unsigned int Triangulation<2,3>::n_raw_quads (const unsigned int level) const;
3769 template <> unsigned int Triangulation<1,3>::n_raw_hexs (const unsigned int level) const;
3770 template <> unsigned int Triangulation<1,3>::n_active_quads (const unsigned int level) const;
3771 template <> unsigned int Triangulation<1,3>::n_active_quads () const;
3772 template <> unsigned int Triangulation<1,3>::max_adjacent_cells () const;
3773 
3774 
3775 #endif // DOXYGEN
3776 
3777 DEAL_II_NAMESPACE_CLOSE
3778 
3779 // Include tria_accessor.h here, so that it is possible for an end
3780 // user to use the iterators of Triangulation<dim> directly without
3781 // the need to include tria_accessor.h separately. (Otherwise the
3782 // iterators are an 'opaque' or 'incomplete' type.)
3783 #include <deal.II/grid/tria_accessor.h>
3784 
3785 #endif
std::vector< CellData< 1 > > boundary_lines
Definition: tria.h:256
std::vector<::internal::Triangulation::TriaLevel< dim > * > levels
Definition: tria.h:3434
TriaActiveIterator< CellAccessor< dim, spacedim > > active_cell_iterator
Definition: tria.h:1499
boost::signals2::signal< void()> any_change
Definition: tria.h:2150
unsigned int n_active_cells() const
Definition: tria.cc:11244
void set_boundary(const types::manifold_id number, const Boundary< dim, spacedim > &boundary_object)
Definition: tria.cc:9115
static const unsigned int space_dimension
Definition: tria.h:1560
virtual void copy_triangulation(const Triangulation< dim, spacedim > &other_tria)
Definition: tria.cc:9315
unsigned int n_vertices() const
unsigned int n_used_vertices() const
Definition: tria.cc:11772
static const unsigned int invalid_unsigned_int
Definition: types.h:170
static ::ExceptionBase & ExcInvalidLevel(int arg1)
void load_user_flags_line(std::istream &in)
Definition: tria.cc:10024
#define DeclException2(Exception2, type1, type2, outsequence)
Definition: exceptions.h:576
hex_iterator begin_hex(const unsigned int level=0) const
Definition: tria.cc:11136
void clear_user_flags()
Definition: tria.cc:9889
active_face_iterator begin_active_face() const
Definition: tria.cc:10848
::internal::Triangulation::NumberCache< dim > number_cache
Definition: tria.h:3482
void save_user_flags_quad(std::ostream &out) const
Definition: tria.cc:10123
virtual bool has_hanging_nodes() const
Definition: tria.cc:11366
unsigned int n_raw_cells(const unsigned int level) const
Definition: tria.cc:11310
cell_iterator last() const
Definition: tria.cc:10688
void save_user_pointers_hex(std::vector< void *> &v) const
Definition: tria.cc:10590
vertex_iterator begin_vertex() const
Definition: tria.cc:10892
unsigned int n_cells() const
Definition: tria.cc:11237
std_cxx11::unique_ptr<::internal::Triangulation::TriaFaces< dim > > faces
Definition: tria.h:3441
unsigned int n_raw_hexs() const
std::vector< GridTools::PeriodicFacePair< cell_iterator > > periodic_face_pairs_level_0
Definition: tria.h:3227
std::list< typename Triangulation< dim, spacedim >::cell_iterator > distorted_cells
Definition: tria.h:1549
unsigned char material_id
Definition: types.h:130
std::vector< Point< spacedim > > vertices
Definition: tria.h:3447
boost::signals2::signal< void()> clear
Definition: tria.h:2139
IteratorRange< active_cell_iterator > active_cell_iterators() const
Definition: tria.cc:10792
void set_all_refine_flags()
Definition: tria.cc:9592
void load_user_flags(std::istream &in)
Definition: tria.cc:9946
bool anisotropic_refinement
Definition: tria.h:3464
boost::signals2::signal< unsigned int(const cell_iterator &, const CellStatus), CellWeightSum< unsigned int > > cell_weight
Definition: tria.h:2177
std::vector< unsigned int > n_active_lines_level
Definition: tria.h:346
std::vector< unsigned int > n_hexes_level
Definition: tria.h:453
boost::signals2::signal< void(const typename Triangulation< dim, spacedim >::cell_iterator &cell)> pre_coarsening_on_cell
Definition: tria.h:2109
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:13517
line_iterator begin_line(const unsigned int level=0) const
Definition: tria.cc:10976
virtual ~DistortedCellList() DEAL_II_NOEXCEPT
Definition: tria.cc:13577
line_iterator end_line() const
Definition: tria.cc:11008
boost::signals2::signal< void()> mesh_movement
Definition: tria.h:2100
static ::ExceptionBase & ExcGridReadError()
void clear_user_flags_quad()
Definition: tria.cc:9849
unsigned int n_faces() const
Definition: tria.cc:11258
std::vector< unsigned int > n_quads_level
Definition: tria.h:394
void flip_all_direction_flags()
Definition: tria.cc:9581
active_cell_iterator begin_active(const unsigned int level=0) const
Definition: tria.cc:10668
STL namespace.
types::boundary_id boundary_id
Definition: tria.h:169
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:13485
unsigned int n_active_hexs() const
Definition: tria.cc:11710
void save_user_pointers_quad(std::vector< void *> &v) const
Definition: tria.cc:10557
static ::ExceptionBase & ExcIndexRange(int arg1, int arg2, int arg3)
std::vector< unsigned int > n_active_quads_level
Definition: tria.h:404
void execute_coarsening()
Definition: tria.cc:12066
cell_iterator begin(const unsigned int level=0) const
Definition: tria.cc:10648
const Boundary< dim, spacedim > & get_boundary(const types::manifold_id number) const
Definition: tria.cc:9223
void load_user_flags_quad(std::istream &in)
Definition: tria.cc:10134
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:9123
raw_hex_iterator begin_raw_hex(const unsigned int level=0) const
Definition: tria.cc:11106
std_cxx11::unique_ptr< std::map< unsigned int, types::boundary_id > > vertex_to_boundary_id_map_1d
Definition: tria.h:3498
static ::ExceptionBase & ExcFacesHaveNoLevel()
void load_user_pointers_line(const std::vector< void *> &v)
Definition: tria.cc:10543
unsigned int n_active_faces() const
Definition: tria.cc:11292
raw_quad_iterator begin_raw_quad(const unsigned int level=0) const
Definition: tria.cc:11022
cell_iterator end() const
Definition: tria.cc:10736
void load_coarsen_flags(std::istream &out)
Definition: tria.cc:9717
void load_user_flags_hex(std::istream &in)
Definition: tria.cc:10197
active_quad_iterator begin_active_quad(const unsigned int level=0) const
Definition: tria.cc:11077
virtual void execute_coarsening_and_refinement()
Definition: tria.cc:11899
Definition: tria.h:76
unsigned int n_active_lines() const
Definition: tria.cc:11459
IteratorRange< cell_iterator > cell_iterators_on_level(const unsigned int level) const
Definition: tria.cc:10803
Definition: tria.h:52
virtual bool prepare_coarsening_and_refinement()
Definition: tria.cc:12592
static ::ExceptionBase & ExcMessage(std::string arg1)
bool check_consistency(const unsigned int dim) const
Definition: tria.cc:47
static ::ExceptionBase & ExcTriangulationNotEmpty(int arg1, int arg2)
void reset_active_cell_indices()
Definition: tria.cc:11943
DistortedCellList execute_refinement()
Definition: tria.cc:12032
const bool check_for_distorted_cells
Definition: tria.h:3471
boost::signals2::signal< void()> pre_refinement
Definition: tria.h:2084
static const unsigned int dimension
Definition: tria.h:1555
void save_user_flags_line(std::ostream &out) const
Definition: tria.cc:10013
static ::ExceptionBase & ExcNonOrientableTriangulation()
void save_user_pointers_line(std::vector< void *> &v) const
Definition: tria.cc:10530
Triangulation(const MeshSmoothing smooth_grid=none, const bool check_for_distorted_cells=false)
Definition: tria.cc:8948
#define DeclException1(Exception1, type1, outsequence)
Definition: exceptions.h:564
TriaIterator< CellAccessor< dim, spacedim > > cell_iterator
Definition: tria.h:1481
Triangulation & operator=(Triangulation< dim, spacedim > &&tria)
Definition: tria.cc:9020
void clear_user_flags_hex()
Definition: tria.cc:9881
void load_user_indices_line(const std::vector< unsigned int > &v)
Definition: tria.cc:10345
Definition: types.h:30
unsigned int global_dof_index
Definition: types.h:88
vertex_iterator end_vertex() const
Definition: tria.cc:10929
unsigned int n_raw_quads() const
Definition: tria.cc:11652
#define Assert(cond, exc)
Definition: exceptions.h:313
Signals signals
Definition: tria.h:2183
active_hex_iterator begin_active_hex(const unsigned int level=0) const
Definition: tria.cc:11152
void save_user_indices_line(std::vector< unsigned int > &v) const
Definition: tria.cc:10332
std::map< types::manifold_id, SmartPointer< const Manifold< dim, spacedim >, Triangulation< dim, spacedim > > > manifold
Definition: tria.h:3458
void set_all_manifold_ids(const types::manifold_id number)
Definition: tria.cc:9154
boost::signals2::signal< void()> create
Definition: tria.h:2075
static const StraightBoundary< dim, spacedim > straight_boundary
Definition: tria.h:1260
unsigned int max_adjacent_cells() const
Definition: tria.cc:11813
bool get_anisotropic_refinement_flag() const
Definition: tria.cc:9746
void load(Archive &ar, const unsigned int version)
unsigned int n_quads() const
Definition: tria.cc:11606
std::vector< bool > vertices_used
Definition: tria.h:3452
#define DeclException0(Exception0)
Definition: exceptions.h:541
virtual void create_triangulation(const std::vector< Point< spacedim > > &vertices, const std::vector< CellData< dim > > &cells, const SubCellData &subcelldata)
Definition: tria.cc:9401
void save_coarsen_flags(std::ostream &out) const
Definition: tria.cc:9706
void save_user_indices(std::vector< unsigned int > &v) const
Definition: tria.cc:10230
types::material_id material_id
Definition: tria.h:158
const std::vector< Point< spacedim > > & get_vertices() const
void load_user_indices(const std::vector< unsigned int > &v)
Definition: tria.cc:10260
void save_refine_flags(std::ostream &out) const
Definition: tria.cc:9641
unsigned int n_lines() const
Definition: tria.cc:11377
void clear_despite_subscriptions()
Definition: tria.cc:12010
raw_cell_iterator begin_raw(const unsigned int level=0) const
Definition: tria.cc:10628
unsigned int n_raw_lines() const
Definition: tria.cc:11442
virtual ~Triangulation()
Definition: tria.cc:9050
virtual std::size_t memory_consumption() const
Definition: tria.cc:13555
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:3232
::internal::Triangulation::Iterators< dim, spacedim > IteratorSelector
Definition: tria.h:1253
void save(Archive &ar, const unsigned int version) const
virtual void set_mesh_smoothing(const MeshSmoothing mesh_smoothing)
Definition: tria.cc:9095
void load_user_pointers_hex(const std::vector< void *> &v)
Definition: tria.cc:10607
void save_user_flags_hex(std::ostream &out) const
Definition: tria.cc:10186
face_iterator begin_face() const
Definition: tria.cc:10827
unsigned int subdomain_id
Definition: types.h:42
boost::signals2::signal< void(const typename Triangulation< dim, spacedim >::cell_iterator &cell)> post_refinement_on_cell
Definition: tria.h:2117
boost::signals2::signal< void()> post_refinement
Definition: tria.h:2091
virtual types::global_dof_index n_global_active_cells() const
Definition: tria.cc:11250
unsigned int n_hexs() const
Definition: tria.cc:11687
Definition: hp.h:102
unsigned int n_active_quads() const
Definition: tria.cc:11669
active_line_iterator begin_active_line(const unsigned int level=0) const
Definition: tria.cc:10992
types::manifold_id manifold_id
Definition: tria.h:180
raw_cell_iterator end_raw(const unsigned int level) const
Definition: tria.cc:10747
unsigned int n_raw_faces() const
Definition: tria.cc:11276
void load_user_indices_hex(const std::vector< unsigned int > &v)
Definition: tria.cc:10408
active_vertex_iterator begin_active_vertex() const
Definition: tria.cc:10920
std::vector< types::boundary_id > get_boundary_ids() const
Definition: tria.cc:9261
const types::manifold_id invalid_manifold_id
Definition: types.h:226
std::vector< unsigned int > n_active_hexes_level
Definition: tria.h:463
unsigned int manifold_id
Definition: types.h:122
void load_user_pointers_quad(const std::vector< void *> &v)
Definition: tria.cc:10574
void fix_coarsen_flags()
Definition: tria.cc:12138
void serialize(Archive &ar, const unsigned int version)
active_cell_iterator end_active(const unsigned int level) const
Definition: tria.cc:10770
void update_periodic_face_map()
Definition: tria.cc:11961
void save_user_indices_quad(std::vector< unsigned int > &v) const
Definition: tria.cc:10358
virtual void add_periodicity(const std::vector< GridTools::PeriodicFacePair< cell_iterator > > &)
Definition: tria.cc:11874
const std::vector< bool > & get_used_vertices() const
Definition: tria.cc:11782
virtual unsigned int n_global_levels() const
hex_iterator end_hex() const
Definition: tria.cc:11168
std::vector< CellData< 2 > > boundary_quads
Definition: tria.h:264
void serialize(Archive &ar, const unsigned int version)
MeshSmoothing smooth_grid
Definition: tria.h:3185
IteratorRange< active_cell_iterator > active_cell_iterators_on_level(const unsigned int level) const
Definition: tria.cc:10814
void load_user_pointers(const std::vector< void *> &v)
Definition: tria.cc:10495
void refine_global(const unsigned int times=1)
Definition: tria.cc:9608
void save_user_pointers(std::vector< void *> &v) const
Definition: tria.cc:10465
void save_user_flags(std::ostream &out) const
Definition: tria.cc:9899
quad_iterator end_quad() const
Definition: tria.cc:11093
static ::ExceptionBase & ExcEmptyLevel(int arg1)
std_cxx11::unique_ptr< std::map< unsigned int, types::manifold_id > > vertex_to_manifold_id_map_1d
Definition: tria.h:3520
IteratorRange< cell_iterator > cell_iterators() const
Definition: tria.cc:10782
unsigned char boundary_id
Definition: types.h:110
face_iterator end_face() const
Definition: tria.cc:10869
void set_all_manifold_ids_on_boundary(const types::manifold_id number)
Definition: tria.cc:9169
active_cell_iterator last_active() const
Definition: tria.cc:10715
void clear_user_flags_line()
Definition: tria.cc:9817
static ::ExceptionBase & ExcBoundaryIdNotFound(types::boundary_id arg1)
quad_iterator begin_quad(const unsigned int level=0) const
Definition: tria.cc:11061
void clear_user_data()
Definition: tria.cc:9789
std::vector< types::manifold_id > get_manifold_ids() const
Definition: tria.cc:9293
bool vertex_used(const unsigned int index) const
const Manifold< dim, spacedim > & get_manifold(const types::manifold_id number) const
Definition: tria.cc:9236
virtual void create_triangulation_compatibility(const std::vector< Point< spacedim > > &vertices, const std::vector< CellData< dim > > &cells, const SubCellData &subcelldata)
Definition: tria.cc:9381
void load_user_indices_quad(const std::vector< unsigned int > &v)
Definition: tria.cc:10375
virtual types::subdomain_id locally_owned_subdomain() const
Definition: tria.cc:11846
raw_line_iterator begin_raw_line(const unsigned int level=0) const
Definition: tria.cc:10951
virtual void clear()
Definition: tria.cc:9080
virtual const MeshSmoothing & get_mesh_smoothing() const
Definition: tria.cc:9106
boost::signals2::signal< void(const Triangulation< dim, spacedim > &destination_tria)> copy
Definition: tria.h:2125
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:11890
void load_refine_flags(std::istream &in)
Definition: tria.cc:9652
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:139
std::vector< unsigned int > n_lines_level
Definition: tria.h:336
Triangulation< dim, spacedim > & get_triangulation()
Definition: tria.cc:11855
void save_user_indices_hex(std::vector< unsigned int > &v) const
Definition: tria.cc:10391