]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Fix bug #4: Triangulation::distort_random accidentally only ever moved points in...
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 5 Apr 2013 17:47:28 +0000 (17:47 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 5 Apr 2013 17:47:28 +0000 (17:47 +0000)
git-svn-id: https://svn.dealii.org/trunk@29203 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/doc/news/changes.h
deal.II/source/grid/tria.cc

index c6c59816ac9249e996cb60145a155575fe2f6ec1..ae9c06b683956dad2cb3e22b891327f0a2091209 100644 (file)
@@ -88,13 +88,22 @@ this function.
 <h3>Specific improvements</h3>
 
 <ol>
+<li> Fixed: GridTools::distort_random (previously called Triangulation::distort_random)
+had a bug where points were only ever moved in <i>positive</i> coordinate
+directions rather than with uniform probability in either direction. The 1d
+implementation also had the problem that it did not move vertices if the
+<i>cell</i> they were on was at the boundary, even if the <i>vertex</i>
+itself was not. All of these problems are now fixed.
+<br>
+(Wolfgang Bangerth, 2013/4/5)
+</li>
+
 <li> New: There is a class VectorFunctionFromTensorFunction that converts
 between objects of type TensorFunction and Function.
 <br>
 (Spencer Patty, 2013/4/2)
 </li>
 
-
 <li> Fixed: The ParameterHandler class could not deal with parameters named
 <code>"value"</code> (and a few other names). This is now fixed.
 <br>
index c6ba3b09de0bb81ade31f3bb8e005457a1483d28..4b7607565d1ad9dc006860b861e7de72761bb799 100644 (file)
@@ -2793,20 +2793,12 @@ namespace internal
 
         std::vector<double> minimal_length (triangulation.vertices.size(),
                                             almost_infinite_length);
-        // also note if a vertex is at
-        // the boundary
         std::vector<bool>   at_boundary (triangulation.vertices.size(), false);
 
         for (typename Triangulation<dim,spacedim>::active_line_iterator
              line=triangulation.begin_active_line();
              line != triangulation.end_line(); ++line)
           {
-            if (keep_boundary && line->at_boundary())
-              {
-                at_boundary[line->vertex_index(0)] = true;
-                at_boundary[line->vertex_index(1)] = true;
-              }
-
             minimal_length[line->vertex_index(0)]
               = std::min(line->diameter(),
                          minimal_length[line->vertex_index(0)]);
@@ -2815,6 +2807,16 @@ namespace internal
                          minimal_length[line->vertex_index(1)]);
           }
 
+        // also note if a vertex is at the boundary if we are asked to
+        // keep boundary vertices untouched
+       if (keep_boundary)
+         for (typename Triangulation<dim,spacedim>::active_line_iterator
+                line=triangulation.begin_active_line();
+              line != triangulation.end_line(); ++line)
+           for (unsigned int vertex=0; vertex<2; ++vertex)
+             if (line->at_boundary(vertex) == true)
+               at_boundary[line->vertex_index(vertex)] = true;
+
 
         const unsigned int n_vertices = triangulation.vertices.size();
         Point<spacedim> shift_vector;
@@ -2831,7 +2833,7 @@ namespace internal
             // first compute a random shift
             // vector
             for (unsigned int d=0; d<spacedim; ++d)
-              shift_vector(d) = std::rand()*1.0/RAND_MAX;
+              shift_vector(d) = std::rand()*2.0/RAND_MAX-1;
 
             shift_vector *= factor * minimal_length[vertex] /
                             std::sqrt(shift_vector.square());
@@ -2927,7 +2929,7 @@ namespace internal
             // first compute a random shift
             // vector
             for (unsigned int d=0; d<spacedim; ++d)
-              shift_vector(d) = std::rand()*1.0/RAND_MAX;
+              shift_vector(d) = std::rand()*2.0/RAND_MAX-1;
 
             shift_vector *= factor * minimal_length[vertex] /
                             std::sqrt(shift_vector.square());

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.