Reference documentation for deal.II version 8.4.2
tria_accessor.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_accessor_h
17 #define dealii__tria_accessor_h
18 
19 
20 #include <deal.II/base/config.h>
21 #include <deal.II/base/exceptions.h>
22 #include <deal.II/base/geometry_info.h>
23 #include <deal.II/base/point.h>
24 #include <deal.II/grid/tria_iterator_base.h>
25 #include <deal.II/grid/tria_iterator_selector.h>
26 #include <deal.II/grid/cell_id.h>
27 
28 #include <utility>
29 
30 
31 DEAL_II_NAMESPACE_OPEN
32 
33 template <int dim, int spacedim> class Triangulation;
34 template <typename Accessor> class TriaRawIterator;
35 template <typename Accessor> class TriaIterator;
36 template <typename Accessor> class TriaActiveIterator;
37 
38 template <int dim, int spacedim> class Boundary;
39 template <int dim, int spacedim> class Manifold;
40 
41 
42 namespace internal
43 {
44  namespace Triangulation
45  {
46  template <int dim> class TriaObject;
47  template <typename G> class TriaObjects;
48  struct Implementation;
49  }
50 
51  namespace TriaAccessor
52  {
53  struct Implementation;
54 
60  template <int structdim, int dim> struct PresentLevelType
61  {
62  struct type
63  {
67  type ()
68  {}
69 
73  type (const int level)
74  {
75  Assert (level == 0, ExcInternalError());
76  (void)level; // removes -Wunused-parameter warning in optimized mode
77  }
78 
82  operator int () const
83  {
84  return 0;
85  }
86 
87  void operator ++ () const
88  {
89  Assert (false, ExcInternalError());
90  }
91 
92  void operator -- () const
93  {
94  Assert (false, ExcInternalError());
95  }
96  };
97  };
98 
99 
105  template <int dim> struct PresentLevelType<dim,dim>
106  {
107  typedef int type;
108  };
109 
110  }
111 }
112 template <int structdim, int dim, int spacedim> class TriaAccessor;
113 template <int dim, int spacedim> class TriaAccessor<0, dim, spacedim>;
114 template <int spacedim> class TriaAccessor<0, 1, spacedim>;
115 
116 // note: the file tria_accessor.templates.h is included at the end of
117 // this file. this includes a lot of templates. originally, this was
118 // only done in debug mode, but led to cyclic reduction problems and
119 // so is now on by default.
120 
121 
126 {
127 //TODO: Write documentation!
131  DeclException0 (ExcCellNotUsed);
141  DeclException0 (ExcCellNotActive);
147  DeclException0 (ExcCellHasNoChildren);
154  DeclException0 (ExcCellHasNoParent);
155 //TODO: Write documentation!
159  DeclException0 (ExcUnusedCellAsChild);
160 //TODO: Write documentation!
164  DeclException1 (ExcCantSetChildren,
165  int,
166  << "You can only set the child index if the cell has no "
167  << "children, or clear it. The given "
168  << "index was " << arg1 << " (-1 means: clear children)");
169 //TODO: Write documentation!
173  DeclException0 (ExcUnusedCellAsNeighbor);
174 //TODO: Write documentation!
178  DeclException0 (ExcUncaughtCase);
179 //TODO: Write documentation!
183  DeclException0 (ExcDereferenceInvalidObject);
184 //TODO: Write documentation!
188  DeclException0 (ExcCantCompareIterators);
189 //TODO: Write documentation!
193  DeclException0 (ExcNeighborIsCoarser);
194 //TODO: Write documentation!
198  DeclException0 (ExcNeighborIsNotCoarser);
206  DeclException0 (ExcFacesHaveNoLevel);
207 //TODO: Write documentation!
211  DeclException1 (ExcSetOnlyEvenChildren,
212  int,
213  << "You can only set the child index of an even numbered child."
214  << "The number of the child given was " << arg1 << ".");
215 }
216 
217 
244 template <int structdim, int dim, int spacedim=dim>
246 {
247 public:
253  static const unsigned int space_dimension = spacedim;
254 
260  static const unsigned int dimension = dim;
261 
267  static const unsigned int structure_dimension = structdim;
268 
269 protected:
275  typedef void AccessorData;
276 
281  const int level = -1,
282  const int index = -1,
283  const AccessorData * = 0);
284 
289 
297  void copy_from (const TriaAccessorBase &);
298 
302  TriaAccessorBase &operator = (const TriaAccessorBase &);
303 
310  bool operator < (const TriaAccessorBase &other) const;
311 
312 protected:
322  void operator = (const TriaAccessorBase *);
323 
327  bool operator == (const TriaAccessorBase &) const;
328 
332  bool operator != (const TriaAccessorBase &) const;
333 
347  void operator ++ ();
348 
356  void operator -- ();
365  objects () const;
366 
367 public:
373  typedef void *LocalData;
374 
398  int level () const;
399 
426  int index () const;
427 
432  IteratorState::IteratorStates state () const;
433 
438  const Triangulation<dim,spacedim> &get_triangulation () const;
439 
443 protected:
448  typename ::internal::TriaAccessor::PresentLevelType<structdim,dim>::type present_level;
449 
455 
460 
461 private:
462 
463  template <typename Accessor> friend class TriaRawIterator;
464  template <typename Accessor> friend class TriaIterator;
465  template <typename Accessor> friend class TriaActiveIterator;
466 };
467 
468 
469 
490 template <int structdim, int dim, int spacedim=dim>
491 class InvalidAccessor : public TriaAccessorBase<structdim,dim,spacedim>
492 {
493 public:
498 
506  InvalidAccessor (const Triangulation<dim,spacedim> *parent = 0,
507  const int level = -1,
508  const int index = -1,
509  const AccessorData *local_data = 0);
510 
519 
524  template <typename OtherAccessor>
525  InvalidAccessor (const OtherAccessor &);
526 
530  void copy_from (const InvalidAccessor &);
531 
535  bool operator == (const InvalidAccessor &) const;
536  bool operator != (const InvalidAccessor &) const;
537 
541  void operator ++ () const;
542  void operator -- () const;
543 
548  bool used () const;
549 
554  bool has_children () const;
555 };
556 
557 
558 
574 template <int structdim, int dim, int spacedim>
575 class TriaAccessor : public TriaAccessorBase<structdim, dim, spacedim>
576 {
577 public:
581  typedef
584 
588  TriaAccessor (const Triangulation<dim,spacedim> *parent = 0,
589  const int level = -1,
590  const int index = -1,
591  const AccessorData *local_data = 0);
592 
605  template <int structdim2, int dim2, int spacedim2>
607 
612  template <int structdim2, int dim2, int spacedim2>
614 
621  bool used () const;
622 
634  typename ::internal::Triangulation::Iterators<dim,spacedim>::vertex_iterator
635  vertex_iterator (const unsigned int i) const;
636 
652  unsigned int vertex_index (const unsigned int i) const;
653 
691  Point<spacedim> &vertex (const unsigned int i) const;
692 
696  typename ::internal::Triangulation::Iterators<dim,spacedim>::line_iterator
697  line (const unsigned int i) const;
698 
705  unsigned int line_index (const unsigned int i) const;
706 
710  typename ::internal::Triangulation::Iterators<dim,spacedim>::quad_iterator
711  quad (const unsigned int i) const;
712 
719  unsigned int quad_index (const unsigned int i) const;
742  bool face_orientation (const unsigned int face) const;
743 
753  bool face_flip (const unsigned int face) const;
754 
764  bool face_rotation (const unsigned int face) const;
765 
776  bool line_orientation (const unsigned int line) const;
791  bool has_children () const;
792 
797  unsigned int n_children() const;
798 
812  unsigned int number_of_children () const;
813 
827  unsigned int max_refinement_depth () const;
828 
833  child (const unsigned int i) const;
834 
844  isotropic_child (const unsigned int i) const;
845 
849  RefinementCase<structdim> refinement_case () const;
850 
856  int child_index (const unsigned int i) const;
857 
863  int isotropic_child_index (const unsigned int i) const;
885  types::boundary_id boundary_id () const;
886 
893  types::boundary_id boundary_indicator () const DEAL_II_DEPRECATED;
894 
924  void set_boundary_id (const types::boundary_id) const;
925 
932  void set_boundary_indicator (const types::boundary_id) const DEAL_II_DEPRECATED;
933 
964  void set_all_boundary_ids (const types::boundary_id) const;
965 
972  void set_all_boundary_indicators (const types::boundary_id) const DEAL_II_DEPRECATED;
973 
981  bool at_boundary () const;
982 
988  const Boundary<dim,spacedim> &get_boundary () const;
989 
999  const Manifold<dim,spacedim> &get_manifold () const;
1000 
1021  types::manifold_id manifold_id () const;
1022 
1040  void set_manifold_id (const types::manifold_id) const;
1041 
1055  void set_all_manifold_ids (const types::manifold_id) const;
1056 
1073  bool user_flag_set () const;
1074 
1080  void set_user_flag () const;
1081 
1087  void clear_user_flag () const;
1088 
1094  void recursively_set_user_flag () const;
1095 
1101  void recursively_clear_user_flag () const;
1102 
1108  void clear_user_data () const;
1109 
1121  void set_user_pointer (void *p) const;
1122 
1128  void clear_user_pointer () const;
1129 
1145  void *user_pointer () const;
1146 
1168  void recursively_set_user_pointer (void *p) const;
1169 
1176  void recursively_clear_user_pointer () const;
1177 
1187  void set_user_index (const unsigned int p) const;
1188 
1194  void clear_user_index () const;
1195 
1207  unsigned int user_index () const;
1208 
1226  void recursively_set_user_index (const unsigned int p) const;
1227 
1236  void recursively_clear_user_index () const;
1255  double diameter () const;
1256 
1266  double extent_in_direction (const unsigned int axis) const;
1267 
1271  double minimum_vertex_distance () const;
1272 
1286  Point<spacedim> intermediate_point(const Point<structdim> &coordinates) const;
1287 
1306  Point<spacedim> center (const bool respect_manifold=false,
1307  const bool use_laplace_transformation=false) const;
1308 
1312  Point<spacedim> barycenter () const;
1313 
1339  double measure () const;
1340 
1355  bool
1356  is_translation_of (const TriaIterator<TriaAccessor<structdim,dim,spacedim> > &o) const;
1357 
1363 private:
1368  void set (const ::internal::Triangulation::TriaObject<structdim> &o) const;
1369 
1377  void set_line_orientation (const unsigned int line,
1378  const bool orientation) const;
1379 
1390  void set_face_orientation (const unsigned int face,
1391  const bool orientation) const;
1392 
1399  void set_face_flip (const unsigned int face,
1400  const bool flip) const;
1401 
1408  void set_face_rotation (const unsigned int face,
1409  const bool rotation) const;
1410 
1414  void set_used_flag () const;
1415 
1419  void clear_used_flag () const;
1420 
1429  void set_refinement_case (const RefinementCase<structdim> &ref_case) const;
1430 
1438  void clear_refinement_case () const;
1439 
1446  void set_children (const unsigned int i, const int index) const;
1447 
1452  void clear_children () const;
1453 
1454 private:
1465  void operator = (const TriaAccessor &);
1466 
1467  template <int, int> friend class Triangulation;
1468 
1469  friend struct ::internal::Triangulation::Implementation;
1470  friend struct ::internal::TriaAccessor::Implementation;
1471 };
1472 
1473 
1474 
1475 
1476 
1477 
1491 template<int dim, int spacedim>
1492 class TriaAccessor<0, dim, spacedim>
1493 {
1494 public:
1500  static const unsigned int space_dimension = spacedim;
1501 
1507  static const unsigned int dimension = dim;
1508 
1514  static const unsigned int structure_dimension = 0;
1515 
1519  typedef void AccessorData;
1520 
1525  TriaAccessor (const Triangulation<dim,spacedim> *tria,
1526  const unsigned int vertex_index);
1527 
1533  TriaAccessor (const Triangulation<dim,spacedim> *tria = NULL,
1534  const int level = 0,
1535  const int index = 0,
1536  const AccessorData * = 0);
1537 
1541  template <int structdim2, int dim2, int spacedim2>
1542  TriaAccessor (const TriaAccessor<structdim2,dim2,spacedim2> &);
1543 
1547  template <int structdim2, int dim2, int spacedim2>
1548  TriaAccessor (const InvalidAccessor<structdim2,dim2,spacedim2> &);
1549 
1553  IteratorState::IteratorStates state () const;
1554 
1559  static int level ();
1560 
1565  int index () const;
1566 
1576  void operator ++ ();
1577 
1581  void operator -- ();
1585  bool operator == (const TriaAccessor &) const;
1586 
1590  bool operator != (const TriaAccessor &) const;
1591 
1619  unsigned int vertex_index (const unsigned int i = 0) const;
1620 
1626  Point<spacedim> &vertex (const unsigned int i = 0) const;
1627 
1632  typename ::internal::Triangulation::Iterators<dim,spacedim>::line_iterator
1633  static line (const unsigned int);
1634 
1638  static unsigned int line_index (const unsigned int i);
1639 
1643  static
1644  typename ::internal::Triangulation::Iterators<dim,spacedim>::quad_iterator
1645  quad (const unsigned int i);
1646 
1650  static unsigned int quad_index (const unsigned int i);
1651 
1667  double diameter () const;
1668 
1676  double extent_in_direction (const unsigned int axis) const;
1677 
1685  Point<spacedim> center (const bool respect_manifold=false,
1686  const bool use_laplace_transformation=false) const;
1687 
1696  double measure () const;
1711  static bool face_orientation (const unsigned int face);
1712 
1716  static bool face_flip (const unsigned int face);
1717 
1721  static bool face_rotation (const unsigned int face);
1722 
1726  static bool line_orientation (const unsigned int line);
1727 
1742  static bool has_children ();
1743 
1748  static unsigned int n_children();
1749 
1754  static unsigned int number_of_children ();
1755 
1759  static unsigned int max_refinement_depth ();
1760 
1764  static
1766  child (const unsigned int);
1767 
1771  static
1773  isotropic_child (const unsigned int);
1774 
1778  static
1779  RefinementCase<0> refinement_case ();
1780 
1784  static
1785  int child_index (const unsigned int i);
1786 
1790  static
1791  int isotropic_child_index (const unsigned int i);
1799  bool used () const;
1800 
1801 protected:
1809  void copy_from (const TriaAccessor &);
1810 
1815 
1819  unsigned int global_vertex_index;
1820 
1821 private:
1822 
1823  template <typename Accessor> friend class TriaRawIterator;
1824  template <typename Accessor> friend class TriaIterator;
1825  template <typename Accessor> friend class TriaActiveIterator;
1826 };
1827 
1828 
1829 
1839 template <int spacedim>
1840 class TriaAccessor<0, 1, spacedim>
1841 {
1842 public:
1848  static const unsigned int space_dimension = spacedim;
1849 
1855  static const unsigned int dimension = 1;
1856 
1862  static const unsigned int structure_dimension = 0;
1863 
1867  typedef void AccessorData;
1868 
1874  {
1875  left_vertex,
1876  interior_vertex,
1877  right_vertex
1878  };
1879 
1892  const VertexKind vertex_kind,
1893  const unsigned int vertex_index);
1894 
1900  TriaAccessor (const Triangulation<1,spacedim> *tria = 0,
1901  const int = 0,
1902  const int = 0,
1903  const AccessorData * = 0);
1904 
1908  template <int structdim2, int dim2, int spacedim2>
1910 
1914  template <int structdim2, int dim2, int spacedim2>
1915  TriaAccessor (const InvalidAccessor<structdim2,dim2,spacedim2> &);
1916 
1921  void copy_from (const TriaAccessor &);
1922 
1928  static IteratorState::IteratorStates state ();
1929 
1934  static int level ();
1935 
1940  int index () const;
1941 
1952  void operator ++ () const;
1953 
1958  void operator -- () const;
1962  bool operator == (const TriaAccessor &) const;
1963 
1967  bool operator != (const TriaAccessor &) const;
1968 
1995  unsigned int vertex_index (const unsigned int i = 0) const;
1996 
2002  Point<spacedim> &vertex (const unsigned int i = 0) const;
2003 
2008  Point<spacedim> center () const;
2009 
2014  typename ::internal::Triangulation::Iterators<1,spacedim>::line_iterator
2015  static line (const unsigned int);
2016 
2023  static unsigned int line_index (const unsigned int i);
2024 
2028  static
2029  typename ::internal::Triangulation::Iterators<1,spacedim>::quad_iterator
2030  quad (const unsigned int i);
2031 
2038  static unsigned int quad_index (const unsigned int i);
2039 
2049  bool at_boundary () const;
2050 
2065  types::boundary_id boundary_id () const;
2066 
2073  types::boundary_id boundary_indicator () const DEAL_II_DEPRECATED;
2074 
2081  types::manifold_id manifold_id () const;
2082 
2083 
2094  static bool face_orientation (const unsigned int face);
2095 
2099  static bool face_flip (const unsigned int face);
2100 
2104  static bool face_rotation (const unsigned int face);
2105 
2109  static bool line_orientation (const unsigned int line);
2110 
2125  static bool has_children ();
2126 
2131  static unsigned int n_children();
2132 
2137  static unsigned int number_of_children ();
2138 
2142  static unsigned int max_refinement_depth ();
2143 
2147  static
2149  child (const unsigned int);
2150 
2154  static
2156  isotropic_child (const unsigned int);
2157 
2161  static
2162  RefinementCase<0> refinement_case ();
2163 
2167  static
2168  int child_index (const unsigned int i);
2169 
2173  static
2174  int isotropic_child_index (const unsigned int i);
2207  void
2208  set_boundary_id (const types::boundary_id);
2209 
2216  void set_boundary_indicator (const types::boundary_id) DEAL_II_DEPRECATED;
2217 
2224  void
2225  set_manifold_id (const types::manifold_id);
2226 
2238  void
2239  set_all_boundary_ids (const types::boundary_id);
2240 
2247  void set_all_boundary_indicators (const types::boundary_id) DEAL_II_DEPRECATED;
2248 
2260  void
2261  set_all_manifold_ids (const types::manifold_id);
2269  bool used () const;
2270 
2271 protected:
2276 
2282 
2286  unsigned int global_vertex_index;
2287 };
2288 
2289 
2290 
2291 
2308 template <int dim, int spacedim=dim>
2309 class CellAccessor : public TriaAccessor<dim,dim,spacedim>
2310 {
2311 public:
2316 
2321 
2332  CellAccessor (const Triangulation<dim,spacedim> *parent = 0,
2333  const int level = -1,
2334  const int index = -1,
2335  const AccessorData *local_data = 0);
2336 
2340  CellAccessor (const TriaAccessor<dim,dim,spacedim> &cell_accessor);
2341 
2354  template <int structdim2, int dim2, int spacedim2>
2356 
2361  template <int structdim2, int dim2, int spacedim2>
2363 
2380  child (const unsigned int i) const;
2381 
2385  TriaIterator<TriaAccessor<dim-1,dim,spacedim> >
2386  face (const unsigned int i) const;
2387 
2397  unsigned int
2398  face_index (const unsigned int i) const;
2399 
2448  neighbor_child_on_subface (const unsigned int face_no,
2449  const unsigned int subface_no) const;
2450 
2473  neighbor (const unsigned int i) const;
2474 
2479  int neighbor_index (const unsigned int i) const;
2480 
2485  int neighbor_level (const unsigned int i) const;
2486 
2498  unsigned int neighbor_of_neighbor (const unsigned int neighbor) const;
2499 
2510  bool neighbor_is_coarser (const unsigned int neighbor) const;
2511 
2526  std::pair<unsigned int, unsigned int>
2527  neighbor_of_coarser_neighbor (const unsigned int neighbor) const;
2528 
2535  unsigned int neighbor_face_no (const unsigned int neighbor) const;
2536 
2553  bool at_boundary (const unsigned int i) const;
2554 
2563  bool at_boundary () const;
2564 
2572  bool has_boundary_lines () const;
2598  RefinementCase<dim> refine_flag_set () const;
2599 
2605  void set_refine_flag (const RefinementCase<dim> ref_case = RefinementCase<dim>::isotropic_refinement) const;
2606 
2610  void clear_refine_flag () const;
2611 
2619  bool flag_for_face_refinement (const unsigned int face_no,
2620  const RefinementCase<dim-1> &face_refinement_case=RefinementCase<dim-1>::isotropic_refinement) const;
2621 
2627  bool flag_for_line_refinement (const unsigned int line_no) const;
2628 
2637  ::internal::SubfaceCase<dim> subface_case(const unsigned int face_no) const;
2638 
2642  bool coarsen_flag_set () const;
2643 
2648  void set_coarsen_flag () const;
2649 
2653  void clear_coarsen_flag () const;
2676  types::material_id material_id () const;
2677 
2689  void set_material_id (const types::material_id new_material_id) const;
2690 
2699  void recursively_set_material_id (const types::material_id new_material_id) const;
2725  types::subdomain_id subdomain_id () const;
2726 
2742  void set_subdomain_id (const types::subdomain_id new_subdomain_id) const;
2743 
2748  types::subdomain_id level_subdomain_id () const;
2749 
2754  void set_level_subdomain_id (const types::subdomain_id new_level_subdomain_id) const;
2755 
2756 
2772  void recursively_set_subdomain_id (const types::subdomain_id new_subdomain_id) const;
2790  bool direction_flag () const;
2791 
2817  unsigned int active_cell_index () const;
2818 
2826  int parent_index () const;
2827 
2834  parent () const;
2835 
2855  bool active () const;
2856 
2876  bool is_locally_owned () const;
2877 
2882  bool is_locally_owned_on_level () const;
2883 
2907  bool is_ghost () const;
2908 
2935  bool is_artificial () const;
2936 
2950  bool point_inside (const Point<spacedim> &p) const;
2951 
2960  void set_neighbor (const unsigned int i,
2961  const TriaIterator<CellAccessor<dim, spacedim> > &pointer) const;
2962 
2976  CellId id() const;
2977 
2986  DeclException0 (ExcRefineCellNotActive);
2990  DeclException0 (ExcCellFlaggedForRefinement);
2994  DeclException0 (ExcCellFlaggedForCoarsening);
2995 
2996 protected:
3012  unsigned int neighbor_of_neighbor_internal (const unsigned int neighbor) const;
3013 
3019  template<int dim_,int spacedim_ >
3020  bool point_inside_codim(const Point<spacedim_> &p) const;
3021 
3022 
3023 
3024 private:
3029  void set_active_cell_index (const unsigned int active_cell_index);
3030 
3034  void set_parent (const unsigned int parent_index);
3035 
3042  void set_direction_flag (const bool new_direction_flag) const;
3052  void operator = (const CellAccessor<dim, spacedim> &);
3053 
3054  template <int, int> friend class Triangulation;
3055 
3056  friend struct ::internal::Triangulation::Implementation;
3057 };
3058 
3059 
3060 
3061 /* -------------- declaration of explicit
3062  specializations and general templates ------------- */
3063 
3064 
3065 template <int structdim, int dim, int spacedim>
3066 template <typename OtherAccessor>
3068 InvalidAccessor (const OtherAccessor &)
3069 {
3070  Assert (false,
3071  ExcMessage ("You are attempting an illegal conversion between "
3072  "iterator/accessor types. The constructor you call "
3073  "only exists to make certain template constructs "
3074  "easier to write as dimension independent code but "
3075  "the conversion is not valid in the current context."));
3076 }
3077 
3078 
3079 
3080 template <int structdim, int dim, int spacedim>
3081 template <int structdim2, int dim2, int spacedim2>
3084 {
3085  Assert (false,
3086  ExcMessage ("You are attempting an illegal conversion between "
3087  "iterator/accessor types. The constructor you call "
3088  "only exists to make certain template constructs "
3089  "easier to write as dimension independent code but "
3090  "the conversion is not valid in the current context."));
3091 }
3092 
3093 
3094 
3095 template <int dim, int spacedim>
3096 template <int structdim2, int dim2, int spacedim2>
3099 {
3100  Assert (false,
3101  ExcMessage ("You are attempting an illegal conversion between "
3102  "iterator/accessor types. The constructor you call "
3103  "only exists to make certain template constructs "
3104  "easier to write as dimension independent code but "
3105  "the conversion is not valid in the current context."));
3106 }
3107 
3108 
3109 
3110 template <int structdim, int dim, int spacedim>
3111 template <int structdim2, int dim2, int spacedim2>
3114 {
3115  Assert (false,
3116  ExcMessage ("You are attempting an illegal conversion between "
3117  "iterator/accessor types. The constructor you call "
3118  "only exists to make certain template constructs "
3119  "easier to write as dimension independent code but "
3120  "the conversion is not valid in the current context."));
3121 }
3122 
3123 
3124 
3125 template <int dim, int spacedim>
3126 template <int structdim2, int dim2, int spacedim2>
3129 {
3130  Assert (false,
3131  ExcMessage ("You are attempting an illegal conversion between "
3132  "iterator/accessor types. The constructor you call "
3133  "only exists to make certain template constructs "
3134  "easier to write as dimension independent code but "
3135  "the conversion is not valid in the current context."));
3136 }
3137 
3138 template <int dim, int spacedim>
3139 CellId
3141 {
3142  std::vector<unsigned char> id(this->level(), -1);
3143  unsigned int coarse_index;
3144 
3145  CellAccessor<dim,spacedim> ptr = *this;
3146  while (ptr.level()>0)
3147  {
3148  // determine which child we are
3149  unsigned char v=-1;
3150  for (unsigned int c=0; c<ptr.parent()->n_children(); ++c)
3151  {
3152  if (ptr.parent()->child_index(c)==ptr.index())
3153  {
3154  v = c;
3155  break;
3156  }
3157  }
3158 
3159  Assert(v != (unsigned char)-1, ExcInternalError());
3160  id[ptr.level()-1] = v;
3161 
3162  ptr.copy_from( *(ptr.parent()));
3163  }
3164 
3165  Assert(ptr.level()==0, ExcInternalError());
3166  coarse_index = ptr.index();
3167 
3168  return CellId(coarse_index, id);
3169 }
3170 
3171 
3172 #ifndef DOXYGEN
3173 
3174 template <> bool CellAccessor<1,1>::point_inside (const Point<1> &) const;
3175 template <> bool CellAccessor<2,2>::point_inside (const Point<2> &) const;
3176 template <> bool CellAccessor<3,3>::point_inside (const Point<3> &) const;
3177 template <> bool CellAccessor<1,2>::point_inside (const Point<2> &) const;
3178 template <> bool CellAccessor<1,3>::point_inside (const Point<3> &) const;
3179 template <> bool CellAccessor<2,3>::point_inside (const Point<3> &) const;
3180 // -------------------------------------------------------------------
3181 
3182 template <> void TriaAccessor<3,3,3>::set_all_manifold_ids (const types::manifold_id) const;
3183 
3184 #endif // DOXYGEN
3185 
3186 DEAL_II_NAMESPACE_CLOSE
3187 
3188 // include more templates in debug and optimized mode
3189 # include "tria_accessor.templates.h"
3190 
3191 #endif
TriaAccessor< dim, dim, spacedim >::AccessorData AccessorData
unsigned char material_id
Definition: types.h:130
const Triangulation< dim, spacedim > * tria
TriaAccessorBase< structdim, dim, spacedim >::AccessorData AccessorData
::ExceptionBase & ExcMessage(std::string arg1)
DeclException1(ExcGridHasInvalidCell, int,<< "Something went wrong when making cell "<< arg1<< ". Read the docs and the source code "<< "for more information.")
void copy_from(const TriaAccessorBase &)
void set_all_manifold_ids(const types::manifold_id) const
const Triangulation< 1, spacedim > * tria
int level() const
TriaIterator< CellAccessor< dim, spacedim > > parent() const
CellId id() const
BlockDynamicSparsityPattern BlockCompressedSparsityPattern DEAL_II_DEPRECATED
Definition: tria.h:46
TriaAccessorBase< structdim, dim, spacedim >::AccessorData AccessorData
Definition: types.h:30
#define Assert(cond, exc)
Definition: exceptions.h:294
TriaAccessor(const Triangulation< dim, spacedim > *parent=0, const int level=-1, const int index=-1, const AccessorData *local_data=0)
const Triangulation< dim, spacedim > * tria
#define DeclException0(Exception0)
Definition: exceptions.h:522
int index() const
typename ::internal::TriaAccessor::PresentLevelType< structdim, dim >::type present_level
unsigned int subdomain_id
Definition: types.h:42
Definition: cell_id.h:55
unsigned int manifold_id
Definition: types.h:122
bool point_inside(const Point< spacedim > &p) const
CellAccessor(const Triangulation< dim, spacedim > *parent=0, const int level=-1, const int index=-1, const AccessorData *local_data=0)
Triangulation< dim, spacedim > Container
InvalidAccessor(const Triangulation< dim, spacedim > *parent=0, const int level=-1, const int index=-1, const AccessorData *local_data=0)
unsigned char boundary_id
Definition: types.h:110