]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Make the algorithm backward compatible by replicating a previous (harmless) bug. 3166/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Thu, 29 Sep 2016 17:35:17 +0000 (12:35 -0500)
committerWolfgang Bangerth <bangerth@colostate.edu>
Thu, 29 Sep 2016 17:39:03 +0000 (12:39 -0500)
source/grid/grid_reordering.cc

index b06963a8948700a7ab3024a08e68019932ebc575..7a83fc51677043595b19b0c08aa4dc032c3e300e 100644 (file)
@@ -428,8 +428,43 @@ namespace internal
     {
       const unsigned int dim = 2;
 
-      // choose the direction of the first edge by chance
-      edges[cells[cell].edge_indices[local_edge]].orientation_status = Edge<dim>::forward;
+      // choose the direction of the first edge. we have free choice
+      // here and could simply choose "forward" if that's what pleases
+      // us. however, for backward compatibility with the previous
+      // implementation used till 2016, let us just choose the
+      // direction so that it matches what we have in the given cell.
+      //
+      // in fact, in what can only be assumed to be a bug in the
+      // original implementation, after orienting all edges, the code
+      // that rotates the cells so that they match edge orientations
+      // (see the rotate_cell() function below) rotated the cell two
+      // more times by 90 degrees. this is ok -- it simply flips all
+      // edge orientations, which leaves them valid. rather than do
+      // the same in the current implementation, we can achieve the
+      // same effect by modifying the rule above to choose the
+      // direction of the starting edge of this parallel set
+      // *opposite* to what it looks like in the current cell
+      if (edges[cells[cell].edge_indices[local_edge]].vertex_indices[0]
+          ==
+          cells[cell].vertex_indices[GeometryInfo<dim>::line_to_cell_vertices (local_edge, 0)])
+        // orient initial edge *opposite* to the way it is in the cell
+        // (see above for the reason)
+        edges[cells[cell].edge_indices[local_edge]].orientation_status = Edge<dim>::backward;
+      else
+        {
+          Assert (edges[cells[cell].edge_indices[local_edge]].vertex_indices[0]
+                  ==
+                  cells[cell].vertex_indices[GeometryInfo<dim>::line_to_cell_vertices (local_edge, 1)],
+                  ExcInternalError());
+          Assert (edges[cells[cell].edge_indices[local_edge]].vertex_indices[1]
+                  ==
+                  cells[cell].vertex_indices[GeometryInfo<dim>::line_to_cell_vertices (local_edge, 0)],
+                  ExcInternalError());
+
+          // orient initial edge *opposite* to the way it is in the cell
+          // (see above for the reason)
+          edges[cells[cell].edge_indices[local_edge]].orientation_status = Edge<dim>::forward;
+        }
 
       // walk outward from the given edge as described in
       // the algorithm in the paper that documents all of

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.