]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
new features and COMMON interface for all dimensions
authorguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 15 Feb 1999 16:22:16 +0000 (16:22 +0000)
committerguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 15 Feb 1999 16:22:16 +0000 (16:22 +0000)
git-svn-id: https://svn.dealii.org/trunk@801 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/include/grid/geometry_info.h

index e1cbdd25ffd8758d00209c71553e2080bfee25a8..cfcaf9d4ef383c313c50822d4f199b5691e7454c 100644 (file)
@@ -8,41 +8,63 @@
 
 #include <base/exceptions.h>
 
+template <int _dim> struct GeometryInfo;
 
-template <int dim> struct GeometryInfo;
+/**
+ * Pseudo-class for recursive functions in #GeometryInfo<dim>#.
+ */
+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 <int _dim>
+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<<dim);
+    static const unsigned int children_per_cell = (1<<_dim);
 
                                     /**
                                      * Number of faces a cell has.
                                      */
-    static const unsigned int faces_per_cell    = 2*dim;
+    static const unsigned int faces_per_cell    = 2*_dim;
+
+                                    /**
+                                     * Number of children each face has
+                                     * when the adjacent cell is refined.
+                                     */
+    static const unsigned int subfaces_per_face = ((_dim>1) ? (1<<(_dim-1)) : 0);
 
                                     /**
                                      * Number of vertices a cell has.
                                      */
-    static const unsigned int vertices_per_cell = (1<<dim);
+    static const unsigned int vertices_per_cell = (1<<_dim);
 
                                     /**
                                      * Number of vertices each face has.
@@ -53,54 +75,46 @@ struct GeometryInfo<1> {
                                      * #for (i=0; i<vertices_per_face; ++i)#,
                                      * at least if #i# is an #unsigned int#.
                                      */
-    static const unsigned int vertices_per_face = 0;
-    
-};
-
-
-
-/**
- *  Publish some information about geometrical interconnections to the
- *  outside world, for two 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<2> {
-  public:
-                                    /**
-                                     * Present dimension
-                                     */
-    static const unsigned int dim               = 2;
-
-                                    /**
-                                     * Number of children a cell has.
-                                     */
-    static const unsigned int children_per_cell = (1<<dim);
+    static const unsigned int vertices_per_face = ((_dim>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<dim-1>::lines_per_cell
+                                               + GeometryInfo<dim-1>::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<<dim);
+    static const unsigned int quads_per_cell = (2*GeometryInfo<dim-1>::quads_per_cell
+                                               + GeometryInfo<dim-1>::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<dim-1>::hexes_per_cell
+                                               + GeometryInfo<dim-1>::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<<dim);
-
-                                    /**
-                                     * 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.
-                                     */
-    static const unsigned int subfaces_per_face = (1<<(dim-1));
-
-                                    /**
-                                     * Number of vertices a cell has.
-                                     */
-    static const unsigned int vertices_per_cell = (1<<dim);
-
-                                    /**
-                                     * Number of vertices each face has.
-                                     */
-    static const unsigned int vertices_per_face = (1<<(dim-1));
-
-                                    /**
-                                     * Exception
-                                     */
+                                     * Exception */
     DeclException2 (ExcInvalidIndex,
                    int,
                    int,
@@ -207,13 +165,13 @@ struct GeometryInfo<3> {
 
 
 
-
-
 /*---------------------------- 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<faces_per_cell, ExcInvalidIndex(face,faces_per_cell));
   Assert (subface<subfaces_per_face, ExcInvalidIndex(subface,subfaces_per_face));
   
@@ -225,6 +183,14 @@ unsigned int GeometryInfo<2>::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 */

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.