#include <base/config.h>
#include <base/exceptions.h>
-
+#include <base/point.h>
+/**
+ * Topological description of zero dimensional cells,
+ * i.e. points. This class might not look too useful but often is if
+ * in a certain dimension we would like to enquire information about
+ * objects with dimension one lower than the present, e.g. about
+ * faces.
+ *
+ * This class contains as static members information on vertices and
+ * faces of a @p{dim}-dimensional grid cell. The interface is the same
+ * for all dimensions. If a value is of no use in a low dimensional
+ * cell, it is (correctly) set to zero, e.g. @p{subfaces_per_cell} in
+ * 1d.
+ *
+ * This information should always replace hard-coded numbers of
+ * vertices, neighbors and so on, since it can be used dimension
+ * independently.
+ *
+ * @author Wolfgang Bangerth, 1998
+ */
+template <>
+struct GeometryInfo<0>
+{
+ /**
+ * Present dimension. Does not
+ * look useful, but might be.
+ */
+ static const unsigned int dim = 0;
+
+ /**
+ * Number of children a cell has.
+ */
+ static const unsigned int children_per_cell = 1;
+
+ /**
+ * Number of faces a cell has.
+ */
+ static const unsigned int faces_per_cell = 0;
+
+ /**
+ * Number of children each face has
+ * when the adjacent cell is refined.
+ */
+ static const unsigned int subfaces_per_face = 0;
+
+ /**
+ * Number of vertices a cell has.
+ */
+ static const unsigned int vertices_per_cell = 1;
+
+ /**
+ * Number of vertices each face has.
+ * Since this is not useful in one
+ * dimension, we provide a useless
+ * number (in the hope that a compiler
+ * may warn when it sees constructs like
+ * @p{for (i=0; i<vertices_per_face; ++i)},
+ * at least if @p{i} is an @p{unsigned int}.
+ */
+ static const unsigned int vertices_per_face = 0;
+
+ /**
+ * Number of lines each face has.
+ */
+ static const unsigned int lines_per_face = 0;
+
+ /**
+ * Number of quads on each face.
+ */
+ static const unsigned int quads_per_face = 0;
+
+ /**
+ * Number of lines of a cell.
+ */
+ static const unsigned int lines_per_cell = 0;
+
+ /**
+ * Number of quadrilaterals of a
+ * cell.
+ */
+ static const unsigned int quads_per_cell = 0;
+
+ /**
+ * Number of hexahedra of a
+ * cell.
+ */
+ static const unsigned int hexes_per_cell = 0;
+};
+
+
+
/**
* Topological description of one dimensional cells.
*
static const unsigned int hexes_per_cell = 0;
/**
- * List of numbers which is
- * denote which face is opposite
+ * List of numbers which
+ * denotes which face is opposite
* to a given face. In 1d, this
* list is @p{{1,0}}, in 2d @p{{2, 3, 0, 1}},
* in 3d @p{{1, 0, 4, 5, 2, 3}}.
*/
static unsigned int child_cell_on_face (const unsigned int face,
const unsigned int subface);
-};
-
-
-
-/**
- * Topological description of zero dimensional cells,
- * i.e. points. This class might not look too useful but often is if
- * in a certain dimension we would like to enquire information about
- * objects with dimension one lower than the present, e.g. about
- * faces.
- *
- * This class contains as static members information on vertices and
- * faces of a @p{dim}-dimensional grid cell. The interface is the same
- * for all dimensions. If a value is of no use in a low dimensional
- * cell, it is (correctly) set to zero, e.g. @p{subfaces_per_cell} in
- * 1d.
- *
- * This information should always replace hard-coded numbers of
- * vertices, neighbors and so on, since it can be used dimension
- * independently.
- *
- * @author Wolfgang Bangerth, 1998
- */
-template <>
-struct GeometryInfo<0>
-{
- /**
- * Present dimension. Does not
- * look useful, but might be.
- */
- static const unsigned int dim = 0;
/**
- * Number of children a cell has.
+ * Return the position of the
+ * @p{i}th vertex on the unit
+ * cell. The order of vertices is
+ * the canonical one in deal.II,
+ * as described in the
+ * documentation of the
+ * @ref{Triangulation} class.
*/
- static const unsigned int children_per_cell = 1;
+ static Point<1> unit_cell_vertex (const unsigned int vertex);
/**
- * Number of faces a cell has.
- */
- static const unsigned int faces_per_cell = 0;
-
- /**
- * Number of children each face has
- * when the adjacent cell is refined.
- */
- static const unsigned int subfaces_per_face = 0;
-
- /**
- * Number of vertices a cell has.
- */
- static const unsigned int vertices_per_cell = 1;
-
- /**
- * Number of vertices each face has.
- * Since this is not useful in one
- * dimension, we provide a useless
- * number (in the hope that a compiler
- * may warn when it sees constructs like
- * @p{for (i=0; i<vertices_per_face; ++i)},
- * at least if @p{i} is an @p{unsigned int}.
- */
- static const unsigned int vertices_per_face = 0;
-
- /**
- * Number of lines each face has.
- */
- static const unsigned int lines_per_face = 0;
-
- /**
- * Number of quads on each face.
- */
- static const unsigned int quads_per_face = 0;
-
- /**
- * Number of lines of a cell.
- */
- static const unsigned int lines_per_cell = 0;
-
- /**
- * Number of quadrilaterals of a
- * cell.
- */
- static const unsigned int quads_per_cell = 0;
-
- /**
- * Number of hexahedra of a
- * cell.
- */
- static const unsigned int hexes_per_cell = 0;
+ * Report, for @p{vertex=0,1} the
+ * indices of the two vertices
+ * adjacent to the line with
+ * index @p{line} among the lines
+ * forming this cell. In 1d, the
+ * only line is the cell itself,
+ * while in 2d and 3d there are 4
+ * and 12 lines, respectively.
+ *
+ * The positions of these
+ * vertices in the unit cell can
+ * be obtained using the
+ * @p{unit_cell_vertex} function.
+ *
+ * The order of the lines, as
+ * well as their direction (which
+ * in turn determines which is
+ * the first and which the second
+ * vertex on a line) is the
+ * canonical one in deal.II, as
+ * described in the documentation
+ * of the @ref{Triangulation}
+ * class.
+ */
+ static unsigned int vertices_adjacent_to_line (const unsigned int line,
+ const unsigned int vertex);
};
static const unsigned int hexes_per_cell = 0;
/**
- * List of numbers which is
- * denote which face is opposite
+ * List of numbers which
+ * denotes which face is opposite
* to a given face. In 1d, this
* list is @p{{1,0}}, in 2d @p{{2, 3, 0, 1}},
* in 3d @p{{1, 0, 4, 5, 2, 3}}.
*/
static unsigned int child_cell_on_face (const unsigned int face,
const unsigned int subface);
+
+
+ /**
+ * Return the position of the
+ * @p{i}th vertex on the unit
+ * cell. The order of vertices is
+ * the canonical one in deal.II,
+ * as described in the
+ * documentation of the
+ * @ref{Triangulation} class.
+ */
+ static Point<2> unit_cell_vertex (const unsigned int i);
+
+ /**
+ * Report, for @p{vertex=0,1} the
+ * indices of the two vertices
+ * adjacent to the line with
+ * index @p{line} among the lines
+ * forming this cell. In 1d, the
+ * only line is the cell itself,
+ * while in 2d and 3d there are 4
+ * and 12 lines, respectively.
+ *
+ * The positions of these
+ * vertices in the unit cell can
+ * be obtained using the
+ * @p{unit_cell_vertex} function.
+ *
+ * The order of the lines, as
+ * well as their direction (which
+ * in turn determines which is
+ * the first and which the second
+ * vertex on a line) is the
+ * canonical one in deal.II, as
+ * described in the documentation
+ * of the @ref{Triangulation}
+ * class.
+ */
+ static unsigned int vertices_adjacent_to_line (const unsigned int line,
+ const unsigned int vertex);
};
static const unsigned int hexes_per_cell = 1;
/**
- * List of numbers which is
- * denote which face is opposite
+ * List of numbers which
+ * denotes which face is opposite
* to a given face. In 1d, this
* list is @p{{1,0}}, in 2d @p{{2, 3, 0, 1}},
* in 3d @p{{1, 0, 4, 5, 2, 3}}.
*/
static unsigned int child_cell_on_face (const unsigned int face,
const unsigned int subface);
+ /**
+ * Return the position of the
+ * @p{i}th vertex on the unit
+ * cell. The order of vertices is
+ * the canonical one in deal.II,
+ * as described in the
+ * documentation of the
+ * @ref{Triangulation} class.
+ */
+ static Point<3> unit_cell_vertex (const unsigned int i);
+
+ /**
+ * Report, for @p{vertex=0,1} the
+ * indices of the two vertices
+ * adjacent to the line with
+ * index @p{line} among the lines
+ * forming this cell. In 1d, the
+ * only line is the cell itself,
+ * while in 2d and 3d there are 4
+ * and 12 lines, respectively.
+ *
+ * The positions of these
+ * vertices in the unit cell can
+ * be obtained using the
+ * @p{unit_cell_vertex} function.
+ *
+ * The order of the lines, as
+ * well as their direction (which
+ * in turn determines which is
+ * the first and which the second
+ * vertex on a line) is the
+ * canonical one in deal.II, as
+ * described in the documentation
+ * of the @ref{Triangulation}
+ * class.
+ */
+ static unsigned int vertices_adjacent_to_line (const unsigned int line,
+ const unsigned int vertex);
};
};
+/* ---------------- inline functions --------------- */
+
+inline
+Point<1>
+GeometryInfo<1>::unit_cell_vertex (const unsigned int vertex)
+{
+ Assert (vertex < vertices_per_cell,
+ ExcIndexRange (vertex, 0, vertices_per_cell));
+
+ static const Point<dim> vertices[vertices_per_cell] =
+ { Point<dim>(0.), Point<dim>(1.) };
+ return vertices[vertex];
+};
+
+
+
+inline
+Point<2>
+GeometryInfo<2>::unit_cell_vertex (const unsigned int vertex)
+{
+ Assert (vertex < vertices_per_cell,
+ ExcIndexRange (vertex, 0, vertices_per_cell));
+
+ static const Point<dim> vertices[vertices_per_cell] =
+ { Point<dim>(0., 0.), Point<dim>(1., 0.),
+ Point<dim>(1.,1.), Point<dim>(0.,1.) };
+ return vertices[vertex];
+};
+
+
+
+inline
+Point<3>
+GeometryInfo<3>::unit_cell_vertex (const unsigned int vertex)
+{
+ Assert (vertex < vertices_per_cell,
+ ExcIndexRange (vertex, 0, vertices_per_cell));
+
+ static const Point<dim> vertices[vertices_per_cell] =
+ { Point<dim>(0., 0., 0.), Point<dim>(1., 0., 0.),
+ Point<dim>(1., 0., 1.), Point<dim>(0., 0., 1.),
+ Point<dim>(0., 1., 0.), Point<dim>(1., 1., 0.),
+ Point<dim>(1., 1., 1.), Point<dim>(0., 1., 1.) };
+ return vertices[vertex];
+};
+
+
+
+inline
+unsigned int
+GeometryInfo<1>::vertices_adjacent_to_line (const unsigned int line,
+ const unsigned int vertex)
+{
+ Assert (line < lines_per_cell,
+ ExcIndexRange (line, 0, lines_per_cell));
+ Assert (vertex < vertices_per_cell,
+ ExcIndexRange (vertex, 0, 2));
+
+ return vertex;
+};
+
+
+
+inline
+unsigned int
+GeometryInfo<2>::vertices_adjacent_to_line (const unsigned int line,
+ const unsigned int vertex)
+{
+ Assert (line < lines_per_cell,
+ ExcIndexRange (line, 0, lines_per_cell));
+ Assert (vertex < vertices_per_cell,
+ ExcIndexRange (vertex, 0, 2));
+
+ static const unsigned int vertex_indices[lines_per_cell][2] =
+ { {0, 1}, {1, 2}, {3, 2}, {0, 3} };
+
+ return vertex_indices[line][vertex];
+};
+
+
+
+inline
+unsigned int
+GeometryInfo<3>::vertices_adjacent_to_line (const unsigned int line,
+ const unsigned int vertex)
+{
+ Assert (line < lines_per_cell,
+ ExcIndexRange (line, 0, lines_per_cell));
+ Assert (vertex < vertices_per_cell,
+ ExcIndexRange (vertex, 0, 2));
+
+ static const unsigned int vertex_indices[lines_per_cell][2] =
+ { {0, 1}, {1, 2}, {3, 2}, {0, 3},
+ {4, 5}, {5, 6}, {7, 6}, {4, 7},
+ {0, 4}, {1, 5}, {2, 6}, {3, 7} };
+
+ return vertex_indices[line][vertex];
+};
+
+
#endif