]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Unify a bunch of functions that were previously independent explicit specializations...
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 5 Sep 2007 04:12:14 +0000 (04:12 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 5 Sep 2007 04:12:14 +0000 (04:12 +0000)
git-svn-id: https://svn.dealii.org/trunk@15124 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/include/grid/tria.h
deal.II/deal.II/source/grid/tria.cc

index 3a878d4121d69cee98e793c058ba2ce5741e7d0b..8422115c7335fd7a0b3f81946c40c706c1f88d1b 100644 (file)
@@ -2716,16 +2716,21 @@ class Triangulation : public Subscriptor
 
                                     /**
                                      *  Return total number of used faces,
-                                     *  active or not.
-                                     *  Maps to <tt>n_lines()</tt> in two space
-                                     *  dimensions and so on.
+                                     *  active or not.  In 2d, the result
+                                     *  equals n_lines(), while in 3d it
+                                     *  equals n_quads(). Since there are no
+                                     *  face objects in 1d, the function
+                                     *  returns zero in 1d.
                                      */
     unsigned int n_faces () const;
 
                                     /**
-                                     *  Return total number of active faces.
-                                     *  Maps to <tt>n_active_lines()</tt> in two space
-                                     *  dimensions and so on.
+                                     *  Return total number of active faces,
+                                     *  active or not.  In 2d, the result
+                                     *  equals n_active_lines(), while in 3d
+                                     *  it equals n_active_quads(). Since
+                                     *  there are no face objects in 1d, the
+                                     *  function returns zero in 1d.
                                      */
     unsigned int n_active_faces () const;
 
@@ -3399,15 +3404,6 @@ template <> Triangulation<3>::raw_face_iterator Triangulation<3>::last_raw_face
 template <> Triangulation<3>::face_iterator Triangulation<3>::last_face () const;
 template <> Triangulation<3>::active_face_iterator Triangulation<3>::last_active_face () const;
 template <> Triangulation<3>::raw_quad_iterator Triangulation<3>::begin_raw_quad (const unsigned int level) const;
-template <> unsigned int Triangulation<1>::n_raw_cells (const unsigned int level) const;
-template <> unsigned int Triangulation<1>::n_cells (const unsigned int level) const;
-template <> unsigned int Triangulation<1>::n_active_cells (const unsigned int level) const;
-template <> unsigned int Triangulation<2>::n_raw_cells (const unsigned int level) const;
-template <> unsigned int Triangulation<2>::n_cells (const unsigned int level) const;
-template <> unsigned int Triangulation<2>::n_active_cells (const unsigned int level) const;
-template <> unsigned int Triangulation<3>::n_raw_cells (const unsigned int level) const;
-template <> unsigned int Triangulation<3>::n_cells (const unsigned int level) const;
-template <> unsigned int Triangulation<3>::n_active_cells (const unsigned int level) const;
 template <> unsigned int Triangulation<1>::n_raw_lines (const unsigned int level) const;
 template <> unsigned int Triangulation<1>::n_quads () const;
 template <> unsigned int Triangulation<1>::n_quads (const unsigned int level) const;
index 367e211b01320090c364eb8697b1f53f2660ec89..4ed530d32e403aca0501dd4fd94689fc184adf4b 100644 (file)
@@ -4399,9 +4399,17 @@ unsigned int Triangulation<dim>::n_active_cells () const
 template <int dim>
 unsigned int Triangulation<dim>::n_faces () const
 {
-  Assert (dim<=3, ExcNotImplemented());
-  if (dim==2) return n_lines();
-  if (dim==3) return n_quads();
+  switch (dim)
+    {
+      case 1:
+           return 0;
+      case 2:
+           return n_lines();
+      case 3:
+            return n_quads();
+      default:
+           Assert (false, ExcNotImplemented());
+    }
   return 0;
 }
 
@@ -4409,89 +4417,76 @@ unsigned int Triangulation<dim>::n_faces () const
 template <int dim>
 unsigned int Triangulation<dim>::n_active_faces () const
 {
-  Assert (dim<=3, ExcNotImplemented());
-  if (dim==2) return n_active_lines();
-  if (dim==3) return n_active_quads();
+  switch (dim)
+    {
+      case 1:
+           return 0;
+      case 2:
+           return n_active_lines();
+      case 3:
+            return n_active_quads();
+      default:
+           Assert (false, ExcNotImplemented());
+    }
   return 0;
 }
 
 
-//TODO:[GK] Implement this like above and remove specialization declaration in tria.h
-//TODO:[GK] Add a remark to Triangulation doc telling 1d-Triangulations have no face
-
-#if deal_II_dimension == 1
-
-template <>
-unsigned int Triangulation<1>::n_raw_cells (const unsigned int level) const
-{
-  return n_raw_lines (level);
-}
-
-template <>
-unsigned int Triangulation<1>::n_cells (const unsigned int level) const
-{
-  return n_lines (level);
-}
-
-
-template <>
-unsigned int Triangulation<1>::n_active_cells (const unsigned int level) const
-{
-  return n_active_lines (level);
-}
-
-
-#endif
-
-
-#if deal_II_dimension == 2
-
-template <>
-unsigned int Triangulation<2>::n_raw_cells (const unsigned int level) const
-{
-  return n_raw_quads (level);
-}
-
-
-template <>
-unsigned int Triangulation<2>::n_cells (const unsigned int level) const
-{
-  return n_quads (level);
-}
-
-
-template <>
-unsigned int Triangulation<2>::n_active_cells (const unsigned int level) const
+template <int dim>
+unsigned int Triangulation<dim>::n_raw_cells (const unsigned int level) const
 {
-  return n_active_quads (level);
+  switch (dim)
+    {
+      case 1:
+           return n_raw_lines(level);
+      case 2:
+           return n_raw_quads(level);
+      case 3:
+            return n_raw_hexs(level);
+      default:
+           Assert (false, ExcNotImplemented());
+    }
+  return 0;
 }
 
-#endif
-
 
-#if deal_II_dimension == 3
 
-template <>
-unsigned int Triangulation<3>::n_raw_cells (const unsigned int level) const
+template <int dim>
+unsigned int Triangulation<dim>::n_cells (const unsigned int level) const
 {
-  return n_raw_hexs (level);
+  switch (dim)
+    {
+      case 1:
+           return n_lines(level);
+      case 2:
+           return n_quads(level);
+      case 3:
+            return n_hexs(level);
+      default:
+           Assert (false, ExcNotImplemented());
+    }
+  return 0;
 }
 
 
-template <>
-unsigned int Triangulation<3>::n_cells (const unsigned int level) const
-{
-  return n_hexs (level);
-}
 
-
-template <>
-unsigned int Triangulation<3>::n_active_cells (const unsigned int level) const
+template <int dim>
+unsigned int Triangulation<dim>::n_active_cells (const unsigned int level) const
 {
-  return n_active_hexs (level);
+  switch (dim)
+    {
+      case 1:
+           return n_active_lines(level);
+      case 2:
+           return n_active_quads(level);
+      case 3:
+            return n_active_hexs(level);
+      default:
+           Assert (false, ExcNotImplemented());
+    }
+  return 0;
 }
 
-#endif
 
 
 template <int dim>

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.