#include <grid/tria_iterator.h>
#include <grid/tria_boundary.h>
#include <grid/dof_constraints.h>
+#include <grid/grid_generator.h>
#include <base/function.h>
#include <basic/data_io.h>
#include <fe/fe_lib.lagrange.h>
cout << ">" << endl;
cout << " Making grid... ";
- tria->create_hyper_ball ();
+ GridGenerator::hyper_ball (*tria);
HyperBallBoundary<dim> boundary_description;
tria->set_boundary (&boundary_description);
tria->begin_active()->set_refine_flag();
#include <grid/tria_boundary.h>
#include <grid/tria_iterator.h>
#include <grid/tria_accessor.h>
+#include <grid/grid_generator.h>
#include <lac/sparsematrix.h>
#include <base/parameter_handler.h>
#include <grid/dof_constraints.h>
if (tria != 0) delete tria;
tria = new Triangulation<dim>();
- tria->create_hypercube();
+ GridGenerator::hyper_cube(*tria);
dof = new DoFHandler<dim> (tria);
};
#include <grid/tria_iterator.h>
#include <grid/tria_boundary.h>
#include <grid/dof_constraints.h>
+#include <grid/grid_generator.h>
#include <base/function.h>
#include <basic/data_io.h>
#include <base/parameter_handler.h>
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")
#include <grid/tria_accessor.h>
#include <grid/tria_iterator.h>
#include <grid/tria.h>
+#include <grid/grid_generator.h>
#include <fstream>
#include <string>
#include <cmath>
cout << "Running testcase " << test_case
<< " in " << dim << " dimensions." << endl;
Triangulation<dim> tria;
- tria.create_hypercube();
+ GridGenerator::hyper_cube(tria);
if ((dim==1) && ((test_case==2) || (test_case==3)))
{
#include <grid/tria_iterator.h>
#include <grid/tria_boundary.h>
#include <grid/dof_constraints.h>
+#include <grid/grid_generator.h>
#include <base/function.h>
#include <basic/data_io.h>
#include <fe/fe_lib.lagrange.h>
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();
#include <grid/dof_accessor.h>
#include <grid/tria_iterator.h>
#include <grid/tria_boundary.h>
+#include <grid/grid_generator.h>
#include <basic/data_io.h>
#include <base/function.h>
#include <fe/fe_lib.lagrange.h>
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)
#include "poisson.h"
#include <lac/vector.h>
+#include <grid/grid_generator.h>
{
static const Point<dim> origin;
boundary = new HyperBallBoundary<dim>(origin, 1.);
- tria->create_hyper_ball (origin, 1.);
+ GridGenerator::hyper_ball (*tria, origin, 1.);
tria->set_boundary (boundary);
break;
};
// set the boundary function
{
boundary = new CurvedLine<dim>();
- tria->create_hypercube ();
+ GridGenerator::hyper_cube (*tria);
tria->set_boundary (boundary);
break;
};
case 5:
boundary = new StraightBoundary<dim>();
tria->set_boundary (boundary);
- tria->create_hypercube ();
+ GridGenerator::hyper_cube (*tria);
break;
case 6:
boundary = new StraightBoundary<dim>();
tria->set_boundary (boundary);
- tria->create_hypercube ();
+ GridGenerator::hyper_cube (*tria);
tria->refine_global (1);
for (unsigned int i=0; i<5; ++i)
{
case 7:
boundary = new StraightBoundary<dim>();
tria->set_boundary (boundary);
- tria->create_hyper_L ();
+ GridGenerator::hyper_L (*tria);
break;
default:
return false;
template <int dim>
void PoissonProblem<dim>::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 ();
template <int dim>
void PoissonProblem<dim>::make_random_grid () {
- tria->create_hypercube ();
+ GridGenerator::hyper_cube (*tria);
tria->refine_global (1);
Triangulation<dim>::active_cell_iterator cell, endc;
--- /dev/null
+/*---------------------------- grid_generator.h ---------------------------*/
+/* $Id$ */
+#ifndef __grid_generator_H
+#define __grid_generator_H
+/*---------------------------- grid_generator.h ---------------------------*/
+
+
+#include <base/forward-declarations.h>
+#include <basic/forward-declarations.h>
+
+/**
+ * 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<dim>::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 <int dim>
+ static void hyper_cube (Triangulation<dim> &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 <int dim>
+ static void hyper_ball (Triangulation<dim> &tria,
+ const Point<dim> ¢er = Point<dim>(),
+ 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 <int dim>
+ static void hyper_L (Triangulation<dim> &tria,
+ const double left = -1.,
+ const double right= 1.);
+};
+
+
+
+
+/*---------------------------- grid_generator.h ---------------------------*/
+/* end of #ifndef __grid_generator_H */
+#endif
+/*---------------------------- grid_generator.h ---------------------------*/
*
* 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<dim>::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<dim>::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<dim>::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
void create_triangulation (const vector<Point<dim> > &vertices,
const vector<CellData<dim> > &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<dim> ¢er = Point<dim>(),
- const double radius = 1.);
/**
* Distort the grid by randomly moving
--- /dev/null
+/* $Id$ */
+
+
+#include <grid/grid_generator.h>
+#include <grid/tria.h>
+#include <cmath>
+
+
+
+
+
+#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<CellData<1> > cells (1, CellData<1>());
+ cells[0].vertices[0] = 0;
+ cells[0].vertices[1] = 1;
+ cells[0].material_id = 0;
+
+ tria.create_triangulation (vector<Point<1> >(&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<CellData<2> > 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<Point<2> >(&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<dim> vertices[8] = { Point<dim> (a,a),
+ Point<dim> ((a+b)/2,a),
+ Point<dim> (b,a),
+ Point<dim> (a,(a+b)/2),
+ Point<dim> ((a+b)/2,(a+b)/2),
+ Point<dim> (b,(a+b)/2),
+ Point<dim> (a,b),
+ Point<dim> ((a+b)/2,b) };
+ const int cell_vertices[3][4] = {{0, 1, 4, 3},
+ {1, 2, 5, 4},
+ {3, 4, 7, 6}};
+
+ vector<CellData<2> > 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<Point<dim> >(&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<CellData<2> > 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<Point<2> >(&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<CellData<3> > 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<Point<3> >(&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<dim> vertices[26]
+ = {
+ // front face of the big cube
+ Point<dim> (a, a,a),
+ Point<dim> ((a+b)/2,a,a),
+ Point<dim> (b, a,a),
+ Point<dim> (a, a,(a+b)/2),
+ Point<dim> ((a+b)/2,a,(a+b)/2),
+ Point<dim> (b, a,(a+b)/2),
+ Point<dim> (a, a,b),
+ Point<dim> ((a+b)/2,a,b),
+ Point<dim> (b, a,b),
+ // middle face of the big cube
+ Point<dim> (a, (a+b)/2,a),
+ Point<dim> ((a+b)/2,(a+b)/2,a),
+ Point<dim> (b, (a+b)/2,a),
+ Point<dim> (a, (a+b)/2,(a+b)/2),
+ Point<dim> ((a+b)/2,(a+b)/2,(a+b)/2),
+ Point<dim> (b, (a+b)/2,(a+b)/2),
+ Point<dim> (a, (a+b)/2,b),
+ Point<dim> ((a+b)/2,(a+b)/2,b),
+ Point<dim> (b, (a+b)/2,b),
+ // back face of the big cube
+ // last (top right) point is missing
+ Point<dim> (a, b,a),
+ Point<dim> ((a+b)/2,b,a),
+ Point<dim> (b, b,a),
+ Point<dim> (a, b,(a+b)/2),
+ Point<dim> ((a+b)/2,b,(a+b)/2),
+ Point<dim> (b, b,(a+b)/2),
+ Point<dim> (a, b,b),
+ Point<dim> ((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<CellData<3> > 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<Point<dim> >(&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<CellData<3> > cells (n_cells, CellData<3>());
+
+ for (unsigned int i=0; i<n_cells; ++i)
+ {
+ for (unsigned int j=0; j<GeometryInfo<3>::vertices_per_cell; ++j)
+ cells[i].vertices[j] = cell_vertices[i][j];
+ cells[i].material_id = 0;
+ };
+
+ tria.create_triangulation (vector<Point<3> >(&vertices[0], &vertices[n_vertices]),
+ cells,
+ SubCellData()); // no boundary information
+};
+
+
+
+#endif
+
+
+
+
+// explicit instantiations
+// template void GridGenerator::hyper_cube (Triangulation<deal_II_dimension> &,
+// const double,
+// const double);
+// template void GridGenerator::hyper_L (Triangulation<deal_II_dimension> &,
+// const double,
+// const double);
+// template void GridGenerator::hyper_ball (Triangulation<deal_II_dimension> &,
+// const Point<deal_II_dimension> &,
+// const double);
+
};
};
-
-
-
-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<CellData<1> > cells (1, CellData<1>());
- cells[0].vertices[0] = 0;
- cells[0].vertices[1] = 1;
- cells[0].material_id = 0;
-
- create_triangulation (vector<Point<1> >(&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
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<CellData<2> > 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<Point<2> >(&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<dim> vertices[8] = { Point<dim> (a,a),
- Point<dim> ((a+b)/2,a),
- Point<dim> (b,a),
- Point<dim> (a,(a+b)/2),
- Point<dim> ((a+b)/2,(a+b)/2),
- Point<dim> (b,(a+b)/2),
- Point<dim> (a,b),
- Point<dim> ((a+b)/2,b) };
- const int cell_vertices[3][4] = {{0, 1, 4, 3},
- {1, 2, 5, 4},
- {3, 4, 7, 6}};
-
- vector<CellData<2> > 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<Point<dim> >(&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<CellData<2> > 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<Point<2> >(&vertices[0], &vertices[8]),
- cells,
- SubCellData()); // no boundary information
-};
-
#endif
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<CellData<3> > 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<Point<3> >(&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<dim> vertices[26]
- = {
- // front face of the big cube
- Point<dim> (a, a,a),
- Point<dim> ((a+b)/2,a,a),
- Point<dim> (b, a,a),
- Point<dim> (a, a,(a+b)/2),
- Point<dim> ((a+b)/2,a,(a+b)/2),
- Point<dim> (b, a,(a+b)/2),
- Point<dim> (a, a,b),
- Point<dim> ((a+b)/2,a,b),
- Point<dim> (b, a,b),
- // middle face of the big cube
- Point<dim> (a, (a+b)/2,a),
- Point<dim> ((a+b)/2,(a+b)/2,a),
- Point<dim> (b, (a+b)/2,a),
- Point<dim> (a, (a+b)/2,(a+b)/2),
- Point<dim> ((a+b)/2,(a+b)/2,(a+b)/2),
- Point<dim> (b, (a+b)/2,(a+b)/2),
- Point<dim> (a, (a+b)/2,b),
- Point<dim> ((a+b)/2,(a+b)/2,b),
- Point<dim> (b, (a+b)/2,b),
- // back face of the big cube
- // last (top right) point is missing
- Point<dim> (a, b,a),
- Point<dim> ((a+b)/2,b,a),
- Point<dim> (b, b,a),
- Point<dim> (a, b,(a+b)/2),
- Point<dim> ((a+b)/2,b,(a+b)/2),
- Point<dim> (b, b,(a+b)/2),
- Point<dim> (a, b,b),
- Point<dim> ((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<CellData<3> > 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<Point<dim> >(&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<CellData<3> > cells (n_cells, CellData<3>());
-
- for (unsigned int i=0; i<n_cells; ++i)
- {
- for (unsigned int j=0; j<GeometryInfo<3>::vertices_per_cell; ++j)
- cells[i].vertices[j] = cell_vertices[i][j];
- cells[i].material_id = 0;
- };
-
- create_triangulation (vector<Point<3> >(&vertices[0], &vertices[n_vertices]),
- cells,
- SubCellData()); // no boundary information
-};
-
-
-
#endif
#include <grid/tria_iterator.h>
#include <grid/tria_boundary.h>
#include <grid/dof_constraints.h>
+#include <grid/grid_generator.h>
#include <base/function.h>
#include <basic/data_io.h>
#include <fe/fe_lib.lagrange.h>
cout << ">" << endl;
cout << " Making grid... ";
- tria->create_hyper_ball ();
+ GridGenerator::hyper_ball (*tria);
HyperBallBoundary<dim> boundary_description;
tria->set_boundary (&boundary_description);
tria->begin_active()->set_refine_flag();
#include <grid/tria_boundary.h>
#include <grid/tria_iterator.h>
#include <grid/tria_accessor.h>
+#include <grid/grid_generator.h>
#include <lac/sparsematrix.h>
#include <base/parameter_handler.h>
#include <grid/dof_constraints.h>
if (tria != 0) delete tria;
tria = new Triangulation<dim>();
- tria->create_hypercube();
+ GridGenerator::hyper_cube(*tria);
dof = new DoFHandler<dim> (tria);
};
#include <grid/tria_iterator.h>
#include <grid/tria_boundary.h>
#include <grid/dof_constraints.h>
+#include <grid/grid_generator.h>
#include <base/function.h>
#include <basic/data_io.h>
#include <base/parameter_handler.h>
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")
#include <grid/tria_accessor.h>
#include <grid/tria_iterator.h>
#include <grid/tria.h>
+#include <grid/grid_generator.h>
#include <fstream>
#include <string>
#include <cmath>
cout << "Running testcase " << test_case
<< " in " << dim << " dimensions." << endl;
Triangulation<dim> tria;
- tria.create_hypercube();
+ GridGenerator::hyper_cube(tria);
if ((dim==1) && ((test_case==2) || (test_case==3)))
{
#include <grid/tria_iterator.h>
#include <grid/tria_boundary.h>
#include <grid/dof_constraints.h>
+#include <grid/grid_generator.h>
#include <base/function.h>
#include <basic/data_io.h>
#include <fe/fe_lib.lagrange.h>
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();
#include <grid/dof_accessor.h>
#include <grid/tria_iterator.h>
#include <grid/tria_boundary.h>
+#include <grid/grid_generator.h>
#include <basic/data_io.h>
#include <base/function.h>
#include <fe/fe_lib.lagrange.h>
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)
#include "poisson.h"
#include <lac/vector.h>
+#include <grid/grid_generator.h>
{
static const Point<dim> origin;
boundary = new HyperBallBoundary<dim>(origin, 1.);
- tria->create_hyper_ball (origin, 1.);
+ GridGenerator::hyper_ball (*tria, origin, 1.);
tria->set_boundary (boundary);
break;
};
// set the boundary function
{
boundary = new CurvedLine<dim>();
- tria->create_hypercube ();
+ GridGenerator::hyper_cube (*tria);
tria->set_boundary (boundary);
break;
};
case 5:
boundary = new StraightBoundary<dim>();
tria->set_boundary (boundary);
- tria->create_hypercube ();
+ GridGenerator::hyper_cube (*tria);
break;
case 6:
boundary = new StraightBoundary<dim>();
tria->set_boundary (boundary);
- tria->create_hypercube ();
+ GridGenerator::hyper_cube (*tria);
tria->refine_global (1);
for (unsigned int i=0; i<5; ++i)
{
case 7:
boundary = new StraightBoundary<dim>();
tria->set_boundary (boundary);
- tria->create_hyper_L ();
+ GridGenerator::hyper_L (*tria);
break;
default:
return false;
template <int dim>
void PoissonProblem<dim>::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 ();
template <int dim>
void PoissonProblem<dim>::make_random_grid () {
- tria->create_hypercube ();
+ GridGenerator::hyper_cube (*tria);
tria->refine_global (1);
Triangulation<dim>::active_cell_iterator cell, endc;
#include <grid/dof.h>
#include <grid/tria.h>
+#include <grid/grid_generator.h>
#include <fe/fe_lib.lagrange.h>
#include <grid/tria_boundary.h>
#include <grid/tria_iterator.h>
if (tria != 0) delete tria;
tria = new Triangulation<dim>();
- tria->create_hypercube();
+ GridGenerator::hyper_cube(*tria);
dof = new DoFHandler<dim> (tria);
};
#include <grid/tria_boundary.h>
#include <grid/dof.h>
#include <grid/dof_accessor.h>
+#include <grid/grid_generator.h>
#include <iomanip>
#include <base/logstream.h>
print_fe_statistics(const FiniteElement<dim>& fe)
{
Triangulation<dim> tr;
- tr.create_hypercube(-1,1);
+ GridGenerator::hyper_cube(tr,-1,1);
DoFHandler<dim> dof(&tr);
dof.distribute_dofs(fe);
StraightBoundary<dim> boundary;
#include <grid/tria.h>
#include <grid/tria_boundary.h>
#include <grid/dof.h>
+#include <grid/grid_generator.h>
#include <fe/fe_values.h>
#include <fe/fe_lib.lagrange.h>
#include <base/quadrature_lib.h>
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;
#include <grid/tria_accessor.h>
#include <grid/tria_iterator.h>
#include <grid/tria.h>
+#include <grid/grid_generator.h>
#include <cmath>
#include <cstdlib>
cout << "Running testcase " << test_case
<< " in " << dim << " dimensions." << endl;
Triangulation<dim> tria;
- tria.create_hypercube();
+ GridGenerator::hyper_cube(tria);
if ((dim==1) && ((test_case==2) || (test_case==3)))
{
#include <numerics/mg_smoother.h>
#include <grid/tria.h>
#include <grid/mg_dof.h>
+#include <grid/grid_generator.h>
#include <fe/fe_lib.lagrange.h>
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);
}
#include <grid/tria.h>
#include <grid/tria_boundary.h>
#include <grid/dof.h>
+#include <grid/grid_generator.h>
#include <fe/fe_values.h>
#include <fe/fe_lib.lagrange.h>
#include <base/quadrature_lib.h>
int main () {
Triangulation<2> tria;
- tria.create_hypercube (0,1);
+ GridGenerator::hyper_cube (tria,0,1);
FELinear<2> fe;
DoFHandler<2> dof(&tria);