/[escript]/trunk/esys2/finley/src/finleyC/Solvers/Solver_coloring.c
ViewVC logotype

Diff of /trunk/esys2/finley/src/finleyC/Solvers/Solver_coloring.c

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

revision 112 by jgs, Wed Dec 15 07:08:39 2004 UTC revision 113 by jgs, Mon Feb 28 07:06:33 2005 UTC
# Line 18  Line 18 
18    
19    
20  /* used to generate pseudo random numbers: */  /* used to generate pseudo random numbers: */
21  static double Finley_Solver_coloring_seed=.4142135623730951;  static double Finley_Solver_coloring_seed2=.4142135623730951;
22    
23  #define CONNECTED_TO_CURRENT_COLOR -1  #define CONNECTED_TO_CURRENT_COLOR -1
24  #define NOT_COLORED_NOW -2  #define NOT_COLORED_NOW -2
# Line 29  static double Finley_Solver_coloring_see Line 29  static double Finley_Solver_coloring_see
29  /* inverse preconditioner setup */  /* inverse preconditioner setup */
30    
31  void Finley_Solver_coloring(Finley_SystemMatrixPattern* pattern_p,maybelong* numColors, maybelong* color) {  void Finley_Solver_coloring(Finley_SystemMatrixPattern* pattern_p,maybelong* numColors, maybelong* color) {
 #if ITERATIVE_SOLVER == NO_LIB  
32    int i,iptr,currentColor,naib;    int i,iptr,currentColor,naib;
33    maybelong n=pattern_p->n_ptr;    maybelong n=pattern_p->n_ptr;
34    double *value=TMPMEMALLOC(n,double);    double *value=TMPMEMALLOC(n,double);
# Line 58  void Finley_Solver_coloring(Finley_Syste Line 57  void Finley_Solver_coloring(Finley_Syste
57                  #pragma omp for private(i) schedule(static)                  #pragma omp for private(i) schedule(static)
58                  for (i=0;i<n;i++) {                  for (i=0;i<n;i++) {
59                     if (color[i]==MAYBE_COLORED_NOW) {                     if (color[i]==MAYBE_COLORED_NOW) {
60                         value[i]=fmod(Finley_Solver_coloring_seed*(i+1),1.);                         value[i]=fmod(Finley_Solver_coloring_seed2*(i+1),1.);
61                     } else {                     } else {
62                         value[i]=2.;                         value[i]=2.;
63                     }                     }
64                  }                  }
65                  /* update the seed */                  /* update the seed */
66                  #pragma omp master                  #pragma omp master
67                  Finley_Solver_coloring_seed=fmod(sqrt(Finley_Solver_coloring_seed*(n+1)),1.);                  Finley_Solver_coloring_seed2=fmod(sqrt(Finley_Solver_coloring_seed2*(n+1)),1.);
68                  /* if a row is MAYBE_COLORED_NOW and its value is smaller than all the values of its naigbours */                  /* if a row is MAYBE_COLORED_NOW and its value is smaller than all the values of its naigbours */
69                  /* the row is independent from the un-colored rows */                  /* the row is independent from the un-colored rows */
70                  /* otherwise the row is connected to another row and the row is marked as NOT_COLORED_NOW */                  /* otherwise the row is connected to another row and the row is marked as NOT_COLORED_NOW */
# Line 73  void Finley_Solver_coloring(Finley_Syste Line 72  void Finley_Solver_coloring(Finley_Syste
72                  #pragma omp for private(naib,i,iptr) schedule(static)                  #pragma omp for private(naib,i,iptr) schedule(static)
73                  for (i=0;i<n;i++) {                  for (i=0;i<n;i++) {
74                     if (color[i]==MAYBE_COLORED_NOW) {                     if (color[i]==MAYBE_COLORED_NOW) {
75                       for (iptr=pattern_p->ptr[i];iptr<pattern_p->ptr[i+1]; iptr++) {                       for (iptr=pattern_p->ptr[i];iptr<pattern_p->ptr[i+1]; ++iptr) {
76                            naib=pattern_p->index[iptr];                            naib=pattern_p->index[iptr];
77                            if (naib!=i && value[naib]<=value[i]) {                            if (naib!=i && value[naib]<=value[i]) {
78                                 color[i]=NOT_COLORED_NOW;                                 color[i]=NOT_COLORED_NOW;
# Line 87  void Finley_Solver_coloring(Finley_Syste Line 86  void Finley_Solver_coloring(Finley_Syste
86                  #pragma omp for private(naib,iptr,i) schedule(static)                  #pragma omp for private(naib,iptr,i) schedule(static)
87                  for (i=0;i<n;i++) {                  for (i=0;i<n;i++) {
88                     if (color[i]==MAYBE_COLORED_NOW) {                     if (color[i]==MAYBE_COLORED_NOW) {
89                       for (iptr=pattern_p->ptr[i];iptr<pattern_p->ptr[i+1]; iptr++) {                       for (iptr=pattern_p->ptr[i];iptr<pattern_p->ptr[i+1]; ++iptr) {
90                            naib=pattern_p->index[iptr];                            naib=pattern_p->index[iptr];
91                            if (naib!=i && color[naib]<0) color[naib]=CONNECTED_TO_CURRENT_COLOR;                            if (naib!=i && color[naib]<0) color[naib]=CONNECTED_TO_CURRENT_COLOR;
92                       }                       }
# Line 108  void Finley_Solver_coloring(Finley_Syste Line 107  void Finley_Solver_coloring(Finley_Syste
107    printf("row coloring finalized. %d colors used.\n",*numColors);    printf("row coloring finalized. %d colors used.\n",*numColors);
108    #endif    #endif
109    TMPMEMFREE(value);    TMPMEMFREE(value);
 #endif  
110  }  }
111  #undef CONNECTED_TO_CURRENT_COLOR  #undef CONNECTED_TO_CURRENT_COLOR
112  #undef MAYBE_COLORED_NOW  #undef MAYBE_COLORED_NOW
113  #undef NOT_COLORED_NOW  #undef NOT_COLORED_NOW
   

Legend:
Removed from v.112  
changed lines
  Added in v.113

  ViewVC Help
Powered by ViewVC 1.1.26