Fixed a bug handling ghosts in FEM_Node::fillNodeAdjacency
authorIsaac Dooley <idooley2@illinois.edu>
Mon, 18 Jul 2005 21:57:09 +0000 (21:57 +0000)
committerIsaac Dooley <idooley2@illinois.edu>
Mon, 18 Jul 2005 21:57:09 +0000 (21:57 +0000)
src/libs/ck-libs/fem/fem_mesh_adjacency.C

index e572eeb0227c3978e82bf581e904dbf1272e7a2c..f1c065bcee204080fa51d826ff9f40df2da186e3 100644 (file)
@@ -136,69 +136,69 @@ void FEM_Node::fillNodeAdjacency(const FEM_Elem &elem){
 
        // Add the adjacencies defined by the non-ghost elements
        for(int i=0;i<elem.size();i++){        // for each element of the given type
-               const int *conn = elem.connFor(i);
-               for(int j=0;j<nodesPerElem;j++){   // for each node adjacent to the element
-                       int node = conn[j];
-                       if(FEM_Is_ghost_index(node)) { // A ghost node
-                         for(int k=0;k<nodesPerElem;k++){
-                               if(conn[k] != node){ // Here we need the node id which is negative not the corresponding positive index
-                                 var_id nodeIDAdded = var_id::createNodeID(1,conn[k]);
-                                 int idx = ghostAdjacencyAttr->findInRow(node,nodeIDAdded); // find position of k'th node in adjacency list
-                                 if(idx == -1){ // If k'th node is not currently in the adjacency list, push it onto list
-                                       (ghostAdjacencyAttr->get())[FEM_To_ghost_index(node)].push_back(nodeIDAdded); // Here we need the node index which is positive
-                                 }
+         const int *conn = elem.connFor(i);
+         for(int j=0;j<nodesPerElem;j++){   // for each node adjacent to the element
+               int node = conn[j];
+               if (node!=-1){
+                 if(FEM_Is_ghost_index(node)) { // A ghost node
+                       for(int k=0;k<nodesPerElem;k++){
+                         if(conn[k] != node){ // Here we need the node id which is negative not the corresponding positive index
+                               var_id nodeIDAdded = var_id::createNodeID(1,conn[k]);
+                               int idx = ghostAdjacencyAttr->findInRow(FEM_To_ghost_index(node),nodeIDAdded); // find position of k'th node in adjacency list
+                               if(idx == -1){ // If k'th node is not currently in the adjacency list, push it onto list
+                                 ghostAdjacencyTable[FEM_To_ghost_index(node)].push_back(nodeIDAdded); // Here we need the node index which is positive
                                }
                          }
                        }
-                       else if (node!=-1) { // A non-ghost node, almost same as for ghost nodes
-                         for(int k=0;k<nodesPerElem;k++){
-                               if(conn[k] != node){
-                                 var_id nodeIDAdded = var_id::createNodeID(1,conn[k]);
-                                 int idx = nodeAdjacency->findInRow(node,nodeIDAdded);
-                                 if(idx == -1){
-                                       (nodeAdjacency->get())[node].push_back(nodeIDAdded);
-                                 }
+                 }
+                 else { // A non-ghost node, almost same as for ghost nodes
+                       for(int k=0;k<nodesPerElem;k++){
+                         if(conn[k] != node){
+                               var_id nodeIDAdded = var_id::createNodeID(1,conn[k]);
+                               int idx = nodeAdjacency->findInRow(node,nodeIDAdded);
+                               if(idx == -1){
+                                 adjacencyTable[node].push_back(nodeIDAdded);
                                }
                          }
                        }
-                       else{}//invalid node.. shouldn't happen
-                       
+                 }
                }
+         }
        }
-
-       // Add adjacencies defined by the ghost elements
+       // Add the adjacencies defined by the ghost elements
        if(elem.getGhost()){
-         for(int i=0;i<((FEM_Elem*)elem.getGhost())->size();i++){        // for each element of the given type
+         for(int i=0;i<elem.getGhost()->size();i++){        // for each element of the given type
                const int *conn = ((FEM_Elem*)elem.getGhost())->connFor(i);
                for(int j=0;j<nodesPerElem;j++){   // for each node adjacent to the element
                  int node = conn[j];
-                 if(FEM_Is_ghost_index(node)) { // A ghost node
-                       for(int k=0;k<nodesPerElem;k++){
-                         if(conn[k] != node){ // Here we need the node id which is negative not the corresponding positive index
+                 if (node!=-1){
+                       if(FEM_Is_ghost_index(node)) { // A ghost node
+                         for(int k=0;k<nodesPerElem;k++){
+                               if(conn[k] != node){ // Here we need the node id which is negative not the corresponding positive index
                                  var_id nodeIDAdded = var_id::createNodeID(1,conn[k]);
-                                 int idx = ghostAdjacencyAttr->findInRow(node,nodeIDAdded); // find position of k'th node in adjacency list
+                                 int idx = ghostAdjacencyAttr->findInRow(FEM_To_ghost_index(node),nodeIDAdded); // find position of k'th node in adjacency list
                                  if(idx == -1){ // If k'th node is not currently in the adjacency list, push it onto list
-                                       (ghostAdjacencyAttr->get())[FEM_To_ghost_index(node)].push_back(nodeIDAdded); // Here we need the node index which is positive
+                                       ghostAdjacencyTable[FEM_To_ghost_index(node)].push_back(nodeIDAdded); // Here we need the node index which is positive
                                  }
+                               }
                          }
                        }
-                 }
-                 else if (node!=-1) { // A non-ghost node, almost same as for ghost nodes
-                       for(int k=0;k<nodesPerElem;k++){
-                         if(conn[k] != node){
-                               var_id nodeIDAdded = var_id::createNodeID(1,conn[k]);
-                               int idx = nodeAdjacency->findInRow(node,nodeIDAdded);
-                               if(idx == -1){
-                                 (nodeAdjacency->get())[node].push_back(nodeIDAdded);
+                       else { // A non-ghost node, almost same as for ghost nodes
+                         for(int k=0;k<nodesPerElem;k++){
+                               if(conn[k] != node){
+                                 var_id nodeIDAdded = var_id::createNodeID(1,conn[k]);
+                                 int idx = nodeAdjacency->findInRow(node,nodeIDAdded);
+                                 if(idx == -1){
+                                       adjacencyTable[node].push_back(nodeIDAdded);
+                                 }
                                }
                          }
                        }
                  }
-                 else{}//invalid node.. shouldn't happen
-                 
                }
          }
        }
+
 };
 
 void FEM_Node::setNodeAdjacency(const FEM_Elem &elem){