]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Remove duplicated code. 8481/head
authorDavid Wells <drwells@email.unc.edu>
Wed, 7 Aug 2019 15:36:26 +0000 (09:36 -0600)
committerDavid Wells <drwells@email.unc.edu>
Wed, 7 Aug 2019 16:03:43 +0000 (10:03 -0600)
The exact same code is in the GridTools function.

source/grid/tria_accessor.cc

index 8f2e1b315529e04bedc28651196067694ee87527..06321aebf5b2f460ec96718b6dcbd2c3eb578ec5 100644 (file)
@@ -1264,52 +1264,12 @@ namespace
   double
   measure(const TriaAccessor<2, 2, 2> &accessor)
   {
-    // the evaluation of the formulae
-    // is a bit tricky when done dimension
-    // independently, so we write this function
-    // for 2D and 3D separately
-    /*
-      Get the computation of the measure by this little Maple script. We
-      use the blinear mapping of the unit quad to the real quad. However,
-      every transformation mapping the unit faces to straight lines should
-      do.
-
-      Remember that the area of the quad is given by
-      \int_K 1 dx dy  = \int_{\hat K} |det J| d(xi) d(eta)
-
-      # x and y are arrays holding the x- and y-values of the four vertices
-      # of this cell in real space.
-      x := array(0..3);
-      y := array(0..3);
-      tphi[0] := (1-xi)*(1-eta):
-      tphi[1] :=     xi*(1-eta):
-      tphi[2] := (1-xi)*eta:
-      tphi[3] :=     xi*eta:
-      x_real := sum(x[s]*tphi[s], s=0..3):
-      y_real := sum(y[s]*tphi[s], s=0..3):
-      detJ := diff(x_real,xi)*diff(y_real,eta) -
-      diff(x_real,eta)*diff(y_real,xi):
-
-      measure := simplify ( int ( int (detJ, xi=0..1), eta=0..1)):
-      readlib(C):
-
-      C(measure, optimized);
-
-      additional optimizaton: divide by 2 only one time
-    */
-
-    const double x[4] = {accessor.vertex(0)(0),
-                         accessor.vertex(1)(0),
-                         accessor.vertex(2)(0),
-                         accessor.vertex(3)(0)};
-    const double y[4] = {accessor.vertex(0)(1),
-                         accessor.vertex(1)(1),
-                         accessor.vertex(2)(1),
-                         accessor.vertex(3)(1)};
+    unsigned int vertex_indices[GeometryInfo<2>::vertices_per_cell];
+    for (unsigned int i = 0; i < GeometryInfo<2>::vertices_per_cell; ++i)
+      vertex_indices[i] = accessor.vertex_index(i);
 
-    return (-x[1] * y[0] + x[1] * y[3] + y[0] * x[2] + x[0] * y[1] -
-            x[0] * y[2] - y[1] * x[3] - x[2] * y[3] + x[3] * y[2]) /
-           2;
+    return GridTools::cell_measure<2>(
+      accessor.get_triangulation().get_vertices(), vertex_indices);
   }
 
 

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.