From 64cf401a8888918a7818ce9bbc2cb214aa894ff7 Mon Sep 17 00:00:00 2001 From: guido Date: Mon, 15 Feb 1999 16:22:16 +0000 Subject: [PATCH] new features and COMMON interface for all dimensions git-svn-id: https://svn.dealii.org/trunk@801 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/include/grid/geometry_info.h | 202 ++++++++----------- 1 file changed, 84 insertions(+), 118 deletions(-) diff --git a/deal.II/deal.II/include/grid/geometry_info.h b/deal.II/deal.II/include/grid/geometry_info.h index e1cbdd25ff..cfcaf9d4ef 100644 --- a/deal.II/deal.II/include/grid/geometry_info.h +++ b/deal.II/deal.II/include/grid/geometry_info.h @@ -8,41 +8,63 @@ #include +template struct GeometryInfo; -template struct GeometryInfo; +/** + * Pseudo-class for recursive functions in #GeometryInfo#. + */ +struct GeometryInfo<0> +{ + static const unsigned int vertices_per_cell = 1; + static const unsigned int lines_per_cell = 0; + static const unsigned int quads_per_cell = 0; + static const unsigned int hexes_per_cell = 0; +}; /** - * Publish some information about geometrical interconnections to the - * outside world, for one spatial dimension in this case. These are, - * for example the numbers of children per cell, faces per cell, etc, - * but also neighborship information, It is especially useful if you - * want to loop over all faces in any space dimension, but don't want - * to think about their number in a dimension independent expression. - * This not only reduces thinking effort but also error possibilities. + * Topological description of cells. + * + * This class contains as static members information on vertices and + * faces of a #dim#-dimensinal 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. #sub_faces_per_cell# in + * 1d. + * + * This information should always replace hard-coded numbers of + * vertices, neighbors and so on, since it can be used dimension + * independent. + * + * @author Wolfgang Bangerth, Guido Kanschat, 1998, 1999 */ -template <> -struct GeometryInfo<1> { - public: +template +struct GeometryInfo +{ /** - * Present dimension. + * Present dimension. Does not look useful, but might be. */ - static const unsigned int dim = 1; + static const unsigned int dim = _dim; /** * Number of children a cell has. */ - static const unsigned int children_per_cell = (1<1) ? (1<<(_dim-1)) : 0); /** * Number of vertices a cell has. */ - static const unsigned int vertices_per_cell = (1< { * #for (i=0; i -struct GeometryInfo<2> { - public: - /** - * Present dimension - */ - static const unsigned int dim = 2; - - /** - * Number of children a cell has. - */ - static const unsigned int children_per_cell = (1<1) ? (1<<(_dim-1)) : 0); - /** - * Number of faces a cell has. - */ - static const unsigned int faces_per_cell = 2*dim; /** - * Number of children each face has - * when the adjacent cell is refined. + * Number of lines of a cell. + * + * Computation of this value + * follows the idea, that + * building a hypercube of + * dimension #dim# from one of + * dimension #dim#-1 can be done + * in the following two steps: + * + * 1. Duplicated it in the new coordinate direction. + * + * 2. Connect all corrsponding + * vertices of the original + * hypercube and the copy by + * lines. */ - static const unsigned int subfaces_per_face = (1<<(dim-1)); - + static const unsigned int lines_per_cell = (2*GeometryInfo::lines_per_cell + + GeometryInfo::vertices_per_cell); + /** - * Number of vertices a cell has. + * Number of quadrilaterals of a cell. + * + * Computation is analogous to #lines_per_cell#. */ - static const unsigned int vertices_per_cell = (1<::quads_per_cell + + GeometryInfo::lines_per_cell); /** - * Number of vertices each face has. - */ - static const unsigned int vertices_per_face = (1<<(dim-1)); + * Number of hexahedra of a cell. + * + * Computation is analogous to + * #lines_per_cell#. Very + * important for more than three + * dimensions! */ + static const unsigned int hexes_per_cell = (2*GeometryInfo::hexes_per_cell + + GeometryInfo::quads_per_cell); /** * This field store which child cells @@ -141,63 +155,7 @@ struct GeometryInfo<2> { unsigned int subface); /** - * Exception - */ - DeclException2 (ExcInvalidIndex, - int, - int, - << "Invalid index " << arg1 - << ", index must be between 0 and " << arg2 << "."); -}; - - - -/** - * Publish some information about geometrical interconnections to the - * outside world, for three spatial dimensions in this case. These are, - * for example the numbers of children per cell, faces per cell, etc, - * but also neighborship information, It is especially useful if you - * want to loop over all faces in any space dimension, but don't want - * to think about their number in a dimension independent expression. - * This not only reduces thinking effort but also error possibilities. - */ -template <> -struct GeometryInfo<3> { - public: - /** - * Present dimension - */ - static const unsigned int dim = 3; - - /** - * Number of children a cell has. - */ - static const unsigned int children_per_cell = (1< { - - /*---------------------------- Inline functions --------------------------------*/ -inline -unsigned int GeometryInfo<2>::child_cell_on_face (const unsigned int face, - const unsigned int subface) { +template<> +inline unsigned int +GeometryInfo<2>::child_cell_on_face (const unsigned int face, + const unsigned int subface) +{ Assert (face::child_cell_on_face (const unsigned int face, }; +template<> +inline unsigned int +GeometryInfo<3>::child_cell_on_face (const unsigned int, + const unsigned int) +{ + Assert(false, ExcNotImplemented()); + return 0; +} /*---------------------------- geometry_info.h ---------------------------*/ /* end of #ifndef __geometry_info_H */ -- 2.39.5