]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Clean up comments.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 23 Oct 2003 19:30:55 +0000 (19:30 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 23 Oct 2003 19:30:55 +0000 (19:30 +0000)
git-svn-id: https://svn.dealii.org/trunk@8147 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/source/grid/grid_reordering.cc

index 64f3ab8eb61ae1f038e52a266c0343a2b7e312d9..adaffa56e6027bb95f7002d57cd5570bfdec5935 100644 (file)
@@ -1,13 +1,13 @@
 //----------------------------  grid_reordering.cc  ---------------------------
-//    grid_reordering.cc,v 1.27 2002/05/28 07:43:22 wolf Exp
-//    Version: 
+//   grid_reordering.cc,v 1.27 2002/05/28 07:43:22 wolf Exp
+//   Version: 
 //
-//    Copyright (C) 2000, 2001, 2002, 2003 by the deal.II authors
+//   Copyright (C) 2000, 2001, 2002, 2003 by the deal.II authors
 //
-//    This file is subject to QPL and may not be  distributed
-//    without copyright and license information. Please refer
-//    to the file deal.II/doc/license.html for the  text  and
-//    further information on this license.
+//   This file is subject to QPL and may not be  distributed
+//   without copyright and license information. Please refer
+//   to the file deal.II/doc/license.html for the  text  and
+//   further information on this license.
 //
 //----------------------------  grid_reordering.cc  ---------------------------
 
@@ -247,8 +247,8 @@ namespace internal
     
     
     struct MQuad::MakeQuad : public std::binary_function<CellData<2>,
-                                                        std::vector<MSide>,
-                                                        MQuad>
+                 std::vector<MSide>,
+                 MQuad>
     {
        MQuad operator()(const CellData<2> &q,
                         const std::vector<MSide> &elist) const
@@ -583,33 +583,32 @@ namespace internal
                    <<  "Grid Orientation Error: " << arg1);
 
 
-    //Switched two ints so that v1<v2;
-    inline void sort2(int &v1, int &v2)
+                                    // sort two integers
+    static inline void sort2 (int &v1, int &v2)
     {
-      if(v1>v2)
-       {
-         int t=v1;
-         v1=v2;
-         v2=t;
-       }
+      if (v1>v2)
+       std::swap (v1, v2);
     }
 
+    
     CheapEdge::CheapEdge(int n0, int n1) : node0(n0), node1(n1)
     {
-      //sort the entries so that node0<node1;
+                                      // sort the entries so that
+                                      // node0<node1;
       sort2(node0,node1);
     }
 
+    
     bool CheapEdge::operator<(const CheapEdge & e2) const
     {
-      if ((node0)<(e2.node0)) return true;
-      if ((node0)>(e2.node0)) return false;
-      if ((node1)<(e2.node1)) return true;
+      if (node0 < e2.node0) return true;
+      if (node0 > e2.node0) return false;
+      if (node1 < e2.node1) return true;
       return false;
     }
 
   
-    // This is the guts of the matter...
+                                    // This is the guts of the matter...
     void build_mesh(Mesh &m)
     {
       const ElementInfo &info = m.info; 
@@ -620,57 +619,74 @@ namespace internal
 
 
       unsigned int NumEdges=0;
-      // Corectly build the edge list
+                                      // Correctly build the edge
+                                      // list
       {
-       // edge_map stores the edge_number associated with a given CheapEdge
+                                        // edge_map stores the
+                                        // 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)
          {
-           //Get the local node numbers on edge edge_num
+                                            // Get the local node
+                                            // numbers on edge
+                                            // edge_num
            Cell & cur_cell = cell_list[cur_cell_id];
-           //m.DumpCell(cur_cell);
+                                            // m.DumpCell(cur_cell);
            for(unsigned short int edge_num=0; 
                edge_num<12; 
                ++edge_num)
              {
                unsigned int gl_edge_num=0;
                int l_edge_orient=1;
-               //Construct the CheapEdge
+                                                // 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]];
                CheapEdge cur_edge(node0,node1);
                if(edge_map.count(cur_edge)==0) // Edge not in map
                  {
-                   // put edge in hash map with ctr value;
+                                                    // put edge in
+                                                    // hash map with
+                                                    // ctr value;
                    edge_map[cur_edge]=ctr;
                    gl_edge_num=ctr;
-                   edge_list.push_back(Edge(node0,node1)); //put the edge into the global edge list.
+
+                                                    // put the edge
+                                                    // into the
+                                                    // global edge
+                                                    // list
+                   edge_list.push_back(Edge(node0,node1));
                    ctr++;
                  }
                else
                  {
-                   gl_edge_num=edge_map[cur_edge]; // get edge_num from hash_map;
+                                                    // 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;
                      }
                  }
-               cell_list[cur_cell_id].edges[edge_num]=gl_edge_num; // set edge number to edgenum;
+                                                // 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;
              }
          }
        NumEdges=ctr;
       }
 
-      //Count each of the edges.
+                                      // Count each of the edges.
       {
        std::vector<int> edge_count(NumEdges,0);
       
 
-       //Count every time an edge occurs in a cube.
+                                        // 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)
@@ -684,10 +700,14 @@ namespace internal
              } 
          }
 
-       // So we now know howmany cubes contain a given edge.
-       // Just need to store the list of cubes in the edge
+                                        // So we now know howmany
+                                        // cubes contain a given
+                                        // edge.  Just need to store
+                                        // the list of cubes in the
+                                        // edge
 
-       //Alocate the space for the neighbour list
+                                        // Allocate the space for the
+                                        // neighbour list
        for(unsigned int cur_edge_id = 0;
            cur_edge_id<NumEdges;
            ++cur_edge_id)
@@ -698,7 +718,9 @@ namespace internal
            cur_edge.neighbouring_cubes = new unsigned int [NN];
          }
       
-       //Stores the position of the current neighbour in the edge's neighbour list
+                                        // Stores the position of the
+                                        // 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;
@@ -719,58 +741,63 @@ namespace internal
       }
     }
 
-    // Deal Element Information
-    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}
-      };
+                                    // 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}
+    };
 
-    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 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}
+    };
 
-    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}
-      };
+    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
-    const int DealFaceNodeArray[6][4] = //TODO: HERE
-      {
-       {0,1,2,3},
-       {0,4,5,1},
-       {1,5,6,2},
-       {3,2,6,7},
-       {0,3,7,4},
-       {4,7,6,5}
-      };
+                                    // Starting at emination node
+                                    // (for edges) and chosing
+                                    // clockwise order
+ // TODO: HERE
+    static const int DealFaceNodeArray[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}
+    };
 
+
+    
     DealElemInfo::DealElemInfo() : ElementInfo()
     {
       for(int node=0; node<8; ++node)
@@ -804,6 +831,8 @@ namespace internal
       delete [] neighbouring_cubes;
     }
 
+
+    
     bool Mesh::sanity_check() const
     {
       bool retval=true;
@@ -814,8 +843,9 @@ namespace internal
 
     bool Mesh::sanity_check(int cellnum) const
     {
-      //Should check that every edge coming into a node has the 
-      //same node value
+                                      // Should check that every edge
+                                      // coming into a node has the
+                                      // same node value
       bool retval=true;
       for(int i=0;i<8;++i)
        {
@@ -826,12 +856,13 @@ namespace internal
 
     bool Mesh::sanity_check_node(int cell_num, int local_node_num) const
     {
-      // Get the Local Node Numbers of the incoming edges
+                                      // Get the Local Node Numbers
+                                      // of the incoming edges
       int e0 = info.edge_to_node[local_node_num][0];
       int e1 = info.edge_to_node[local_node_num][1]; 
       int e2 = info.edge_to_node[local_node_num][2];
 
-      // Global Edge Numbers
+                                      // Global Edge Numbers
       const Cell& c = cell_list[cell_num];
   
       int ge0 = c.edges[e0];
@@ -839,25 +870,26 @@ namespace internal
       int ge2 = c.edges[e2];
 
 
-      //  std::cout<<"Coming Into Node "<<node_num<< " are the local edges : "
-      //    <<e0<<" "<<e1<<" "<<e2<<std::endl;
+//  std::cout<<"Coming Into Node "<<node_num<< " are the local edges : "
+//    <<e0<<" "<<e1<<" "<<e2<<std::endl;
 
       int or0 = info.edge_to_node_orient[local_node_num][0]*c.local_orientation_flags[e0];
       int or1 = info.edge_to_node_orient[local_node_num][1]*c.local_orientation_flags[e1];
       int or2 = info.edge_to_node_orient[local_node_num][2]*c.local_orientation_flags[e2];
 
-      //  std::cout<<"They have orientations : "<<or0<<" "<<or1<<" "<<or2<<std::endl;
+//  std::cout<<"They have orientations : "<<or0<<" "<<or1<<" "<<or2<<std::endl;
 
-      //What each edge thinks the current node should be.
+                                      // 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];
 
-      //  std::cout<<"This means the current node is "
-      //    <<curglobalnodenum0 <<" "
-      //    <<curglobalnodenum1 <<" "
-      //    <<curglobalnodenum2 <<std::endl; 
+//  std::cout<<"This means the current node is "
+//    <<curglobalnodenum0 <<" "
+//    <<curglobalnodenum1 <<" "
+//    <<curglobalnodenum2 <<std::endl; 
 
       bool retval = ((curglobalnodenum0 == curglobalnodenum1)&&
                     (curglobalnodenum1 == curglobalnodenum2) );
@@ -865,7 +897,7 @@ namespace internal
 
       if (!retval)
        {
-         std::cout<<"FAILED SANITY TEST";
+         std::cout << "FAILED SANITY TEST";
          dump_cell(c);
        }
       Assert (retval == true, ExcInternalError());
@@ -873,6 +905,8 @@ namespace internal
       return retval;
     }
 
+
+    
     void Mesh::dump_cell(const Cell &c) const
     {
       std::cout<<std::endl
@@ -926,13 +960,16 @@ namespace internal
            std::cout<<"\t\t"<<c.edges[j]<<" "<<c.local_orientation_flags[j]<<std::endl;
        }
     }
-       
+
+
+    
     void Mesh::dump_edges(char const * const fname) const
     {
       const int nedges = edge_list.size();
       const int npoints = node_list.size();
  
-      //Only do this if we've have the extra information
+                                      // Only do this if we've have
+                                      // the extra information
       if (npoints==0) 
        return;
   
@@ -955,44 +992,61 @@ namespace internal
     }
 
 
-    /**
-     * This assignes an orientation to each edge so that 
-     * every cube is a rotated Deal.II cube.
-     */
+                                    /**
+                                     * This assignes an orientation to each edge so that 
+                                     * every cube is a rotated Deal.II cube.
+                                     */
     bool Orienter::orient_edges(Mesh &m)
     {
   
-      // First check that the mesh is sensible
+                                      // First check that the mesh is
+                                      // sensible
       AssertThrow(m.sanity_check(),GridOrientError("Invalid Mesh Detected"));
 
-      // We start by looking only at the first cube.  
+                                      // We start by looking only at
+                                      // the first cube.
       cur_posn=0; 
       marker_cube=0;
 
-      // We mark each edge with a group number 
-      // (mostly for mesh debugging purposes)
+                                      // We mark each edge with a
+                                      // group number (mostly for
+                                      // mesh debugging purposes)
       cur_edge_group=1;
-      // While there are still cubes to orient
+                                      // While there are still cubes
+                                      // to orient
       while(GetNextUnorientedCube(m))
        {
-         // And there are edges in the cube to orient
+                                          // And there are edges in
+                                          // the cube to orient
          while(OrientNextUnorientedEdge(m))
            {
-             // Make all the sides in the current set match
+                                              // Make all the sides
+                                              // in the current set
+                                              // match
              OrientEdgesInCurrentCube(m);
-             // Add the adjacent cubes to the list for processing
+                                              // Add the adjacent
+                                              // cubes to the list
+                                              // for processing
              GetAdjacentCubes(m);
-             // Start working on this list of cubes
+                                              // Start working on
+                                              // this list of cubes
              while(GetNextActiveCube(m))
                {
-                 // Make sure the Cube doesn't have a contradiction 
+                                                  // Make sure the
+                                                  // Cube doesn't
+                                                  // have a
+                                                  // contradiction
                  if(!Consistant(m,cur_posn))
                    {
                      m.dump_edges("edgelist.dat");
                    }
                  AssertThrow(Consistant(m,cur_posn),GridOrientError("Mesh is Unorientable"));
-                 // If we needed to orient any edges in the current cube
-                 // then we may have to process the neighbour.
+                                                  // If we needed to
+                                                  // orient any edges
+                                                  // in the current
+                                                  // cube then we may
+                                                  // have to process
+                                                  // the neighbour.
                  if(OrientEdgesInCurrentCube(m)) GetAdjacentCubes(m);
                }
              cur_edge_group++;
@@ -1003,14 +1057,17 @@ namespace internal
 
     bool Orienter::GetNextUnorientedCube(Mesh &m)
     {
-      // The last cube in the list
+                                      // The last cube in the list
       unsigned int end_cube_num = m.cell_list.size();
-      // Keep shifting along the list until we find a cube which is not
-      // fully oriented or the end.
+                                      // Keep shifting along the list
+                                      // until we find a cube which
+                                      // is not fully oriented or the
+                                      // end.
       while( (marker_cube<end_cube_num)&&(is_oriented(m,marker_cube)) )
        marker_cube++;
       cur_posn=marker_cube;
-      //Return true if we now point at a valid cube.
+                                      // Return true if we now point
+                                      // at a valid cube.
       return cur_posn<end_cube_num;
     }
 
@@ -1030,65 +1087,86 @@ namespace internal
 
       const Cell& c = m.cell_list[cell_num];
   
-      //Checks that all oriented edges in the group are oriented consistantly.  
+                                      // Checks that all oriented
+                                      // edges in the group are
+                                      // oriented consistantly.
       for(int group=0; group<3; ++group)
        {
-         // When a nonzero orientation is first encoutered in the group it is 
-         // stored in this
+                                          // When a nonzero
+                                          // orientation is first
+                                          // encoutered in the group
+                                          // it is stored in this
          int value=0;
-         //Loop over all parallel edges
+                                          // Loop over all parallel
+                                          // edges
          for(int i=4*group;i<4*(group+1);++i)
            {
-             //The local edge orientation within the cell
+                                              // The local edge
+                                              // orientation within
+                                              // the cell
              int LOR = c.local_orientation_flags[i] *
-               m.edge_list[c.edges[i]].orientation_flag; 
-             //If the edge has orientation
+                       m.edge_list[c.edges[i]].orientation_flag; 
+                                              // If the edge has
+                                              // orientation
              if (LOR!=0)
                {
-                 //And we haven't seen an oriented edge before
+                                                  // And we haven't
+                                                  // seen an oriented
+                                                  // edge before
                  if (value==0) 
-                   {
-                     //Store it's value
-                     value=LOR;
-                   }
+                                                    // Store it's
+                                                    // value
+                   value=LOR;
                  else
-                   {
-                     //If we have seen a oriented edge in this group
-                     //we'd better have the same orientation.
-                     if (value!=LOR) return false;
-                   }
+                                                    // If we have
+                                                    // seen a
+                                                    // oriented edge
+                                                    // in this group
+                                                    // we'd better
+                                                    // have the same
+                                                    // orientation.
+                   if (value!=LOR)
+                     return false;
                }
            }
        }
       return true;
     }
 
+
+    
     bool Orienter::OrientNextUnorientedEdge(Mesh &m)
     {
       cur_posn=marker_cube;
       const Cell& c = m.cell_list[cur_posn];
       int i=0;
  
-      // search for the unoriented side
+                                      // search for the unoriented
+                                      // side
       while((i<12)&&(m.edge_list[c.edges[i]].orientation_flag!=0))
        ++i;
   
-      //if we found none then return false
+                                      // if we found none then return
+                                      // false
       if (i==12)
        return false;
   
-      //Which edge group we're in.
+                                      // Which edge group we're in.
       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!"));
-       }
-
-      //Make the edge alignment match that of the local cube.
+                                      // 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!"));
+
+                                      // 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;
@@ -1098,6 +1176,8 @@ namespace internal
       return true;
     }
 
+
+    
     bool Orienter::OrientEdgesInCurrentCube(Mesh &m)
     {
       bool retval = false;
@@ -1106,11 +1186,14 @@ namespace internal
       return retval;
     }
 
+
+    
     bool Orienter::OrientEdgeSetInCurrentCube(Mesh &m,int n)
     {
       const Cell& c = m.cell_list[cur_posn];
   
-      //Check if Any edge is oriented
+                                      // Check if any edge is
+                                      // oriented
       int num_oriented =0 ;
       int glorient = 0;
       unsigned int edge_flags = 0;
@@ -1118,36 +1201,33 @@ namespace internal
       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];
+                      c.local_orientation_flags[i];
          if (orient!=0)
            {
              num_oriented++;
-             if (glorient!=0)
-               {
-                 AssertThrow(orient==glorient,GridOrientError("Attempted to Orient Misaligned cube"));
-               }
+             if (glorient==0)
+               glorient = orient;
              else
-               {
-                 glorient=orient;
-               }
+               AssertThrow(orient==glorient,
+                           GridOrientError("Attempted to Orient Misaligned cube"));
            }
          else
-           {
-             edge_flags|=cur_flag;
-           }
+           edge_flags|=cur_flag;
          cur_flag*=2;
        }
 
-      //were any of the sides oriented?
-      //were they all already oriented?
-      if ((glorient==0)||(num_oriented==4))
+                                      // were any of the sides
+                                      // oriented?  were they all
+                                      // already oriented?
+      if ((glorient==0) || (num_oriented==4))
        return false;
 
-      //If so orient all edges consistantly.
+                                      // If so orient all edges
+                                      // consistantly.
       cur_flag = 1;
       for(int i=4*n; i<4*(n+1); ++i)
        {
-         //std::cout<<i<<" ORIENTING\n";
+// std::cout<<i<<" ORIENTING\n";
          if ((edge_flags&cur_flag)!=0)
            {
              m.edge_list[c.edges[i]].orientation_flag 
@@ -1160,6 +1240,8 @@ namespace internal
       return true;
     }
 
+
+    
     void Orienter::GetAdjacentCubes(Mesh &m)
     {
       const Cell& c = m.cell_list[cur_posn];
@@ -1191,7 +1273,7 @@ namespace internal
 
     bool Orienter::GetNextActiveCube(Mesh &m)
     {
-      //Mark the curent Cube as finnished with.
+                                      // Mark the curent Cube as finnished with.
       Cell &c = m.cell_list[cur_posn];
       c.waiting_to_be_processed=false;
       if(SheetToProcess.size()!=0)
@@ -1203,6 +1285,8 @@ namespace internal
       return false;
     }
 
+
+    
     bool Orienter::CheckCellEdgeGroupConsistancy(const Mesh &m, const Cell & c, int egrp) const
     {
       int grp=0;
@@ -1212,13 +1296,9 @@ namespace internal
          if (cgrp!=0)
            {
              if(grp==0)
-               {
-                 grp=cgrp;
-               }
+               grp=cgrp;
              else if (grp!=cgrp)
-               {
-                 return false;
-               }
+               return false;
            }
        }
       return true;
@@ -1227,96 +1307,122 @@ namespace internal
     
     bool Orienter::CheckCellEdgeGroupConsistancy(const Mesh &m, const Cell &c) const
     {
-      return ( 
-             CheckCellEdgeGroupConsistancy(m,c,0) &&
+      return (CheckCellEdgeGroupConsistancy(m,c,0) &&
              CheckCellEdgeGroupConsistancy(m,c,1) &&
-             CheckCellEdgeGroupConsistancy(m,c,2)
-             );
+             CheckCellEdgeGroupConsistancy(m,c,2));
     }
 
+
+    
     void Orienter::orient_cubes(Mesh & the_mesh)
     {
-      // We assume that the mesh has all edges oriented already.
-  
+                                      // We assume that the mesh has
+                                      // all edges oriented already.
       const unsigned int numelems=the_mesh.cell_list.size();
   
-      // This is a list of permutations that take node 0 to node i
-      // but only rotate the cube. 
-      // (This set is far from unique (there are 3 for each node - for our
-      // algorithm it doesn't matter which of the three we use)
-      const unsigned int CubePermutations[8][8] = {
-       {0,1,2,3,4,5,6,7},
-       {1,2,3,0,5,6,7,4},
-       {2,3,0,1,6,7,4,5},
-       {3,0,1,2,7,4,5,6},
-       {4,7,6,5,0,3,2,1},
-       {5,4,7,6,1,0,3,2},
-       {6,5,4,7,2,1,0,3},
-       {7,6,5,4,3,2,1,0}
+                                      // This is a list of
+                                      // permutations that take node
+                                      // 0 to node i but only rotate
+                                      // the cube.  (This set is far
+                                      // from unique (there are 3 for
+                                      // each node - for our
+                                      // algorithm it doesn't matter
+                                      // which of the three we use)
+      static const unsigned int CubePermutations[8][8] = {
+           {0,1,2,3,4,5,6,7},
+           {1,2,3,0,5,6,7,4},
+           {2,3,0,1,6,7,4,5},
+           {3,0,1,2,7,4,5,6},
+           {4,7,6,5,0,3,2,1},
+           {5,4,7,6,1,0,3,2},
+           {6,5,4,7,2,1,0,3},
+           {7,6,5,4,3,2,1,0}
       };
   
-      // So now we need to work out which node needs to be mapped to the 
-      // zero node. 
-      // The trick is that the node that should be the local zero node has
-      // three edges coming into it.
+                                      // So now we need to work out
+                                      // which node needs to be
+                                      // mapped to the zero node.
+                                      // The trick is that the node
+                                      // that should be the local
+                                      // zero node has three edges
+                                      // coming into it.
       for(unsigned int i=0;i<numelems;++i)
        {
          Cell& the_cell = the_mesh.cell_list[i];
     
-         // This stores whether the global oriented edge points in the same
-         // direction as it's local edge on the current cube. (for each edge on
-         // the curent cube)
+                                          // This stores whether the
+                                          // global oriented edge
+                                          // points in the same
+                                          // direction as it's local
+                                          // edge on the current
+                                          // cube. (for each edge on
+                                          // the curent cube)
          int local_edge_orientation[12];
          for(unsigned int j=0;j<12;++j)
            {
-             // get the global edge
+                                              // get the global edge
              const Edge& the_edge = the_mesh.edge_list[the_cell.edges[j]];
-             // All edges should be oriented at this stage..
+                                              // All edges should be
+                                              // oriented at this
+                                              // stage..
              Assert(the_edge.orientation_flag!=0,GridOrientError("Unoriented edge encountered"));
-             // calculate whether it points the right way (1) or not (-1)
+                                              // 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);
            }
 
-         // Here the number of incoming edges is tallied for each node.
+                                          // 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)
            {
-             //The local edge numbers coming into the node
+                                              // The local edge
+                                              // numbers coming into
+                                              // the node
              int iedg0 = the_mesh.info.edge_to_node[node_num][0];
              int iedg1 = the_mesh.info.edge_to_node[node_num][1];
              int iedg2 = the_mesh.info.edge_to_node[node_num][2];
 
-             //The local orientation of the edge coming into the node.
+                                              // The local
+                                              // orientation of the
+                                              // edge coming into the
+                                              // node.
              int isign0 = the_mesh.info.edge_to_node_orient[node_num][0];
              int isign1 = the_mesh.info.edge_to_node_orient[node_num][1];
              int isign2 = the_mesh.info.edge_to_node_orient[node_num][2];
 
-             //Add one to the total for each edge pointing in 
+                                              // 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);
+                          + ((local_edge_orientation[iedg1]*isign1==1)?1:0)
+                          + ((local_edge_orientation[iedg2]*isign2==1)?1:0);
       
-             //      std::cout<<"TOTAL : "<<Total<<std::endl;
+//      std::cout<<"TOTAL : "<<Total<<std::endl;
       
              if (Total==3) 
                {
-                 Assert(perm_num==-1, GridOrientError("More than one node with 3 incoming edges found in curent hex.")); 
+                 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.")); 
-
-         // So use the apropriate rotation to get the new cube
+                                          // We should now have a
+                                          // valid permutation number
+         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)
-           {
-             temp[i]=the_cell.nodes[CubePermutations[perm_num][i]];
-           }
+           temp[i] = the_cell.nodes[CubePermutations[perm_num][i]];
          for(int i=0;i<8;++i)
-           {
-             the_cell.nodes[i]=temp[i];
-           }
+           the_cell.nodes[i] = temp[i];
        }
     }
   }
@@ -1324,21 +1430,27 @@ 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"));
   
-  // This keeps track of all the local element conectivity information.
-  // e.g. what edges come into which nodes and with which orientation
+                                  // This keeps track of all the
+                                  // local element conectivity
+                                  // information.  e.g. what edges
+                                  // come into which nodes and with
+                                  // which orientation
   internal::GridReordering3d::DealElemInfo deal_info; 
   
-  //This does the real work
+                                  // This does the real work
   internal::GridReordering3d::Orienter orienter;
 
-  // This is the internal store for all global connectivity information
-  // it starts prety much empty.
+                                  // This is the internal store for
+                                  // all global connectivity
+                                  // information it starts prety much
+                                  // empty.
   internal::GridReordering3d::Mesh the_mesh(deal_info);
 
   if(node_vec_ptr!=NULL)
@@ -1346,7 +1458,8 @@ void GridReordering<3>::reorder_cells(std::vector<CellData<3> >& incubes, std::v
       the_mesh.node_list=*node_vec_ptr;
     }
   
-  //Copy the cells into our own internal data format.
+                                  // Copy the cells into our own
+                                  // internal data format.
   const unsigned int numelems=incubes.size();
   for(unsigned int i =0 ; i<numelems; ++i)
     {
@@ -1358,21 +1471,24 @@ void GridReordering<3>::reorder_cells(std::vector<CellData<3> >& incubes, std::v
       the_mesh.cell_list.push_back(the_cell);
     }
   
-  // Build the conectivity information
-  // This fills in the conectivity information in the internal structure
+                                  // Build the conectivity
+                                  // information This fills in the
+                                  // conectivity information in the
+                                  // internal structure
   build_mesh(the_mesh);
 
-  //Orient the mesh
+                                  // Orient the mesh
   orienter.orient_edges(the_mesh);
 
-  // Now we have a bunch of oriented edges int the structure
-  // we only have to turn the cubes so thy match the edge orientation.
-
+                                  // Now we have a bunch of oriented
+                                  // edges int the structure we only
+                                  // have to turn the cubes so thy
+                                  // match the edge orientation.
   orienter.orient_cubes(the_mesh);
 
-  // Copy the elements from our internal structure back into 
-  // their original location.
-  
+                                  // 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];

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.