]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add codimension versions of cell_measure.
authorDavid Wells <wellsd2@rpi.edu>
Sat, 7 May 2016 12:04:27 +0000 (08:04 -0400)
committerDavid Wells <wellsd2@rpi.edu>
Sun, 8 May 2016 13:29:42 +0000 (09:29 -0400)
These just raise exceptions, but their existence is useful for writing
generic code.

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

index ae3387ba712ec7f066b7e9f3c985ca95ef4926c2..db6adf0ef6a7e38dce0517ce079d560056d1bf26 100644 (file)
@@ -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
index 9cc51c8db74346c2c1ceae667e6355c843ca8143..91dc5d834e32965af1c835ed31559d8e04f7659b 100644 (file)
@@ -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,

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.