From: wolf Date: Mon, 3 May 1999 18:50:21 +0000 (+0000) Subject: Externalize the grid generation functions from the Triangulation class to an own... X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4925025a3376569e90a6a353b0d82c739a800b20;p=dealii-svn.git Externalize the grid generation functions from the Triangulation class to an own class. git-svn-id: https://svn.dealii.org/trunk@1256 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/Attic/examples/convergence/convergence.cc b/deal.II/deal.II/Attic/examples/convergence/convergence.cc index 597bb375f0..5f7badedde 100644 --- a/deal.II/deal.II/Attic/examples/convergence/convergence.cc +++ b/deal.II/deal.II/Attic/examples/convergence/convergence.cc @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -266,7 +267,7 @@ int PoissonProblem::run (const unsigned int level) { cout << ">" << endl; cout << " Making grid... "; - tria->create_hyper_ball (); + GridGenerator::hyper_ball (*tria); HyperBallBoundary boundary_description; tria->set_boundary (&boundary_description); tria->begin_active()->set_refine_flag(); diff --git a/deal.II/deal.II/Attic/examples/dof/dof_test.cc b/deal.II/deal.II/Attic/examples/dof/dof_test.cc index d9ee2ee997..44bd5cefcc 100644 --- a/deal.II/deal.II/Attic/examples/dof/dof_test.cc +++ b/deal.II/deal.II/Attic/examples/dof/dof_test.cc @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -199,7 +200,7 @@ void TestCases::create_new (const unsigned int) { if (tria != 0) delete tria; tria = new Triangulation(); - tria->create_hypercube(); + GridGenerator::hyper_cube(*tria); dof = new DoFHandler (tria); }; diff --git a/deal.II/deal.II/Attic/examples/error-estimation/error-estimation.cc b/deal.II/deal.II/Attic/examples/error-estimation/error-estimation.cc index 93d58e28cc..26b768a808 100644 --- a/deal.II/deal.II/Attic/examples/error-estimation/error-estimation.cc +++ b/deal.II/deal.II/Attic/examples/error-estimation/error-estimation.cc @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -412,7 +413,7 @@ void PoissonProblem::run (ParameterHandler &prm) { cout << "Making initial grid... " << endl; const unsigned int start_level(prm.get_integer("Initial refinement")); tria->set_boundary (boundary); - tria->create_hyper_ball (); + GridGenerator::hyper_ball (*tria); tria->refine_global (start_level); if (prm.get("Test case")=="Gauss shape") diff --git a/deal.II/deal.II/Attic/examples/grid/grid_test.cc b/deal.II/deal.II/Attic/examples/grid/grid_test.cc index f4aa02e899..9d4e2457d2 100644 --- a/deal.II/deal.II/Attic/examples/grid/grid_test.cc +++ b/deal.II/deal.II/Attic/examples/grid/grid_test.cc @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -159,7 +160,7 @@ void test (const int test_case) { cout << "Running testcase " << test_case << " in " << dim << " dimensions." << endl; Triangulation tria; - tria.create_hypercube(); + GridGenerator::hyper_cube(tria); if ((dim==1) && ((test_case==2) || (test_case==3))) { diff --git a/deal.II/deal.II/Attic/examples/multigrid/multigrid.cc b/deal.II/deal.II/Attic/examples/multigrid/multigrid.cc index 3f2d7303a2..c8a052ef3f 100644 --- a/deal.II/deal.II/Attic/examples/multigrid/multigrid.cc +++ b/deal.II/deal.II/Attic/examples/multigrid/multigrid.cc @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -426,7 +427,7 @@ int PoissonProblem::run (const unsigned int level) { cout << ">" << endl; cout << " Making grid... "; - tria->create_hypercube (); + GridGenerator::hyper_cube (*tria); tria->refine_global (level+1); tria->begin_active()->set_refine_flag(); (++(++(tria->begin_active())))->set_refine_flag(); diff --git a/deal.II/deal.II/Attic/examples/nonlinear/fixed-point-iteration/nonlinear.cc b/deal.II/deal.II/Attic/examples/nonlinear/fixed-point-iteration/nonlinear.cc index 357accccd6..dd4053a9e2 100644 --- a/deal.II/deal.II/Attic/examples/nonlinear/fixed-point-iteration/nonlinear.cc +++ b/deal.II/deal.II/Attic/examples/nonlinear/fixed-point-iteration/nonlinear.cc @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -173,7 +174,7 @@ void NonlinearProblem::run () { dirichlet_bc[0] = &boundary_values; - tria->create_hypercube (); + GridGenerator::hypercube (*tria); tria->refine_global (4); for (unsigned int refinement_step=0; refinement_step<10; ++refinement_step) diff --git a/deal.II/deal.II/Attic/examples/poisson/problem.cc b/deal.II/deal.II/Attic/examples/poisson/problem.cc index 56903c84e0..41d8e7566d 100644 --- a/deal.II/deal.II/Attic/examples/poisson/problem.cc +++ b/deal.II/deal.II/Attic/examples/poisson/problem.cc @@ -5,6 +5,7 @@ #include "poisson.h" #include +#include @@ -348,7 +349,7 @@ bool PoissonProblem::make_grid (ParameterHandler &prm) { { static const Point origin; boundary = new HyperBallBoundary(origin, 1.); - tria->create_hyper_ball (origin, 1.); + GridGenerator::hyper_ball (*tria, origin, 1.); tria->set_boundary (boundary); break; }; @@ -356,7 +357,7 @@ bool PoissonProblem::make_grid (ParameterHandler &prm) { // set the boundary function { boundary = new CurvedLine(); - tria->create_hypercube (); + GridGenerator::hyper_cube (*tria); tria->set_boundary (boundary); break; }; @@ -368,12 +369,12 @@ bool PoissonProblem::make_grid (ParameterHandler &prm) { case 5: boundary = new StraightBoundary(); tria->set_boundary (boundary); - tria->create_hypercube (); + GridGenerator::hyper_cube (*tria); break; case 6: boundary = new StraightBoundary(); tria->set_boundary (boundary); - tria->create_hypercube (); + GridGenerator::hyper_cube (*tria); tria->refine_global (1); for (unsigned int i=0; i<5; ++i) { @@ -385,7 +386,7 @@ bool PoissonProblem::make_grid (ParameterHandler &prm) { case 7: boundary = new StraightBoundary(); tria->set_boundary (boundary); - tria->create_hyper_L (); + GridGenerator::hyper_L (*tria); break; default: return false; @@ -405,7 +406,7 @@ bool PoissonProblem::make_grid (ParameterHandler &prm) { template void PoissonProblem::make_zoom_in_grid () { - tria->create_hypercube (); + GridGenerator::hyper_cube (*tria); // refine first cell tria->begin_active()->set_refine_flag(); tria->execute_coarsening_and_refinement (); @@ -432,7 +433,7 @@ void PoissonProblem::make_zoom_in_grid () { template void PoissonProblem::make_random_grid () { - tria->create_hypercube (); + GridGenerator::hyper_cube (*tria); tria->refine_global (1); Triangulation::active_cell_iterator cell, endc; diff --git a/deal.II/deal.II/include/grid/grid_generator.h b/deal.II/deal.II/include/grid/grid_generator.h new file mode 100644 index 0000000000..12e4b82cf6 --- /dev/null +++ b/deal.II/deal.II/include/grid/grid_generator.h @@ -0,0 +1,109 @@ +/*---------------------------- grid_generator.h ---------------------------*/ +/* $Id$ */ +#ifndef __grid_generator_H +#define __grid_generator_H +/*---------------------------- grid_generator.h ---------------------------*/ + + +#include +#include + +/** + * This class offers triangulations of some standard domains such as hypercubes, + * hyperball and the like. Following is a list of domains that can be generated + * by the functions of this class: + * \begin{itemize} + * \item Hypercube triangulations: a hypercube triangulation is a + * domain which is the tensor product of an interval $[a,b]$ in + * the given number of spatial dimensions. If you want to create such + * a domain, which is a common test case for model problems, call + * #GridGenerator::create_hypercube (tria, a,b)#, which produces a + * hypercube domain triangulated with exactly one element. You can + * get tensor product meshes by successive refinement of this cell. + * + * \item Generalized L-shape domain: + * using the #GridGenerator::create_L_region (tria, a,b)# function produces + * the hypercube with the interval $[a,b]$ without the hypercube + * made out of the interval $[(a+b)/2,b]$. Let, for example, be $a=-1$ + * and $b=1$, then the hpyer-L in two dimensions is the region + * $[-1,1]^2 - [0,1]^2$. To create a hyper-L in one dimension results in + * an error. The function is also implemented for three space dimensions. + * + * \item Hyper balls: + * You get the circle or ball (or generalized: hyperball) around origin + * #p# and with radius #r# by calling + * #Triangulation::create_hyper_ball (p, r)#. The circle is triangulated + * by five cells, the ball by seven cells. The diameter of the center cell is + * chosen so that the aspect ratio of the boundary cells after one refinement + * is minimized in some way. To create a hyperball in one dimension results in + * an error. + * + * Do not forget to attach a suitable + * boundary approximation object if you want the triangulation to be refined + * at the outer boundaries. + * \end{itemize} + * + * @author Wolfgang Bangerth, 1998, 1999 + */ +class GridGenerator +{ + public: + + /** + * Initialize the given triangulation with a + * hypercube (line in 1D, square in 2D, etc) + * consisting of exactly one cell. The + * hypercube volume is the tensor product + * of the intervall $[left,right]$ in the + * present number of dimensions, where + * the limits are given as arguments. They + * default to zero and unity, then producing + * the unit hypercube. + * + * The triangulation needs to be void + * upon calling this function. + */ + template + static void hyper_cube (Triangulation &tria, + const double left = 0., + const double right= 1.); + + /** + * Initialize the given triangulation with a + * hyperball, i.e. a circle or a ball. + * See the general documentation for a + * more concise description. The center of + * the hyperball default to the origin, + * the radius defaults to unity. + * + * The triangulation needs to be void + * upon calling this function. + */ + template + static void hyper_ball (Triangulation &tria, + const Point ¢er = Point(), + const double radius = 1.); + + /** + * Initialize the given triangulation with a + * hyper-L consisting of exactly #2^dim-1# + * cells. See the general documentation for a + * description of the L-region. The limits + * default to minus unity and unity. + * + * The triangulation needs to be void + * upon calling this function. + */ + template + static void hyper_L (Triangulation &tria, + const double left = -1., + const double right= 1.); +}; + + + + +/*---------------------------- grid_generator.h ---------------------------*/ +/* end of #ifndef __grid_generator_H */ +#endif +/*---------------------------- grid_generator.h ---------------------------*/ diff --git a/deal.II/deal.II/include/grid/tria.h b/deal.II/deal.II/include/grid/tria.h index d3abc49943..6564de3658 100644 --- a/deal.II/deal.II/include/grid/tria.h +++ b/deal.II/deal.II/include/grid/tria.h @@ -466,33 +466,12 @@ class TriaDimensionInfo<3> { * * There are several possibilities to create a triangulation: * \begin{itemize} - * \item Hypercube triangulations: a hypercube triangulation is a - * domain which is the tensor product of an interval $[a,b]$ in - * the given number of spatial dimensions. If you want to create such - * a domain, which is a common test case for model problems, call - * #Triangulation::create_hypercube (a,b)#, which produces a - * hypercube domain triangulated with exactly one element. You can - * get tensor product meshes by successive refinement of this cell. - * - * \item Other standard regions: you can get the generalized L-shape domain - * using the #Triangulation::create_L_region (a,b)# function, which - * is the hypercube with the interval $[a,b]$ without the hypercube - * made out of the interval $[(a+b)/2,b]$. Let, for example, be $a=-1$ - * and $b=1$, then the hpyer-L in two dimensions is the region - * $[-1,1]^2 - [0,1]^2$. To create a hyper-L in one dimension results in - * an error. - * - * You get the circle or ball (or generalized: hyperball) around origin - * #p# and with radius #r# by calling - * #Triangulation::create_hyper_ball (p, r)#. The circle is triangulated - * by five cells, the ball by seven cells. The diameter of the center cell is - * chosen so that the aspect ratio of the boundary cells after one refinement - * is minimized in some way. To create a hyperball in one dimension results in - * an error. - * - * Do not forget to attach a suitable - * boundary approximation object if you want the triangulation to be refined - * at the outer boundaries. + * \item The most common domains, such as hypercubes (i.e. lines, squares, + * cubes, etc), hyperballs (circles, balls, ...) and some other, more + * weird domains such as the L-shape region and higher dimensional + * generalizations and others, are provided by the #GridGenerator# + * class which takes a triangulation and fills it by a division + * of the required domain. * * \item Reading in a triangulation: By using an object of the #DataIn# * class, you can read in fairly general triangulations. See there for @@ -1597,50 +1576,6 @@ class Triangulation : public TriaDimensionInfo, public Subscriptor { void create_triangulation (const vector > &vertices, const vector > &cells, const SubCellData &subcelldata); - - /** - * Initialize the triangulation with a - * hypercube (line in 1D, square in 2D, etc) - * consisting of exactly one cell. The - * hypercube volume is the tensor product - * of the intervall $[left,right]$ in the - * present number of dimensions, where - * the limits are given as arguments. They - * default to zero and unity, then producing - * the unit hypercube. - * - * The triangulation needs to be void - * upon calling this function. - */ - void create_hypercube (const double left = 0., - const double right= 1.); - - /** - * Initialize the triangulation with a - * hyper-L consisting of exactly #2^dim-1# - * cells. See the general documentation for a - * description of the L-region. The limits - * default to minus unity and unity. - * - * The triangulation needs to be void - * upon calling this function. - */ - void create_hyper_L (const double left = -1., - const double right= 1.); - - /** - * Initialize the triangulation with a - * hyperball, i.e. a circle or a ball. - * See the general documentation for a - * more concise description. The center of - * the hyperball default to the origin, - * the radius defaults to unity. - * - * The triangulation needs to be void - * upon calling this function. - */ - void create_hyper_ball (const Point ¢er = Point(), - const double radius = 1.); /** * Distort the grid by randomly moving diff --git a/deal.II/deal.II/source/grid/grid_generator.cc b/deal.II/deal.II/source/grid/grid_generator.cc new file mode 100644 index 0000000000..ace7d6beec --- /dev/null +++ b/deal.II/deal.II/source/grid/grid_generator.cc @@ -0,0 +1,312 @@ +/* $Id$ */ + + +#include +#include +#include + + + + + +#if deal_II_dimension == 1 + +template <> +void GridGenerator::hyper_cube<> (Triangulation<1> &tria, + const double left, + const double right) { + const Point<1> vertices[2] = { Point<1>(left), Point<1>(right) }; + vector > cells (1, CellData<1>()); + cells[0].vertices[0] = 0; + cells[0].vertices[1] = 1; + cells[0].material_id = 0; + + tria.create_triangulation (vector >(&vertices[0], &vertices[2]), + cells, + SubCellData()); // no boundary information +}; + + + +template <> +void GridGenerator::hyper_L<> (Triangulation<1> &, + const double, + const double) { + Assert (false, ExcInternalError()); +}; + + + +template <> +void GridGenerator::hyper_ball<> (Triangulation<1> &, + const Point<1> &, + const double) { + Assert (false, ExcInternalError()); +}; + +#endif + + + +#if deal_II_dimension == 2 + +template <> +void GridGenerator::hyper_cube<> (Triangulation<2> &tria, + const double left, + const double right) { + const Point<2> vertices[4] = { Point<2>(left,left), + Point<2>(right,left), + Point<2>(right,right), + Point<2>(left,right) }; + const int cell_vertices[1][4] = { { 0,1,2,3 } }; + vector > cells (1, CellData<2>()); + for (unsigned int j=0; j<4; ++j) + cells[0].vertices[j] = cell_vertices[0][j]; + cells[0].material_id = 0; + + tria.create_triangulation (vector >(&vertices[0], &vertices[4]), + cells, + SubCellData()); // no boundary information +}; + + + +template <> +void GridGenerator::hyper_L<> (Triangulation<2> &tria, + const double a, + const double b) { + const unsigned int dim=2; + const Point vertices[8] = { Point (a,a), + Point ((a+b)/2,a), + Point (b,a), + Point (a,(a+b)/2), + Point ((a+b)/2,(a+b)/2), + Point (b,(a+b)/2), + Point (a,b), + Point ((a+b)/2,b) }; + const int cell_vertices[3][4] = {{0, 1, 4, 3}, + {1, 2, 5, 4}, + {3, 4, 7, 6}}; + + vector > cells (3, CellData<2>()); + + for (unsigned int i=0; i<3; ++i) + { + for (unsigned int j=0; j<4; ++j) + cells[i].vertices[j] = cell_vertices[i][j]; + cells[i].material_id = 0; + }; + + tria.create_triangulation (vector >(&vertices[0], &vertices[8]), + cells, + SubCellData()); // no boundary information +}; + + + +template <> +void GridGenerator::hyper_ball<> (Triangulation<2> &tria, + const Point<2> &p, + const double radius) { + const double a = 1./(1+sqrt(2)); // equilibrate cell sizes at transition + // from the inner part to the radial + // cells + const Point<2> vertices[8] = { p+Point<2>(-1,-1)*(radius/sqrt(2)), + p+Point<2>(+1,-1)*(radius/sqrt(2)), + p+Point<2>(-1,-1)*(radius/sqrt(2)*a), + p+Point<2>(+1,-1)*(radius/sqrt(2)*a), + p+Point<2>(-1,+1)*(radius/sqrt(2)*a), + p+Point<2>(+1,+1)*(radius/sqrt(2)*a), + p+Point<2>(-1,+1)*(radius/sqrt(2)), + p+Point<2>(+1,+1)*(radius/sqrt(2)) }; + + const int cell_vertices[5][4] = {{0, 1, 3, 2}, + {0, 2, 4, 6}, + {2, 3, 5, 4}, + {1, 7, 5, 3}, + {6, 4, 5, 7}}; + + vector > cells (5, CellData<2>()); + + for (unsigned int i=0; i<5; ++i) + { + for (unsigned int j=0; j<4; ++j) + cells[i].vertices[j] = cell_vertices[i][j]; + cells[i].material_id = 0; + }; + + tria.create_triangulation (vector >(&vertices[0], &vertices[8]), + cells, + SubCellData()); // no boundary information +}; + +#endif + + +#if deal_II_dimension == 3 + +template <> +void GridGenerator::hyper_cube<> (Triangulation<3> &tria, + const double left, + const double right) { + const Point<3> vertices[8] = { Point<3>(left,left,left), + Point<3>(right,left,left), + Point<3>(right,left,right), + Point<3>(left,left,right), + + Point<3>(left,right,left), + Point<3>(right,right,left), + Point<3>(right,right,right), + Point<3>(left,right,right)}; + const int cell_vertices[1][8] = { { 0,1,2,3,4,5,6,7 } }; + vector > cells (1, CellData<3>()); + for (unsigned int j=0; j<8; ++j) + cells[0].vertices[j] = cell_vertices[0][j]; + cells[0].material_id = 0; + + tria.create_triangulation (vector >(&vertices[0], &vertices[8]), + cells, + SubCellData()); // no boundary information +}; + + + +template <> +void GridGenerator::hyper_L<> (Triangulation<3> &tria, + const double a, + const double b) { + const unsigned int dim=3; + // we slice out the top back right + // part of the cube + const Point vertices[26] + = { + // front face of the big cube + Point (a, a,a), + Point ((a+b)/2,a,a), + Point (b, a,a), + Point (a, a,(a+b)/2), + Point ((a+b)/2,a,(a+b)/2), + Point (b, a,(a+b)/2), + Point (a, a,b), + Point ((a+b)/2,a,b), + Point (b, a,b), + // middle face of the big cube + Point (a, (a+b)/2,a), + Point ((a+b)/2,(a+b)/2,a), + Point (b, (a+b)/2,a), + Point (a, (a+b)/2,(a+b)/2), + Point ((a+b)/2,(a+b)/2,(a+b)/2), + Point (b, (a+b)/2,(a+b)/2), + Point (a, (a+b)/2,b), + Point ((a+b)/2,(a+b)/2,b), + Point (b, (a+b)/2,b), + // back face of the big cube + // last (top right) point is missing + Point (a, b,a), + Point ((a+b)/2,b,a), + Point (b, b,a), + Point (a, b,(a+b)/2), + Point ((a+b)/2,b,(a+b)/2), + Point (b, b,(a+b)/2), + Point (a, b,b), + Point ((a+b)/2,b,b) + }; + const int cell_vertices[7][8] = {{0, 1, 4, 3, 9, 10, 13, 12}, + {1, 2, 5, 4, 10, 11, 14, 13}, + {3, 4, 7, 6, 12, 13, 16, 15}, + {4, 5, 8, 7, 13, 14, 17, 16}, + {9, 10, 13, 12, 18, 19, 22, 21}, + {10, 11, 14, 13, 19, 20, 23, 22}, + {12, 13, 16, 15, 21, 22, 25, 24}}; + + vector > cells (7, CellData<3>()); + + for (unsigned int i=0; i<7; ++i) + { + for (unsigned int j=0; j<8; ++j) + cells[i].vertices[j] = cell_vertices[i][j]; + cells[i].material_id = 0; + }; + + tria.create_triangulation (vector >(&vertices[0], &vertices[26]), + cells, + SubCellData()); // no boundary information +}; + + + +template <> +void GridGenerator::hyper_ball<> (Triangulation<3> &tria, + const Point<3> &p, + const double radius) { + const double a = 1./(1+sqrt(3)); // equilibrate cell sizes at transition + // from the inner part to the radial + // cells + const unsigned int n_vertices = 16; + const Point<3> vertices[n_vertices] + = { + // first the vertices of the inner + // cell + p+Point<3>(-1,-1,-1)*(radius/sqrt(3)*a), + p+Point<3>(+1,-1,-1)*(radius/sqrt(3)*a), + p+Point<3>(+1,+1,-1)*(radius/sqrt(3)*a), + p+Point<3>(-1,+1,-1)*(radius/sqrt(3)*a), + p+Point<3>(-1,-1,+1)*(radius/sqrt(3)*a), + p+Point<3>(+1,-1,+1)*(radius/sqrt(3)*a), + p+Point<3>(+1,+1,+1)*(radius/sqrt(3)*a), + p+Point<3>(-1,+1,+1)*(radius/sqrt(3)*a), + // now the eight vertices at + // the outer sphere + p+Point<3>(-1,-1,-1)*(radius/sqrt(3)), + p+Point<3>(+1,-1,-1)*(radius/sqrt(3)), + p+Point<3>(+1,+1,-1)*(radius/sqrt(3)), + p+Point<3>(-1,+1,-1)*(radius/sqrt(3)), + p+Point<3>(-1,-1,+1)*(radius/sqrt(3)), + p+Point<3>(+1,-1,+1)*(radius/sqrt(3)), + p+Point<3>(+1,+1,+1)*(radius/sqrt(3)), + p+Point<3>(-1,+1,+1)*(radius/sqrt(3)) + }; + + // one needs to draw the seven cubes to + // understand what's going on here + const unsigned int n_cells = 7; + const int cell_vertices[n_cells][8] = {{0, 1, 2, 3, 4, 5, 6, 7}, + {8, 9, 10, 11, 0, 1, 2, 3}, + {9, 13, 14, 10, 1, 5, 6, 2}, + {12, 4, 7, 15, 13, 5, 6, 14}, + {8, 0, 3, 11, 12, 4, 7, 15}, + {11, 10,14, 15, 3, 2, 6, 7}, + {8, 9, 13, 12, 0, 1, 5, 4}}; + + vector > cells (n_cells, CellData<3>()); + + for (unsigned int i=0; i::vertices_per_cell; ++j) + cells[i].vertices[j] = cell_vertices[i][j]; + cells[i].material_id = 0; + }; + + tria.create_triangulation (vector >(&vertices[0], &vertices[n_vertices]), + cells, + SubCellData()); // no boundary information +}; + + + +#endif + + + + +// explicit instantiations +// template void GridGenerator::hyper_cube (Triangulation &, +// const double, +// const double); +// template void GridGenerator::hyper_L (Triangulation &, +// const double, +// const double); +// template void GridGenerator::hyper_ball (Triangulation &, +// const Point &, +// const double); + diff --git a/deal.II/deal.II/source/grid/tria.cc b/deal.II/deal.II/source/grid/tria.cc index 02ba3e0aa1..67f7e0c640 100644 --- a/deal.II/deal.II/source/grid/tria.cc +++ b/deal.II/deal.II/source/grid/tria.cc @@ -302,40 +302,6 @@ void Triangulation<1>::create_triangulation (const vector > &v, }; }; - - - -template <> -void Triangulation<1>::create_hypercube (const double left, - const double right) { - Assert (vertices.size() == 0, ExcTriangulationNotEmpty()); - Assert (n_lines() == 0, ExcTriangulationNotEmpty()); - - const Point<1> vertices[2] = { Point<1>(left), Point<1>(right) }; - vector > cells (1, CellData<1>()); - cells[0].vertices[0] = 0; - cells[0].vertices[1] = 1; - cells[0].material_id = 0; - - create_triangulation (vector >(&vertices[0], &vertices[2]), - cells, - SubCellData()); // no boundary information -}; - - - -template <> -void Triangulation<1>::create_hyper_L (const double, const double) { - Assert (false, ExcInternalError()); -}; - - - -template <> -void Triangulation<1>::create_hyper_ball (const Point<1> &, const double) { - Assert (false, ExcInternalError()); -}; - #endif @@ -627,97 +593,6 @@ void Triangulation<2>::create_triangulation (const vector > &v, adjacent_cells[cell->line(side)->index()][0]); }; - - -template <> -void Triangulation<2>::create_hypercube (const double left, - const double right) { - Assert (vertices.size() == 0, ExcTriangulationNotEmpty()); - Assert (n_lines() == 0, ExcTriangulationNotEmpty()); - Assert (n_quads() == 0, ExcTriangulationNotEmpty()); - - const Point<2> vertices[4] = { Point<2>(left,left), - Point<2>(right,left), - Point<2>(right,right), - Point<2>(left,right) }; - const int cell_vertices[1][4] = { { 0,1,2,3 } }; - vector > cells (1, CellData<2>()); - for (unsigned int j=0; j<4; ++j) - cells[0].vertices[j] = cell_vertices[0][j]; - cells[0].material_id = 0; - - create_triangulation (vector >(&vertices[0], &vertices[4]), - cells, - SubCellData()); // no boundary information -}; - - - -template <> -void Triangulation<2>::create_hyper_L (const double a, const double b) { - const unsigned int dim=2; - const Point vertices[8] = { Point (a,a), - Point ((a+b)/2,a), - Point (b,a), - Point (a,(a+b)/2), - Point ((a+b)/2,(a+b)/2), - Point (b,(a+b)/2), - Point (a,b), - Point ((a+b)/2,b) }; - const int cell_vertices[3][4] = {{0, 1, 4, 3}, - {1, 2, 5, 4}, - {3, 4, 7, 6}}; - - vector > cells (3, CellData<2>()); - - for (unsigned int i=0; i<3; ++i) - { - for (unsigned int j=0; j<4; ++j) - cells[i].vertices[j] = cell_vertices[i][j]; - cells[i].material_id = 0; - }; - - create_triangulation (vector >(&vertices[0], &vertices[8]), - cells, - SubCellData()); // no boundary information -}; - - - -template <> -void Triangulation<2>::create_hyper_ball (const Point<2> &p, const double radius) { - const double a = 1./(1+sqrt(2)); // equilibrate cell sizes at transition - // from the inner part to the radial - // cells - const Point<2> vertices[8] = { p+Point<2>(-1,-1)*(radius/sqrt(2)), - p+Point<2>(+1,-1)*(radius/sqrt(2)), - p+Point<2>(-1,-1)*(radius/sqrt(2)*a), - p+Point<2>(+1,-1)*(radius/sqrt(2)*a), - p+Point<2>(-1,+1)*(radius/sqrt(2)*a), - p+Point<2>(+1,+1)*(radius/sqrt(2)*a), - p+Point<2>(-1,+1)*(radius/sqrt(2)), - p+Point<2>(+1,+1)*(radius/sqrt(2)) }; - - const int cell_vertices[5][4] = {{0, 1, 3, 2}, - {0, 2, 4, 6}, - {2, 3, 5, 4}, - {1, 7, 5, 3}, - {6, 4, 5, 7}}; - - vector > cells (5, CellData<2>()); - - for (unsigned int i=0; i<5; ++i) - { - for (unsigned int j=0; j<4; ++j) - cells[i].vertices[j] = cell_vertices[i][j]; - cells[i].material_id = 0; - }; - - create_triangulation (vector >(&vertices[0], &vertices[8]), - cells, - SubCellData()); // no boundary information -}; - #endif @@ -1221,157 +1096,6 @@ void Triangulation<3>::create_triangulation (const vector > &v, adjacent_cells[cell->quad(face)->index()][0]); }; - - -template <> -void Triangulation<3>::create_hypercube (const double left, - const double right) { - Assert (vertices.size() == 0, ExcTriangulationNotEmpty()); - Assert (n_lines() == 0, ExcTriangulationNotEmpty()); - Assert (n_quads() == 0, ExcTriangulationNotEmpty()); - Assert (n_hexs() == 0, ExcTriangulationNotEmpty()); - - const Point<3> vertices[8] = { Point<3>(left,left,left), - Point<3>(right,left,left), - Point<3>(right,left,right), - Point<3>(left,left,right), - - Point<3>(left,right,left), - Point<3>(right,right,left), - Point<3>(right,right,right), - Point<3>(left,right,right)}; - const int cell_vertices[1][8] = { { 0,1,2,3,4,5,6,7 } }; - vector > cells (1, CellData<3>()); - for (unsigned int j=0; j<8; ++j) - cells[0].vertices[j] = cell_vertices[0][j]; - cells[0].material_id = 0; - - create_triangulation (vector >(&vertices[0], &vertices[8]), - cells, - SubCellData()); // no boundary information -}; - - - -template <> -void Triangulation<3>::create_hyper_L (const double a, const double b) { - const unsigned int dim=3; - // we slice out the top back right - // part of the cube - const Point vertices[26] - = { - // front face of the big cube - Point (a, a,a), - Point ((a+b)/2,a,a), - Point (b, a,a), - Point (a, a,(a+b)/2), - Point ((a+b)/2,a,(a+b)/2), - Point (b, a,(a+b)/2), - Point (a, a,b), - Point ((a+b)/2,a,b), - Point (b, a,b), - // middle face of the big cube - Point (a, (a+b)/2,a), - Point ((a+b)/2,(a+b)/2,a), - Point (b, (a+b)/2,a), - Point (a, (a+b)/2,(a+b)/2), - Point ((a+b)/2,(a+b)/2,(a+b)/2), - Point (b, (a+b)/2,(a+b)/2), - Point (a, (a+b)/2,b), - Point ((a+b)/2,(a+b)/2,b), - Point (b, (a+b)/2,b), - // back face of the big cube - // last (top right) point is missing - Point (a, b,a), - Point ((a+b)/2,b,a), - Point (b, b,a), - Point (a, b,(a+b)/2), - Point ((a+b)/2,b,(a+b)/2), - Point (b, b,(a+b)/2), - Point (a, b,b), - Point ((a+b)/2,b,b) - }; - const int cell_vertices[7][8] = {{0, 1, 4, 3, 9, 10, 13, 12}, - {1, 2, 5, 4, 10, 11, 14, 13}, - {3, 4, 7, 6, 12, 13, 16, 15}, - {4, 5, 8, 7, 13, 14, 17, 16}, - {9, 10, 13, 12, 18, 19, 22, 21}, - {10, 11, 14, 13, 19, 20, 23, 22}, - {12, 13, 16, 15, 21, 22, 25, 24}}; - - vector > cells (7, CellData<3>()); - - for (unsigned int i=0; i<7; ++i) - { - for (unsigned int j=0; j<8; ++j) - cells[i].vertices[j] = cell_vertices[i][j]; - cells[i].material_id = 0; - }; - - create_triangulation (vector >(&vertices[0], &vertices[26]), - cells, - SubCellData()); // no boundary information -}; - - - -template <> -void Triangulation<3>::create_hyper_ball (const Point<3> &p, const double radius) { - const double a = 1./(1+sqrt(3)); // equilibrate cell sizes at transition - // from the inner part to the radial - // cells - const unsigned int n_vertices = 16; - const Point<3> vertices[n_vertices] - = { - // first the vertices of the inner - // cell - p+Point<3>(-1,-1,-1)*(radius/sqrt(3)*a), - p+Point<3>(+1,-1,-1)*(radius/sqrt(3)*a), - p+Point<3>(+1,+1,-1)*(radius/sqrt(3)*a), - p+Point<3>(-1,+1,-1)*(radius/sqrt(3)*a), - p+Point<3>(-1,-1,+1)*(radius/sqrt(3)*a), - p+Point<3>(+1,-1,+1)*(radius/sqrt(3)*a), - p+Point<3>(+1,+1,+1)*(radius/sqrt(3)*a), - p+Point<3>(-1,+1,+1)*(radius/sqrt(3)*a), - // now the eight vertices at - // the outer sphere - p+Point<3>(-1,-1,-1)*(radius/sqrt(3)), - p+Point<3>(+1,-1,-1)*(radius/sqrt(3)), - p+Point<3>(+1,+1,-1)*(radius/sqrt(3)), - p+Point<3>(-1,+1,-1)*(radius/sqrt(3)), - p+Point<3>(-1,-1,+1)*(radius/sqrt(3)), - p+Point<3>(+1,-1,+1)*(radius/sqrt(3)), - p+Point<3>(+1,+1,+1)*(radius/sqrt(3)), - p+Point<3>(-1,+1,+1)*(radius/sqrt(3)) - }; - - // one needs to draw the seven cubes to - // understand what's going on here - const unsigned int n_cells = 7; - const int cell_vertices[n_cells][8] = {{0, 1, 2, 3, 4, 5, 6, 7}, - {8, 9, 10, 11, 0, 1, 2, 3}, - {9, 13, 14, 10, 1, 5, 6, 2}, - {12, 4, 7, 15, 13, 5, 6, 14}, - {8, 0, 3, 11, 12, 4, 7, 15}, - {11, 10,14, 15, 3, 2, 6, 7}, - {8, 9, 13, 12, 0, 1, 5, 4}}; - - vector > cells (n_cells, CellData<3>()); - - for (unsigned int i=0; i::vertices_per_cell; ++j) - cells[i].vertices[j] = cell_vertices[i][j]; - cells[i].material_id = 0; - }; - - create_triangulation (vector >(&vertices[0], &vertices[n_vertices]), - cells, - SubCellData()); // no boundary information -}; - - - #endif diff --git a/tests/big-tests/convergence/convergence.cc b/tests/big-tests/convergence/convergence.cc index 597bb375f0..5f7badedde 100644 --- a/tests/big-tests/convergence/convergence.cc +++ b/tests/big-tests/convergence/convergence.cc @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -266,7 +267,7 @@ int PoissonProblem::run (const unsigned int level) { cout << ">" << endl; cout << " Making grid... "; - tria->create_hyper_ball (); + GridGenerator::hyper_ball (*tria); HyperBallBoundary boundary_description; tria->set_boundary (&boundary_description); tria->begin_active()->set_refine_flag(); diff --git a/tests/big-tests/dof/dof_test.cc b/tests/big-tests/dof/dof_test.cc index d9ee2ee997..44bd5cefcc 100644 --- a/tests/big-tests/dof/dof_test.cc +++ b/tests/big-tests/dof/dof_test.cc @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -199,7 +200,7 @@ void TestCases::create_new (const unsigned int) { if (tria != 0) delete tria; tria = new Triangulation(); - tria->create_hypercube(); + GridGenerator::hyper_cube(*tria); dof = new DoFHandler (tria); }; diff --git a/tests/big-tests/error-estimation/error-estimation.cc b/tests/big-tests/error-estimation/error-estimation.cc index 93d58e28cc..26b768a808 100644 --- a/tests/big-tests/error-estimation/error-estimation.cc +++ b/tests/big-tests/error-estimation/error-estimation.cc @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -412,7 +413,7 @@ void PoissonProblem::run (ParameterHandler &prm) { cout << "Making initial grid... " << endl; const unsigned int start_level(prm.get_integer("Initial refinement")); tria->set_boundary (boundary); - tria->create_hyper_ball (); + GridGenerator::hyper_ball (*tria); tria->refine_global (start_level); if (prm.get("Test case")=="Gauss shape") diff --git a/tests/big-tests/grid/grid_test.cc b/tests/big-tests/grid/grid_test.cc index f4aa02e899..9d4e2457d2 100644 --- a/tests/big-tests/grid/grid_test.cc +++ b/tests/big-tests/grid/grid_test.cc @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -159,7 +160,7 @@ void test (const int test_case) { cout << "Running testcase " << test_case << " in " << dim << " dimensions." << endl; Triangulation tria; - tria.create_hypercube(); + GridGenerator::hyper_cube(tria); if ((dim==1) && ((test_case==2) || (test_case==3))) { diff --git a/tests/big-tests/multigrid/multigrid.cc b/tests/big-tests/multigrid/multigrid.cc index 3f2d7303a2..c8a052ef3f 100644 --- a/tests/big-tests/multigrid/multigrid.cc +++ b/tests/big-tests/multigrid/multigrid.cc @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -426,7 +427,7 @@ int PoissonProblem::run (const unsigned int level) { cout << ">" << endl; cout << " Making grid... "; - tria->create_hypercube (); + GridGenerator::hyper_cube (*tria); tria->refine_global (level+1); tria->begin_active()->set_refine_flag(); (++(++(tria->begin_active())))->set_refine_flag(); diff --git a/tests/big-tests/nonlinear/fixed-point-iteration/nonlinear.cc b/tests/big-tests/nonlinear/fixed-point-iteration/nonlinear.cc index 357accccd6..dd4053a9e2 100644 --- a/tests/big-tests/nonlinear/fixed-point-iteration/nonlinear.cc +++ b/tests/big-tests/nonlinear/fixed-point-iteration/nonlinear.cc @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -173,7 +174,7 @@ void NonlinearProblem::run () { dirichlet_bc[0] = &boundary_values; - tria->create_hypercube (); + GridGenerator::hypercube (*tria); tria->refine_global (4); for (unsigned int refinement_step=0; refinement_step<10; ++refinement_step) diff --git a/tests/big-tests/poisson/problem.cc b/tests/big-tests/poisson/problem.cc index 56903c84e0..41d8e7566d 100644 --- a/tests/big-tests/poisson/problem.cc +++ b/tests/big-tests/poisson/problem.cc @@ -5,6 +5,7 @@ #include "poisson.h" #include +#include @@ -348,7 +349,7 @@ bool PoissonProblem::make_grid (ParameterHandler &prm) { { static const Point origin; boundary = new HyperBallBoundary(origin, 1.); - tria->create_hyper_ball (origin, 1.); + GridGenerator::hyper_ball (*tria, origin, 1.); tria->set_boundary (boundary); break; }; @@ -356,7 +357,7 @@ bool PoissonProblem::make_grid (ParameterHandler &prm) { // set the boundary function { boundary = new CurvedLine(); - tria->create_hypercube (); + GridGenerator::hyper_cube (*tria); tria->set_boundary (boundary); break; }; @@ -368,12 +369,12 @@ bool PoissonProblem::make_grid (ParameterHandler &prm) { case 5: boundary = new StraightBoundary(); tria->set_boundary (boundary); - tria->create_hypercube (); + GridGenerator::hyper_cube (*tria); break; case 6: boundary = new StraightBoundary(); tria->set_boundary (boundary); - tria->create_hypercube (); + GridGenerator::hyper_cube (*tria); tria->refine_global (1); for (unsigned int i=0; i<5; ++i) { @@ -385,7 +386,7 @@ bool PoissonProblem::make_grid (ParameterHandler &prm) { case 7: boundary = new StraightBoundary(); tria->set_boundary (boundary); - tria->create_hyper_L (); + GridGenerator::hyper_L (*tria); break; default: return false; @@ -405,7 +406,7 @@ bool PoissonProblem::make_grid (ParameterHandler &prm) { template void PoissonProblem::make_zoom_in_grid () { - tria->create_hypercube (); + GridGenerator::hyper_cube (*tria); // refine first cell tria->begin_active()->set_refine_flag(); tria->execute_coarsening_and_refinement (); @@ -432,7 +433,7 @@ void PoissonProblem::make_zoom_in_grid () { template void PoissonProblem::make_random_grid () { - tria->create_hypercube (); + GridGenerator::hyper_cube (*tria); tria->refine_global (1); Triangulation::active_cell_iterator cell, endc; diff --git a/tests/deal.II/dof_test.cc b/tests/deal.II/dof_test.cc index b975fd17e2..bec350bc8a 100644 --- a/tests/deal.II/dof_test.cc +++ b/tests/deal.II/dof_test.cc @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -198,7 +199,7 @@ void TestCases::create_new () { if (tria != 0) delete tria; tria = new Triangulation(); - tria->create_hypercube(); + GridGenerator::hyper_cube(*tria); dof = new DoFHandler (tria); }; diff --git a/tests/deal.II/fe_tables.cc b/tests/deal.II/fe_tables.cc index 03e1b8d536..ab5ca42e51 100644 --- a/tests/deal.II/fe_tables.cc +++ b/tests/deal.II/fe_tables.cc @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -32,7 +33,7 @@ inline void print_fe_statistics(const FiniteElement& fe) { Triangulation tr; - tr.create_hypercube(-1,1); + GridGenerator::hyper_cube(tr,-1,1); DoFHandler dof(&tr); dof.distribute_dofs(fe); StraightBoundary boundary; diff --git a/tests/deal.II/gradients.cc b/tests/deal.II/gradients.cc index 079c65442f..3963071d73 100644 --- a/tests/deal.II/gradients.cc +++ b/tests/deal.II/gradients.cc @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -27,7 +28,7 @@ int main () { Triangulation<2> tria; - tria.create_hypercube (0,1); + GridGenerator::hyper_cube (tria,0,1); tria.begin_active()->vertex(2)(0) = 2; FELinear<2> fe; diff --git a/tests/deal.II/grid_test.cc b/tests/deal.II/grid_test.cc index 1d520a84ed..7bbcd56750 100644 --- a/tests/deal.II/grid_test.cc +++ b/tests/deal.II/grid_test.cc @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -163,7 +164,7 @@ void test (const int test_case) { cout << "Running testcase " << test_case << " in " << dim << " dimensions." << endl; Triangulation tria; - tria.create_hypercube(); + GridGenerator::hyper_cube(tria); if ((dim==1) && ((test_case==2) || (test_case==3))) { diff --git a/tests/deal.II/mg2.cc b/tests/deal.II/mg2.cc index 6e3ace4dac..44dd281b4a 100644 --- a/tests/deal.II/mg2.cc +++ b/tests/deal.II/mg2.cc @@ -7,6 +7,7 @@ #include #include #include +#include #include main() @@ -15,7 +16,7 @@ main() MGDoFHandler<2> dof(&tr); FELinear<2> fe; - tr.create_hypercube(-1.,1.); + GridGenerator::hyper_cube(tr,-1.,1.); tr.refine_global(3); dof.distribute_dofs(fe); } diff --git a/tests/deal.II/second_derivatives.cc b/tests/deal.II/second_derivatives.cc index df675fb3c8..2ad62be46c 100644 --- a/tests/deal.II/second_derivatives.cc +++ b/tests/deal.II/second_derivatives.cc @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -19,7 +20,7 @@ int main () { Triangulation<2> tria; - tria.create_hypercube (0,1); + GridGenerator::hyper_cube (tria,0,1); FELinear<2> fe; DoFHandler<2> dof(&tria);