From: leicht Date: Fri, 9 Feb 2007 06:48:31 +0000 (+0000) Subject: New function GridGenerator::moebius() creating a loop of cells which are rotated... X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=64d04cbf08e1498f9be05cbe6cd5bec5550c4ae3;p=dealii-svn.git New function GridGenerator::moebius() creating a loop of cells which are rotated against each other before one end of the string is attached to the other one. This is a partial merge from branch_general_meshes. git-svn-id: https://svn.dealii.org/trunk@14441 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 12c4f364e2..ad85d444af 100644 --- a/deal.II/deal.II/include/grid/grid_generator.h +++ b/deal.II/deal.II/include/grid/grid_generator.h @@ -663,6 +663,24 @@ class GridGenerator const unsigned int n_cells = 0); + /** + * Produce a ring of cells in 3D that is + * cut open, twisted and glued together + * again. This results in a kind of + * moebius-loop. + * + * @param tria The triangulation to be worked on. + * @param n_cells The number of cells in the loop. Must be greater than 4. + * @param n_rotations The number of rotations (Pi/2 each) to be performed before glueing the loop together. + * @param R The radius of the circle, which forms the middle line of the torus containing the loop of cells. Must be greater than @p r. + * @param r The radius of the cylinder bend together as loop. + */ + static void moebius (Triangulation<3>& tria, + const unsigned int n_cells, + const unsigned int n_rotations, + const double R, + const double r); + /** * This function transformes the * @p Triangulation @p tria diff --git a/deal.II/deal.II/source/grid/grid_generator.cc b/deal.II/deal.II/source/grid/grid_generator.cc index 3d6c1e3463..803b82ee8c 100644 --- a/deal.II/deal.II/source/grid/grid_generator.cc +++ b/deal.II/deal.II/source/grid/grid_generator.cc @@ -150,6 +150,64 @@ void GridGenerator::hyper_cube (Triangulation &tria, } +#if deal_II_dimension == 3 + +void +GridGenerator::moebius ( + Triangulation<3>& tria, + const unsigned int n_cells, + const unsigned int n_rotations, + const double R, + const double r) +{ + const unsigned int dim=3; + Assert (n_cells>4, ExcMessage("More than 4 cells are needed to create a moebius grid.")); + Assert (r>0 && R>0, ExcMessage("Outer and inner radius must be positive.")); + Assert (R>r, ExcMessage("Outer radius must be greater than inner radius.")); + + + std::vector > vertices (4*n_cells); + double beta_step=n_rotations*deal_II_numbers::PI/2.0/n_cells; + double alpha_step=2.0*deal_II_numbers::PI/n_cells; + + for (unsigned int i=0; i > cells (n_cells); + for (unsigned int i=0; i::invert_all_cells_of_negative_grid(vertices,cells); + tria.create_triangulation_compatibility (vertices, cells, SubCellData()); +} + +#endif + + + // Implementation for 2D only template void