]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
add face_orientation() to TriaObjects
authorkanschat <kanschat@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 5 Jun 2007 21:24:20 +0000 (21:24 +0000)
committerkanschat <kanschat@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 5 Jun 2007 21:24:20 +0000 (21:24 +0000)
git-svn-id: https://svn.dealii.org/trunk@14755 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/include/grid/tria_accessor.templates.h
deal.II/deal.II/include/grid/tria_objects.h

index 31769431e68a23dd7bdf1058a56e12a2d0d9efe5..2e184ee1d7a2b00735e79f424d0444ac6f41588d 100644 (file)
@@ -232,11 +232,11 @@ TriaAccessor<dim,dim>::get_triangulation () const
 
 template <int dim>
 inline
-TriaObjectAccessor<1,dim>::
-TriaObjectAccessor (const Triangulation<dim> *parent,
-                    const int                 level,
-                    const int                 index,
-                    const AccessorData       *local_data)
+TriaObjectAccessor<1,dim>::TriaObjectAccessor (
+  const Triangulation<dim> *parent,
+  const int                 level,
+  const int                 index,
+  const AccessorData       *local_data)
                 :
                 TriaAccessor<1,dim> (parent, level, index, local_data)
 {
@@ -513,11 +513,11 @@ TriaObjectAccessor<1,1>::operator -- ()
 
 template <int dim>
 inline
-TriaObjectAccessor<2,dim>::
-TriaObjectAccessor (const Triangulation<dim> *parent,
-                    const int                 level,
-                    const int                 index,
-                    const AccessorData       *local_data)
+TriaObjectAccessor<2,dim>::TriaObjectAccessor (
+  const Triangulation<dim> *parent,
+  const int                 level,
+  const int                 index,
+  const AccessorData       *local_data)
                 :
                 TriaAccessor<2,dim> (parent, level, index, local_data)
 {
@@ -725,18 +725,12 @@ inline
 bool
 TriaObjectAccessor<2,3>::line_orientation (const unsigned int line) const
 {
-                                  // we cannot use the objects() function here,
+                                  // we cannot use the objects() function here,
                                   // since it returns a reference to
                                   // TriaObjects<Quad>, but we need a
                                   // (reference to) TriaObjectsQuad3D
   Assert (used(), TriaAccessorExceptions::ExcCellNotUsed());
-  Assert (line<GeometryInfo<2>::lines_per_cell,
-          ExcIndexRange (line, 0, GeometryInfo<2>::lines_per_cell));
-      Assert (this->present_index * GeometryInfo<2>::lines_per_cell + line
-             < this->tria->faces->quads.line_orientations.size(),
-             ExcInternalError());
-  return this->tria->faces->quads.
-    line_orientations[this->present_index * GeometryInfo<2>::lines_per_cell + line];
+  return this->tria->faces->quads.face_orientation(this->present_index, line);
 }
 
 
@@ -841,11 +835,11 @@ TriaObjectAccessor<2,2>::operator -- ()
 
 template <int dim>
 inline
-TriaObjectAccessor<3,dim>::
-TriaObjectAccessor (const Triangulation<dim> *parent,
-                    const int                 level,
-                    const int                 index,
-                    const AccessorData       *local_data)
+TriaObjectAccessor<3,dim>::TriaObjectAccessor (
+  const Triangulation<dim> *parent,
+  const int                 level,
+  const int                 index,
+  const AccessorData       *local_data)
                 :
                 TriaAccessor<3,dim> (parent, level, index, local_data)
 {
@@ -1072,29 +1066,18 @@ TriaObjectAccessor<3,dim>::max_refinement_depth () const
 template <>
 inline
 bool
-TriaObjectAccessor<3, 3>::
-face_orientation (const unsigned int face) const
+TriaObjectAccessor<3, 3>::face_orientation (const unsigned int face) const
 {
-  Assert (used(), TriaAccessorExceptions::ExcCellNotUsed());
-  Assert (face<GeometryInfo<3>::faces_per_cell,
-          ExcIndexRange (face, 0, GeometryInfo<3>::faces_per_cell));
-  Assert (this->present_index * GeometryInfo<3>::faces_per_cell + face
-         < this->tria->levels[this->present_level]
-         ->cells.face_orientations.size(),
-         ExcInternalError());
-  
+  Assert (used(), TriaAccessorExceptions::ExcCellNotUsed());  
   return (this->tria->levels[this->present_level]
-         ->cells.face_orientations[this->present_index *
-                                   GeometryInfo<3>::faces_per_cell
-                                   + face]);
+         ->cells.face_orientation(this->present_index, face));
 }
 
 
 template <>
 inline
 bool
-TriaObjectAccessor<3, 3>::
-face_flip (const unsigned int face) const
+TriaObjectAccessor<3, 3>::face_flip (const unsigned int face) const
 {
   Assert (used(), TriaAccessorExceptions::ExcCellNotUsed());
   Assert (face<GeometryInfo<3>::faces_per_cell,
@@ -1114,8 +1097,7 @@ face_flip (const unsigned int face) const
 template <>
 inline
 bool
-TriaObjectAccessor<3, 3>::
-face_rotation (const unsigned int face) const
+TriaObjectAccessor<3, 3>::face_rotation (const unsigned int face) const
 {
   Assert (used(), TriaAccessorExceptions::ExcCellNotUsed());
   Assert (face<GeometryInfo<3>::faces_per_cell,
@@ -1135,8 +1117,7 @@ face_rotation (const unsigned int face) const
 template <>
 inline
 bool
-TriaObjectAccessor<3, 3>::
-line_orientation (const unsigned int line) const
+TriaObjectAccessor<3, 3>::line_orientation (const unsigned int line) const
 {
   const int dim=3;
   Assert (used(), TriaAccessorExceptions::ExcCellNotUsed());
@@ -1278,11 +1259,11 @@ TriaObjectAccessor<3,3>::operator -- ()
 
 template <int dim>
 inline
-CellAccessor<dim>::
-CellAccessor (const Triangulation<dim> *parent,
-              const int                 level,
-              const int                 index,
-              const AccessorData       *local_data)
+CellAccessor<dim>::CellAccessor (
+  const Triangulation<dim> *parent,
+  const int                 level,
+  const int                 index,
+  const AccessorData       *local_data)
                 :
                 TriaObjectAccessor<dim,dim> (parent, level, index, local_data)
 {}
index 9db759b4f0962806de7819295597ee732623905a..88557e6adf795f04ab5ec0300f92cf3799bc43ad 100644 (file)
@@ -154,13 +154,26 @@ namespace internal
                                          * <tt>cell</tt>. The return
                                          * value is <tt>true</tt>, if
                                          * the normal vector points
-                                         * the usual way and
-                                         * <tt>false</tt> else.
+                                         * the usual way
+                                         * (GeometryInfo::unit_normal_orientation)
+                                         * and <tt>false</tt> else.
                                          *
                                          * The result is always
                                          * <tt>true</tt> in this
-                                         * class, but derived vlasses
+                                         * class, but derived classes
                                          * will reimplement this.
+                                         *
+                                         * @warning There is a bug in
+                                         * the class hierarchy right
+                                         * now. Avoid ever calling
+                                         * this function through a
+                                         * reference, since you might
+                                         * end up with the base class
+                                         * function instead of the
+                                         * derived class. Still, we
+                                         * do not want to make it
+                                         * virtual for efficiency
+                                         * reasons.
                                          */
        bool face_orientation(const unsigned int cell, const unsigned int face) const;
        
@@ -304,6 +317,21 @@ namespace internal
     class TriaObjectsHex: public TriaObjects<TriaObject<3> >
     {
       public:
+                                        /**
+                                         * The orientation of the
+                                         * face number <tt>face</tt>
+                                         * of the cell with number
+                                         * <tt>cell</tt>. The return
+                                         * value is <tt>true</tt>, if
+                                         * the normal vector points
+                                         * the usual way
+                                         * (GeometryInfo::unit_normal_orientation)
+                                         * and <tt>false</tt> if they
+                                         * point in opposite
+                                         * direction.
+                                         */
+       bool face_orientation(const unsigned int cell, const unsigned int face) const;
+       
 
                                         /**
                                          * For edges, we enforce a
@@ -406,6 +434,21 @@ namespace internal
     class TriaObjectsQuad3D: public TriaObjects<Quad>
     {
       public:
+                                        /**
+                                         * The orientation of the
+                                         * face number <tt>face</tt>
+                                         * of the cell with number
+                                         * <tt>cell</tt>. The return
+                                         * value is <tt>true</tt>, if
+                                         * the normal vector points
+                                         * the usual way
+                                         * (GeometryInfo::unit_normal_orientation)
+                                         * and <tt>false</tt> if they
+                                         * point in opposite
+                                         * direction.
+                                         */
+       bool face_orientation(const unsigned int cell, const unsigned int face) const;
+       
 
                                         /**
                                          * In effect, this field has
@@ -450,16 +493,21 @@ namespace internal
         unsigned int memory_consumption () const;          
     };
     
-
+//----------------------------------------------------------------------//
+    
     template<typename G>
-    bool TriaObjects<G>::face_orientation(const unsigned int, const unsigned int) const
+    inline
+    bool
+    TriaObjects<G>::face_orientation(const unsigned int, const unsigned int) const
     {
       return true;
     }
     
     
     template<typename G>
-    void*& TriaObjects<G>::user_pointer (const unsigned int i)
+    inline
+    void*&
+    TriaObjects<G>::user_pointer (const unsigned int i)
     {
 #ifdef DEBUG
       Assert(user_data_type == data_unknown || user_data_type == data_pointer,
@@ -472,7 +520,9 @@ namespace internal
     
 
     template<typename G>
-    const void* TriaObjects<G>::user_pointer (const unsigned int i) const
+    inline
+    const void*
+    TriaObjects<G>::user_pointer (const unsigned int i) const
     {
 #ifdef DEBUG
       Assert(user_data_type == data_unknown || user_data_type == data_pointer,
@@ -485,7 +535,9 @@ namespace internal
     
 
     template<typename G>
-    unsigned int& TriaObjects<G>::user_index (const unsigned int i)
+    inline
+    unsigned int&
+    TriaObjects<G>::user_index (const unsigned int i)
     {
 #ifdef DEBUG
       Assert(user_data_type == data_unknown || user_data_type == data_index,
@@ -496,13 +548,17 @@ namespace internal
       return user_data[i].i;
     }
     
+    
     template <typename G>
+    inline
     TriaObjects<G>::TriaObjects()
                    :
                    user_data_type(data_unknown)
     {}    
-
+    
+    
     template<typename G>
+    inline
     unsigned int TriaObjects<G>::user_index (const unsigned int i) const
     {
 #ifdef DEBUG
@@ -516,13 +572,40 @@ namespace internal
     
     
     template<typename G>
+    inline
     void TriaObjects<G>::clear_user_data ()
     {
       user_data_type = data_unknown;
       for (unsigned int i=0;i<user_data.size();++i)
        user_data[i].p = 0;
     }
-    
+
+//----------------------------------------------------------------------//
+
+    inline
+    bool
+    TriaObjectsHex::face_orientation(const unsigned int cell, const unsigned int face) const
+    {
+      Assert (cell < face_orientations.size() / GeometryInfo<3>::faces_per_cell,
+             ExcIndexRange(0, cell, face_orientations.size() / GeometryInfo<3>::faces_per_cell));
+      Assert (face < GeometryInfo<3>::faces_per_cell,
+             ExcIndexRange(0, face, GeometryInfo<3>::faces_per_cell));
+      
+      return face_orientations[cell * GeometryInfo<3>::faces_per_cell
+                              + face];
+    }
+
+//----------------------------------------------------------------------//
+
+    inline
+    bool
+    TriaObjectsQuad3D::face_orientation(const unsigned int cell, const unsigned int face) const
+    {
+      return line_orientations[cell * GeometryInfo<2>::faces_per_cell
+                              + face];
+    }
+
+
   }
 }
 

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.