/[escript]/trunk/finley/src/IndexList.c
ViewVC logotype

Diff of /trunk/finley/src/IndexList.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 616 by elspeth, Wed Mar 22 02:46:56 2006 UTC revision 969 by ksteube, Tue Feb 13 23:02:23 2007 UTC
# Line 23  Line 23 
23    
24  #include "IndexList.h"  #include "IndexList.h"
25    
26    /* Translate from distributed/local array indices to global indices */
27    
28    #ifdef PASO_MPI
29    int Finley_IndexList_localToGlobal(Finley_NodeDistribution *dofDistribution, int my_CPU, int localIndex) {
30      /*
31        get global id of icol
32        if icol is internal node (on this CPU): use icol+vtxdist[my_CPU]
33        else use indexExternal[icol-numLocal] to get global index of node
34        (actually DOF...the NodeDistribution structure should have been called DofDistribution)
35      */
36      if (localIndex < dofDistribution->numLocal) {
37        localIndex = localIndex + dofDistribution->vtxdist[my_CPU];
38      }
39      else {
40        localIndex = dofDistribution->indexExternal[localIndex-dofDistribution->numLocal];
41      }
42      return(localIndex);
43    }
44    #endif
45    
46  /**************************************************************/  /**************************************************************/
47  /* inserts the contributions from the element matrices of elements  /* inserts the contributions from the element matrices of elements
48     into the row index col. If symmetric is set, only the upper     into the row index col. If symmetric is set, only the upper
49     triangle of the matrix is stored. */     triangle of the matrix is stored. */
50    
51  void Finley_IndexList_insertElements(Finley_IndexList* index_list, Finley_ElementFile* elements,  void Finley_IndexList_insertElements(Finley_IndexList* index_list, Finley_Mesh* mesh, Finley_ElementFile* elements,
52                                         bool_t reduce_row_order, index_t* row_Label,                                         bool_t reduce_row_order, index_t* row_Label,
53                                         bool_t reduce_col_order, index_t* col_Label) {                                         bool_t reduce_col_order, index_t* col_Label) {
54    index_t color;    /* index_list is an array of linked lists. Each entry is a row (DOF) and contains the indices to the non-zero columns */
55      index_t color, num_CPUs = 1, my_CPU = 0;
56    dim_t e,kr,kc,NN_row,NN_col,i,icol,irow;    dim_t e,kr,kc,NN_row,NN_col,i,icol,irow;
57    #ifdef PASO_MPI
58        num_CPUs = mesh->MPIInfo->size;
59        my_CPU = mesh->MPIInfo->rank;
60    #endif
61      /* print_mesh_statistics( mesh, TRUE ); */
62    
63    if (elements!=NULL) {    if (elements!=NULL) {
64      dim_t NN=elements->ReferenceElement->Type->numNodes;      dim_t NN=elements->ReferenceElement->Type->numNodes;
# Line 52  void Finley_IndexList_insertElements(Fin Line 78  void Finley_IndexList_insertElements(Fin
78         row_node=id;         row_node=id;
79         NN_row=elements->ReferenceElement->Type->numNodes;         NN_row=elements->ReferenceElement->Type->numNodes;
80      }      }
81        if (num_CPUs == 1) {
82      for (color=elements->minColor;color<=elements->maxColor;color++) {      for (color=elements->minColor;color<=elements->maxColor;color++) {
83          #pragma omp for private(e,irow,kr,kc,icol) schedule(static)          #pragma omp for private(e,irow,kr,kc,icol) schedule(static)
84          for (e=0;e<elements->numElements;e++) {          for (e=0;e<elements->numElements;e++) {
# Line 66  void Finley_IndexList_insertElements(Fin Line 93  void Finley_IndexList_insertElements(Fin
93              }              }
94          }          }
95        }        }
96        }
97        else {  /* More than one CPU (what's below should also work for one CPU, but let's build confidence in it first) */
98    #ifdef PASO_MPI
99        Finley_NodeDistribution *row_degreeOfFreedomDistribution;
100        Finley_NodeDistribution *col_degreeOfFreedomDistribution;
101        if (reduce_col_order) {
102          col_degreeOfFreedomDistribution = mesh->Nodes->reducedDegreeOfFreedomDistribution;
103        }
104        else {
105          col_degreeOfFreedomDistribution = mesh->Nodes->degreeOfFreedomDistribution;
106        }
107        if (reduce_row_order) {
108          row_degreeOfFreedomDistribution = mesh->Nodes->reducedDegreeOfFreedomDistribution;
109        }
110        else {
111          row_degreeOfFreedomDistribution = mesh->Nodes->degreeOfFreedomDistribution;
112        }
113        /* Not using loop over colors as above */ {
114            #pragma omp for private(e,irow,kr,kc,icol) schedule(static)
115        for (e=0;e<elements->numElements;e++) {
116                    for (kr=0;kr<NN_row;kr++) {
117                      irow=row_Label[elements->Nodes[INDEX2(row_node[kr],e,NN)]];
118              if (irow < row_degreeOfFreedomDistribution->numLocal) {
119                        for (kc=0;kc<NN_col;kc++) {
120                   /* Get the local col ID */
121                           icol=col_Label[elements->Nodes[INDEX2(col_node[kc],e,NN)]];
122                   /* Convert to global col ID (row ID is saved as local value) */
123                   icol = Finley_IndexList_localToGlobal(col_degreeOfFreedomDistribution, my_CPU, icol);
124                           Finley_IndexList_insertIndex(&(index_list[irow]),icol);
125                   printf("ksteube Finley_IndexList_insertIndex cpu= %d irow= %d icol= %d\n", my_CPU, irow, icol);
126                        }
127              }
128                    }
129            }
130          }
131    #endif
132        }   /* More than one CPU */
133    }    }
134    return;    return;
135  }  }

Legend:
Removed from v.616  
changed lines
  Added in v.969

  ViewVC Help
Powered by ViewVC 1.1.26