Reference documentation for deal.II version 8.4.2
tria.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 1998 - 2016 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/grid/tria_iterator_selector.h>
28 #include <deal.II/grid/tria_faces.h>
29 #include <deal.II/grid/tria_levels.h>
30 
31 // Ignore deprecation warnings for auto_ptr.
32 DEAL_II_DISABLE_EXTRA_DIAGNOSTICS
33 #include <boost/signals2.hpp>
34 #include <boost/serialization/vector.hpp>
35 #include <boost/serialization/map.hpp>
36 #include <boost/serialization/split_member.hpp>
38 
39 #include <vector>
40 #include <list>
41 #include <map>
42 
43 
44 DEAL_II_NAMESPACE_OPEN
45 
46 template <int dim, int spacedim> class Boundary;
47 template <int dim, int spacedim> class StraightBoundary;
48 template <int dim, int spacedim> class Manifold;
49 
50 template <int, int, int> class TriaAccessor;
51 template <int spacedim> class TriaAccessor<0,1,spacedim>;
52 
53 
54 namespace internal
55 {
56  namespace Triangulation
57  {
58  template <int dim> class TriaLevel;
59  template <int dim> class TriaFaces;
60 
61  template <typename> class TriaObjects;
62 
68  struct Implementation;
69  }
70 
71  namespace TriaAccessor
72  {
73  struct Implementation;
74  }
75 }
76 
77 template <int dim, int spacedim> class DoFHandler;
78 namespace hp
79 {
80  template <int dim, int spacedim> class DoFHandler;
81 }
82 
83 
84 /*------------------------------------------------------------------------*/
85 
104 template <int structdim>
105 struct CellData
106 {
111 
120  union
121  {
122  types::boundary_id boundary_id;
123  types::material_id material_id;
124  };
125 
132 
139  CellData ();
140 };
141 
142 
143 
174 {
179  std::vector<CellData<1> > boundary_lines;
180 
185  std::vector<CellData<2> > boundary_quads;
186 
196  bool check_consistency (const unsigned int dim) const;
197 };
198 
199 
200 /*------------------------------------------------------------------------*/
201 
202 
203 namespace internal
204 {
209  namespace Triangulation
210  {
211 
225  template <int dim>
226  struct NumberCache
227  {
228  };
229 
243  template <>
244  struct NumberCache<1>
245  {
249  unsigned int n_levels;
250 
254  unsigned int n_lines;
255 
259  std::vector<unsigned int> n_lines_level;
260 
264  unsigned int n_active_lines;
265 
269  std::vector<unsigned int> n_active_lines_level;
270 
274  NumberCache ();
275 
280  std::size_t memory_consumption () const;
281 
286  template <class Archive>
287  void serialize (Archive &ar,
288  const unsigned int version);
289  };
290 
291 
306  template <>
307  struct NumberCache<2> : public NumberCache<1>
308  {
312  unsigned int n_quads;
313 
317  std::vector<unsigned int> n_quads_level;
318 
322  unsigned int n_active_quads;
323 
327  std::vector<unsigned int> n_active_quads_level;
328 
332  NumberCache ();
333 
338  std::size_t memory_consumption () const;
339 
344  template <class Archive>
345  void serialize (Archive &ar,
346  const unsigned int version);
347  };
348 
349 
365  template <>
366  struct NumberCache<3> : public NumberCache<2>
367  {
371  unsigned int n_hexes;
372 
376  std::vector<unsigned int> n_hexes_level;
377 
381  unsigned int n_active_hexes;
382 
386  std::vector<unsigned int> n_active_hexes_level;
387 
391  NumberCache ();
392 
397  std::size_t memory_consumption () const;
398 
403  template <class Archive>
404  void serialize (Archive &ar,
405  const unsigned int version);
406  };
407  }
408 }
409 
410 
411 /*------------------------------------------------------------------------*/
412 
413 
1155 template <int dim, int spacedim=dim>
1156 class Triangulation : public Subscriptor
1157 {
1158 private:
1159 
1164  typedef ::internal::Triangulation::Iterators<dim, spacedim> IteratorSelector;
1165 
1166 public:
1172 
1178  {
1183  none = 0x0,
1226  limit_level_difference_at_vertices = 0x1,
1247  eliminate_unrefined_islands = 0x2,
1263  patch_level_1 = 0x4,
1284  coarsest_level_1 = 0x8,
1309  allow_anisotropic_smoothing = 0x10,
1342  eliminate_refined_inner_islands = 0x100,
1347  eliminate_refined_boundary_islands = 0x200,
1353  do_not_produce_unrefined_islands = 0x400,
1354 
1359  smoothing_on_refinement = (limit_level_difference_at_vertices |
1360  eliminate_unrefined_islands),
1365  smoothing_on_coarsening = (eliminate_refined_inner_islands |
1366  eliminate_refined_boundary_islands |
1367  do_not_produce_unrefined_islands),
1368 
1374  maximum_smoothing = 0xffff ^ allow_anisotropic_smoothing
1375  };
1376 
1393 
1411 
1412  typedef TriaIterator <TriaAccessor<dim-1, dim, spacedim> > face_iterator;
1413  typedef TriaActiveIterator<TriaAccessor<dim-1, dim, spacedim> > active_face_iterator;
1414 
1415  typedef typename IteratorSelector::vertex_iterator vertex_iterator;
1416  typedef typename IteratorSelector::active_vertex_iterator active_vertex_iterator;
1417 
1418  typedef typename IteratorSelector::line_iterator line_iterator;
1419  typedef typename IteratorSelector::active_line_iterator active_line_iterator;
1420 
1421  typedef typename IteratorSelector::quad_iterator quad_iterator;
1422  typedef typename IteratorSelector::active_quad_iterator active_quad_iterator;
1423 
1424  typedef typename IteratorSelector::hex_iterator hex_iterator;
1425  typedef typename IteratorSelector::active_hex_iterator active_hex_iterator;
1426 
1446  {
1453  virtual ~DistortedCellList () throw();
1454 
1459  std::list<typename Triangulation<dim,spacedim>::cell_iterator>
1461  };
1462 
1463 
1467  static const unsigned int dimension = dim;
1468 
1472  static const unsigned int space_dimension = spacedim;
1473 
1488  Triangulation (const MeshSmoothing smooth_grid = none,
1489  const bool check_for_distorted_cells = false);
1490 
1507 
1511  virtual ~Triangulation ();
1512 
1519  virtual void clear ();
1520 
1526  virtual void set_mesh_smoothing (const MeshSmoothing mesh_smoothing);
1527 
1565  void set_boundary (const types::manifold_id number,
1566  const Boundary<dim,spacedim> &boundary_object);
1567 
1568 
1580  void set_boundary (const types::manifold_id number);
1581 
1606  void set_manifold (const types::manifold_id number,
1607  const Manifold<dim,spacedim> &manifold_object);
1608 
1609 
1621  void set_manifold (const types::manifold_id number);
1622 
1631  void set_all_manifold_ids (const types::manifold_id number);
1632 
1641  void set_all_manifold_ids_on_boundary (const types::manifold_id number);
1642 
1652  void set_all_manifold_ids_on_boundary (const types::boundary_id b_id,
1653  const types::manifold_id number);
1654 
1655 
1665  const Boundary<dim,spacedim> &get_boundary (const types::manifold_id number) const;
1666 
1676  const Manifold<dim,spacedim> &get_manifold (const types::manifold_id number) const;
1677 
1689  std::vector<types::boundary_id> get_boundary_ids() const;
1690 
1696  std::vector<types::boundary_id> get_boundary_indicators() const DEAL_II_DEPRECATED;
1697 
1709  std::vector<types::manifold_id> get_manifold_ids() const;
1710 
1738  virtual void copy_triangulation (const Triangulation<dim, spacedim> &old_tria);
1739 
1783  virtual void create_triangulation (const std::vector<Point<spacedim> > &vertices,
1784  const std::vector<CellData<dim> > &cells,
1785  const SubCellData &subcelldata);
1786 
1795  virtual void create_triangulation_compatibility (
1796  const std::vector<Point<spacedim> > &vertices,
1797  const std::vector<CellData<dim> > &cells,
1798  const SubCellData &subcelldata);
1799 
1806  void flip_all_direction_flags();
1807 
1819  void set_all_refine_flags ();
1820 
1835  void refine_global (const unsigned int times = 1);
1836 
1868  virtual void execute_coarsening_and_refinement ();
1869 
1899  virtual bool prepare_coarsening_and_refinement ();
1900 
1901  /*
1902  * @}
1903  */
1904 
1919  {
1936  CELL_INVALID
1937  };
1938 
1944  template<typename T>
1946  {
1947  typedef T result_type;
1948 
1949  template<typename InputIterator>
1950  T operator()(InputIterator first, InputIterator last) const
1951  {
1952  // If there are no slots to call, just return the
1953  // default-constructed value
1954  if (first == last)
1955  return T();
1956 
1957  T sum = *first++;
1958  while (first != last)
1959  {
1960  sum += *first++;
1961  }
1962 
1963  return sum;
1964  }
1965  };
1966 
1976  struct Signals
1977  {
1985  boost::signals2::signal<void ()> create;
1986 
1994  boost::signals2::signal<void ()> pre_refinement;
1995 
2001  boost::signals2::signal<void ()> post_refinement;
2002 
2010  boost::signals2::signal<void (const typename Triangulation<dim, spacedim>::cell_iterator &cell)> pre_coarsening_on_cell;
2011 
2018  boost::signals2::signal<void (const typename Triangulation<dim, spacedim>::cell_iterator &cell)> post_refinement_on_cell;
2019 
2026  boost::signals2::signal<void (const Triangulation<dim, spacedim> &destination_tria)> copy;
2027 
2034  boost::signals2::signal<void ()> clear;
2035 
2045  boost::signals2::signal<void ()> any_change;
2046 
2070  boost::signals2::signal<unsigned int (const cell_iterator &,
2071  const CellStatus),
2073  };
2074 
2078  mutable Signals signals;
2079 
2080  /*
2081  * @}
2082  */
2083 
2093  void save_refine_flags (std::ostream &out) const;
2094 
2098  void save_refine_flags (std::vector<bool> &v) const;
2099 
2103  void load_refine_flags (std::istream &in);
2104 
2108  void load_refine_flags (const std::vector<bool> &v);
2109 
2113  void save_coarsen_flags (std::ostream &out) const;
2114 
2118  void save_coarsen_flags (std::vector<bool> &v) const;
2119 
2123  void load_coarsen_flags (std::istream &out);
2124 
2128  void load_coarsen_flags (const std::vector<bool> &v);
2129 
2134  bool get_anisotropic_refinement_flag() const;
2135 
2136  /*
2137  * @}
2138  */
2139 
2149  void clear_user_flags ();
2150 
2156  void save_user_flags (std::ostream &out) const;
2157 
2163  void save_user_flags (std::vector<bool> &v) const;
2164 
2169  void load_user_flags (std::istream &in);
2170 
2175  void load_user_flags (const std::vector<bool> &v);
2176 
2181  void clear_user_flags_line ();
2182 
2187  void save_user_flags_line (std::ostream &out) const;
2188 
2194  void save_user_flags_line (std::vector<bool> &v) const;
2195 
2200  void load_user_flags_line (std::istream &in);
2201 
2206  void load_user_flags_line (const std::vector<bool> &v);
2207 
2212  void clear_user_flags_quad ();
2213 
2218  void save_user_flags_quad (std::ostream &out) const;
2219 
2225  void save_user_flags_quad (std::vector<bool> &v) const;
2226 
2231  void load_user_flags_quad (std::istream &in);
2232 
2237  void load_user_flags_quad (const std::vector<bool> &v);
2238 
2239 
2244  void clear_user_flags_hex ();
2245 
2250  void save_user_flags_hex (std::ostream &out) const;
2251 
2257  void save_user_flags_hex (std::vector<bool> &v) const;
2258 
2263  void load_user_flags_hex (std::istream &in);
2264 
2269  void load_user_flags_hex (const std::vector<bool> &v);
2270 
2276  void clear_user_data ();
2277 
2283  void save_user_indices (std::vector<unsigned int> &v) const;
2284 
2289  void load_user_indices (const std::vector<unsigned int> &v);
2290 
2296  void save_user_pointers (std::vector<void *> &v) const;
2297 
2302  void load_user_pointers (const std::vector<void *> &v);
2303 
2309  void save_user_indices_line (std::vector<unsigned int> &v) const;
2310 
2315  void load_user_indices_line (const std::vector<unsigned int> &v);
2316 
2322  void save_user_indices_quad (std::vector<unsigned int> &v) const;
2323 
2328  void load_user_indices_quad (const std::vector<unsigned int> &v);
2329 
2335  void save_user_indices_hex (std::vector<unsigned int> &v) const;
2336 
2341  void load_user_indices_hex (const std::vector<unsigned int> &v);
2347  void save_user_pointers_line (std::vector<void *> &v) const;
2348 
2353  void load_user_pointers_line (const std::vector<void *> &v);
2354 
2360  void save_user_pointers_quad (std::vector<void *> &v) const;
2361 
2366  void load_user_pointers_quad (const std::vector<void *> &v);
2367 
2373  void save_user_pointers_hex (std::vector<void *> &v) const;
2374 
2379  void load_user_pointers_hex (const std::vector<void *> &v);
2380 
2381  /*
2382  * @}
2383  */
2384 
2393  cell_iterator begin (const unsigned int level = 0) const;
2394 
2407  active_cell_iterator begin_active(const unsigned int level = 0) const;
2408 
2413  cell_iterator end () const;
2414 
2419  cell_iterator end (const unsigned int level) const;
2420 
2426  active_cell_iterator end_active (const unsigned int level) const;
2427 
2428 
2432  cell_iterator last () const;
2433 
2437  active_cell_iterator last_active () const;
2438 
2453  IteratorRange<cell_iterator> cell_iterators () const;
2454 
2491  IteratorRange<active_cell_iterator> active_cell_iterators () const;
2492 
2508  IteratorRange<cell_iterator> cell_iterators_on_level (const unsigned int level) const;
2509 
2525  IteratorRange<active_cell_iterator> active_cell_iterators_on_level (const unsigned int level) const;
2526 
2527  /*
2528  * @}
2529  */
2530 
2531  /*---------------------------------------*/
2532  /*---------------------------------------*/
2533 
2542  face_iterator begin_face () const;
2543 
2547  active_face_iterator begin_active_face() const;
2548 
2553  face_iterator end_face () const;
2554 
2555  /*
2556  * @}
2557  */
2558 
2559  /*---------------------------------------*/
2560  /*---------------------------------------*/
2561 
2571  vertex_iterator begin_vertex() const;
2572 
2578  active_vertex_iterator begin_active_vertex() const;
2579 
2585  vertex_iterator end_vertex() const;
2586 
2587  /*
2588  * @}
2589  */
2590 
2608  unsigned int n_lines () const;
2609 
2613  unsigned int n_lines (const unsigned int level) const;
2614 
2618  unsigned int n_active_lines () const;
2619 
2623  unsigned int n_active_lines (const unsigned int level) const;
2624 
2628  unsigned int n_quads () const;
2629 
2633  unsigned int n_quads (const unsigned int level) const;
2634 
2638  unsigned int n_active_quads () const;
2639 
2643  unsigned int n_active_quads (const unsigned int level) const;
2644 
2648  unsigned int n_hexs() const;
2649 
2654  unsigned int n_hexs(const unsigned int level) const;
2655 
2659  unsigned int n_active_hexs() const;
2660 
2665  unsigned int n_active_hexs(const unsigned int level) const;
2666 
2671  unsigned int n_cells () const;
2672 
2677  unsigned int n_cells (const unsigned int level) const;
2678 
2683  unsigned int n_active_cells () const;
2684 
2692  virtual types::global_dof_index n_global_active_cells () const;
2693 
2694 
2699  unsigned int n_active_cells (const unsigned int level) const;
2700 
2706  unsigned int n_faces () const;
2707 
2713  unsigned int n_active_faces () const;
2714 
2732  unsigned int n_levels () const;
2733 
2740  virtual
2741  unsigned int n_global_levels () const;
2742 
2752  virtual
2753  bool has_hanging_nodes() const;
2754 
2762  unsigned int n_vertices () const;
2763 
2772  const std::vector<Point<spacedim> > &
2773  get_vertices () const;
2774 
2779  unsigned int n_used_vertices () const;
2780 
2784  bool vertex_used (const unsigned int index) const;
2785 
2790  const std::vector<bool> &
2791  get_used_vertices () const;
2792 
2804  unsigned int max_adjacent_cells () const;
2805 
2812  virtual types::subdomain_id locally_owned_subdomain () const;
2813 
2824  get_triangulation ();
2825 
2831  get_triangulation () const;
2832 
2833 
2834  /*
2835  * @}
2836  */
2837 
2852  unsigned int n_raw_lines () const;
2853 
2863  unsigned int n_raw_lines (const unsigned int level) const;
2864 
2874  unsigned int n_raw_quads () const;
2875 
2885  unsigned int n_raw_quads (const unsigned int level) const;
2886 
2896  unsigned int n_raw_hexs () const;
2897 
2907  unsigned int n_raw_hexs (const unsigned int level) const;
2908 
2918  unsigned int n_raw_cells (const unsigned int level) const;
2919 
2930  unsigned int n_raw_faces () const;
2931 
2932  /*
2933  * @}
2934  */
2935 
2944  virtual std::size_t memory_consumption () const;
2945 
2954  template <class Archive>
2955  void save (Archive &ar,
2956  const unsigned int version) const;
2957 
2973  template <class Archive>
2974  void load (Archive &ar,
2975  const unsigned int version);
2976 
2977  BOOST_SERIALIZATION_SPLIT_MEMBER()
2978 
2979 
2989  DeclException1 (ExcInvalidLevel,
2990  int,
2991  << "The given level " << arg1
2992  << " is not in the valid range!");
2999  DeclException2 (ExcTriangulationNotEmpty,
3000  int, int,
3001  << "You are trying to perform an operation on a triangulation "
3002  << "that is only allowed if the triangulation is currently empty. "
3003  << "However, it currently stores " << arg1 << " vertices and has "
3004  << "cells on " << arg2 << " levels.");
3010  DeclException0 (ExcGridReadError);
3015  DeclException0 (ExcFacesHaveNoLevel);
3021  DeclException1 (ExcEmptyLevel,
3022  int,
3023  << "You tried to do something on level " << arg1
3024  << ", but this level is empty.");
3030  DeclException0 (ExcNonOrientableTriangulation);
3031 
3039  DeclException1 (ExcBoundaryIdNotFound,
3040  types::boundary_id,
3041  << "The given boundary_id " << arg1
3042  << " is not defined in this Triangulation!");
3043 
3044  /*
3045  * @}
3046  */
3047 
3048 protected:
3053  MeshSmoothing smooth_grid;
3054 
3068  static void write_bool_vector (const unsigned int magic_number1,
3069  const std::vector<bool> &v,
3070  const unsigned int magic_number2,
3071  std::ostream &out);
3072 
3077  static void read_bool_vector (const unsigned int magic_number1,
3078  std::vector<bool> &v,
3079  const unsigned int magic_number2,
3080  std::istream &in);
3081 
3082 private:
3097  typedef TriaRawIterator <TriaAccessor<dim-1, dim, spacedim> > raw_face_iterator;
3098  typedef typename IteratorSelector::raw_vertex_iterator raw_vertex_iterator;
3099  typedef typename IteratorSelector::raw_line_iterator raw_line_iterator;
3100  typedef typename IteratorSelector::raw_quad_iterator raw_quad_iterator;
3101  typedef typename IteratorSelector::raw_hex_iterator raw_hex_iterator;
3102 
3107  raw_cell_iterator begin_raw (const unsigned int level = 0) const;
3108 
3113  raw_cell_iterator end_raw (const unsigned int level) const;
3114 
3115  /*
3116  * @}
3117  */
3118 
3130  raw_line_iterator
3131  begin_raw_line (const unsigned int level = 0) const;
3132 
3136  line_iterator
3137  begin_line (const unsigned int level = 0) const;
3138 
3142  active_line_iterator
3143  begin_active_line(const unsigned int level = 0) const;
3144 
3149  line_iterator end_line () const;
3150 
3151  /*
3152  * @}
3153  */
3154 
3165  raw_quad_iterator
3166  begin_raw_quad (const unsigned int level = 0) const;
3167 
3171  quad_iterator
3172  begin_quad (const unsigned int level = 0) const;
3173 
3177  active_quad_iterator
3178  begin_active_quad (const unsigned int level = 0) const;
3179 
3184  quad_iterator
3185  end_quad () const;
3186 
3187  /*
3188  * @}
3189  */
3190 
3200  raw_hex_iterator
3201  begin_raw_hex (const unsigned int level = 0) const;
3202 
3206  hex_iterator
3207  begin_hex (const unsigned int level = 0) const;
3208 
3212  active_hex_iterator
3213  begin_active_hex (const unsigned int level = 0) const;
3214 
3219  hex_iterator
3220  end_hex () const;
3221 
3222  /*
3223  * @}
3224  */
3225 
3226 
3240  void clear_despite_subscriptions ();
3241 
3248  void reset_active_cell_indices ();
3249 
3263  DistortedCellList execute_refinement ();
3264 
3271  void execute_coarsening ();
3272 
3277  void fix_coarsen_flags ();
3278 
3283  std::vector<::internal::Triangulation::TriaLevel<dim>*> levels;
3284 
3290  ::internal::Triangulation::TriaFaces<dim> *faces;
3291 
3292 
3296  std::vector<Point<spacedim> > vertices;
3297 
3301  std::vector<bool> vertices_used;
3302 
3307  std::map<types::manifold_id, SmartPointer<const Manifold<dim,spacedim> , Triangulation<dim, spacedim> > > manifold;
3308 
3309 
3313  bool anisotropic_refinement;
3314 
3315 
3320  const bool check_for_distorted_cells;
3321 
3331  ::internal::Triangulation::NumberCache<dim> number_cache;
3332 
3347  std::map<unsigned int, types::boundary_id> *vertex_to_boundary_id_map_1d;
3348 
3349 
3369  std::map<unsigned int, types::manifold_id> *vertex_to_manifold_id_map_1d;
3370 
3371  // make a couple of classes friends
3372  template <int,int,int> friend class TriaAccessorBase;
3373  template <int,int,int> friend class TriaAccessor;
3374  friend class TriaAccessor<0, 1, spacedim>;
3375 
3376  friend class CellAccessor<dim, spacedim>;
3377 
3378  friend struct ::internal::TriaAccessor::Implementation;
3379 
3380  friend class hp::DoFHandler<dim,spacedim>;
3381 
3382  friend struct ::internal::Triangulation::Implementation;
3383 
3384  template <typename>
3385  friend class ::internal::Triangulation::TriaObjects;
3386 };
3387 
3388 
3389 #ifndef DOXYGEN
3390 
3391 
3392 template <int structdim>
3393 inline
3395 {
3396  for (unsigned int i=0; i<GeometryInfo<structdim>::vertices_per_cell; ++i)
3397  vertices[i] = numbers::invalid_unsigned_int;
3398 
3399  material_id = 0;
3400 
3401  // And the manifold to be invalid
3402  manifold_id = numbers::invalid_manifold_id;
3403 }
3404 
3405 
3406 
3407 namespace internal
3408 {
3409  namespace Triangulation
3410  {
3411  template <class Archive>
3412  void NumberCache<1>::serialize (Archive &ar,
3413  const unsigned int)
3414  {
3415  ar &n_levels;
3416  ar &n_lines &n_lines_level;
3417  ar &n_active_lines &n_active_lines_level;
3418  }
3419 
3420 
3421  template <class Archive>
3422  void NumberCache<2>::serialize (Archive &ar,
3423  const unsigned int version)
3424  {
3425  this->NumberCache<1>::serialize (ar, version);
3426 
3427  ar &n_quads &n_quads_level;
3428  ar &n_active_quads &n_active_quads_level;
3429  }
3430 
3431 
3432  template <class Archive>
3433  void NumberCache<3>::serialize (Archive &ar,
3434  const unsigned int version)
3435  {
3436  this->NumberCache<2>::serialize (ar, version);
3437 
3438  ar &n_hexes &n_hexes_level;
3439  ar &n_active_hexes &n_active_hexes_level;
3440  }
3441 
3442  }
3443 }
3444 
3445 
3446 template <int dim, int spacedim>
3447 inline
3448 bool
3449 Triangulation<dim,spacedim>::vertex_used(const unsigned int index) const
3450 {
3451  Assert (index < vertices_used.size(),
3452  ExcIndexRange(index, 0, vertices_used.size()));
3453  return vertices_used[index];
3454 }
3455 
3456 
3457 
3458 template <int dim, int spacedim>
3459 inline
3460 unsigned int Triangulation<dim, spacedim>::n_levels () const
3461 {
3462  return number_cache.n_levels;
3463 }
3464 
3465 template <int dim, int spacedim>
3466 inline
3468 {
3469  return number_cache.n_levels;
3470 }
3471 
3472 
3473 template <int dim, int spacedim>
3474 inline
3475 unsigned int
3477 {
3478  return vertices.size();
3479 }
3480 
3481 
3482 
3483 template <int dim, int spacedim>
3484 inline
3485 const std::vector<Point<spacedim> > &
3487 {
3488  return vertices;
3489 }
3490 
3491 
3492 template <int dim, int spacedim>
3493 template <class Archive>
3494 void
3496  const unsigned int) const
3497 {
3498  // as discussed in the documentation, do not store the signals as
3499  // well as boundary and manifold description but everything else
3500  ar &smooth_grid;
3501  ar &levels;
3502  ar &faces;
3503  ar &vertices;
3504  ar &vertices_used;
3505 
3506  ar &anisotropic_refinement;
3507  ar &number_cache;
3508 
3509  ar &check_for_distorted_cells;
3510 
3511  if (dim == 1)
3512  {
3513  ar &vertex_to_boundary_id_map_1d;
3514  ar &vertex_to_manifold_id_map_1d;
3515  }
3516 }
3517 
3518 
3519 
3520 template <int dim, int spacedim>
3521 template <class Archive>
3522 void
3524  const unsigned int)
3525 {
3526  // clear previous content. this also calls the respective signal
3527  clear ();
3528 
3529  // as discussed in the documentation, do not store the signals as
3530  // well as boundary and manifold description but everything else
3531  ar &smooth_grid;
3532  ar &levels;
3533  ar &faces;
3534  ar &vertices;
3535  ar &vertices_used;
3536 
3537  ar &anisotropic_refinement;
3538  ar &number_cache;
3539 
3540  // the levels do not serialize the active_cell_indices because
3541  // they are easy enough to rebuild upon re-loading data. do
3542  // this here. don't forget to first resize the fields appropriately
3543  {
3544  for (unsigned int l=0; l<levels.size(); ++l)
3545  levels[l]->active_cell_indices.resize (levels[l]->refine_flags.size());
3546  reset_active_cell_indices ();
3547  }
3548 
3549 
3550  bool my_check_for_distorted_cells;
3551  ar &my_check_for_distorted_cells;
3552 
3553  Assert (my_check_for_distorted_cells == check_for_distorted_cells,
3554  ExcMessage ("The triangulation loaded into here must have the "
3555  "same setting with regard to reporting distorted "
3556  "cell as the one previously stored."));
3557 
3558  if (dim == 1)
3559  {
3560  ar &vertex_to_boundary_id_map_1d;
3561  ar &vertex_to_manifold_id_map_1d;
3562  }
3563 
3564  // trigger the create signal to indicate
3565  // that new content has been imported into
3566  // the triangulation
3567  signals.create();
3568 }
3569 
3570 
3571 /* -------------- declaration of explicit specializations ------------- */
3572 
3573 template <> unsigned int Triangulation<1,1>::n_raw_lines (const unsigned int level) const;
3574 template <> unsigned int Triangulation<1,1>::n_quads () const;
3575 template <> unsigned int Triangulation<1,1>::n_quads (const unsigned int level) const;
3576 template <> unsigned int Triangulation<1,1>::n_raw_quads (const unsigned int level) const;
3577 template <> unsigned int Triangulation<2,2>::n_raw_quads (const unsigned int level) const;
3578 template <> unsigned int Triangulation<1,1>::n_raw_hexs (const unsigned int level) const;
3579 template <> unsigned int Triangulation<1,1>::n_active_quads (const unsigned int level) const;
3580 template <> unsigned int Triangulation<1,1>::n_active_quads () const;
3581 template <> unsigned int Triangulation<1,1>::max_adjacent_cells () const;
3582 
3583 
3584 // -------------------------------------------------------------------
3585 // -- Explicit specializations for codimension one grids
3586 
3587 
3588 template <> unsigned int Triangulation<1,2>::n_raw_lines (const unsigned int level) const;
3589 template <> unsigned int Triangulation<1,2>::n_quads () const;
3590 template <> unsigned int Triangulation<1,2>::n_quads (const unsigned int level) const;
3591 template <> unsigned int Triangulation<1,2>::n_raw_quads (const unsigned int level) const;
3592 template <> unsigned int Triangulation<2,3>::n_raw_quads (const unsigned int level) const;
3593 template <> unsigned int Triangulation<1,2>::n_raw_hexs (const unsigned int level) const;
3594 template <> unsigned int Triangulation<1,2>::n_active_quads (const unsigned int level) const;
3595 template <> unsigned int Triangulation<1,2>::n_active_quads () const;
3596 template <> unsigned int Triangulation<1,2>::max_adjacent_cells () const;
3597 
3598 // -------------------------------------------------------------------
3599 // -- Explicit specializations for codimension two grids
3600 
3601 
3602 template <> unsigned int Triangulation<1,3>::n_raw_lines (const unsigned int level) const;
3603 template <> unsigned int Triangulation<1,3>::n_quads () const;
3604 template <> unsigned int Triangulation<1,3>::n_quads (const unsigned int level) const;
3605 template <> unsigned int Triangulation<1,3>::n_raw_quads (const unsigned int level) const;
3606 template <> unsigned int Triangulation<2,3>::n_raw_quads (const unsigned int level) const;
3607 template <> unsigned int Triangulation<1,3>::n_raw_hexs (const unsigned int level) const;
3608 template <> unsigned int Triangulation<1,3>::n_active_quads (const unsigned int level) const;
3609 template <> unsigned int Triangulation<1,3>::n_active_quads () const;
3610 template <> unsigned int Triangulation<1,3>::max_adjacent_cells () const;
3611 
3612 
3613 // -------------------------------------------------------------------
3614 // Explicit invalid things...
3615 template <>
3617 template <>
3619 template <>
3621 
3622 
3623 #endif // DOXYGEN
3624 
3625 DEAL_II_NAMESPACE_CLOSE
3626 
3627 // Include tria_accessor.h here, so that it is possible for an end
3628 // user to use the iterators of Triangulation<dim> directly without
3629 // the need to include tria_accessor.h separately. (Otherwise the
3630 // iterators are an 'opaque' or 'incomplete' type.)
3631 #include <deal.II/grid/tria_accessor.h>
3632 
3633 #endif
std::vector< CellData< 1 > > boundary_lines
Definition: tria.h:179
TriaActiveIterator< CellAccessor< dim, spacedim > > active_cell_iterator
Definition: tria.h:1410
boost::signals2::signal< void()> any_change
Definition: tria.h:2045
unsigned int n_vertices() const
static const unsigned int invalid_unsigned_int
Definition: types.h:164
unsigned int n_raw_hexs() const
std::list< typename Triangulation< dim, spacedim >::cell_iterator > distorted_cells
Definition: tria.h:1460
unsigned char material_id
Definition: types.h:130
boost::signals2::signal< void()> clear
Definition: tria.h:2034
::ExceptionBase & ExcMessage(std::string arg1)
boost::signals2::signal< unsigned int(const cell_iterator &, const CellStatus), CellWeightSum< unsigned int > > cell_weight
Definition: tria.h:2072
std::vector< unsigned int > n_active_lines_level
Definition: tria.h:269
DeclException1(ExcGridHasInvalidCell, int,<< "Something went wrong when making cell "<< arg1<< ". Read the docs and the source code "<< "for more information.")
std::vector< unsigned int > n_hexes_level
Definition: tria.h:376
std::vector< unsigned int > n_quads_level
Definition: tria.h:317
STL namespace.
std::vector< unsigned int > n_active_quads_level
Definition: tria.h:327
Definition: point.h:89
void serialize(Archive &ar, const unsigned int version)
unsigned int n_levels() const
BlockDynamicSparsityPattern BlockCompressedSparsityPattern DEAL_II_DEPRECATED
Definition: tria.h:46
boost::signals2::signal< void()> pre_refinement
Definition: tria.h:1994
TriaIterator< CellAccessor< dim, spacedim > > cell_iterator
Definition: tria.h:1392
Definition: types.h:30
unsigned int global_dof_index
Definition: types.h:88
unsigned int n_raw_quads() const
Definition: tria.cc:11381
#define Assert(cond, exc)
Definition: exceptions.h:294
Signals signals
Definition: tria.h:2078
boost::signals2::signal< void()> create
Definition: tria.h:1985
static const StraightBoundary< dim, spacedim > straight_boundary
Definition: tria.h:1171
unsigned int max_adjacent_cells() const
Definition: tria.cc:11542
void load(Archive &ar, const unsigned int version)
unsigned int n_quads() const
Definition: tria.cc:11335
const std::vector< Point< spacedim > > & get_vertices() const
unsigned int n_raw_lines() const
Definition: tria.cc:11171
::internal::Triangulation::Iterators< dim, spacedim > IteratorSelector
Definition: tria.h:1164
void save(Archive &ar, const unsigned int version) const
unsigned int subdomain_id
Definition: types.h:42
boost::signals2::signal< void()> post_refinement
Definition: tria.h:2001
DeclException2(ExcLineInexistant, int, int,<< "While trying to assign a boundary indicator to a line: "<< "the line with end vertices "<< arg1<< " and "<< arg2<< " does not exist.")
Definition: hp.h:102
unsigned int n_active_quads() const
Definition: tria.cc:11398
types::manifold_id manifold_id
Definition: tria.h:131
const types::manifold_id invalid_manifold_id
Definition: types.h:220
std::vector< unsigned int > n_active_hexes_level
Definition: tria.h:386
unsigned int manifold_id
Definition: types.h:122
void serialize(Archive &ar, const unsigned int version)
virtual unsigned int n_global_levels() const
std::vector< CellData< 2 > > boundary_quads
Definition: tria.h:185
void serialize(Archive &ar, const unsigned int version)
unsigned char boundary_id
Definition: types.h:110
bool vertex_used(const unsigned int index) const
const Manifold< dim, spacedim > & get_manifold(const types::manifold_id number) const
Definition: tria.cc:8955
std::vector< unsigned int > n_lines_level
Definition: tria.h:259