Meshes can be generated from different tools like <a
href="http://geuz.org/gmsh/" rel="nofollow">gmsh</a>, <a
href="https://lagrit.lanl.gov/" rel="nofollow">lagrit</a> and <a
-href="http://cubit.sandia.gov/" rel="nofollow">cubit</a>. The problem is that
-deal.II needs meshes that only consist of quads and hexas -- tetrahedral
-meshes won't work (this means tools like tetgen can not be used directly).
+href="http://cubit.sandia.gov/" rel="nofollow">cubit</a>. See the
+documentation of GridIn for more information. The problem is that deal.II
+needs meshes that only consist of quads and hexas -- tetrahedral meshes won't
+work (this means tools like tetgen can not be used directly).
We will describe a possible workflow using Gmsh. Gmsh is the smallest and
quickest to set up open source tool, that we know of. It can generate
GridTools::rotate, GridTools::scale is fairly obvious, so we won't discuss
those functions here.
+The function GridTools::transform allows you to transform the vertices of a
+given mesh using a smooth function.
- GridTools::transform
- - transform via smooth function
+In the function grid_5() we perturb the y coordinate of a mesh with
+a sin curve:
+<TABLE WIDTH="60%" ALIGN="center">
+ <tr>
+ <td ALIGN="center">
+ @image html step-49.grid-5a.png regular input mesh
+ </td>
+ <td ALIGN="center">
+ @image html step-49.grid-5.png output mesh
+ </td>
+ </tr>
+</TABLE>
- - perturb/randomize mesh
+Using the formula
+$(x,y) \mapsto (x,tanh(2*y)/tanh(2))$, we transform a regular refined
+unit square to a wall-adapted mesh in y direction. This is done in grid_6()
+of this tutorial:
+<TABLE WIDTH="60%" ALIGN="center">
+ <tr>
+ <td ALIGN="center">
+ @image html step-49.grid-6a.png regular input mesh
+ </td>
+ <td ALIGN="center">
+ @image html step-49.grid-6.png wall-adapted output mesh
+ </td>
+ </tr>
+</TABLE>
+The function Triangulation::distort_random allows you to move vertices in the
+mesh (optionally ignoring boundary nodes) by a random amount. This is
+demonstrated in grid_7() and the result is as follows:
+<TABLE WIDTH="60%" ALIGN="center">
+ <tr>
+ <td ALIGN="center">
+ @image html step-49.grid-7a.png regular input mesh
+ </td>
+ <td ALIGN="center">
+ @image html step-49.grid-7.png perturbed output mesh
+ </td>
+ </tr>
+</TABLE>
+
+Please note that while this allows you to negate some of the superconvergence
+effects one gets when studying convergence on regular meshes, it is better to
+work with a sequence of unstructured meshes (see possible extensions).
<h4>Merge Meshes</h4>
- change boundary indicators
- relax inner vertices
- Database of unstructured meshes for convergence studies
-
+- GridTools::extract_boundary_mesh
#include <deal.II/grid/tria_accessor.h>
#include <deal.II/grid/tria_iterator.h>
#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/grid_tools.h>
#include <deal.II/grid/tria_boundary_lib.h>
#include <deal.II/grid/grid_out.h>
#include <deal.II/grid/grid_in.h>
}
+// demonstrate GridTools::transform
+void grid_5()
+{
+ Triangulation<2> tria;
+ std::vector< unsigned int > repetitions(2);
+ repetitions[0]=14;
+ repetitions[1]=2;
+ GridGenerator::subdivided_hyper_rectangle (tria, repetitions,
+ Point<2>(0.0,0.0), Point<2>(10.0,1.0));
+
+ struct Func
+ {
+ Point<2> operator() (const Point<2> & in) const
+ {
+ return Point<2>(in(0), in(1)+sin(in(0)/5.0*3.14159));
+ }
+ };
+
+ GridTools::transform(Func(), tria);
+ mesh_info(tria, "grid-5.eps");
+}
+
+// demonstrate GridTools::transform
+void grid_6()
+{
+ Triangulation<2> tria;
+ std::vector< unsigned int > repetitions(2);
+ repetitions[0]=40;
+ repetitions[1]=40;
+ GridGenerator::subdivided_hyper_rectangle (tria, repetitions,
+ Point<2>(0.0,0.0), Point<2>(1.0,1.0));
+ struct Func
+ {
+ double trans(double x) const
+ {
+ //return atan((x-0.5)*3.14159);
+ return tanh(2*x)/tanh(2);//(x-0.5)*3.14159);
+ }
+
+ Point<2> operator() (const Point<2> & in) const
+ {
+ return Point<2>((in(0)), trans(in(1)));
+ }
+ };
+
+ GridTools::transform(Func(), tria);
+ mesh_info(tria, "grid-6.eps");
+}
+
+
+
+//demonstrate distort_random
+void grid_7()
+{
+ Triangulation<2> tria;
+ std::vector< unsigned int > repetitions(2);
+ repetitions[0]=16;
+ repetitions[1]=16;
+ GridGenerator::subdivided_hyper_rectangle (tria, repetitions,
+ Point<2>(0.0,0.0), Point<2>(1.0,1.0));
+
+ tria.distort_random(0.3, true);
+ mesh_info(tria, "grid-7.eps");
+}
// @sect3{The main function}
grid_2 ();
grid_3 ();
grid_4 ();
+ grid_5 ();
+ grid_6 ();
+ grid_7 ();
}