From: David Wells <wellsd2@rpi.edu>
Date: Sat, 7 May 2016 12:04:27 +0000 (-0400)
Subject: Add codimension versions of cell_measure.
X-Git-Tag: v8.5.0-rc1~1050^2~4
X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d8bafee27cc7e271af5ecfa8bb2f02420f1482a0;p=dealii.git

Add codimension versions of cell_measure.

These just raise exceptions, but their existence is useful for writing
generic code.
---

diff --git a/include/deal.II/grid/grid_tools.h b/include/deal.II/grid/grid_tools.h
index ae3387ba71..db6adf0ef6 100644
--- a/include/deal.II/grid/grid_tools.h
+++ b/include/deal.II/grid/grid_tools.h
@@ -158,8 +158,8 @@ namespace GridTools
    * function also works for cells that do not exist except that you make it
    * up by naming its vertices from the list.
    */
-  template <int dim>
-  double cell_measure (const std::vector<Point<dim> > &all_vertices,
+  template <int dim, int spacedim=dim>
+  double cell_measure (const std::vector<Point<spacedim> > &all_vertices,
                        const unsigned int (&vertex_indices)[GeometryInfo<dim>::vertices_per_cell]);
 
   /*@}*/
@@ -1782,18 +1782,6 @@ namespace GridTools
             }
         }
   }
-
-// declaration of explicit specializations
-
-  template <>
-  double
-  cell_measure<3>(const std::vector<Point<3> > &all_vertices,
-                  const unsigned int (&vertex_indices) [GeometryInfo<3>::vertices_per_cell]);
-
-  template <>
-  double
-  cell_measure<2>(const std::vector<Point<2> > &all_vertices,
-                  const unsigned int (&vertex_indices) [GeometryInfo<2>::vertices_per_cell]);
 }
 
 #endif
diff --git a/source/grid/grid_tools.cc b/source/grid/grid_tools.cc
index 9cc51c8db7..91dc5d834e 100644
--- a/source/grid/grid_tools.cc
+++ b/source/grid/grid_tools.cc
@@ -167,10 +167,60 @@ namespace GridTools
   }
 
 
+
+  template <>
+  double
+  cell_measure<1, 1>
+  (const std::vector<Point<1> > &all_vertices,
+   const unsigned int (&vertex_indices)[GeometryInfo<1>::vertices_per_cell])
+  {
+    return all_vertices[vertex_indices[1]][0]
+           - all_vertices[vertex_indices[0]][0];
+  }
+
+
+
+  template <>
+  double
+  cell_measure<1, 2>
+  (const std::vector<Point<2> > &,
+   const unsigned int (&)[GeometryInfo<1>::vertices_per_cell])
+  {
+    Assert(false, ExcNotImplemented());
+    return std::numeric_limits<double>::quiet_NaN();
+  }
+
+
+
+  template <>
+  double
+  cell_measure<1, 3>
+  (const std::vector<Point<3> > &,
+   const unsigned int (&)[GeometryInfo<1>::vertices_per_cell])
+  {
+    Assert(false, ExcNotImplemented());
+    return std::numeric_limits<double>::quiet_NaN();
+  }
+
+
+
+  template <>
+  double
+  cell_measure<2, 3>
+  (const std::vector<Point<3> > &,
+   const unsigned int (&)[GeometryInfo<2>::vertices_per_cell])
+  {
+    Assert(false, ExcNotImplemented());
+    return std::numeric_limits<double>::quiet_NaN();
+  }
+
+
+
   template <>
   double
-  cell_measure<3>(const std::vector<Point<3> > &all_vertices,
-                  const unsigned int (&vertex_indices)[GeometryInfo<3>::vertices_per_cell])
+  cell_measure<3, 3>
+  (const std::vector<Point<3> > &all_vertices,
+   const unsigned int (&vertex_indices)[GeometryInfo<3>::vertices_per_cell])
   {
     // note that this is the
     // cell_measure based on the new
@@ -292,8 +342,9 @@ namespace GridTools
 
   template <>
   double
-  cell_measure(const std::vector<Point<2> > &all_vertices,
-               const unsigned int (&vertex_indices) [GeometryInfo<2>::vertices_per_cell])
+  cell_measure<2, 2>
+  (const std::vector<Point<2> > &all_vertices,
+   const unsigned int (&vertex_indices) [GeometryInfo<2>::vertices_per_cell])
   {
     /*
       Get the computation of the measure by this little Maple script. We
@@ -348,19 +399,6 @@ namespace GridTools
   }
 
 
-
-
-  template <int dim>
-  double
-  cell_measure(const std::vector<Point<dim> > &,
-               const unsigned int ( &) [GeometryInfo<dim>::vertices_per_cell])
-  {
-    Assert(false, ExcNotImplemented());
-    return 0.;
-  }
-
-
-
   template <int dim, int spacedim>
   void
   delete_unused_vertices (std::vector<Point<spacedim> >    &vertices,