]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
GeometryInfo<dim>::child_cell_from_point
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 24 Apr 2003 22:57:45 +0000 (22:57 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 24 Apr 2003 22:57:45 +0000 (22:57 +0000)
git-svn-id: https://svn.dealii.org/trunk@7472 0785d39b-7218-0410-832d-ea1e28bc413d

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

index 7a07383468f31a413505eba406a4e3d6902cb0f1..0c1774e9609e2309f3ab9fcc8eee9edf592ccb64 100644 (file)
@@ -320,6 +320,31 @@ struct GeometryInfo<1>
                                      */
     static unsigned int vertices_adjacent_to_line (const unsigned int line,
                                                   const unsigned int vertex);
+
+                                    /**
+                                     * Given a point @p{p} in unit
+                                     * coordinates, return the number
+                                     * of the child cell in which it
+                                     * would lie in. If the point
+                                     * lies on the interface of two
+                                     * children, return any one of
+                                     * their indices. The result is
+                                     * always less than
+                                     * @p{GeometryInfo<dim>::children_per_cell}.
+                                     *
+                                     * The order of child cells is
+                                     * described the documentation of
+                                     * the @ref{Triangulation} class.
+                                     */
+    static unsigned int child_cell_from_point (const Point<1> &p);
+
+                                    /**
+                                     * Exception
+                                     */
+    DeclException1 (ExcInvalidCoordinate,
+                   double,
+                   << "The coordinates must satisfy 0 <= x_i <= 1, "
+                   << "but here we have x_i=" << arg1);
 };
 
 
@@ -519,6 +544,31 @@ struct GeometryInfo<2>
                                      */
     static unsigned int vertices_adjacent_to_line (const unsigned int line,
                                                   const unsigned int vertex);
+
+                                    /**
+                                     * Given a point @p{p} in unit
+                                     * coordinates, return the number
+                                     * of the child cell in which it
+                                     * would lie in. If the point
+                                     * lies on the interface of two
+                                     * children, return any one of
+                                     * their indices. The result is
+                                     * always less than
+                                     * @p{GeometryInfo<dim>::children_per_cell}.
+                                     *
+                                     * The order of child cells is
+                                     * described the documentation of
+                                     * the @ref{Triangulation} class.
+                                     */
+    static unsigned int child_cell_from_point (const Point<2> &p);
+
+                                    /**
+                                     * Exception
+                                     */
+    DeclException1 (ExcInvalidCoordinate,
+                   double,
+                   << "The coordinates must satisfy 0 <= x_i <= 1, "
+                   << "but here we have x_i=" << arg1);
 };
 
 
@@ -716,6 +766,31 @@ struct GeometryInfo<3>
                                      */
     static unsigned int vertices_adjacent_to_line (const unsigned int line,
                                                   const unsigned int vertex);
+
+                                    /**
+                                     * Given a point @p{p} in unit
+                                     * coordinates, return the number
+                                     * of the child cell in which it
+                                     * would lie in. If the point
+                                     * lies on the interface of two
+                                     * children, return any one of
+                                     * their indices. The result is
+                                     * always less than
+                                     * @p{GeometryInfo<dim>::children_per_cell}.
+                                     *
+                                     * The order of child cells is
+                                     * described the documentation of
+                                     * the @ref{Triangulation} class.
+                                     */
+    static unsigned int child_cell_from_point (const Point<3> &p);
+
+                                    /**
+                                     * Exception
+                                     */
+    DeclException1 (ExcInvalidCoordinate,
+                   double,
+                   << "The coordinates must satisfy 0 <= x_i <= 1, "
+                   << "but here we have x_i=" << arg1);
 };
 
 
@@ -910,5 +985,50 @@ GeometryInfo<3>::vertices_adjacent_to_line (const unsigned int line,
 
 
 
+inline
+unsigned int
+GeometryInfo<1>::child_cell_from_point (const Point<1> &p)
+{
+  Assert ((p[0] >= 0) && (p[0] <= 1), ExcInvalidCoordinate(p[0]));
+  
+  return (p[0] <= 0.5 ? 0 : 1);
+}
+
+
+
+inline
+unsigned int
+GeometryInfo<2>::child_cell_from_point (const Point<2> &p)
+{
+  Assert ((p[0] >= 0) && (p[0] <= 1), ExcInvalidCoordinate(p[0]));
+  Assert ((p[1] >= 0) && (p[1] <= 1), ExcInvalidCoordinate(p[1]));
+  
+  return (p[0] <= 0.5 ?
+         (p[1] <= 0.5 ? 0 : 3) :
+         (p[1] <= 0.5 ? 1 : 2));
+}
+
+
+
+inline
+unsigned int
+GeometryInfo<3>::child_cell_from_point (const Point<3> &p)
+{
+  Assert ((p[0] >= 0) && (p[0] <= 1), ExcInvalidCoordinate(p[0]));
+  Assert ((p[1] >= 0) && (p[1] <= 1), ExcInvalidCoordinate(p[1]));
+  Assert ((p[2] >= 0) && (p[2] <= 1), ExcInvalidCoordinate(p[2]));
+  
+  return (p[0] <= 0.5 ?
+         (p[1] <= 0.5 ?
+          (p[2] <= 0.5 ? 0 : 3) :
+          (p[2] <= 0.5 ? 4 : 7)) :
+         (p[1] <= 0.5 ?
+          (p[2] <= 0.5 ? 1 : 2) :
+          (p[2] <= 0.5 ? 5 : 6)));
+}
+
+
+
+
 
 #endif
index 3118dcd39666f91e0de9b7e714bfbbcc7a901330..8e50daa5be3b87304e67f140d096d1d55bbb38b2 100644 (file)
@@ -756,6 +756,15 @@ contributor's names are abbreviated by WB (Wolfgang Bangerth), GK
 <h3>deal.II</h3>
 
 <ol>
+  <li> <p>
+       New: The <code class="class">GeometryInfo</code> classes now
+       have a static member function <code
+       class="member">child_cell_from_point</code> that, given a point
+       in the unit cell, returns which child cell it is on.
+       <br>
+       (WB 2003/04/24)
+       </p>
+
   <li> <p>
        New: There are now functions <code
        class="member">recursively_set/clear_user_pointer</code> that

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.