From 5c2ce895282d21c30a91ca726ac65d3762f6e59a Mon Sep 17 00:00:00 2001 From: wolf Date: Thu, 30 May 2002 11:34:25 +0000 Subject: [PATCH] New members of GeometryInfo. git-svn-id: https://svn.dealii.org/trunk@5930 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/include/grid/geometry_info.h | 401 ++++++++++++++----- deal.II/doc/news/2002/c-3-3.html | 11 + 2 files changed, 320 insertions(+), 92 deletions(-) diff --git a/deal.II/deal.II/include/grid/geometry_info.h b/deal.II/deal.II/include/grid/geometry_info.h index 37bc3a79d9..87a10778b8 100644 --- a/deal.II/deal.II/include/grid/geometry_info.h +++ b/deal.II/deal.II/include/grid/geometry_info.h @@ -16,7 +16,7 @@ #include #include - +#include @@ -35,6 +35,96 @@ struct GeometryInfo +/** + * 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 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}}. @@ -191,96 +281,45 @@ struct GeometryInfo<1> */ 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 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}}. @@ -440,6 +479,46 @@ struct GeometryInfo<2> */ 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); }; @@ -528,8 +607,8 @@ struct GeometryInfo<3> 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}}. @@ -599,6 +678,44 @@ struct GeometryInfo<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); }; @@ -692,6 +809,106 @@ struct GeometryInfo<4> }; +/* ---------------- 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 vertices[vertices_per_cell] = + { Point(0.), Point(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 vertices[vertices_per_cell] = + { Point(0., 0.), Point(1., 0.), + Point(1.,1.), Point(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 vertices[vertices_per_cell] = + { Point(0., 0., 0.), Point(1., 0., 0.), + Point(1., 0., 1.), Point(0., 0., 1.), + Point(0., 1., 0.), Point(1., 1., 0.), + Point(1., 1., 1.), Point(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 diff --git a/deal.II/doc/news/2002/c-3-3.html b/deal.II/doc/news/2002/c-3-3.html index 102e1016b8..b6bb149a3f 100644 --- a/deal.II/doc/news/2002/c-3-3.html +++ b/deal.II/doc/news/2002/c-3-3.html @@ -296,6 +296,17 @@ contributor's names are abbreviated by WB (Wolfgang Bangerth), GK

deal.II

    +
  1. + New: The GeometryInfo class now + provides two methods, + unit_cell_vertex and vertices_adjacent_to_line, that reveal + something about the placement and numbering of vertices on the + uni cell. +
    + (GK 2002/05/29) +

    +
  2. New: The GridOut:: write_dx function is now implemented. -- 2.39.5