]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
New members of GeometryInfo.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 30 May 2002 11:34:25 +0000 (11:34 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 30 May 2002 11:34:25 +0000 (11:34 +0000)
git-svn-id: https://svn.dealii.org/trunk@5930 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/include/grid/geometry_info.h
deal.II/doc/news/2002/c-3-3.html

index 37bc3a79d9439177096f0f30912471fb2616d8e1..87a10778b80a47279d0488154eaadc2409789757 100644 (file)
@@ -16,7 +16,7 @@
 
 #include <base/config.h>
 #include <base/exceptions.h>
-
+#include <base/point.h>
 
 
 
@@ -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<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.
  *
@@ -119,8 +209,8 @@ struct GeometryInfo<1>
     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<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);
 };
 
 
@@ -369,8 +408,8 @@ struct GeometryInfo<2>
     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<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
index 102e1016b85a0e66d63e012391cc8767378944d2..b6bb149a3f5853bba80b741480bb882ad23852a4 100644 (file)
@@ -296,6 +296,17 @@ contributor's names are abbreviated by WB (Wolfgang Bangerth), GK
 <h3>deal.II</h3>
 
 <ol>
+  <li> <p> 
+       New: The <code class="class">GeometryInfo</code> class now
+       provides two methods,
+       <code class="member">unit_cell_vertex</code> and <code
+       class="member">vertices_adjacent_to_line</code>, that reveal
+       something about the placement and numbering of vertices on the
+       uni cell.
+       <br>
+       (GK 2002/05/29)
+       </p>
+
   <li> <p> 
        New: The <code class="class">GridOut::</code>
        <code class="member">write_dx</code> function is now implemented.

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.