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

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

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

revision 102 by jgs, Wed Dec 15 07:08:39 2004 UTC revision 123 by jgs, Fri Jul 8 04:08:13 2005 UTC
# Line 19  Line 19 
19    
20  /**************************************************************/  /**************************************************************/
21    
22  void Finley_ElementFile_improveColoring(Finley_ElementFile* in,maybelong numNodes, maybelong* degreeOfFreedom) {  void Finley_ElementFile_improveColoring(Finley_ElementFile* in,dim_t numNodes, index_t* degreeOfFreedom) {
23      if (in==NULL) return;      if (in==NULL) return;
24      maybelong NN=in->ReferenceElement->Type->numNodes;      dim_t NN=in->ReferenceElement->Type->numNodes;
25      maybelong old_numColors,*maskDOF,*old_Color,e,i,numUncoloredElements,n,color,independent;      dim_t e,i,numUncoloredElements,n,len;
26        index_t *maskDOF,*old_Color,color,min_id,max_id,old_maxColor,old_minColor;
27        bool_t independent;
28      Finley_ErrorCode=NO_ERROR;      Finley_ErrorCode=NO_ERROR;
     int min_id,max_id;  
     maybelong len;  
29    
30      if (in->numElements<1) return;      if (in->numElements<1) return;
31    
32      min_id=Finley_Util_getMinInt(1,numNodes,degreeOfFreedom);      min_id=Finley_Util_getMinInt(1,numNodes,degreeOfFreedom);
33      max_id=Finley_Util_getMaxInt(1,numNodes,degreeOfFreedom);      max_id=Finley_Util_getMaxInt(1,numNodes,degreeOfFreedom);
34      len=max_id-min_id+1;      len=max_id-min_id+1;
35      maskDOF=TMPMEMALLOC(len,maybelong);      maskDOF=TMPMEMALLOC(len,index_t);
36      old_Color=TMPMEMALLOC(in->numElements,maybelong);      old_Color=TMPMEMALLOC(in->numElements,index_t);
37            
38      if (! (Finley_checkPtr(maskDOF) || Finley_checkPtr(old_Color) ) ) {      if (! (Finley_checkPtr(maskDOF) || Finley_checkPtr(old_Color) ) ) {
39           #pragma omp parallel for private(e) schedule(static)           #pragma omp parallel for private(e) schedule(static)
# Line 41  void Finley_ElementFile_improveColoring( Line 41  void Finley_ElementFile_improveColoring(
41                 old_Color[e]=in->Color[e];                 old_Color[e]=in->Color[e];
42                 in->Color[e]=-1;                 in->Color[e]=-1;
43           }           }
44           old_numColors=in->numColors;           old_maxColor=in->maxColor;
45           in->numColors=0;           old_minColor=in->minColor;
46             in->maxColor=-1;
47             in->minColor=0;
48           numUncoloredElements=in->numElements;           numUncoloredElements=in->numElements;
49           while (numUncoloredElements>0) {           while (numUncoloredElements>0) {
50              #pragma omp parallel private(color)              #pragma omp parallel private(color)
# Line 53  void Finley_ElementFile_improveColoring( Line 55  void Finley_ElementFile_improveColoring(
55                 /* the existing coloring is used to make sure that the new coloring can be done in parallel */                 /* the existing coloring is used to make sure that the new coloring can be done in parallel */
56                 #pragma omp master                 #pragma omp master
57                 numUncoloredElements=0;                 numUncoloredElements=0;
58                 for (color=0;color<old_numColors;color++) {                 for (color=old_minColor;color<=old_maxColor;color++) {
59                    #pragma omp for private(i,e,independent) schedule(static) reduction(+:numUncoloredElements)                    #pragma omp for private(i,e,independent) schedule(static) reduction(+:numUncoloredElements)
60                    for (e=0;e<in->numElements;e++) {                    for (e=0;e<in->numElements;e++) {
61                       if (old_Color[e]==color) {                       if (old_Color[e]==color) {
# Line 64  void Finley_ElementFile_improveColoring( Line 66  void Finley_ElementFile_improveColoring(
66                          if (independent) {                          if (independent) {
67                              for (i=0;i<NN;i++) maskDOF[degreeOfFreedom[in->Nodes[INDEX2(i,e,NN)]]-min_id]=1;                              for (i=0;i<NN;i++) maskDOF[degreeOfFreedom[in->Nodes[INDEX2(i,e,NN)]]-min_id]=1;
68                              old_Color[e]=-1;                              old_Color[e]=-1;
69                              in->Color[e]=in->numColors;                              in->Color[e]=in->maxColor+1;
70                           } else {                           } else {
71                              numUncoloredElements++;                              numUncoloredElements++;
72                           }                           }
# Line 72  void Finley_ElementFile_improveColoring( Line 74  void Finley_ElementFile_improveColoring(
74                    }                    }
75                 } /* end of color loop */                 } /* end of color loop */
76              }              }
77              in->numColors++;              in->maxColor++;
78           }  /* end of while loop */           }  /* end of while loop */
79      }      }
80    
# Line 83  void Finley_ElementFile_improveColoring( Line 85  void Finley_ElementFile_improveColoring(
85  }  }
86  /*  /*
87  * $Log$  * $Log$
88    * Revision 1.5  2005/07/08 04:07:49  jgs
89    * Merge of development branch back to main trunk on 2005-07-08
90    *
91  * Revision 1.4  2004/12/15 07:08:32  jgs  * Revision 1.4  2004/12/15 07:08:32  jgs
92  * *** empty log message ***  * *** empty log message ***
93    * Revision 1.1.1.1.2.2  2005/06/29 02:34:49  gross
94    * some changes towards 64 integers in finley
95    *
96    * Revision 1.1.1.1.2.1  2004/11/24 01:37:13  gross
97    * some changes dealing with the integer overflow in memory allocation. Finley solves 4M unknowns now
98  *  *
99  *  *
100  *  *

Legend:
Removed from v.102  
changed lines
  Added in v.123

  ViewVC Help
Powered by ViewVC 1.1.26