From: heister Date: Sun, 17 Feb 2013 18:47:46 +0000 (+0000) Subject: work on step-49 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1b5ab380bf3d74d54ea7caa4523ad262887cba28;p=dealii-svn.git work on step-49 git-svn-id: https://svn.dealii.org/trunk@28443 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/examples/step-49/doc/intro.dox b/deal.II/examples/step-49/doc/intro.dox index c9da6be05e..9e6cccb41a 100644 --- a/deal.II/examples/step-49/doc/intro.dox +++ b/deal.II/examples/step-49/doc/intro.dox @@ -62,9 +62,10 @@ grid_1 in this example. Meshes can be generated from different tools like gmsh, lagrit and cubit. 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. 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 @@ -120,12 +121,54 @@ a given mesh in various ways. The usage of the functions GridTools::shift, 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: + + + + + +
+ @image html step-49.grid-5a.png regular input mesh + + @image html step-49.grid-5.png output mesh +
- - 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: + + + + + +
+ @image html step-49.grid-6a.png regular input mesh + + @image html step-49.grid-6.png wall-adapted output mesh +
+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: + + + + + +
+ @image html step-49.grid-7a.png regular input mesh + + @image html step-49.grid-7.png perturbed output mesh +
+ +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).

Merge Meshes

@@ -208,4 +251,4 @@ above. This is the output from grid_4(): - change boundary indicators - relax inner vertices - Database of unstructured meshes for convergence studies - +- GridTools::extract_boundary_mesh diff --git a/deal.II/examples/step-49/doc/step-49.grid-5.png b/deal.II/examples/step-49/doc/step-49.grid-5.png new file mode 100644 index 0000000000..5b0920ded7 Binary files /dev/null and b/deal.II/examples/step-49/doc/step-49.grid-5.png differ diff --git a/deal.II/examples/step-49/doc/step-49.grid-5a.png b/deal.II/examples/step-49/doc/step-49.grid-5a.png new file mode 100644 index 0000000000..3257a9a6af Binary files /dev/null and b/deal.II/examples/step-49/doc/step-49.grid-5a.png differ diff --git a/deal.II/examples/step-49/doc/step-49.grid-6.png b/deal.II/examples/step-49/doc/step-49.grid-6.png new file mode 100644 index 0000000000..ba416ad76d Binary files /dev/null and b/deal.II/examples/step-49/doc/step-49.grid-6.png differ diff --git a/deal.II/examples/step-49/doc/step-49.grid-6a.png b/deal.II/examples/step-49/doc/step-49.grid-6a.png new file mode 100644 index 0000000000..34240c30bd Binary files /dev/null and b/deal.II/examples/step-49/doc/step-49.grid-6a.png differ diff --git a/deal.II/examples/step-49/doc/step-49.grid-7.png b/deal.II/examples/step-49/doc/step-49.grid-7.png new file mode 100644 index 0000000000..d56dfe63fa Binary files /dev/null and b/deal.II/examples/step-49/doc/step-49.grid-7.png differ diff --git a/deal.II/examples/step-49/doc/step-49.grid-7a.png b/deal.II/examples/step-49/doc/step-49.grid-7a.png new file mode 100644 index 0000000000..96f8f3b2c7 Binary files /dev/null and b/deal.II/examples/step-49/doc/step-49.grid-7a.png differ diff --git a/deal.II/examples/step-49/step-49.cc b/deal.II/examples/step-49/step-49.cc index a9851a4d8d..41150a9eb0 100644 --- a/deal.II/examples/step-49/step-49.cc +++ b/deal.II/examples/step-49/step-49.cc @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -148,7 +149,71 @@ void grid_4() } +// 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} @@ -160,4 +225,7 @@ int main () grid_2 (); grid_3 (); grid_4 (); + grid_5 (); + grid_6 (); + grid_7 (); }