From: bangerth Date: Wed, 15 Nov 2006 18:04:46 +0000 (+0000) Subject: Add Yaqi's function for non-uniformly graded hyper rectangles. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=741929bc60aa7617d37509c8eb83267063338703;p=dealii-svn.git Add Yaqi's function for non-uniformly graded hyper rectangles. git-svn-id: https://svn.dealii.org/trunk@14196 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/include/grid/grid_generator.h b/deal.II/deal.II/include/grid/grid_generator.h index e6697bf843..16190bbcb7 100644 --- a/deal.II/deal.II/include/grid/grid_generator.h +++ b/deal.II/deal.II/include/grid/grid_generator.h @@ -267,6 +267,44 @@ class GridGenerator const Point &p2, const bool colorize=false); + /** + * Like the previous + * function. However, here the + * second argument does not + * denote the number of + * subdivisions in each + * coordinate direction, but a + * sequence of step sizes for + * each coordinate direction. The + * domain will therefore be + * subdivided into + * step_sizes[i].size() + * cells in coordinate direction + * i, with widths + * step_sizes[i][j] + * for the jth cell. + * + * This function is therefore the + * right one to generate graded + * meshes where cells are + * concentrated in certain areas, + * rather than a uniformly + * subdivided mesh as the + * previous function generates. + * + * The step sizes have to add up + * to the dimensions of the hyper + * rectangle specified by the + * points @p p1 and @p p2. + */ + template + void + subdivided_hyper_rectangle(Triangulation &tria, + const std::vector > &step_sizes, + const Point &p_1, + const Point &p_2, + const bool colorize); + /** * A parallelogram. The first * corner point is the diff --git a/deal.II/deal.II/source/grid/grid_generator.cc b/deal.II/deal.II/source/grid/grid_generator.cc index 9f34e64200..cfb251096d 100644 --- a/deal.II/deal.II/source/grid/grid_generator.cc +++ b/deal.II/deal.II/source/grid/grid_generator.cc @@ -442,6 +442,202 @@ subdivided_hyper_rectangle (Triangulation &tria, } + +template +void +GridGenerator:: +subdivided_hyper_rectangle(Triangulation &tria, + const std::vector > &step_sz, + const Point &p_1, + const Point &p_2, + const bool colorize) +{ + // contributed by Joerg R. Weimar + // (j.weimar@jweimar.de) 2003 + // modified by Yaqi Wang 2006 + Assert(step_sz.size() == dim, + ExcInvalidRepetitionsDimension(dim)); + + + // First, normalize input such that + // p1 is lower in all coordinate + // directions. + + // and check the consistency of + // step sizes, i.e. that they all + // add up to the sizes specified by + // p_1 and p_2 + Point p1(p_1); + Point p2(p_2); + std::vector< std::vector > step_sizes(step_sz); + + for (unsigned int i=0;i p2(i)) + { + std::swap (p1(i), p2(i)); + std::reverse (step_sizes[i].begin(), step_sizes[i].end()); + } + + double x = 0; + for (unsigned int j=0; j > points; + switch (dim) + { + case 1: + { + double x=0; + for (unsigned int i=0; i<=step_sizes[0].size(); ++i) + { + points.push_back (Point (p1[0]+x)); + x += step_sizes[0][i]; + } + break; + } + + case 2: + { + double y=0; + for (unsigned int j=0; j<=step_sizes[1].size(); ++j) + { + double x=0; + for (unsigned int i=0; i<=step_sizes[0].size(); ++i) + { + points.push_back (Point (p1[0]+x, + p1[1]+y)); + x += step_sizes[0][i]; + } + y += step_sizes[1][j]; + } + break; + + } + case 3: + { + double z=0; + for (unsigned int k=0; k<=step_sizes[2].size(); ++k) + { + double y=0; + for (unsigned int j=0; j<=step_sizes[1].size(); ++j) + { + double x=0; + for (unsigned int i=0; i<=step_sizes[0].size(); ++i) + { + points.push_back (Point (p1[0]+x, + p1[1]+y, + p1[2]+z)); + x += step_sizes[0][i]; + } + y += step_sizes[1][j]; + } + z += step_sizes[2][k]; + } + break; + } + + default: + Assert (false, ExcNotImplemented()); + } + + // next create the cells + // Prepare cell data + std::vector > cells; + switch (dim) + { + case 1: + { + cells.resize (step_sizes[0].size()); + for (unsigned int x=0; x const Point&, const Point&, bool); +template void +GridGenerator::subdivided_hyper_rectangle +(Triangulation &, + const std::vector >&, + const Point&, + const Point&, bool); + template void GridGenerator::parallelogram ( Triangulation &, diff --git a/deal.II/doc/news/changes.html b/deal.II/doc/news/changes.html index 7130190b1e..e0b9c9c9d2 100644 --- a/deal.II/doc/news/changes.html +++ b/deal.II/doc/news/changes.html @@ -418,7 +418,7 @@ inconvenience this causes.
  • Extended: The QGaussLobatto quadrature rule computes Legendre-Gauss-Lobatto nodes and quadrature weights.
    - (F. Prill 2006/11/02) + (Florian Prill 2006/11/02)

  • Extended: The contract function family contracts two @@ -717,7 +717,7 @@ inconvenience this causes.

  • Improved: PETSc 2.3.1 (build 16) is now supported by the linear preconditioner classes. The new PETSc functions PCFactorSetXXX are used.
    - (F. Prill, 2006/08/04) + (Florian Prill, 2006/08/04)

  • New: The class TransposeMatrix @@ -922,11 +922,19 @@ inconvenience this causes.

      +
    1. New: There is now a function GridGenerator::subdivided_hyper_rectangle + that produces a non-uniformly subdivided rectangle, ideally + suited for graded meshes. +
      + (Yaqi Wang 2006/11/15) +

      +
    2. Fixed: Corrected clone method of FE_DGQ class for non-equidistant support points.
      - (F. Prill 2006/10/31) + (Florian Prill 2006/10/31)

    3. Improved: The lookup mechanism in