/[escript]/branches/domexper/dudley/src/Util.c
ViewVC logotype

Diff of /branches/domexper/dudley/src/Util.c

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

revision 765 by gross, Fri Jun 30 06:37:11 2006 UTC revision 888 by gross, Tue Nov 7 08:31:26 2006 UTC
# Line 72  void Finley_Util_Gather_int(dim_t len,in Line 72  void Finley_Util_Gather_int(dim_t len,in
72    
73  /*   adds a vector in into out using and index. */  /*   adds a vector in into out using and index. */
74    
75  /*        out(1:numData,index(1:len))+=in(1:numData,1:len) */  /*        out(1:numData,index[p])+=in(1:numData,p) where p = {k=1...len , index[k]<upperBound}*/
76    
 void Finley_Util_AddScatter(dim_t len,index_t* index,dim_t numData,double* in,double * out){  
    dim_t i,s;  
    for (s=0;s<len;s++) {  
        for(i=0;i<numData;i++) {  
           #pragma omp atomic  
           out[INDEX2(i,index[s],numData)]+=in[INDEX2(i,s,numData)];  
        }  
    }  
 }  
77    
78  #ifdef PASO_MPI  void Finley_Util_AddScatter(dim_t len,index_t* index,dim_t numData,double* in,double * out, index_t upperBound){
 /* same as AddScatter(), but checks that value index[] is below an upper bound upperBound before    
    addition. This is used to ensure that only the influence of local DOF is added */  
 /*        out(1:numData,index[p])+=in(1:numData,p)  
         where p = {k=1...len , index[k]<upperBound}*/  
 void Finley_Util_AddScatter_upperBound(dim_t len,index_t* index,dim_t numData,double* in,double * out, index_t upperBound){  
79     dim_t i,s;     dim_t i,s;
80     for (s=0;s<len;s++) {     for (s=0;s<len;s++) {
81         for(i=0;i<numData;i++) {         for(i=0;i<numData;i++) {
82            //#pragma omp atomic            if( index[s]<upperBound ) {
83            if( index[s]<upperBound )              #pragma omp atomic
84              out[INDEX2(i,index[s],numData)]+=in[INDEX2(i,s,numData)];              out[INDEX2(i,index[s],numData)]+=in[INDEX2(i,s,numData)];
85          }
86         }         }
87     }     }
88  }    }
   
   
 #endif  
89    
90  /*    multiplies two matrices */  /*    multiplies two matrices */
91    
# Line 374  int Finley_Util_ValueAndIndex_compar(con Line 358  int Finley_Util_ValueAndIndex_compar(con
358     if (e1->value > e2->value) return  1;     if (e1->value > e2->value) return  1;
359     if (e1->index < e2->index) return -1;     if (e1->index < e2->index) return -1;
360     if (e1->index > e2->index) return  1;     if (e1->index > e2->index) return  1;
   
361     return 0;     return 0;
362  }  }
363    
# Line 508  void Finley_printDoubleArray( FILE *fid, Line 491  void Finley_printDoubleArray( FILE *fid,
491      fprintf( fid, "%s [ ", name );      fprintf( fid, "%s [ ", name );
492    else    else
493      fprintf( fid, "[ " );        fprintf( fid, "[ " );  
494    for( i=0; i<(n<30 ? n : 30); i++ )    for( i=0; i<(n<60 ? n : 60); i++ )
495      fprintf( fid, "%g ", array[i] );      fprintf( fid, "%g ", array[i] );
496    if( n>=30 )    if( n>=30 )
497      fprintf( fid, "... " );      fprintf( fid, "... " );
# Line 522  void Finley_printIntArray( FILE *fid, di Line 505  void Finley_printIntArray( FILE *fid, di
505      fprintf( fid, "%s [ ", name );      fprintf( fid, "%s [ ", name );
506    else    else
507      fprintf( fid, "[ " );        fprintf( fid, "[ " );  
508    for( i=0; i<(n<30 ? n : 30); i++ )    for( i=0; i<(n<60 ? n : 60); i++ )
509      fprintf( fid, "%d ", array[i] );      fprintf( fid, "%d ", array[i] );
510    if( n>=30 )    if( n>=30 )
511      fprintf( fid, "... " );      fprintf( fid, "... " );
# Line 536  void Finley_printMaskArray( FILE *fid, d Line 519  void Finley_printMaskArray( FILE *fid, d
519      fprintf( fid, "%s [ ", name );      fprintf( fid, "%s [ ", name );
520    else    else
521      fprintf( fid, "[ " );        fprintf( fid, "[ " );  
522    for( i=0; i<(n<30 ? n : 30); i++ )    for( i=0; i<(n<60 ? n : 60); i++ )
523      if( array[i]!=-1 )      if( array[i]!=-1 )
524        fprintf( fid, "%d ", array[i] );        fprintf( fid, "%3d ", array[i] );
525      else      else
526        fprintf( fid, "* " );        fprintf( fid, "  * " );
527    if( n>=30 )    if( n>=30 )
528      fprintf( fid, "... " );      fprintf( fid, "... " );
529    fprintf( fid, "]\n" );    fprintf( fid, "]\n" );

Legend:
Removed from v.765  
changed lines
  Added in v.888

  ViewVC Help
Powered by ViewVC 1.1.26