]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Make cell_measure(...) work again. 2587/head
authorDavid Wells <wellsd2@rpi.edu>
Thu, 12 May 2016 00:38:57 +0000 (20:38 -0400)
committerDavid Wells <wellsd2@rpi.edu>
Thu, 12 May 2016 01:06:17 +0000 (21:06 -0400)
A result of d8bafee27cc was that users can no longer write

cell_measure(...)

with no given template argument (in the codimension zero case). This
commit fixes that.

Note: since dim does not explicitly appear alone and unmodified in the
function arguments of cell_measure<dim, spacedim>, that function can
never have its type (more exactly, the value for dim) inferred correctly
from just the arguments. Put another way, one must always write
cell_measure<dim, spacedim> to use this function. This was not a problem
in the past when Point<dim> appeared instead of Point<spacedim>.

include/deal.II/grid/grid_tools.h

index fd35b9952dfcffd1dcebfbe8d94b3f07a7f720a8..6aca950feae062f59d12ba801117a2ac93364325 100644 (file)
@@ -166,6 +166,22 @@ namespace GridTools
   double cell_measure (const std::vector<Point<spacedim> > &all_vertices,
                        const unsigned int (&vertex_indices)[GeometryInfo<dim>::vertices_per_cell]);
 
+
+  /**
+   * Same as the last function, but for the codimension zero case. This extra
+   * function allows one to write
+   *
+   * @code
+   * cell_measure(vertices, indices);
+   * @endcode
+   *
+   * and have the template function argument (i.e. <code>dim</code>) inferred
+   * automatically.
+   */
+  template <int dim>
+  double cell_measure (const std::vector<Point<dim> > &all_vertices,
+                       const unsigned int (&vertex_indices)[GeometryInfo<dim>::vertices_per_cell]);
+
   /*@}*/
   /**
    * @name Functions supporting the creation of meshes
@@ -1639,6 +1655,16 @@ namespace GridTools
 
 namespace GridTools
 {
+  // This function just wraps the general case: see the note in its
+  // documentation above.
+  template <int dim>
+  double cell_measure (const std::vector<Point<dim> > &all_vertices,
+                       const unsigned int (&vertex_indices)[GeometryInfo<dim>::vertices_per_cell])
+  {
+    return cell_measure<dim, dim>(all_vertices, vertex_indices);
+  }
+
+
 
   template <int dim, typename Predicate, int spacedim>
   void transform (const Predicate    &predicate,

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.