]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Many more clean-ups.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 23 Oct 2003 20:40:31 +0000 (20:40 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 23 Oct 2003 20:40:31 +0000 (20:40 +0000)
git-svn-id: https://svn.dealii.org/trunk@8150 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/include/grid/grid_reordering_internal.h
deal.II/deal.II/source/grid/grid_reordering.cc

index c2eab607a069d63784876650b1af38f8cf0df698..9a63335a7f8ca1cc0ad429fd229daec0b9131e54 100644 (file)
@@ -427,9 +427,13 @@ namespace internal
     };
 
   
-    class ElementInfo
+    struct ElementInfo
     {
-      public:
+                                        /**
+                                         * Constructor.
+                                         */
+       ElementInfo ();
+       
                                          /**
                                           * The numbers of the edges
                                           * coming into node i are
@@ -461,9 +465,9 @@ namespace internal
         int nodes_on_face[6][4];
     };
 
-    class DealElemInfo : public ElementInfo
+    
+    struct DealElemInfo : public ElementInfo
     {
-      public:
         DealElemInfo();
     };
 
@@ -474,19 +478,14 @@ namespace internal
                                       * A conectivity and orientation
                                       * aware edge class.
                                       */
-    class Edge
+    struct Edge
     {
-      public:
                                          /**
                                           * Simple constructor
                                           */
-        Edge (int n0, int n1, int orient=0)
-                        :
-                        orientation_flag(orient),
-                        group(0),
-                        num_neighbouring_cubes(0),
-                        neighbouring_cubes(NULL)
-          {nodes[0]=n0; nodes[1]=n1;};
+        Edge (int n0,
+             int n1,
+             int orient=0);
       
                                          /**
                                           * Simple Destructor
@@ -539,18 +538,17 @@ namespace internal
                                       * TODO: Need to move conectivity information out 
                                       *       of cell and into edge.
                                       */
-    class Cell
+    struct Cell
     {
-      public:
                                          /**
                                           * The IDs for each of the edges.
                                           */
-        int edges[12];
+        int edges[GeometryInfo<3>::lines_per_cell];
         
                                          /**
                                           * The IDs for each of the nodes.
                                           */        
-        int nodes[8];  
+        int nodes[GeometryInfo<3>::vertices_per_cell];  
 
                                          /**
                                           * Which way do the edges
@@ -560,7 +558,7 @@ namespace internal
                                           * (1) or node 1 is the base
                                           * (-1).
                                           */
-        int local_orientation_flags[12];
+        int local_orientation_flags[GeometryInfo<3>::lines_per_cell];
         
                                          /**
                                           * An internal flag used to
@@ -574,36 +572,12 @@ namespace internal
                                          /**
                                           * Copy Constructor
                                           */
-        Cell (const Cell &c)
-         {
-           for(int i=0;i<12;++i)
-              {
-                edges[i]=c.edges[i];
-                local_orientation_flags[i]=c.local_orientation_flags[i];
-              }
-           for(int i=0;i<8;++i)
-              {
-                nodes[i]=c.nodes[i];
-              }
-           waiting_to_be_processed=c.waiting_to_be_processed;
-         }
+        Cell (const Cell &c);
 
                                          /**
                                           * Default Constructor
                                           */
-        Cell()
-         {
-           for(int i=0;i<12;++i)
-              {
-                edges[i]=-1;
-                local_orientation_flags[i]=1;
-              }
-           for(int i=0;i<8;++i)
-              {
-                nodes[i]=-1;
-              }
-           waiting_to_be_processed=false;
-         }
+        Cell();
     };
 
 
@@ -684,18 +658,14 @@ namespace internal
     };
 
 
+    
     class Orienter
     {
       public:
                                          /**
                                           * Constructor.
                                           */
-        Orienter()
-          {
-            for (unsigned int i=0; i<12; ++i)
-              edge_orient_array[i]=false;
-          }
-
+        Orienter();
 
                                          /**
                                           * The cube we're looking at now.
@@ -708,7 +678,7 @@ namespace internal
                                           */
         unsigned int marker_cube;
 
-        std::vector<int> SheetToProcess;
+        std::vector<int> sheet_to_process;
 
         int cur_edge_group;
 
@@ -717,20 +687,20 @@ namespace internal
         bool orient_edges (Mesh &m);
         void orient_cubes (Mesh &m);
       
-        bool GetNextUnorientedCube (Mesh &m);
+        bool get_next_unoriented_cube (Mesh &m);
         bool is_oriented (const Mesh &m,
                           int cell_num);
 
-        bool OrientEdgesInCurrentCube (Mesh &m);
-        bool OrientEdgeSetInCurrentCube (Mesh &m,
-                                         int edge_set);
-        bool OrientNextUnorientedEdge (Mesh &m);
-        bool Consistent (Mesh &m,
+        bool orient_edges_in_current_cube (Mesh &m);
+        bool orient_edge_set_in_current_cube (Mesh &m,
+                                             int edge_set);
+        bool orient_next_unoriented_edge (Mesh &m);
+        bool consistent (Mesh &m,
                          int cell_num);
 
 
-        void GetAdjacentCubes (Mesh &m);
-        bool GetNextActiveCube (Mesh &m);
+        void get_adjacent_cubes (Mesh &m);
+        bool get_next_active_cube (Mesh &m);
     };
 
 
index 30311ee1fa8edca696168d324065af2ce1f6da4e..992c39655e7b91b6174468a1f978abfcec5f8609 100644 (file)
@@ -42,13 +42,13 @@ namespace internal
   namespace GridReordering2d
   {
 // -- Definition Of conectivity information --
-    const int ConnectGlobals::EdgeToNode[4][2]=
+    const int ConnectGlobals::EdgeToNode[4][2] = 
     { {0,1},{1,2},{2,3},{3,0} };
 
-    const int ConnectGlobals::NodeToEdge[4][2]=
+    const int ConnectGlobals::NodeToEdge[4][2] = 
     { {3,0},{0,1},{1,2},{2,3} };
 
-    const int ConnectGlobals::DefaultOrientation[4][2]=
+    const int ConnectGlobals::DefaultOrientation[4][2] = 
     {{0,1},{1,2},{3,2},{0,3}};
 
 
@@ -108,7 +108,7 @@ namespace internal
                                           // we want them
                                            // (std::set eliminates
                                            // duplicated by itself)
-          for (unsigned int i=0; i<4; ++i)
+          for (unsigned int i = 0; i<4; ++i)
            {
              const Edge e(reverse_edges[i].v1, reverse_edges[i].v0);
              edges.insert (e);
@@ -141,28 +141,28 @@ namespace internal
            int s2vmin,s2vmax;
            if (s1.v0<s1.v1)
              {
-               s1vmin=s1.v0;
-               s1vmax=s1.v1;
+               s1vmin = s1.v0;
+               s1vmax = s1.v1;
              }
            else
              {
-               s1vmin=s1.v1;
-               s1vmax=s1.v0;
+               s1vmin = s1.v1;
+               s1vmax = s1.v0;
              }
            if (s2.v0<s2.v1)
              {
-               s2vmin=s2.v0;
-               s2vmax=s2.v1;
+               s2vmin = s2.v0;
+               s2vmax = s2.v1;
              }
            else
              {
-               s2vmin=s2.v1;
-               s2vmax=s2.v0;
+               s2vmin = s2.v1;
+               s2vmax = s2.v0;
              }
 
-           if(s1vmin<s2vmin)
+           if (s1vmin<s2vmin)
              return true;
-           if(s1vmin>s2vmin)
+           if (s1vmin>s2vmin)
              return false;
            return s1vmax<s2vmax;
          }
@@ -206,14 +206,14 @@ namespace internal
                    :
                    original_cell_data (cd)
     {
-      v[0]=v0;
-      v[1]=v1;
-      v[2]=v2;
-      v[3]=v3;
-      side[0]=s0;
-      side[1]=s1;
-      side[2]=s2;
-      side[3]=s3;
+      v[0] = v0;
+      v[1] = v1;
+      v[2] = v2;
+      v[3] = v3;
+      side[0] = s0;
+      side[1] = s1;
+      side[2] = s2;
+      side[3] = s3;
     }
 
 
@@ -231,16 +231,16 @@ namespace internal
     
     
     bool
-    MSide::operator== (const MSide& s2) const
+    MSide::operator == (const MSide& s2) const
     {
-      if ((v0==s2.v0)&&(v1==s2.v1)) {return true;}
-      if ((v0==s2.v1)&&(v1==s2.v0)) {return true;}
+      if ((v0 == s2.v0)&&(v1 == s2.v1)) {return true;}
+      if ((v0 == s2.v1)&&(v1 == s2.v0)) {return true;}
       return false;
     }
 
 
     bool
-    MSide::operator!= (const MSide& s2) const
+    MSide::operator != (const MSide& s2) const
     {
       return !(*this == s2);
     }
@@ -298,7 +298,7 @@ namespace internal
       mquads.reserve(inquads.size());
   
                                       //Insert all the sides into the side vector
-      for (int i=0;i<4;++i)
+      for (int i = 0;i<4;++i)
        {
          std::transform(inquads.begin(),inquads.end(),
                         std::back_inserter(sides), std::bind2nd(QuadSide(),i));
@@ -326,21 +326,21 @@ namespace internal
                std::bind2nd(MQuad::MakeQuad(),sides) );
   
                                       // Assign the quads to their sides also.
-      int qctr=0;
-      for(std::vector<MQuad>::iterator it=mquads.begin(); it!=mquads.end(); ++it)
+      int qctr = 0;
+      for (std::vector<MQuad>::iterator it = mquads.begin(); it != mquads.end(); ++it)
        {
-         for(unsigned int i=0;i<4;++i)
+         for (unsigned int i = 0;i<4;++i)
            {
-             MSide &ss =sides[(*it).side[i]];
-             if(ss.Q0==static_cast<unsigned int>(-1))
+             MSide &ss = sides[(*it).side[i]];
+             if (ss.Q0 == static_cast<unsigned int>(-1))
                {
-                 ss.Q0=qctr;
-                 ss.lsn0=i;
+                 ss.Q0 = qctr;
+                 ss.lsn0 = i;
                }
-             else if (ss.Q1==static_cast<unsigned int>(-1))
+             else if (ss.Q1 == static_cast<unsigned int>(-1))
                {
-                 ss.Q1=qctr;
-                 ss.lsn1=i;
+                 ss.Q1 = qctr;
+                 ss.lsn1 = i;
                }
              else
                AssertThrow (false, ExcInternalError());
@@ -354,14 +354,14 @@ namespace internal
     {
                                       // do what the comment in the
                                       // class declaration says
-      unsigned int qnum=0;
+      unsigned int qnum = 0;
       while(get_unoriented_quad(qnum))
        {
-         unsigned int lsn=0;
+         unsigned int lsn = 0;
          while(get_unoriented_side(qnum,lsn))
            {
              orient_side(qnum,lsn);
-             unsigned int qqnum=qnum;
+             unsigned int qqnum = qnum;
              while(side_hop(qqnum,lsn))
                {
                                                   // switch this face
@@ -387,34 +387,34 @@ namespace internal
       MQuad &quad = mquads[quadnum];
       int op_side_l = (localsidenum+2)%4;
       MSide &side = sides[mquads[quadnum].side[localsidenum]];
-      const MSide &op_side =sides[mquads[quadnum].side[op_side_l]]; 
+      const MSide &op_side = sides[mquads[quadnum].side[op_side_l]]; 
   
                                       //is the opposite side oriented?    
       if (op_side.Oriented)
        {
                                           //YES - Make the orientations match
                                           //Is op side in default orientation?
-         if (op_side.v0==quad.v[ConnectGlobals::DefaultOrientation[op_side_l][0]])
+         if (op_side.v0 == quad.v[ConnectGlobals::DefaultOrientation[op_side_l][0]])
            {
                                               //YES
-             side.v0=quad.v[ConnectGlobals::DefaultOrientation[localsidenum][0]];
-             side.v1=quad.v[ConnectGlobals::DefaultOrientation[localsidenum][1]];
+             side.v0 = quad.v[ConnectGlobals::DefaultOrientation[localsidenum][0]];
+             side.v1 = quad.v[ConnectGlobals::DefaultOrientation[localsidenum][1]];
            }
          else
            {
                                               //NO, its reversed
-             side.v0=quad.v[ConnectGlobals::DefaultOrientation[localsidenum][1]];
-             side.v1=quad.v[ConnectGlobals::DefaultOrientation[localsidenum][0]];
+             side.v0 = quad.v[ConnectGlobals::DefaultOrientation[localsidenum][1]];
+             side.v1 = quad.v[ConnectGlobals::DefaultOrientation[localsidenum][0]];
            }
        }
       else
        {
                                           //NO
                                           //Just use the default orientation      
-         side.v0=quad.v[ConnectGlobals::DefaultOrientation[localsidenum][0]];
-         side.v1=quad.v[ConnectGlobals::DefaultOrientation[localsidenum][1]];
+         side.v0 = quad.v[ConnectGlobals::DefaultOrientation[localsidenum][0]];
+         side.v1 = quad.v[ConnectGlobals::DefaultOrientation[localsidenum][1]];
        }
-      side.Oriented=true;  
+      side.Oriented = true;  
     }
 
 
@@ -448,7 +448,7 @@ namespace internal
       while( (UnOrQLoc<mquads.size()) &&
             is_fully_oriented_quad(UnOrQLoc) )
        UnOrQLoc++;
-      return (UnOrQLoc!=mquads.size());
+      return (UnOrQLoc != mquads.size());
     }
 
 
@@ -458,24 +458,24 @@ namespace internal
                                         unsigned int &lsn) const
     {
       const MQuad &mq = mquads[quadnum];
-      if(!sides[mq.side[0]].Oriented)
+      if (!sides[mq.side[0]].Oriented)
        {
-         lsn=0;
+         lsn = 0;
          return true;
        }
-      if(!sides[mq.side[1]].Oriented)
+      if (!sides[mq.side[1]].Oriented)
        {
-         lsn=1;
+         lsn = 1;
          return true;
        }
-      if(!sides[mq.side[2]].Oriented)
+      if (!sides[mq.side[2]].Oriented)
        {
-         lsn=2;
+         lsn = 2;
          return true;
        }
-      if(!sides[mq.side[3]].Oriented)
+      if (!sides[mq.side[3]].Oriented)
        {
-         lsn=3;
+         lsn = 3;
          return true;
        }
       return false;
@@ -485,21 +485,21 @@ namespace internal
     bool
     GridReordering::side_hop (unsigned int &qnum, unsigned int &lsn) const
     {
-      const MQuad &mq=mquads[qnum];
+      const MQuad &mq = mquads[qnum];
       const MSide &s = sides[mq.side[lsn]];
-      unsigned int opquad=0;
-      if (s.Q0==qnum)
+      unsigned int opquad = 0;
+      if (s.Q0 == qnum)
        {
-         opquad=s.Q1;
-         lsn =s.lsn1;
+         opquad = s.Q1;
+         lsn = s.lsn1;
        }
       else
        {
-         opquad=s.Q0;
-         lsn=s.lsn0;
+         opquad = s.Q0;
+         lsn = s.lsn0;
        }
   
-      if (opquad!=static_cast<unsigned int>(-1))
+      if (opquad != static_cast<unsigned int>(-1))
        {
          qnum = opquad;
          return true;
@@ -514,7 +514,7 @@ namespace internal
     {
       outquads.clear();
       outquads.reserve(mquads.size());
-      for(unsigned int qn=0;qn<mquads.size();++qn)
+      for (unsigned int qn = 0;qn<mquads.size();++qn)
        {
                                           // initialize CellData object with
                                           // previous contents, and the
@@ -524,21 +524,21 @@ namespace internal
          CellData<2> q = mquads[qn].original_cell_data;
          
                                           // Are the sides oriented? 
-         Assert(is_fully_oriented_quad(qn), ExcInternalError());
+         Assert (is_fully_oriented_quad(qn), ExcInternalError());
          bool s[4]; //whether side 1 ,2, 3, 4 are in the default orientation
-         for(int sn=0;sn<4;sn++)
+         for (int sn = 0;sn<4;sn++)
            {
-             s[sn]=is_side_default_oriented(qn,sn);
+             s[sn] = is_side_default_oriented(qn,sn);
            }
                                           // Are they oriented in the "deal way"?
-         Assert(s[0]==s[2], ExcInternalError());
-         Assert(s[1]==s[3], ExcInternalError());
+         Assert (s[0] == s[2], ExcInternalError());
+         Assert (s[1] == s[3], ExcInternalError());
                                           // How much we rotate them by.
          int rotn = 2*(s[0]?1:0)+ ((s[0]^s[1])?1:0);
 
-         for(int i=0;i<4;++i)
+         for (int i = 0;i<4;++i)
            {
-             q.vertices[(i+rotn)%4]=mquads[qn].v[i];
+             q.vertices[(i+rotn)%4] = mquads[qn].v[i];
            }
          outquads.push_back(q);
        }
@@ -549,7 +549,7 @@ namespace internal
     GridReordering::is_side_default_oriented (const unsigned int qnum,
                                              const unsigned int lsn) const
     {
-      return (sides[mquads[qnum].side[lsn]].v0 ==
+      return (sides[mquads[qnum].side[lsn]].v0 == 
              mquads[qnum].v[ConnectGlobals::DefaultOrientation[lsn][0]]);
     }
   } // namespace GridReordering2
@@ -615,10 +615,10 @@ namespace internal
       std::vector<Cell> & cell_list = m.cell_list;
       std::vector<Edge> & edge_list = m.edge_list;
 
-      const unsigned int cell_list_length=cell_list.size();
+      const unsigned int cell_list_length = cell_list.size();
 
 
-      unsigned int NumEdges=0;
+      unsigned int NumEdges = 0;
                                       // Correctly build the edge
                                       // list
       {
@@ -626,33 +626,33 @@ namespace internal
                                         // edge_number associated
                                         // with a given CheapEdge
        std::map<CheapEdge,int> edge_map;
-       unsigned int ctr=0;
-       for(unsigned int cur_cell_id=0; 
-           cur_cell_id<cell_list_length; 
-           ++cur_cell_id)
+       unsigned int ctr = 0;
+       for (unsigned int cur_cell_id = 0; 
+            cur_cell_id<cell_list_length; 
+            ++cur_cell_id)
          {
                                             // Get the local node
                                             // numbers on edge
                                             // edge_num
            Cell & cur_cell = cell_list[cur_cell_id];
 
-           for(unsigned short int edge_num=0; 
-               edge_num<12; 
-               ++edge_num)
+           for (unsigned short int edge_num = 0; 
+                edge_num<12; 
+                ++edge_num)
              {
-               unsigned int gl_edge_num=0;
-               int l_edge_orient=1;
+               unsigned int gl_edge_num = 0;
+               int l_edge_orient = 1;
                                                 // Construct the CheapEdge
-               int node0=cur_cell.nodes[info.nodes_on_edge[edge_num][0]];
-               int node1=cur_cell.nodes[info.nodes_on_edge[edge_num][1]];
+               int node0 = cur_cell.nodes[info.nodes_on_edge[edge_num][0]];
+               int node1 = cur_cell.nodes[info.nodes_on_edge[edge_num][1]];
                CheapEdge cur_edge(node0,node1);
-               if(edge_map.count(cur_edge)==0) // Edge not in map
+               if (edge_map.count(cur_edge) == 0) // Edge not in map
                  {
                                                     // put edge in
                                                     // hash map with
                                                     // ctr value;
-                   edge_map[cur_edge]=ctr;
-                   gl_edge_num=ctr;
+                   edge_map[cur_edge] = ctr;
+                   gl_edge_num = ctr;
 
                                                     // put the edge
                                                     // into the
@@ -665,19 +665,18 @@ namespace internal
                  {
                                                     // get edge_num
                                                     // from hash_map
-                   gl_edge_num=edge_map[cur_edge]; 
-                   if (edge_list[gl_edge_num].nodes[0]!=node0)
-                     { 
-                       l_edge_orient=-1;
-                     }
+                   gl_edge_num = edge_map[cur_edge]; 
+                   if (edge_list[gl_edge_num].nodes[0] != node0)
+                     l_edge_orient = -1;
                  }
                                                 // set edge number to
                                                 // edgenum
-               cell_list[cur_cell_id].edges[edge_num]=gl_edge_num; 
-               cell_list[cur_cell_id].local_orientation_flags[edge_num]=l_edge_orient;
+               cell_list[cur_cell_id].edges[edge_num] = gl_edge_num; 
+               cell_list[cur_cell_id].local_orientation_flags[edge_num]
+                 = l_edge_orient;
              }
          }
-       NumEdges=ctr;
+       NumEdges = ctr;
       }
 
                                       // Count each of the edges.
@@ -687,14 +686,14 @@ namespace internal
 
                                         // Count every time an edge
                                         // occurs in a cube.
-       for(unsigned int cur_cell_id=0; 
-           cur_cell_id<cell_list_length; 
-           ++cur_cell_id)
+       for (unsigned int cur_cell_id = 0; 
+            cur_cell_id<cell_list_length; 
+            ++cur_cell_id)
          {
            Cell & cur_cell = cell_list[cur_cell_id];
-           for(unsigned short int edge_num=0; 
-               edge_num<12; 
-               ++edge_num)
+           for (unsigned short int edge_num = 0; 
+                edge_num<12; 
+                ++edge_num)
              {
                edge_count[cur_cell.edges[edge_num]]++;
              } 
@@ -708,13 +707,13 @@ namespace internal
 
                                         // Allocate the space for the
                                         // neighbour list
-       for(unsigned int cur_edge_id = 0;
-           cur_edge_id<NumEdges;
-           ++cur_edge_id)
+       for (unsigned int cur_edge_id = 0;
+            cur_edge_id<NumEdges;
+            ++cur_edge_id)
          {
            Edge & cur_edge = edge_list[cur_edge_id];
            unsigned int NN = edge_count[cur_edge_id];
-           cur_edge.num_neighbouring_cubes=NN;
+           cur_edge.num_neighbouring_cubes = NN;
            cur_edge.neighbouring_cubes = new unsigned int [NN];
          }
       
@@ -722,18 +721,18 @@ namespace internal
                                         // current neighbour in the
                                         // edge's neighbour list
        std::vector<int> cur_cell_edge_list_posn(NumEdges,0);
-       for(unsigned int cur_cell_id =0;
-           cur_cell_id<cell_list_length;
-           ++cur_cell_id)
+       for (unsigned int cur_cell_id = 0;
+            cur_cell_id<cell_list_length;
+            ++cur_cell_id)
          {
            Cell & cur_cell = cell_list[cur_cell_id];
-           for(unsigned short int edge_num=0; 
-               edge_num<12; 
-               ++edge_num)
+           for (unsigned short int edge_num = 0; 
+                edge_num<12; 
+                ++edge_num)
              {
-               unsigned int gl_edge_id=cur_cell.edges[edge_num];
+               unsigned int gl_edge_id = cur_cell.edges[edge_num];
                Edge & cur_edge = edge_list[gl_edge_id];
-               cur_edge.neighbouring_cubes[cur_cell_edge_list_posn[gl_edge_id]]=cur_cell_id;
+               cur_edge.neighbouring_cubes[cur_cell_edge_list_posn[gl_edge_id]] = cur_cell_id;
                cur_cell_edge_list_posn[gl_edge_id]++;
              }
          }
@@ -741,88 +740,96 @@ namespace internal
       }
     }
 
-                                    // Deal Element Information
-    static const int DealEdgeToNodeArray[8][3] = 
-    { 
-         {0,4,8},
-         {0,5,9},
-         {3,5,10},
-         {3,4,11},
-         {1,7,8},
-         {1,6,9},
-         {2,6,10},
-         {2,7,11}
-    };
-
-    static const int DealEdgeOrientArray[8][3] =
-    {
-         { 1, 1, 1},
-         {-1, 1, 1},
-         {-1,-1, 1},
-         { 1,-1, 1},
-         { 1, 1,-1},
-         {-1, 1,-1},
-         {-1,-1,-1}, 
-         { 1,-1,-1}
-    };
 
-    static const int DealNodesOnEdgeArray[12][2] =
-    {
-         {0,1},
-         {4,5},
-         {7,6},
-         {3,2},
-         {0,3},
-         {1,2},
-         {5,6},
-         {4,7},
-         {0,4},
-         {1,5},
-         {2,6},
-         {3,7}
-    };
 
-                                    // Starting at emination node
-                                    // (for edges) and chosing
-                                    // clockwise order
- // TODO: HERE
-    static const int DealFaceNodeArray[6][4] =
+    ElementInfo::ElementInfo()
     {
-         {0,1,2,3},
-         {0,4,5,1},
-         {1,5,6,2},
-         {3,2,6,7},
-         {0,3,7,4},
-         {4,7,6,5}
-    };
-
+      for (int node = 0; node<8; ++node)
+       for (int i = 0; i<3; ++i)
+         {
+           static const int deal_edge_to_node[8][3] = 
+             { 
+                   {0,4,8},
+                   {0,5,9},
+                   {3,5,10},
+                   {3,4,11},
+                   {1,7,8},
+                   {1,6,9},
+                   {2,6,10},
+                   {2,7,11}
+             };
+           edge_to_node[node][i] = deal_edge_to_node[node][i];
+
+           static const int deal_edge_orient_array[8][3] = 
+             {
+                   { 1, 1, 1},
+                   {-1, 1, 1},
+                   {-1,-1, 1},
+                   { 1,-1, 1},
+                   { 1, 1,-1},
+                   {-1, 1,-1},
+                   {-1,-1,-1}, 
+                   { 1,-1,-1}
+             };            
+           edge_to_node_orient[node][i] = deal_edge_orient_array[node][i];
+         }
 
-    
-    DealElemInfo::DealElemInfo() : ElementInfo()
-    {
-      for(int node=0; node<8; ++node)
+      for (int edge = 0;edge<12; ++edge)
        {
-         for(int i=0;i<3;++i)
+         static const int deal_nodes_on_edge_array[12][2] = 
            {
-             edge_to_node[node][i]=DealEdgeToNodeArray[node][i];
-             edge_to_node_orient[node][i]=DealEdgeOrientArray[node][i];
-           }
+                 {0,1},
+                 {4,5},
+                 {7,6},
+                 {3,2},
+                 {0,3},
+                 {1,2},
+                 {5,6},
+                 {4,7},
+                 {0,4},
+                 {1,5},
+                 {2,6},
+                 {3,7}
+           };    
+         nodes_on_edge[edge][0] = deal_nodes_on_edge_array[edge][0];
+         nodes_on_edge[edge][1] = deal_nodes_on_edge_array[edge][1];
        }
 
-      for (int edge=0;edge<12; ++edge)
-       {
-         nodes_on_edge[edge][0]=DealNodesOnEdgeArray[edge][0];
-         nodes_on_edge[edge][1]=DealNodesOnEdgeArray[edge][1];
-       }
-
-      for(int facenum=0;facenum<6;++facenum)
-       for(int nodenum=0;nodenum<4;++nodenum)
-         nodes_on_face[facenum][nodenum]=DealFaceNodeArray[facenum][nodenum];
+      for (int facenum = 0;facenum<6;++facenum)
+       for (int nodenum = 0;nodenum<4;++nodenum)
+         {
+                                            // Starting at emination node
+                                            // (for edges) and chosing
+                                            // clockwise order
+// TODO: HERE
+           static const int deal_face_node_array[6][4] = 
+             {
+                   {0,1,2,3},
+                   {0,4,5,1},
+                   {1,5,6,2},
+                   {3,2,6,7},
+                   {0,3,7,4},
+                   {4,7,6,5}
+             };
+    
+           nodes_on_face[facenum][nodenum] = deal_face_node_array[facenum][nodenum];
+         }
     }
 
 
-
+    
+    Edge::Edge (int n0,
+               int n1,
+               int orient)
+                   :
+                   orientation_flag(orient),
+                   group(0),
+                   num_neighbouring_cubes(0),
+                   neighbouring_cubes(NULL)
+    {
+      nodes[0] = n0;
+      nodes[1] = n1;
+    }
 
 
 
@@ -832,24 +839,58 @@ namespace internal
     }
 
 
+
+    Cell::Cell (const Cell &c)
+    {
+      for (unsigned int i = 0; i<GeometryInfo<3>::lines_per_cell; ++i)
+       {
+         edges[i] = c.edges[i];
+         local_orientation_flags[i] = c.local_orientation_flags[i];
+       }
+      
+      for (unsigned int i = 0; i<GeometryInfo<3>::vertices_per_cell; ++i)
+       nodes[i] = c.nodes[i];
+      
+      waiting_to_be_processed = c.waiting_to_be_processed;
+    }
+
+
+    
+    Cell::Cell () 
+    {
+      for (unsigned int i = 0; i<GeometryInfo<3>::lines_per_cell; ++i)
+       {
+         edges[i] = -1;
+         local_orientation_flags[i] = 1;
+       }
+      
+      for (unsigned int i = 0; i<GeometryInfo<3>::vertices_per_cell; ++i)
+       nodes[i] = -1;
+      
+      waiting_to_be_processed = false;
+    }
+
+
     
     bool Mesh::sanity_check() const
     {
-      bool retval=true;
-      for(unsigned int i=0; i<cell_list.size(); ++i)
-       retval&=sanity_check(i);
+      bool retval = true;
+      for (unsigned int i = 0; i<cell_list.size(); ++i)
+       retval &= sanity_check(i);
       return retval;
     }
 
+
+    
     bool Mesh::sanity_check(int cellnum) const
     {
                                       // Should check that every edge
                                       // coming into a node has the
                                       // same node value
-      bool retval=true;
-      for(int i=0;i<8;++i)
+      bool retval = true;
+      for (int i = 0;i<8;++i)
        {
-         retval&=sanity_check_node(cellnum,i);
+         retval &= sanity_check_node(cellnum,i);
        }
       return retval;
     }
@@ -877,9 +918,9 @@ namespace internal
                                       // What each edge thinks the
                                       // current node should be.
 
-      int curglobalnodenum0 = edge_list[ge0].nodes[or0==1 ? 0 : 1];
-      int curglobalnodenum1 = edge_list[ge1].nodes[or1==1 ? 0 : 1];
-      int curglobalnodenum2 = edge_list[ge2].nodes[or2==1 ? 0 : 1];
+      int curglobalnodenum0 = edge_list[ge0].nodes[or0 == 1 ? 0 : 1];
+      int curglobalnodenum1 = edge_list[ge1].nodes[or1 == 1 ? 0 : 1];
+      int curglobalnodenum2 = edge_list[ge2].nodes[or2 == 1 ? 0 : 1];
 
       const bool retval = ((curglobalnodenum0 == curglobalnodenum1)&&
                           (curglobalnodenum1 == curglobalnodenum2) );
@@ -890,6 +931,13 @@ namespace internal
     }    
 
 
+
+    Orienter::Orienter () 
+    {
+      for (unsigned int i = 0; i<12; ++i)
+       edge_orient_array[i] = false;
+    }
+
                                     /**
                                      * This assignes an orientation
                                      * to each edge so that every
@@ -905,38 +953,38 @@ namespace internal
 
                                       // We start by looking only at
                                       // the first cube.
-      cur_posn=0; 
-      marker_cube=0;
+      cur_posn = 0; 
+      marker_cube = 0;
 
                                       // We mark each edge with a
                                       // group number (mostly for
                                       // mesh debugging purposes)
-      cur_edge_group=1;
+      cur_edge_group = 1;
                                       // While there are still cubes
                                       // to orient
-      while(GetNextUnorientedCube(m))
+      while(get_next_unoriented_cube(m))
        {
                                           // And there are edges in
                                           // the cube to orient
-         while(OrientNextUnorientedEdge(m))
+         while(orient_next_unoriented_edge(m))
            {
                                               // Make all the sides
                                               // in the current set
                                               // match
-             OrientEdgesInCurrentCube(m);
+             orient_edges_in_current_cube(m);
                                               // Add the adjacent
                                               // cubes to the list
                                               // for processing
-             GetAdjacentCubes(m);
+             get_adjacent_cubes(m);
                                               // Start working on
                                               // this list of cubes
-             while(GetNextActiveCube(m))
+             while(get_next_active_cube(m))
                {
                                                   // Make sure the
                                                   // Cube doesn't
                                                   // have a
                                                   // contradiction
-                 AssertThrow(Consistent(m,cur_posn),
+                 AssertThrow(consistent(m,cur_posn),
                              GridOrientError("Mesh is Unorientable"));
                                                   // If we needed to
                                                   // orient any edges
@@ -944,7 +992,8 @@ namespace internal
                                                   // cube then we may
                                                   // have to process
                                                   // the neighbour.
-                 if(OrientEdgesInCurrentCube(m)) GetAdjacentCubes(m);
+                 if (orient_edges_in_current_cube(m))
+                   get_adjacent_cubes(m);
                }
              cur_edge_group++;
            }
@@ -952,7 +1001,7 @@ namespace internal
       return true;
     }
 
-    bool Orienter::GetNextUnorientedCube(Mesh &m)
+    bool Orienter::get_next_unoriented_cube(Mesh &m)
     {
                                       // The last cube in the list
       unsigned int end_cube_num = m.cell_list.size();
@@ -962,7 +1011,7 @@ namespace internal
                                       // end.
       while( (marker_cube<end_cube_num)&&(is_oriented(m,marker_cube)) )
        marker_cube++;
-      cur_posn=marker_cube;
+      cur_posn = marker_cube;
                                       // Return true if we now point
                                       // at a valid cube.
       return cur_posn<end_cube_num;
@@ -971,15 +1020,17 @@ namespace internal
     bool Orienter::is_oriented(const Mesh &m, int cell_num)
     {
       const Cell& c = m.cell_list[cell_num];
-      for(int i = 0; i<12; ++i)
+      for (int i = 0; i<12; ++i)
        {
          int edgenum = c.edges[i];
-         if (m.edge_list[edgenum].orientation_flag==0) return false;
+         if (m.edge_list[edgenum].orientation_flag == 0) return false;
        }
       return true;
     }
 
-    bool Orienter::Consistent(Mesh &m, int cell_num)
+
+    
+    bool Orienter::consistent(Mesh &m, int cell_num)
     {
 
       const Cell& c = m.cell_list[cell_num];
@@ -987,16 +1038,16 @@ namespace internal
                                       // Checks that all oriented
                                       // edges in the group are
                                       // oriented consistently.
-      for(int group=0; group<3; ++group)
+      for (int group = 0; group<3; ++group)
        {
                                           // When a nonzero
                                           // orientation is first
                                           // encountered in the group
                                           // it is stored in this
-         int value=0;
+         int value = 0;
                                           // Loop over all parallel
                                           // edges
-         for(int i=4*group;i<4*(group+1);++i)
+         for (int i = 4*group;i<4*(group+1);++i)
            {
                                               // The local edge
                                               // orientation within
@@ -1005,15 +1056,15 @@ namespace internal
                        m.edge_list[c.edges[i]].orientation_flag; 
                                               // If the edge has
                                               // orientation
-             if (LOR!=0)
+             if (LOR != 0)
                {
                                                   // And we haven't
                                                   // seen an oriented
                                                   // edge before
-                 if (value==0) 
+                 if (value == 0) 
                                                     // Store it's
                                                     // value
-                   value=LOR;
+                   value = LOR;
                  else
                                                     // If we have
                                                     // seen a
@@ -1022,7 +1073,7 @@ namespace internal
                                                     // we'd better
                                                     // have the same
                                                     // orientation.
-                   if (value!=LOR)
+                   if (value != LOR)
                      return false;
                }
            }
@@ -1032,133 +1083,133 @@ namespace internal
 
 
     
-    bool Orienter::OrientNextUnorientedEdge(Mesh &m)
+    bool Orienter::orient_next_unoriented_edge(Mesh &m)
     {
-      cur_posn=marker_cube;
+      cur_posn = marker_cube;
       const Cell& c = m.cell_list[cur_posn];
-      int i=0;
+      int i = 0;
  
                                       // search for the unoriented
                                       // side
-      while((i<12)&&(m.edge_list[c.edges[i]].orientation_flag!=0))
+      while((i<12)&&(m.edge_list[c.edges[i]].orientation_flag != 0))
        ++i;
   
                                       // if we found none then return
                                       // false
-      if (i==12)
+      if (i == 12)
        return false;
   
                                       // Which edge group we're in.
-      int egrp=i/4;
+      int egrp = i/4;
 
                                       // A sanity check that none of
                                       // the other edges in the group
                                       // have been oriented yet Each
                                       // of the edges in the group
                                       // should be un-oriented
-      for(int j=egrp*4; j<egrp*4+4; ++j)
-       Assert(m.edge_list[c.edges[j]].orientation_flag==0,
-              GridOrientError("Tried to orient edge when other edges "
-                              "in group already oriented!"));
+      for (int j = egrp*4; j<egrp*4+4; ++j)
+       Assert (m.edge_list[c.edges[j]].orientation_flag == 0,
+               GridOrientError("Tried to orient edge when other edges "
+                               "in group already oriented!"));
 
                                       // Make the edge alignment
                                       // match that of the local
                                       // cube.
       m.edge_list[c.edges[i]].orientation_flag
        = c.local_orientation_flags[i];
-      m.edge_list[c.edges[i]].group=cur_edge_group;
+      m.edge_list[c.edges[i]].group = cur_edge_group;
 
-      edge_orient_array[i]=true;
+      edge_orient_array[i] = true;
 
       return true;
     }
 
 
     
-    bool Orienter::OrientEdgesInCurrentCube(Mesh &m)
+    bool Orienter::orient_edges_in_current_cube(Mesh &m)
     {
       bool retval = false;
-      for(int i=0;i<3;++i)
-       retval=retval||OrientEdgeSetInCurrentCube(m,i);
+      for (int i = 0; i<3; ++i)
+       retval = retval || orient_edge_set_in_current_cube(m,i);
       return retval;
     }
 
 
     
-    bool Orienter::OrientEdgeSetInCurrentCube(Mesh &m,int n)
+    bool Orienter::orient_edge_set_in_current_cube(Mesh &m,int n)
     {
       const Cell& c = m.cell_list[cur_posn];
   
                                       // Check if any edge is
                                       // oriented
-      int num_oriented =;
+      int num_oriented = 0;
       int glorient = 0;
       unsigned int edge_flags = 0;
       unsigned int cur_flag = 1;
-      for(int i = 4*n; i<4*(n+1); ++i)
+      for (int i = 4*n; i<4*(n+1); ++i)
        {
          int orient = m.edge_list[c.edges[i]].orientation_flag *
                       c.local_orientation_flags[i];
-         if (orient!=0)
+         if (orient != 0)
            {
              num_oriented++;
-             if (glorient==0)
+             if (glorient == 0)
                glorient = orient;
              else
-               AssertThrow(orient==glorient,
+               AssertThrow(orient == glorient,
                            GridOrientError("Attempted to Orient Misaligned cube"));
            }
          else
-           edge_flags|=cur_flag;
-         cur_flag*=2;
+           edge_flags |= cur_flag;
+         cur_flag *= 2;
        }
 
                                       // were any of the sides
                                       // oriented?  were they all
                                       // already oriented?
-      if ((glorient==0) || (num_oriented==4))
+      if ((glorient == 0) || (num_oriented == 4))
        return false;
 
                                       // If so orient all edges
                                       // consistently.
       cur_flag = 1;
-      for (int i=4*n; i<4*(n+1); ++i)
+      for (int i = 4*n; i<4*(n+1); ++i)
        {
-         if ((edge_flags&cur_flag)!=0)
+         if ((edge_flags&cur_flag) != 0)
            {
              m.edge_list[c.edges[i]].orientation_flag 
                = c.local_orientation_flags[i]*glorient;
-             m.edge_list[c.edges[i]].group=cur_edge_group;
-             edge_orient_array[i]=true;
+             m.edge_list[c.edges[i]].group = cur_edge_group;
+             edge_orient_array[i] = true;
            }
-         cur_flag*=2;
+         cur_flag *= 2;
        } 
       return true;
     }
 
 
     
-    void Orienter::GetAdjacentCubes(Mesh &m)
+    void Orienter::get_adjacent_cubes(Mesh &m)
     {
       const Cell& c = m.cell_list[cur_posn];
-      for(unsigned int e=0;e<12;++e)
+      for (unsigned int e = 0;e<12;++e)
        {
-         if(edge_orient_array[e])
+         if (edge_orient_array[e])
            {
-             edge_orient_array[e]=false;
+             edge_orient_array[e] = false;
              const unsigned int cur_local_edge_num = e;
 
-             Edge & the_edge=m.edge_list[c.edges[cur_local_edge_num]];
-             for(unsigned int local_cube_num = 0; 
-                 local_cube_num < the_edge.num_neighbouring_cubes; 
-                 ++local_cube_num)
+             Edge & the_edge = m.edge_list[c.edges[cur_local_edge_num]];
+             for (unsigned int local_cube_num = 0; 
+                  local_cube_num < the_edge.num_neighbouring_cubes; 
+                  ++local_cube_num)
                {
                  unsigned int global_cell_num = the_edge.neighbouring_cubes[local_cube_num];
-                 Cell& ncell=m.cell_list[global_cell_num];
+                 Cell& ncell = m.cell_list[global_cell_num];
                  if (!ncell.waiting_to_be_processed)
                    {
-                     SheetToProcess.push_back(global_cell_num);
-                     ncell.waiting_to_be_processed=true;
+                     sheet_to_process.push_back(global_cell_num);
+                     ncell.waiting_to_be_processed = true;
                    }
 
                }
@@ -1167,15 +1218,15 @@ namespace internal
        }
     }  
 
-    bool Orienter::GetNextActiveCube(Mesh &m)
+    bool Orienter::get_next_active_cube(Mesh &m)
     {
                                       // Mark the curent Cube as finnished with.
       Cell &c = m.cell_list[cur_posn];
-      c.waiting_to_be_processed=false;
-      if(SheetToProcess.size()!=0)
+      c.waiting_to_be_processed = false;
+      if (sheet_to_process.size() != 0)
        {
-         cur_posn=SheetToProcess.back();
-         SheetToProcess.pop_back();
+         cur_posn = sheet_to_process.back();
+         sheet_to_process.pop_back();
          return true;
        }
       return false;
@@ -1186,7 +1237,7 @@ namespace internal
     {
                                       // We assume that the mesh has
                                       // all edges oriented already.
-      const unsigned int numelems=the_mesh.cell_list.size();
+      const unsigned int numelems = the_mesh.cell_list.size();
   
                                       // This is a list of
                                       // permutations that take node
@@ -1214,7 +1265,7 @@ namespace internal
                                       // that should be the local
                                       // zero node has three edges
                                       // coming into it.
-      for(unsigned int i=0;i<numelems;++i)
+      for (unsigned int i = 0;i<numelems;++i)
        {
          Cell& the_cell = the_mesh.cell_list[i];
     
@@ -1226,25 +1277,25 @@ namespace internal
                                           // cube. (for each edge on
                                           // the curent cube)
          int local_edge_orientation[12];
-         for(unsigned int j=0;j<12;++j)
+         for (unsigned int j = 0;j<12;++j)
            {
                                               // get the global edge
              const Edge& the_edge = the_mesh.edge_list[the_cell.edges[j]];
                                               // All edges should be
                                               // oriented at this
                                               // stage..
-             Assert(the_edge.orientation_flag!=0,GridOrientError("Unoriented edge encountered"));
+             Assert (the_edge.orientation_flag != 0,GridOrientError("Unoriented edge encountered"));
                                               // calculate whether it
                                               // points the right way
                                               // (1) or not (-1)
-             local_edge_orientation[j]=(the_cell.local_orientation_flags[j]*the_edge.orientation_flag);
+             local_edge_orientation[j] = (the_cell.local_orientation_flags[j]*the_edge.orientation_flag);
            }
 
                                           // Here the number of
                                           // incoming edges is
                                           // tallied for each node.
-         int perm_num=-1;
-         for(int node_num=0;node_num<8;++node_num)
+         int perm_num = -1;
+         for (int node_num = 0;node_num<8;++node_num)
            {
                                               // The local edge
                                               // numbers coming into
@@ -1264,30 +1315,30 @@ namespace internal
                                               // Add one to the total
                                               // for each edge
                                               // pointing in
-             int Total  = ((local_edge_orientation[iedg0]*isign0==1)?1:0)
-                          + ((local_edge_orientation[iedg1]*isign1==1)?1:0)
-                          + ((local_edge_orientation[iedg2]*isign2==1)?1:0);
+             int Total  = ((local_edge_orientation[iedg0]*isign0 == 1)?1:0)
+                          + ((local_edge_orientation[iedg1]*isign1 == 1)?1:0)
+                          + ((local_edge_orientation[iedg2]*isign2 == 1)?1:0);
       
-             if (Total==3) 
+             if (Total == 3) 
                {
-                 Assert(perm_num==-1,
-                        GridOrientError("More than one node with 3 incoming "
-                                        "edges found in curent hex.")); 
-                 perm_num=node_num;
+                 Assert (perm_num == -1,
+                         GridOrientError("More than one node with 3 incoming "
+                                         "edges found in curent hex.")); 
+                 perm_num = node_num;
                }
            }
                                           // We should now have a
                                           // valid permutation number
-         Assert(perm_num!=-1,
-                GridOrientError("No node having 3 incoming edges found in curent hex.")); 
+         Assert (perm_num != -1,
+                 GridOrientError("No node having 3 incoming edges found in curent hex.")); 
 
                                           // So use the apropriate
                                           // rotation to get the new
                                           // cube
          int temp[8];
-         for(int i=0;i<8;++i)
+         for (unsigned int i=0; i<8; ++i)
            temp[i] = the_cell.nodes[CubePermutations[perm_num][i]];
-         for(int i=0;i<8;++i)
+         for (unsigned int i=0; i<8; ++i)
            the_cell.nodes[i] = temp[i];
        }
     }
@@ -1296,12 +1347,12 @@ namespace internal
 
 
 
-void GridReordering<3>::reorder_cells(std::vector<CellData<3> >incubes,
-                                     std::vector<Point<3> > node_vec_ptr)
+void GridReordering<3>::reorder_cells(std::vector<CellData<3> > &incubes,
+                                     std::vector<Point<3> >    *node_vec_ptr)
 {
 
-  Assert(incubes.size()!=0,
-        ExcMessage("List of elements to orient was of zero length"));
+  Assert (incubes.size() != 0,
+         ExcMessage("List of elements to orient was of zero length"));
   
                                   // This keeps track of all the
                                   // local element conectivity
@@ -1319,21 +1370,18 @@ void GridReordering<3>::reorder_cells(std::vector<CellData<3> >& incubes,
                                   // empty.
   internal::GridReordering3d::Mesh the_mesh(deal_info);
 
-  if(node_vec_ptr!=NULL)
-    {
-      the_mesh.node_list=*node_vec_ptr;
-    }
+  if (node_vec_ptr != NULL)
+    the_mesh.node_list = *node_vec_ptr;
   
                                   // Copy the cells into our own
                                   // internal data format.
-  const unsigned int numelems=incubes.size();
-  for(unsigned int i =0 ; i<numelems; ++i)
+  const unsigned int numelems = incubes.size();
+  for (unsigned int i=0; i<numelems; ++i)
     {
       internal::GridReordering3d::Cell the_cell;
-      for(unsigned int j=0;j<8;j++)
-       {
-         the_cell.nodes[j]=incubes[i].vertices[j];
-       }
+      for (unsigned int j=0; j<8; j++)
+       the_cell.nodes[j] = incubes[i].vertices[j];
+       
       the_mesh.cell_list.push_back(the_cell);
     }
   
@@ -1355,14 +1403,9 @@ void GridReordering<3>::reorder_cells(std::vector<CellData<3> >& incubes,
                                   // Copy the elements from our
                                   // internal structure back into
                                   // their original location.
-  for(unsigned int i =0 ; i<numelems; ++i)
-    {
-      internal::GridReordering3d::Cell& the_cell = the_mesh.cell_list[i];
-      for(unsigned int j=0;j<8;j++)
-       {
-         incubes[i].vertices[j]=the_cell.nodes[j];
-       }
-    }
+  for (unsigned int i=0; i<numelems; ++i)
+    for (unsigned int j=0; j<8; j++)
+      incubes[i].vertices[j] = the_mesh.cell_list[i].nodes[j];
 }
 
 

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.