* hypercube domain triangulated with exactly one element. You can
* get tensor product meshes by successive refinement of this cell.
*
- * @item Rectangular coordinate parallel domains as a generalization
+ * If you want the hypercube subdivided a certain number of
+ * times (and if this is not achievable by hierarchic
+ * refinement, for example 3 times), then the
+ * @p{subdivided_hyper_cube} function may be what you are
+ * looking for.
+ *
+ * @item Rectangular coordinate-parallel domains as a generalization
* of hypercubes are generated by
* @ref{GridGenerator}@p{::hyper_rectangle (tria, p1, p2)}, with two
* opposite corner points @p{p1} and @p{p2}.
* transform (simple-shaped) grids to a more complicated ones, like a
* shell onto a grid of an airfoil, for example.
*
- * @author Wolfgang Bangerth, Ralf Hartmann, Guido Kanschat, Stefan Nauber, 1998, 1999, 2000, 2001, 2002.
+ * @author Wolfgang Bangerth, Ralf Hartmann, Guido Kanschat, Stefan Nauber, 1998, 1999, 2000, 2001, 2002, 2003.
*/
class GridGenerator
{
const double left = 0.,
const double right= 1.);
+ /**
+ * Same as @ref{hyper_cube}, but
+ * with the difference that not
+ * only one cell is created but
+ * each coordinate direction is
+ * subdivided into
+ * @p{repetitions} cells. Thus,
+ * the number of cells filling
+ * the given volume is
+ * @p{repetitions^d}.
+ */
+ template <int dim>
+ static void subdivided_hyper_cube (Triangulation<dim> &tria,
+ const unsigned int repetitions,
+ const double left = 0.,
+ const double right= 1.);
+
/**
* Create a coordinate-parallel
* parallelepiped from the two
* Exception
*/
DeclException0 (ExcInvalidRadii);
+ /**
+ * Exception
+ */
+ DeclException1 (ExcInvalidRepetitions,
+ int,
+ << "The number of repetitions " << arg1
+ << " must be >=1.");
private:
/**
}
+template <int dim>
+void
+GridGenerator::subdivided_hyper_cube (Triangulation<dim> &tria,
+ const unsigned int repetitions,
+ const double left,
+ const double right)
+{
+ Assert (repetitions >= 1, ExcInvalidRepetitions(repetitions));
+
+ // first generate the necessary
+ // points
+ const double delta = (right-left)/repetitions;
+ std::vector<Point<dim> > points;
+ switch (dim)
+ {
+ case 1:
+ for (unsigned int x=0; x<=repetitions; ++x)
+ points.push_back (Point<dim> (left+x*delta));
+ break;
+
+ case 2:
+ for (unsigned int y=0; y<=repetitions; ++y)
+ for (unsigned int x=0; x<=repetitions; ++x)
+ points.push_back (Point<dim> (left+x*delta,
+ left+y*delta));
+ break;
+
+ case 3:
+ for (unsigned int z=0; z<=repetitions; ++z)
+ for (unsigned int y=0; y<=repetitions; ++y)
+ for (unsigned int x=0; x<=repetitions; ++x)
+ points.push_back (Point<dim> (left+x*delta,
+ left+y*delta,
+ left+z*delta));
+ break;
+
+ default:
+ Assert (false, ExcNotImplemented());
+ }
+
+ // next create the cells
+ // Prepare cell data
+ std::vector<CellData<dim> > cells;
+ switch (dim)
+ {
+ case 1:
+ cells.resize (repetitions);
+ for (unsigned int x=0; x<repetitions; ++x)
+ {
+ cells[x].vertices[0] = x;
+ cells[x].vertices[1] = x+1;
+ cells[x].material_id = 0;
+ }
+ break;
+
+ case 2:
+ cells.resize (repetitions*repetitions);
+ for (unsigned int y=0; y<repetitions; ++y)
+ for (unsigned int x=0; x<repetitions; ++x)
+ {
+ const unsigned int c = x+y*repetitions;
+ cells[c].vertices[0] = y*(repetitions+1)+x;
+ cells[c].vertices[1] = y*(repetitions+1)+x+1;
+ cells[c].vertices[2] = (y+1)*(repetitions+1)+x+1;
+ cells[c].vertices[3] = (y+1)*(repetitions+1)+x;
+ cells[c].material_id = 0;
+ }
+ break;
+
+ default:
+ // should be trivial to
+ // do for 3d as well, but
+ // am too tired at this
+ // point of the night to
+ // do that...
+ //
+ // contributions are welcome!
+ Assert (false, ExcNotImplemented());
+ }
+
+ tria.create_triangulation (points, cells, SubCellData());
+}
+
+
#if deal_II_dimension == 1
void GridGenerator::hyper_cube_slit (Triangulation<1> &,
const double,
const double);
+template void
+GridGenerator::subdivided_hyper_cube<deal_II_dimension> (Triangulation<deal_II_dimension> &,
+ const unsigned int,
+ const double,
+ const double);
+
+
#if deal_II_dimension != 1
template void
GridGenerator::