/[escript]/trunk/paso/src/AMG.c
ViewVC logotype

Diff of /trunk/paso/src/AMG.c

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

revision 3350 by gross, Thu Oct 28 09:53:46 2010 UTC revision 3351 by gross, Tue Nov 16 02:39:40 2010 UTC
# Line 432  void Paso_Preconditioner_AMG_RungeStuebe Line 432  void Paso_Preconditioner_AMG_RungeStuebe
432                           const dim_t* degree, const index_t* S,                           const dim_t* degree, const index_t* S,
433                           index_t*split_marker)                           index_t*split_marker)
434  {  {
435     index_t *lambda=NULL, j, *ST=NULL;     const bool_t usePanel=FALSE;
436     dim_t i,k, p, q, *degreeT=NULL, itmp;    
437     double time0=0;     index_t *lambda=NULL, *ST=NULL, *notInPanel=NULL, *panel=NULL, lambda_max, lambda_k;
438       dim_t i,k, p, q, *degreeT=NULL, len_panel, len_panel_new;
439       register index_t j, itmp;
440        
441     if (n<=0) return; /* make sure that the return of Paso_Util_arg_max is not pointing to nirvana */     if (n<=0) return; /* make sure that the return of Paso_Util_arg_max is not pointing to nirvana */
442        
443     lambda=TMPMEMALLOC(n, index_t);     lambda=TMPMEMALLOC(n, index_t); Esys_checkPtr(lambda);
444     degreeT=TMPMEMALLOC(n, dim_t);     degreeT=TMPMEMALLOC(n, dim_t); Esys_checkPtr(degreeT);
445     ST=TMPMEMALLOC(offset[n], index_t);     ST=TMPMEMALLOC(offset[n], index_t);  Esys_checkPtr(ST);
446       if (usePanel) {
447          notInPanel=TMPMEMALLOC(n, bool_t); Esys_checkPtr(notInPanel);
448          panel=TMPMEMALLOC(n, index_t); Esys_checkPtr(panel);
449       }
450        
451     if (! ( Esys_checkPtr(lambda) || Esys_checkPtr(degreeT) || Esys_checkPtr(ST) ) ) {    
452  time0=Esys_timer();    
453       if (Esys_noError() ) {
454        /* initialize  split_marker and split_marker :*/        /* initialize  split_marker and split_marker :*/
455        /* those unknows which are not influenced go into F, the rest is available for F or C */        /* those unknows which are not influenced go into F, the rest is available for F or C */
456        #pragma omp parallel for private(i) schedule(static)        #pragma omp parallel for private(i) schedule(static)
# Line 482  time0=Esys_timer(); Line 488  time0=Esys_timer();
488          lambda[i]=itmp;          lambda[i]=itmp;
489       }       }
490        }        }
491        /* printf("timing: %e\n",Esys_timer()-time0); */        if (usePanel) {
492        time0=Esys_timer();       #pragma omp parallel for private(i) schedule(static)
493         for (i=0;i<n;++i) notInPanel[i]=TRUE;
494          }
495        /* start search :*/        /* start search :*/
496        i=Paso_Util_arg_max(n,lambda);        i=Paso_Util_arg_max(n,lambda);
497        while (lambda[i]>-1) { /* is there any undecided unknowns? */        while (lambda[i]>-1) { /* is there any undecided unknown? */
498        
499       /* the unknown i is moved to C */       if (usePanel) {
500       split_marker[i]=PASO_AMG_IN_C;          len_panel=0;
501       lambda[i]=-1;  /* lambda fro unavailable unknowns is set to -1 */          do {
502                   /* the unknown i is moved to C */
503       /* all undecided unknown strongly coupled to i are moved to F */             split_marker[i]=PASO_AMG_IN_C;
504       for (p=0; p<degreeT[i]; ++p) {             lambda[i]=-1;  /* lambda from unavailable unknowns is set to -1 */
505          j=ST[offset[i]+p];            
506                   /* all undecided unknown strongly coupled to i are moved to F */
507          if (split_marker[j]==PASO_AMG_UNDECIDED) {             for (p=0; p<degreeT[i]; ++p) {
508                    j=ST[offset[i]+p];
509             split_marker[j]=PASO_AMG_IN_F;            
510             lambda[j]=-1;            if (split_marker[j]==PASO_AMG_UNDECIDED) {
511                      
512             for (q=0; q<degreeT[j]; ++q) {               split_marker[j]=PASO_AMG_IN_F;
513            k=ST[offset[j]+q];               lambda[j]=-1;
514            if (split_marker[k]==PASO_AMG_UNDECIDED) lambda[k]++;              
515                 for (q=0; q<degreeT[j]; ++q) {
516                k=ST[offset[j]+q];
517                if (split_marker[k]==PASO_AMG_UNDECIDED) {
518                   lambda[k]++;
519                   if (notInPanel[k]) {
520                      notInPanel[k]=FALSE;
521                      panel[len_panel]=k;
522                      len_panel++;
523                   }
524    
525                }    /* the unknown i is moved to C */
526                split_marker[i]=PASO_AMG_IN_C;
527                lambda[i]=-1;  /* lambda from unavailable unknowns is set to -1 */
528                 }
529                
530              }
531               }
532               for (p=0; p<degree[i]; ++p) {
533              j=S[offset[i]+p];
534              if (split_marker[j]==PASO_AMG_UNDECIDED) {
535                 lambda[j]--;
536                 if (notInPanel[j]) {
537                notInPanel[j]=FALSE;
538                panel[len_panel]=j;
539                len_panel++;
540                 }
541              }
542             }             }
543    
544               /* consolidate panel */
545               /* remove lambda[q]=-1 */
546               lambda_max=-1;
547               i=-1;
548               len_panel_new=0;
549               for (q=0; q<len_panel; q++) {
550                 k=panel[q];
551                 lambda_k=lambda[k];
552                 if (split_marker[k]==PASO_AMG_UNDECIDED) {
553                panel[len_panel_new]=k;
554                len_panel_new++;
555    
556                if (lambda_max == lambda_k) {
557                   if (k<i) i=k;
558                } else if (lambda_max < lambda_k) {
559                   lambda_max =lambda_k;
560                   i=k;
561                }
562                 }
563               }
564               len_panel=len_panel_new;
565            } while (len_panel>0);    
566         } else {
567            /* the unknown i is moved to C */
568            split_marker[i]=PASO_AMG_IN_C;
569            lambda[i]=-1;  /* lambda from unavailable unknowns is set to -1 */
570            
571            /* all undecided unknown strongly coupled to i are moved to F */
572            for (p=0; p<degreeT[i]; ++p) {
573               j=ST[offset[i]+p];
574               if (split_marker[j]==PASO_AMG_UNDECIDED) {
575            
576              split_marker[j]=PASO_AMG_IN_F;
577              lambda[j]=-1;
578            
579              for (q=0; q<degreeT[j]; ++q) {
580                 k=ST[offset[j]+q];
581                 if (split_marker[k]==PASO_AMG_UNDECIDED) lambda[k]++;
582              }
583    
584               }
585          }          }
586            for (p=0; p<degree[i]; ++p) {
587               j=S[offset[i]+p];
588               if(split_marker[j]==PASO_AMG_UNDECIDED) lambda[j]--;
589            }
590            
591       }       }
      for (p=0; p<degree[i]; ++p) {  
         j=S[offset[i]+p];  
         if(split_marker[j]==PASO_AMG_UNDECIDED) lambda[j]--;  
      }  
       
592       i=Paso_Util_arg_max(n,lambda);       i=Paso_Util_arg_max(n,lambda);
593        }        }
594     }     }
    /* printf("timing: %e\n",Esys_timer()-time0); */  
595     TMPMEMFREE(lambda);     TMPMEMFREE(lambda);
596     TMPMEMFREE(ST);     TMPMEMFREE(ST);
597     TMPMEMFREE(degreeT);     TMPMEMFREE(degreeT);
598       TMPMEMFREE(panel);
599       TMPMEMFREE(notInPanel);
600  }  }

Legend:
Removed from v.3350  
changed lines
  Added in v.3351

  ViewVC Help
Powered by ViewVC 1.1.26