]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
simplify face_to_equivalent_cell_index and add face_to_cell_index
authorguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 8 Jun 2006 08:01:20 +0000 (08:01 +0000)
committerguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 8 Jun 2006 08:01:20 +0000 (08:01 +0000)
git-svn-id: https://svn.dealii.org/trunk@13205 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/include/fe/fe_base.h
deal.II/deal.II/source/fe/fe_data.cc

index 421d62bca7f91dd889403d435eeac6ee5c910823..e48f7c0d2cb7f0d05d9e2f3c9638ea53bd301c8b 100644 (file)
@@ -396,6 +396,25 @@ class FiniteElementData
     bool conforms (const Conformity) const;
 
                                     /**
+                                     * Given an index in the natural
+                                     * ordering of indices on a face,
+                                     * return the index of the same
+                                     * degree of freedom on the cell.
+                                     * 
+                                     */
+    unsigned int face_to_cell_index(unsigned int face_index,
+                                   unsigned int face,
+                                   bool orientation = true) const;
+    
+                                    /**
+                                     * @deprecated This function is
+                                     * just a special version of
+                                     * face_to_cell_index for the face
+                                     * zero. It is therefore of
+                                     * limited use in aplications and
+                                     * most of the time, the other
+                                     * function is what is required.
+                                     *
                                      * Given an index in the natural
                                      * ordering of indices on a face,
                                      * return the index of an
@@ -423,6 +442,7 @@ class FiniteElementData
                                      *  if (fe.is_primitive(fe.face_to_equivalent_cell_index(i)))
                                      *   ... do whatever
                                      * @endcode
+                                     *
                                      */
     unsigned int face_to_equivalent_cell_index (const unsigned int index) const;
     
@@ -535,7 +555,7 @@ FiniteElementData<1>::
 face_to_equivalent_cell_index (const unsigned int index) const
 {
   Assert (index < dofs_per_face,
-         ExcIndexRange (index, 0, dofs_per_vertex));
+         ExcIndexRange (index, 0, dofs_per_face));
   return index;
 }
 
@@ -548,17 +568,11 @@ FiniteElementData<2>::
 face_to_equivalent_cell_index (const unsigned int index) const
 {
   Assert (index < dofs_per_face,
-         ExcIndexRange (index, 0, dofs_per_vertex));
-  return (index < (GeometryInfo<2>::vertices_per_face *
-                  this->dofs_per_vertex)
-         ?
-         index
-         :
-         GeometryInfo<2>::vertices_per_cell *
-         this->dofs_per_vertex +
-         (index -
-          GeometryInfo<2>::vertices_per_face *
-          this->dofs_per_vertex));
+         ExcIndexRange (index, 0, dofs_per_face));
+  return (index < (this->first_face_line_index)
+         ? index
+         : this->first_line_index +
+         (index - this->first_face_line_index));
 }
 
 
@@ -571,34 +585,15 @@ FiniteElementData<3>::
 face_to_equivalent_cell_index (const unsigned int index) const
 {
   Assert (index < dofs_per_face,
-         ExcIndexRange (index, 0, dofs_per_vertex));
+         ExcIndexRange (index, 0, dofs_per_face));
   return (index < (GeometryInfo<3>::vertices_per_face *
                   this->dofs_per_vertex)
-         ?
-         index
-         :
-         (index < (GeometryInfo<3>::vertices_per_face *
-                   this->dofs_per_vertex
-                   +
-                   GeometryInfo<3>::lines_per_face *
-                   this->dofs_per_line)
-          ?
-          GeometryInfo<3>::vertices_per_cell *
-          this->dofs_per_vertex +
-          (index -
-           GeometryInfo<3>::vertices_per_face *
-           this->dofs_per_vertex)
-          :
-          GeometryInfo<3>::vertices_per_cell *
-          this->dofs_per_vertex +
-          GeometryInfo<3>::lines_per_cell *
-          this->dofs_per_line +
-          (index -
-           GeometryInfo<3>::vertices_per_face *
-           this->dofs_per_vertex
-           -
-           GeometryInfo<3>::lines_per_face *
-           this->dofs_per_line)));
+         ? index
+         : (index < (this->first_face_quad_index)
+            ? this->first_line_index +
+            (index - this->first_face_line_index)
+            : this->first_quad_index +
+          (index - this->first_face_quad_index)));
 }
 
 
index defac8ce053a54a976c9e3b93f6ec16592242f21..5287f6f9512bcd39eb663ab6fe649fbdfea74ed2 100644 (file)
@@ -97,6 +97,46 @@ bool FiniteElementData<dim>::operator== (const FiniteElementData<dim> &f) const
          (conforming_space == f.conforming_space));
 }
 
+template<int dim>
+unsigned int
+FiniteElementData<dim>::face_to_cell_index(
+  unsigned int face_index,
+  unsigned int face,
+  bool orientation) const
+{
+  Assert(face_index < this->dofs_per_face,
+        ExcIndexRange(face_index, 0, this->dofs_per_face));
+  Assert(face < GeometryInfo<dim>::faces_per_cell,
+        ExcIndexRange(face, 0, GeometryInfo<dim>::faces_per_cell));
+  
+                                  // DoF on a vertex
+  if (face_index < this->first_face_line_index)
+    {
+                                      // Vertex number on the face
+      const unsigned int face_vertex = face_index / this->dofs_per_vertex;
+      return face_index % this->dofs_per_vertex
+       + GeometryInfo<dim>::face_to_cell_vertices(face, face_vertex, orientation)
+       * this->dofs_per_vertex;
+    }
+                                  // Else, DoF on a line?
+  if (face_index < this->first_face_quad_index)
+    {
+                                      // Ignore vertex dofs
+      const unsigned int index = face_index - this->first_face_line_index;
+                                      // Line number on the face
+      const unsigned int face_line = index / this->dofs_per_line;
+      return this->first_line_index + index % this->dofs_per_line
+       + GeometryInfo<dim>::face_to_cell_lines(face, face_line, orientation)
+       * this->dofs_per_line;
+    }
+                                  // Else, DoF is on a quad
+
+                                  // Ignore vertex and line dofs
+  const unsigned int index = face_index - this->first_face_quad_index;
+  return this->first_quad_index + index
+    + face * this->dofs_per_quad;
+}
+
 
 template class FiniteElementData<1>;
 template class FiniteElementData<2>;

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.