From 083806afbbd86a3c70273504c78804d6ef7fc258 Mon Sep 17 00:00:00 2001 From: Timo Heister Date: Sun, 17 Feb 2013 18:47:46 +0000 Subject: [PATCH] work on step-49 git-svn-id: https://svn.dealii.org/trunk@28443 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/examples/step-49/doc/intro.dox | 57 ++++++++++++++++++--- deal.II/examples/step-49/step-49.cc | 68 ++++++++++++++++++++++++++ 2 files changed, 118 insertions(+), 7 deletions(-) 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/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 (); } -- 2.39.5