]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Add support for hanging nodes to the distort function
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Sun, 4 Oct 1998 19:36:29 +0000 (19:36 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Sun, 4 Oct 1998 19:36:29 +0000 (19:36 +0000)
git-svn-id: https://svn.dealii.org/trunk@613 0785d39b-7218-0410-832d-ea1e28bc413d

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

index aaf813716e739c9714b793b240b7763cca0e81e5..ff81b7896da16f33ecf52c116fc0fcf55e295552 100644 (file)
@@ -553,8 +553,23 @@ class TriaDimensionInfo<2> {
  *   Finally, there is a special function for folks who like bad grids:
  *   #Triangulation<dim>::distort_random#. It moves all the vertices in the
  *   grid a bit around by a random value, leaving behind a distorted mesh.
- *   Note that you should apply this function to the final mesh, since refinement
- *   smoothes the mesh a bit.
+ *   Note that you should apply this function to the final mesh, since
+ *   refinement smoothes the mesh a bit.
+ *
+ *   The function will make sure that vertices on restricted faces (hanging
+ *   nodes) will result in the correct place, i.e. in the middle of the two
+ *   other vertices of the mother line, and the analogue in higher space
+ *   dimensions (vertices on the boundary are not corrected, so don't distort
+ *   boundary vertices in more than two space dimension, i.e. in dimensions
+ *   where boundary vertices can be hanging nodes). Applying the algorithm
+ *   has another drawback related to the
+ *   placement of cells, however: the children of a cell will not occupy the
+ *   same region of the domain as the mother cell does. While this is the
+ *   usual behaviour with cells at the boundary, here you may get into trouble
+ *   when using multigrid algorithms or when transferring solutions from coarse
+ *   to fine grids and back. In general, the use of this function is only safe
+ *   if you only use the most refined level of the triangulation for
+ *   computations.
  *
  *
  *
index ed2f87b0113658539b9ddd627c1375b0517f7a96..32ec210d07a680938d2d5282500e54d14d50ae58 100644 (file)
@@ -715,6 +715,35 @@ void Triangulation<dim>::distort_random (const double factor,
                                       // finally move the vertex
       vertices[vertex] += shift_vector;
     };
+
+  
+                                  // finally correct hanging nodes
+                                  // again. not necessary for 1D
+  if (dim==1)
+    return;
+  
+  active_cell_iterator cell = begin_active(),
+                      endc = end();
+  for (; cell!=endc; ++cell) 
+    for (unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
+      if (cell->face(face)->has_children() &&
+         !cell->face(face)->at_boundary())
+                                        // this lines has children,
+                                        // thus there are restricted
+                                        // nodes
+       {
+                                          // not implemented at present
+                                          // for dim=3 or higher
+         Assert (dim<=2, ExcInternalError());
+
+                                          // compute where the common
+                                          // point of the two child lines
+                                          // will lie and
+                                          // reset it to the correct value
+         vertices[cell->face(face)->child(0)->vertex_index(1)]
+           = (cell->face(face)->vertex(0) +
+              cell->face(face)->vertex(1)) / 2;
+       }
 };
 
 

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.