* 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.
*
*
*
// 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;
+ }
};