Reference documentation for deal.II version Git 4a2ac69 2017-09-19 13:41:17 -0400
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:
1263 
1269  {
1274  none = 0x0,
1445 
1459 
1466  };
1467 
1484 
1502 
1503  typedef TriaIterator <TriaAccessor<dim-1, dim, spacedim> > face_iterator;
1504  typedef TriaActiveIterator<TriaAccessor<dim-1, dim, spacedim> > active_face_iterator;
1505 
1515 
1529 
1530  typedef typename IteratorSelector::line_iterator line_iterator;
1531  typedef typename IteratorSelector::active_line_iterator active_line_iterator;
1532 
1533  typedef typename IteratorSelector::quad_iterator quad_iterator;
1534  typedef typename IteratorSelector::active_quad_iterator active_quad_iterator;
1535 
1536  typedef typename IteratorSelector::hex_iterator hex_iterator;
1537  typedef typename IteratorSelector::active_hex_iterator active_hex_iterator;
1538 
1558  {
1565  virtual ~DistortedCellList () noexcept;
1566 
1571  std::list<typename Triangulation<dim,spacedim>::cell_iterator>
1573  };
1574 
1578  static const unsigned int dimension = dim;
1579 
1583  static const unsigned int space_dimension = spacedim;
1584 
1600  const bool check_for_distorted_cells = false);
1601 
1617  Triangulation (const Triangulation<dim, spacedim> &) = delete;
1618 
1626 
1631 
1635  virtual ~Triangulation ();
1636 
1643  virtual void clear ();
1644 
1650  virtual void set_mesh_smoothing (const MeshSmoothing mesh_smoothing);
1651 
1655  virtual const MeshSmoothing &get_mesh_smoothing() const;
1656 
1694  void set_boundary (const types::manifold_id number,
1695  const Boundary<dim,spacedim> &boundary_object);
1696 
1697 
1709  void set_boundary (const types::manifold_id number);
1710 
1735  void set_manifold (const types::manifold_id number,
1736  const Manifold<dim,spacedim> &manifold_object);
1737 
1738 
1750  void set_manifold (const types::manifold_id number);
1751 
1760  void set_all_manifold_ids (const types::manifold_id number);
1761 
1771 
1782  const types::manifold_id number);
1783 
1784 
1794  const Boundary<dim,spacedim> &get_boundary (const types::manifold_id number) const;
1795 
1805  const Manifold<dim,spacedim> &get_manifold (const types::manifold_id number) const;
1806 
1818  std::vector<types::boundary_id> get_boundary_ids() const;
1819 
1831  std::vector<types::manifold_id> get_manifold_ids() const;
1832 
1860  virtual void copy_triangulation (const Triangulation<dim, spacedim> &other_tria);
1861 
1905  virtual void create_triangulation (const std::vector<Point<spacedim> > &vertices,
1906  const std::vector<CellData<dim> > &cells,
1907  const SubCellData &subcelldata);
1908 
1917  virtual void create_triangulation_compatibility (
1918  const std::vector<Point<spacedim> > &vertices,
1919  const std::vector<CellData<dim> > &cells,
1920  const SubCellData &subcelldata);
1921 
1928  void flip_all_direction_flags();
1929 
1941  void set_all_refine_flags ();
1942 
1957  void refine_global (const unsigned int times = 1);
1958 
1990  virtual void execute_coarsening_and_refinement ();
1991 
2021  virtual bool prepare_coarsening_and_refinement ();
2022 
2023  /*
2024  * @}
2025  */
2026 
2041  {
2059  };
2060 
2066  template <typename T>
2068  {
2069  typedef T result_type;
2070 
2071  template <typename InputIterator>
2072  T operator()(InputIterator first, InputIterator last) const
2073  {
2074  return std::accumulate (first, last, T());
2075  }
2076  };
2077 
2087  struct Signals
2088  {
2096  boost::signals2::signal<void ()> create;
2097 
2105  boost::signals2::signal<void ()> pre_refinement;
2106 
2112  boost::signals2::signal<void ()> post_refinement;
2113 
2121  boost::signals2::signal<void ()> mesh_movement;
2122 
2130  boost::signals2::signal<void (const typename Triangulation<dim, spacedim>::cell_iterator &cell)> pre_coarsening_on_cell;
2131 
2138  boost::signals2::signal<void (const typename Triangulation<dim, spacedim>::cell_iterator &cell)> post_refinement_on_cell;
2139 
2146  boost::signals2::signal<void (const Triangulation<dim, spacedim> &destination_tria)> copy;
2147 
2161  boost::signals2::signal<void ()> clear;
2162 
2172  boost::signals2::signal<void ()> any_change;
2173 
2197  boost::signals2::signal<unsigned int (const cell_iterator &,
2198  const CellStatus),
2200  };
2201 
2205  mutable Signals signals;
2206 
2207  /*
2208  * @}
2209  */
2210 
2220  void save_refine_flags (std::ostream &out) const;
2221 
2225  void save_refine_flags (std::vector<bool> &v) const;
2226 
2230  void load_refine_flags (std::istream &in);
2231 
2235  void load_refine_flags (const std::vector<bool> &v);
2236 
2240  void save_coarsen_flags (std::ostream &out) const;
2241 
2245  void save_coarsen_flags (std::vector<bool> &v) const;
2246 
2250  void load_coarsen_flags (std::istream &out);
2251 
2255  void load_coarsen_flags (const std::vector<bool> &v);
2256 
2261  bool get_anisotropic_refinement_flag() const;
2262 
2263  /*
2264  * @}
2265  */
2266 
2276  void clear_user_flags ();
2277 
2283  void save_user_flags (std::ostream &out) const;
2284 
2290  void save_user_flags (std::vector<bool> &v) const;
2291 
2296  void load_user_flags (std::istream &in);
2297 
2302  void load_user_flags (const std::vector<bool> &v);
2303 
2308  void clear_user_flags_line ();
2309 
2314  void save_user_flags_line (std::ostream &out) const;
2315 
2321  void save_user_flags_line (std::vector<bool> &v) const;
2322 
2327  void load_user_flags_line (std::istream &in);
2328 
2333  void load_user_flags_line (const std::vector<bool> &v);
2334 
2339  void clear_user_flags_quad ();
2340 
2345  void save_user_flags_quad (std::ostream &out) const;
2346 
2352  void save_user_flags_quad (std::vector<bool> &v) const;
2353 
2358  void load_user_flags_quad (std::istream &in);
2359 
2364  void load_user_flags_quad (const std::vector<bool> &v);
2365 
2366 
2371  void clear_user_flags_hex ();
2372 
2377  void save_user_flags_hex (std::ostream &out) const;
2378 
2384  void save_user_flags_hex (std::vector<bool> &v) const;
2385 
2390  void load_user_flags_hex (std::istream &in);
2391 
2396  void load_user_flags_hex (const std::vector<bool> &v);
2397 
2403  void clear_user_data ();
2404 
2410  void save_user_indices (std::vector<unsigned int> &v) const;
2411 
2416  void load_user_indices (const std::vector<unsigned int> &v);
2417 
2423  void save_user_pointers (std::vector<void *> &v) const;
2424 
2429  void load_user_pointers (const std::vector<void *> &v);
2430 
2436  void save_user_indices_line (std::vector<unsigned int> &v) const;
2437 
2442  void load_user_indices_line (const std::vector<unsigned int> &v);
2443 
2449  void save_user_indices_quad (std::vector<unsigned int> &v) const;
2450 
2455  void load_user_indices_quad (const std::vector<unsigned int> &v);
2456 
2462  void save_user_indices_hex (std::vector<unsigned int> &v) const;
2463 
2468  void load_user_indices_hex (const std::vector<unsigned int> &v);
2474  void save_user_pointers_line (std::vector<void *> &v) const;
2475 
2480  void load_user_pointers_line (const std::vector<void *> &v);
2481 
2487  void save_user_pointers_quad (std::vector<void *> &v) const;
2488 
2493  void load_user_pointers_quad (const std::vector<void *> &v);
2494 
2500  void save_user_pointers_hex (std::vector<void *> &v) const;
2501 
2506  void load_user_pointers_hex (const std::vector<void *> &v);
2507 
2508  /*
2509  * @}
2510  */
2511 
2520  cell_iterator begin (const unsigned int level = 0) const;
2521 
2534  active_cell_iterator begin_active(const unsigned int level = 0) const;
2535 
2540  cell_iterator end () const;
2541 
2546  cell_iterator end (const unsigned int level) const;
2547 
2553  active_cell_iterator end_active (const unsigned int level) const;
2554 
2555 
2559  cell_iterator last () const;
2560 
2564  active_cell_iterator last_active () const;
2565 
2581 
2619 
2635  IteratorRange<cell_iterator> cell_iterators_on_level (const unsigned int level) const;
2636 
2653 
2654  /*
2655  * @}
2656  */
2657 
2658  /*---------------------------------------*/
2659  /*---------------------------------------*/
2660 
2669  face_iterator begin_face () const;
2670 
2674  active_face_iterator begin_active_face() const;
2675 
2680  face_iterator end_face () const;
2681 
2682  /*
2683  * @}
2684  */
2685 
2686  /*---------------------------------------*/
2687  /*---------------------------------------*/
2688 
2698  vertex_iterator begin_vertex() const;
2699 
2705  active_vertex_iterator begin_active_vertex() const;
2706 
2712  vertex_iterator end_vertex() const;
2713 
2714  /*
2715  * @}
2716  */
2717 
2735  unsigned int n_lines () const;
2736 
2740  unsigned int n_lines (const unsigned int level) const;
2741 
2745  unsigned int n_active_lines () const;
2746 
2750  unsigned int n_active_lines (const unsigned int level) const;
2751 
2755  unsigned int n_quads () const;
2756 
2760  unsigned int n_quads (const unsigned int level) const;
2761 
2765  unsigned int n_active_quads () const;
2766 
2770  unsigned int n_active_quads (const unsigned int level) const;
2771 
2775  unsigned int n_hexs() const;
2776 
2781  unsigned int n_hexs(const unsigned int level) const;
2782 
2786  unsigned int n_active_hexs() const;
2787 
2792  unsigned int n_active_hexs(const unsigned int level) const;
2793 
2798  unsigned int n_cells () const;
2799 
2804  unsigned int n_cells (const unsigned int level) const;
2805 
2810  unsigned int n_active_cells () const;
2811 
2820 
2821 
2826  unsigned int n_active_cells (const unsigned int level) const;
2827 
2833  unsigned int n_faces () const;
2834 
2840  unsigned int n_active_faces () const;
2841 
2859  unsigned int n_levels () const;
2860 
2867  virtual
2868  unsigned int n_global_levels () const;
2869 
2879  virtual
2880  bool has_hanging_nodes() const;
2881 
2889  unsigned int n_vertices () const;
2890 
2899  const std::vector<Point<spacedim> > &
2900  get_vertices () const;
2901 
2906  unsigned int n_used_vertices () const;
2907 
2911  bool vertex_used (const unsigned int index) const;
2912 
2917  const std::vector<bool> &
2918  get_used_vertices () const;
2919 
2931  unsigned int max_adjacent_cells () const;
2932 
2940 
2951  get_triangulation ();
2952 
2958  get_triangulation () const;
2959 
2960 
2961  /*
2962  * @}
2963  */
2964 
2979  unsigned int n_raw_lines () const;
2980 
2990  unsigned int n_raw_lines (const unsigned int level) const;
2991 
3001  unsigned int n_raw_quads () const;
3002 
3012  unsigned int n_raw_quads (const unsigned int level) const;
3013 
3023  unsigned int n_raw_hexs () const;
3024 
3034  unsigned int n_raw_hexs (const unsigned int level) const;
3035 
3045  unsigned int n_raw_cells (const unsigned int level) const;
3046 
3057  unsigned int n_raw_faces () const;
3058 
3059  /*
3060  * @}
3061  */
3062 
3071  virtual std::size_t memory_consumption () const;
3072 
3081  template <class Archive>
3082  void save (Archive &ar,
3083  const unsigned int version) const;
3084 
3100  template <class Archive>
3101  void load (Archive &ar,
3102  const unsigned int version);
3103 
3104 
3120  virtual void
3122  (const std::vector<GridTools::PeriodicFacePair<cell_iterator> > &);
3123 
3127  const std::map<std::pair<cell_iterator, unsigned int>,std::pair<std::pair<cell_iterator, unsigned int>, std::bitset<3> > > &
3128  get_periodic_face_map() const;
3129 
3130 
3131  BOOST_SERIALIZATION_SPLIT_MEMBER()
3132 
3133 
3144  int,
3145  << "The given level " << arg1
3146  << " is not in the valid range!");
3154  int, int,
3155  << "You are trying to perform an operation on a triangulation "
3156  << "that is only allowed if the triangulation is currently empty. "
3157  << "However, it currently stores " << arg1 << " vertices and has "
3158  << "cells on " << arg2 << " levels.");
3176  int,
3177  << "You tried to do something on level " << arg1
3178  << ", but this level is empty.");
3185 
3194  types::boundary_id,
3195  << "The given boundary_id " << arg1
3196  << " is not defined in this Triangulation!");
3197 
3198  /*
3199  * @}
3200  */
3201 
3202 protected:
3208 
3222  static void write_bool_vector (const unsigned int magic_number1,
3223  const std::vector<bool> &v,
3224  const unsigned int magic_number2,
3225  std::ostream &out);
3226 
3231  static void read_bool_vector (const unsigned int magic_number1,
3232  std::vector<bool> &v,
3233  const unsigned int magic_number2,
3234  std::istream &in);
3235 
3239  void update_periodic_face_map ();
3240 
3241 
3242 private:
3249  std::vector<GridTools::PeriodicFacePair<cell_iterator> > periodic_face_pairs_level_0;
3250 
3254  std::map<std::pair<cell_iterator, unsigned int>, std::pair<std::pair<cell_iterator, unsigned int>, std::bitset<3> > > periodic_face_map;
3255 
3270  typedef TriaRawIterator<TriaAccessor<dim-1, dim, spacedim> > raw_face_iterator;
3271  typedef TriaRawIterator<::TriaAccessor<0, dim, spacedim> > raw_vertex_iterator;
3272  typedef typename IteratorSelector::raw_line_iterator raw_line_iterator;
3273  typedef typename IteratorSelector::raw_quad_iterator raw_quad_iterator;
3274  typedef typename IteratorSelector::raw_hex_iterator raw_hex_iterator;
3275 
3280  raw_cell_iterator begin_raw (const unsigned int level = 0) const;
3281 
3286  raw_cell_iterator end_raw (const unsigned int level) const;
3287 
3288  /*
3289  * @}
3290  */
3291 
3303  raw_line_iterator
3304  begin_raw_line (const unsigned int level = 0) const;
3305 
3309  line_iterator
3310  begin_line (const unsigned int level = 0) const;
3311 
3315  active_line_iterator
3316  begin_active_line(const unsigned int level = 0) const;
3317 
3322  line_iterator end_line () const;
3323 
3324  /*
3325  * @}
3326  */
3327 
3338  raw_quad_iterator
3339  begin_raw_quad (const unsigned int level = 0) const;
3340 
3344  quad_iterator
3345  begin_quad (const unsigned int level = 0) const;
3346 
3350  active_quad_iterator
3351  begin_active_quad (const unsigned int level = 0) const;
3352 
3357  quad_iterator
3358  end_quad () const;
3359 
3360  /*
3361  * @}
3362  */
3363 
3373  raw_hex_iterator
3374  begin_raw_hex (const unsigned int level = 0) const;
3375 
3379  hex_iterator
3380  begin_hex (const unsigned int level = 0) const;
3381 
3385  active_hex_iterator
3386  begin_active_hex (const unsigned int level = 0) const;
3387 
3392  hex_iterator
3393  end_hex () const;
3394 
3395  /*
3396  * @}
3397  */
3398 
3399 
3414 
3421  void reset_active_cell_indices ();
3422 
3436  DistortedCellList execute_refinement ();
3437 
3444  void execute_coarsening ();
3445 
3450  void fix_coarsen_flags ();
3451 
3456  std::vector<std::unique_ptr<::internal::Triangulation::TriaLevel<dim> > > levels;
3457 
3463  std::unique_ptr<::internal::Triangulation::TriaFaces<dim> > faces;
3464 
3465 
3469  std::vector<Point<spacedim> > vertices;
3470 
3474  std::vector<bool> vertices_used;
3475 
3480  std::map<types::manifold_id, SmartPointer<const Manifold<dim,spacedim>, Triangulation<dim, spacedim> > > manifold;
3481 
3482 
3487 
3488 
3494 
3504  ::internal::Triangulation::NumberCache<dim> number_cache;
3505 
3520  std::unique_ptr<std::map<unsigned int, types::boundary_id> > vertex_to_boundary_id_map_1d;
3521 
3522 
3542  std::unique_ptr<std::map<unsigned int, types::manifold_id> > vertex_to_manifold_id_map_1d;
3543 
3544  // make a couple of classes friends
3545  template <int,int,int> friend class TriaAccessorBase;
3546  template <int,int,int> friend class TriaAccessor;
3547  friend class TriaAccessor<0, 1, spacedim>;
3548 
3549  friend class CellAccessor<dim, spacedim>;
3550 
3551  friend struct ::internal::TriaAccessor::Implementation;
3552 
3553  friend class hp::DoFHandler<dim,spacedim>;
3554 
3555  friend struct ::internal::Triangulation::Implementation;
3556 
3557  template <typename>
3558  friend class ::internal::Triangulation::TriaObjects;
3559 
3560  // explicitly check for sensible template arguments, but not on windows
3561  // because MSVC creates bogus warnings during normal compilation
3562 #ifndef DEAL_II_MSVC
3563  static_assert (dim<=spacedim,
3564  "The dimension <dim> of a Triangulation must be less than or "
3565  "equal to the space dimension <spacedim> in which it lives.");
3566 #endif
3567 
3568 };
3569 
3570 
3571 #ifndef DOXYGEN
3572 
3573 
3574 template <int structdim>
3575 inline
3577 {
3578  for (unsigned int i=0; i<GeometryInfo<structdim>::vertices_per_cell; ++i)
3579  vertices[i] = numbers::invalid_unsigned_int;
3580 
3581  material_id = 0;
3582 
3583  // And the manifold to be invalid
3584  manifold_id = numbers::invalid_manifold_id;
3585 }
3586 
3587 
3588 
3589 namespace internal
3590 {
3591  namespace Triangulation
3592  {
3593  template <class Archive>
3594  void NumberCache<1>::serialize (Archive &ar,
3595  const unsigned int)
3596  {
3597  ar &n_levels;
3598  ar &n_lines &n_lines_level;
3599  ar &n_active_lines &n_active_lines_level;
3600  }
3601 
3602 
3603  template <class Archive>
3604  void NumberCache<2>::serialize (Archive &ar,
3605  const unsigned int version)
3606  {
3607  this->NumberCache<1>::serialize (ar, version);
3608 
3609  ar &n_quads &n_quads_level;
3610  ar &n_active_quads &n_active_quads_level;
3611  }
3612 
3613 
3614  template <class Archive>
3615  void NumberCache<3>::serialize (Archive &ar,
3616  const unsigned int version)
3617  {
3618  this->NumberCache<2>::serialize (ar, version);
3619 
3620  ar &n_hexes &n_hexes_level;
3621  ar &n_active_hexes &n_active_hexes_level;
3622  }
3623 
3624  }
3625 }
3626 
3627 
3628 template <int dim, int spacedim>
3629 inline
3630 bool
3631 Triangulation<dim,spacedim>::vertex_used(const unsigned int index) const
3632 {
3633  Assert (index < vertices_used.size(),
3634  ExcIndexRange(index, 0, vertices_used.size()));
3635  return vertices_used[index];
3636 }
3637 
3638 
3639 
3640 template <int dim, int spacedim>
3641 inline
3642 unsigned int Triangulation<dim, spacedim>::n_levels () const
3643 {
3644  return number_cache.n_levels;
3645 }
3646 
3647 template <int dim, int spacedim>
3648 inline
3650 {
3651  return number_cache.n_levels;
3652 }
3653 
3654 
3655 template <int dim, int spacedim>
3656 inline
3657 unsigned int
3659 {
3660  return vertices.size();
3661 }
3662 
3663 
3664 
3665 template <int dim, int spacedim>
3666 inline
3667 const std::vector<Point<spacedim> > &
3669 {
3670  return vertices;
3671 }
3672 
3673 
3674 template <int dim, int spacedim>
3675 template <class Archive>
3676 void
3678  const unsigned int) const
3679 {
3680  // as discussed in the documentation, do not store the signals as
3681  // well as boundary and manifold description but everything else
3682  ar &smooth_grid;
3683 
3684  unsigned int n_levels = levels.size();
3685  ar &n_levels;
3686  for (unsigned int i = 0; i < levels.size(); ++i)
3687  ar &levels[i];
3688 
3689  ar &faces;
3690  ar &vertices;
3691  ar &vertices_used;
3692 
3693  ar &anisotropic_refinement;
3694  ar &number_cache;
3695 
3696  ar &check_for_distorted_cells;
3697 
3698  if (dim == 1)
3699  {
3700  ar &vertex_to_boundary_id_map_1d;
3701  ar &vertex_to_manifold_id_map_1d;
3702  }
3703 }
3704 
3705 
3706 
3707 template <int dim, int spacedim>
3708 template <class Archive>
3709 void
3711  const unsigned int)
3712 {
3713  // clear previous content. this also calls the respective signal
3714  clear ();
3715 
3716  // as discussed in the documentation, do not store the signals as
3717  // well as boundary and manifold description but everything else
3718  ar &smooth_grid;
3719 
3720  unsigned int size;
3721  ar &size;
3722  levels.resize(size);
3723  for (unsigned int i = 0; i < levels.size(); ++i)
3724  {
3725  std::unique_ptr<internal::Triangulation::TriaLevel<dim>> level;
3726  ar &level;
3727  levels[i] = std::move(level);
3728  }
3729 
3730  ar &faces;
3731  ar &vertices;
3732  ar &vertices_used;
3733 
3734  ar &anisotropic_refinement;
3735  ar &number_cache;
3736 
3737  // the levels do not serialize the active_cell_indices because
3738  // they are easy enough to rebuild upon re-loading data. do
3739  // this here. don't forget to first resize the fields appropriately
3740  {
3741  for (unsigned int l=0; l<levels.size(); ++l)
3742  levels[l]->active_cell_indices.resize (levels[l]->refine_flags.size());
3743  reset_active_cell_indices ();
3744  }
3745 
3746 
3747  bool my_check_for_distorted_cells;
3748  ar &my_check_for_distorted_cells;
3749 
3750  Assert (my_check_for_distorted_cells == check_for_distorted_cells,
3751  ExcMessage ("The triangulation loaded into here must have the "
3752  "same setting with regard to reporting distorted "
3753  "cell as the one previously stored."));
3754 
3755  if (dim == 1)
3756  {
3757  ar &vertex_to_boundary_id_map_1d;
3758  ar &vertex_to_manifold_id_map_1d;
3759  }
3760 
3761  // trigger the create signal to indicate
3762  // that new content has been imported into
3763  // the triangulation
3764  signals.create();
3765 }
3766 
3767 
3768 /* -------------- declaration of explicit specializations ------------- */
3769 
3770 template <> unsigned int Triangulation<1,1>::n_raw_lines (const unsigned int level) const;
3771 template <> unsigned int Triangulation<1,1>::n_quads () const;
3772 template <> unsigned int Triangulation<1,1>::n_quads (const unsigned int level) const;
3773 template <> unsigned int Triangulation<1,1>::n_raw_quads (const unsigned int level) const;
3774 template <> unsigned int Triangulation<2,2>::n_raw_quads (const unsigned int level) const;
3775 template <> unsigned int Triangulation<1,1>::n_raw_hexs (const unsigned int level) const;
3776 template <> unsigned int Triangulation<1,1>::n_active_quads (const unsigned int level) const;
3777 template <> unsigned int Triangulation<1,1>::n_active_quads () const;
3778 template <> unsigned int Triangulation<1,1>::max_adjacent_cells () const;
3779 
3780 
3781 // -------------------------------------------------------------------
3782 // -- Explicit specializations for codimension one grids
3783 
3784 
3785 template <> unsigned int Triangulation<1,2>::n_raw_lines (const unsigned int level) const;
3786 template <> unsigned int Triangulation<1,2>::n_quads () const;
3787 template <> unsigned int Triangulation<1,2>::n_quads (const unsigned int level) const;
3788 template <> unsigned int Triangulation<1,2>::n_raw_quads (const unsigned int level) const;
3789 template <> unsigned int Triangulation<2,3>::n_raw_quads (const unsigned int level) const;
3790 template <> unsigned int Triangulation<1,2>::n_raw_hexs (const unsigned int level) const;
3791 template <> unsigned int Triangulation<1,2>::n_active_quads (const unsigned int level) const;
3792 template <> unsigned int Triangulation<1,2>::n_active_quads () const;
3793 template <> unsigned int Triangulation<1,2>::max_adjacent_cells () const;
3794 
3795 // -------------------------------------------------------------------
3796 // -- Explicit specializations for codimension two grids
3797 
3798 
3799 template <> unsigned int Triangulation<1,3>::n_raw_lines (const unsigned int level) const;
3800 template <> unsigned int Triangulation<1,3>::n_quads () const;
3801 template <> unsigned int Triangulation<1,3>::n_quads (const unsigned int level) const;
3802 template <> unsigned int Triangulation<1,3>::n_raw_quads (const unsigned int level) const;
3803 template <> unsigned int Triangulation<2,3>::n_raw_quads (const unsigned int level) const;
3804 template <> unsigned int Triangulation<1,3>::n_raw_hexs (const unsigned int level) const;
3805 template <> unsigned int Triangulation<1,3>::n_active_quads (const unsigned int level) const;
3806 template <> unsigned int Triangulation<1,3>::n_active_quads () const;
3807 template <> unsigned int Triangulation<1,3>::max_adjacent_cells () const;
3808 
3809 
3810 #endif // DOXYGEN
3811 
3812 DEAL_II_NAMESPACE_CLOSE
3813 
3814 // Include tria_accessor.h here, so that it is possible for an end
3815 // user to use the iterators of Triangulation<dim> directly without
3816 // the need to include tria_accessor.h separately. (Otherwise the
3817 // iterators are an 'opaque' or 'incomplete' type.)
3818 #include <deal.II/grid/tria_accessor.h>
3819 
3820 #endif
std::vector< CellData< 1 > > boundary_lines
Definition: tria.h:252
TriaActiveIterator< CellAccessor< dim, spacedim > > active_cell_iterator
Definition: tria.h:1501
boost::signals2::signal< void()> any_change
Definition: tria.h:2172
unsigned int n_raw_faces() const
Definition: tria.cc:11248
void set_boundary(const types::manifold_id number, const Boundary< dim, spacedim > &boundary_object)
Definition: tria.cc:9089
active_line_iterator begin_active_line(const unsigned int level=0) const
Definition: tria.cc:10964
static const unsigned int space_dimension
Definition: tria.h:1583
virtual void copy_triangulation(const Triangulation< dim, spacedim > &other_tria)
Definition: tria.cc:9289
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:9996
#define DeclException2(Exception2, type1, type2, outsequence)
Definition: exceptions.h:605
Iterator points to a valid object.
virtual ~DistortedCellList() noexcept
Definition: tria.cc:13543
void clear_user_flags()
Definition: tria.cc:9861
line_iterator begin_line(const unsigned int level=0) const
Definition: tria.cc:10948
const std::vector< Point< spacedim > > & get_vertices() const
::internal::Triangulation::NumberCache< dim > number_cache
Definition: tria.h:3504
cell_iterator end() const
Definition: tria.cc:10708
virtual unsigned int n_global_levels() const
void save_user_flags_hex(std::ostream &out) const
Definition: tria.cc:10158
unsigned int n_active_lines() const
Definition: tria.cc:11431
active_face_iterator begin_active_face() const
Definition: tria.cc:10820
unsigned int n_used_vertices() const
Definition: tria.cc:11744
std::vector< GridTools::PeriodicFacePair< cell_iterator > > periodic_face_pairs_level_0
Definition: tria.h:3249
std::list< typename Triangulation< dim, spacedim >::cell_iterator > distorted_cells
Definition: tria.h:1572
bool check_consistency(const unsigned int dim) const
Definition: tria.cc:47
unsigned int n_faces() const
Definition: tria.cc:11230
IteratorRange< active_cell_iterator > active_cell_iterators() const
Definition: tria.cc:10764
std::vector< Point< spacedim > > vertices
Definition: tria.h:3469
boost::signals2::signal< void()> clear
Definition: tria.h:2161
void set_all_refine_flags()
Definition: tria.cc:9564
void load_user_flags(std::istream &in)
Definition: tria.cc:9918
TriaActiveIterator<::TriaAccessor< 0, dim, spacedim > > active_vertex_iterator
Definition: tria.h:1528
unsigned int boundary_id
Definition: types.h:110
bool anisotropic_refinement
Definition: tria.h:3486
boost::signals2::signal< unsigned int(const cell_iterator &, const CellStatus), CellWeightSum< unsigned int > > cell_weight
Definition: tria.h:2199
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:2130
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:13483
boost::signals2::signal< void()> mesh_movement
Definition: tria.h:2121
static::ExceptionBase & ExcGridReadError()
void clear_user_flags_quad()
Definition: tria.cc:9821
face_iterator begin_face() const
Definition: tria.cc:10799
std::vector< unsigned int > n_quads_level
Definition: tria.h:390
void save_user_pointers_quad(std::vector< void * > &v) const
Definition: tria.cc:10529
void flip_all_direction_flags()
Definition: tria.cc:9553
raw_hex_iterator begin_raw_hex(const unsigned int level=0) const
Definition: tria.cc:11078
STL namespace.
const std::vector< bool > & get_used_vertices() const
Definition: tria.cc:11754
cell_iterator last() const
Definition: tria.cc:10660
line_iterator end_line() const
Definition: tria.cc:10980
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:13451
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:10620
void execute_coarsening()
Definition: tria.cc:12032
void load_user_flags_quad(std::istream &in)
Definition: tria.cc:10106
void save_user_flags_line(std::ostream &out) const
Definition: tria.cc:9985
unsigned int n_active_cells() const
Definition: tria.cc:11216
void load_user_pointers_line(const std::vector< void * > &v)
Definition: tria.cc:10515
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:9097
IteratorRange< cell_iterator > cell_iterators() const
Definition: tria.cc:10754
static::ExceptionBase & ExcFacesHaveNoLevel()
bool get_anisotropic_refinement_flag() const
Definition: tria.cc:9718
vertex_iterator end_vertex() const
Definition: tria.cc:10901
void load_coarsen_flags(std::istream &out)
Definition: tria.cc:9689
void load_user_flags_hex(std::istream &in)
Definition: tria.cc:10169
virtual void execute_coarsening_and_refinement()
Definition: tria.cc:11871
Definition: tria.h:75
void save_user_indices_hex(std::vector< unsigned int > &v) const
Definition: tria.cc:10363
unsigned int n_active_quads() const
Definition: tria.cc:11641
void save_coarsen_flags(std::ostream &out) const
Definition: tria.cc:9678
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:11862
Definition: tria.h:48
void save_user_indices(std::vector< unsigned int > &v) const
Definition: tria.cc:10202
virtual bool prepare_coarsening_and_refinement()
Definition: tria.cc:12558
static::ExceptionBase & ExcMessage(std::string arg1)
unsigned int n_raw_lines() const
Definition: tria.cc:11414
static::ExceptionBase & ExcTriangulationNotEmpty(int arg1, int arg2)
void reset_active_cell_indices()
Definition: tria.cc:11915
DistortedCellList execute_refinement()
Definition: tria.cc:11998
const Boundary< dim, spacedim > & get_boundary(const types::manifold_id number) const
Definition: tria.cc:9197
const bool check_for_distorted_cells
Definition: tria.h:3493
boost::signals2::signal< void()> pre_refinement
Definition: tria.h:2105
quad_iterator end_quad() const
Definition: tria.cc:11065
static const unsigned int dimension
Definition: tria.h:1578
static::ExceptionBase & ExcNonOrientableTriangulation()
Triangulation(const MeshSmoothing smooth_grid=none, const bool check_for_distorted_cells=false)
Definition: tria.cc:8953
unsigned int n_cells() const
Definition: tria.cc:11209
#define DeclException1(Exception1, type1, outsequence)
Definition: exceptions.h:593
TriaIterator< CellAccessor< dim, spacedim > > cell_iterator
Definition: tria.h:1483
Triangulation & operator=(Triangulation< dim, spacedim > &&tria)
Definition: tria.cc:9002
void clear_user_flags_hex()
Definition: tria.cc:9853
void load_user_indices_line(const std::vector< unsigned int > &v)
Definition: tria.cc:10317
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:10742
IteratorRange< cell_iterator > cell_iterators_on_level(const unsigned int level) const
Definition: tria.cc:10775
#define Assert(cond, exc)
Definition: exceptions.h:337
std::unique_ptr<::internal::Triangulation::TriaFaces< dim > > faces
Definition: tria.h:3463
std::vector< types::manifold_id > get_manifold_ids() const
Definition: tria.cc:9267
void save_user_flags(std::ostream &out) const
Definition: tria.cc:9871
hex_iterator end_hex() const
Definition: tria.cc:11140
unsigned int n_raw_quads() const
Definition: tria.cc:11624
unsigned int n_hexs() const
Definition: tria.cc:11659
void set_all_manifold_ids(const types::manifold_id number)
Definition: tria.cc:9128
void load_user_pointers_quad(const std::vector< void * > &v)
Definition: tria.cc:10546
active_vertex_iterator begin_active_vertex() const
Definition: tria.cc:10892
boost::signals2::signal< void()> create
Definition: tria.h:2096
static const StraightBoundary< dim, spacedim > straight_boundary
Definition: tria.h:1262
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:3542
std::vector< bool > vertices_used
Definition: tria.h:3474
#define DeclException0(Exception0)
Definition: exceptions.h:570
virtual bool has_hanging_nodes() const
Definition: tria.cc:11338
virtual void create_triangulation(const std::vector< Point< spacedim > > &vertices, const std::vector< CellData< dim > > &cells, const SubCellData &subcelldata)
Definition: tria.cc:9373
types::material_id material_id
Definition: tria.h:154
void load_user_indices(const std::vector< unsigned int > &v)
Definition: tria.cc:10232
void save_user_pointers(std::vector< void * > &v) const
Definition: tria.cc:10437
raw_line_iterator begin_raw_line(const unsigned int level=0) const
Definition: tria.cc:10923
void clear_despite_subscriptions()
Definition: tria.cc:11982
std::map< types::manifold_id, SmartPointer< const Manifold< dim, spacedim >, Triangulation< dim, spacedim > > > manifold
Definition: tria.h:3480
const Manifold< dim, spacedim > & get_manifold(const types::manifold_id number) const
Definition: tria.cc:9210
hex_iterator begin_hex(const unsigned int level=0) const
Definition: tria.cc:11108
raw_cell_iterator begin_raw(const unsigned int level=0) const
Definition: tria.cc:10600
void save_refine_flags(std::ostream &out) const
Definition: tria.cc:9613
virtual ~Triangulation()
Definition: tria.cc:9027
unsigned int n_lines() const
Definition: tria.cc:11349
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:3254
vertex_iterator begin_vertex() const
Definition: tria.cc:10864
::internal::Triangulation::Iterators< dim, spacedim > IteratorSelector
Definition: tria.h:1255
std::vector< std::unique_ptr<::internal::Triangulation::TriaLevel< dim > > > levels
Definition: tria.h:3456
void save_user_indices_line(std::vector< unsigned int > &v) const
Definition: tria.cc:10304
virtual void set_mesh_smoothing(const MeshSmoothing mesh_smoothing)
Definition: tria.cc:9069
unsigned int subdomain_id
Definition: types.h:42
virtual types::subdomain_id locally_owned_subdomain() const
Definition: tria.cc:11818
boost::signals2::signal< void(const typename Triangulation< dim, spacedim >::cell_iterator &cell)> post_refinement_on_cell
Definition: tria.h:2138
boost::signals2::signal< void()> post_refinement
Definition: tria.h:2112
std::unique_ptr< std::map< unsigned int, types::boundary_id > > vertex_to_boundary_id_map_1d
Definition: tria.h:3520
active_cell_iterator last_active() const
Definition: tria.cc:10687
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:10786
void save_user_pointers_line(std::vector< void * > &v) const
Definition: tria.cc:10502
types::manifold_id manifold_id
Definition: tria.h:176
active_quad_iterator begin_active_quad(const unsigned int level=0) const
Definition: tria.cc:11049
virtual types::global_dof_index n_global_active_cells() const
Definition: tria.cc:11222
virtual const MeshSmoothing & get_mesh_smoothing() const
Definition: tria.cc:9080
void load_user_indices_hex(const std::vector< unsigned int > &v)
Definition: tria.cc:10380
void save_user_indices_quad(std::vector< unsigned int > &v) const
Definition: tria.cc:10330
unsigned int n_raw_cells(const unsigned int level) const
Definition: tria.cc:11282
const types::manifold_id invalid_manifold_id
Definition: types.h:229
unsigned int n_active_faces() const
Definition: tria.cc:11264
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:12104
void serialize(Archive &ar, const unsigned int version)
void save_user_pointers_hex(std::vector< void * > &v) const
Definition: tria.cc:10562
void update_periodic_face_map()
Definition: tria.cc:11933
void save(Archive &ar, const unsigned int version) const
face_iterator end_face() const
Definition: tria.cc:10841
Signals signals
Definition: tria.h:2205
virtual void add_periodicity(const std::vector< GridTools::PeriodicFacePair< cell_iterator > > &)
Definition: tria.cc:11846
raw_cell_iterator end_raw(const unsigned int level) const
Definition: tria.cc:10719
std::vector< CellData< 2 > > boundary_quads
Definition: tria.h:260
void serialize(Archive &ar, const unsigned int version)
MeshSmoothing smooth_grid
Definition: tria.h:3207
quad_iterator begin_quad(const unsigned int level=0) const
Definition: tria.cc:11033
unsigned int n_quads() const
Definition: tria.cc:11578
active_hex_iterator begin_active_hex(const unsigned int level=0) const
Definition: tria.cc:11124
void refine_global(const unsigned int times=1)
Definition: tria.cc:9580
unsigned int n_raw_hexs() const
static::ExceptionBase & ExcEmptyLevel(int arg1)
void load_user_pointers_hex(const std::vector< void * > &v)
Definition: tria.cc:10579
void set_all_manifold_ids_on_boundary(const types::manifold_id number)
Definition: tria.cc:9143
void load_user_pointers(const std::vector< void * > &v)
Definition: tria.cc:10467
active_cell_iterator begin_active(const unsigned int level=0) const
Definition: tria.cc:10640
std::vector< types::boundary_id > get_boundary_ids() const
Definition: tria.cc:9235
void clear_user_flags_line()
Definition: tria.cc:9789
static::ExceptionBase & ExcBoundaryIdNotFound(types::boundary_id arg1)
unsigned int max_adjacent_cells() const
Definition: tria.cc:11785
unsigned int n_vertices() const
void clear_user_data()
Definition: tria.cc:9761
unsigned int n_active_hexs() const
Definition: tria.cc:11682
raw_quad_iterator begin_raw_quad(const unsigned int level=0) const
Definition: tria.cc:10994
virtual void create_triangulation_compatibility(const std::vector< Point< spacedim > > &vertices, const std::vector< CellData< dim > > &cells, const SubCellData &subcelldata)
Definition: tria.cc:9353
void load_user_indices_quad(const std::vector< unsigned int > &v)
Definition: tria.cc:10347
virtual void clear()
Definition: tria.cc:9054
boost::signals2::signal< void(const Triangulation< dim, spacedim > &destination_tria)> copy
Definition: tria.h:2146
void save_user_flags_quad(std::ostream &out) const
Definition: tria.cc:10095
void load_refine_flags(std::istream &in)
Definition: tria.cc:9624
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:11827
TriaIterator<::TriaAccessor< 0, dim, spacedim > > vertex_iterator
Definition: tria.h:1514
virtual std::size_t memory_consumption() const
Definition: tria.cc:13521