/[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 471 by jgs, Fri Jan 27 01:33:02 2006 UTC revision 757 by woo409, Mon Jun 26 13:12:56 2006 UTC
# Line 1  Line 1 
1  /*  /*
2   ******************************************************************************   ************************************************************
3   *                                                                            *   *          Copyright 2006 by ACcESS MNRF                   *
4   *       COPYRIGHT  ACcESS 2003,2004,2005 -  All Rights Reserved              *   *                                                          *
5   *                                                                            *   *              http://www.access.edu.au                    *
6   * This software is the property of ACcESS. No part of this code              *   *       Primary Business: Queensland, Australia            *
7   * may be copied in any form or by any means without the expressed written    *   *  Licensed under the Open Software License version 3.0    *
8   * consent of ACcESS.  Copying, use or modification of this software          *   *     http://www.opensource.org/licenses/osl-3.0.php       *
9   * by any unauthorised person is illegal unless that person has a software    *   *                                                          *
10   * license agreement with ACcESS.                                             *   ************************************************************
  *                                                                            *  
  ******************************************************************************  
11  */  */
12    
13  /**************************************************************/  /**************************************************************/
# Line 25  Line 23 
23    
24  #include "Finley.h"  #include "Finley.h"
25  #include "Util.h"  #include "Util.h"
26    
27  #ifdef _OPENMP  #ifdef _OPENMP
28  #include <omp.h>  #include <omp.h>
29  #endif  #endif
# Line 85  void Finley_Util_AddScatter(dim_t len,in Line 84  void Finley_Util_AddScatter(dim_t len,in
84     }     }
85  }  }
86    
87    #ifdef PASO_MPI
88    /* same as AddScatter(), but checks that value index[] is below an upper bound upperBound before  
89       addition. This is used to ensure that only the influence of local DOF is added */
90    /*        out(1:numData,index[p])+=in(1:numData,p)
91            where p = {k=1...len , index[k]<upperBound}*/
92    void Finley_Util_AddScatter_upperBound(dim_t len,index_t* index,dim_t numData,double* in,double * out, index_t upperBound){
93       dim_t i,s;
94       for (s=0;s<len;s++) {
95           for(i=0;i<numData;i++) {
96              //#pragma omp atomic
97              if( index[s]<upperBound )
98                out[INDEX2(i,index[s],numData)]+=in[INDEX2(i,s,numData)];
99           }
100       }
101    }  
102    
103    
104    #endif
105    
106  /*    multiplies two matrices */  /*    multiplies two matrices */
107    
108  /*          A(1:A1,1:A2)=B(1:A1,1:B2)*C(1:B2,1:A2) */  /*          A(1:A1,1:A2)=B(1:A1,1:B2)*C(1:B2,1:A2) */
# Line 356  int Finley_Util_ValueAndIndex_compar(con Line 374  int Finley_Util_ValueAndIndex_compar(con
374     if (e1->value > e2->value) return  1;     if (e1->value > e2->value) return  1;
375     return 0;     return 0;
376  }  }
377    
378  void Finley_Util_sortValueAndIndex(dim_t n,Finley_Util_ValueAndIndex* array) {  void Finley_Util_sortValueAndIndex(dim_t n,Finley_Util_ValueAndIndex* array) {
379       /* OMP : needs parallelization !*/       /* OMP : needs parallelization !*/
380       qsort(array,n,sizeof(Finley_Util_ValueAndIndex),Finley_Util_ValueAndIndex_compar);       qsort(array,n,sizeof(Finley_Util_ValueAndIndex),Finley_Util_ValueAndIndex_compar);
# Line 477  void Finley_copyDouble(dim_t n,double* s Line 496  void Finley_copyDouble(dim_t n,double* s
496    for (i=0;i<n;i++) target[i]=source[i];    for (i=0;i<n;i++) target[i]=source[i];
497  }  }
498    
499    #ifdef PASO_MPI
500    void Finley_printDoubleArray( FILE *fid, dim_t n, double *array, char *name  )
501    {
502      index_t i;
503      
504      if( name )
505        fprintf( fid, "%s [ ", name );
506      else
507        fprintf( fid, "[ " );  
508      for( i=0; i<(n<30 ? n : 30); i++ )
509        fprintf( fid, "%g ", array[i] );
510      if( n>=30 )
511        fprintf( fid, "... " );
512      fprintf( fid, "]\n" );
513    }
514    void Finley_printIntArray( FILE *fid, dim_t n, int *array, char *name  )
515    {
516      index_t i;
517      
518      if( name )
519        fprintf( fid, "%s [ ", name );
520      else
521        fprintf( fid, "[ " );  
522      for( i=0; i<(n<30 ? n : 30); i++ )
523        fprintf( fid, "%d ", array[i] );
524      if( n>=30 )
525        fprintf( fid, "... " );
526      fprintf( fid, "]\n" );
527    }
528    void Finley_printMaskArray( FILE *fid, dim_t n, int *array, char *name  )
529    {
530      index_t i;
531      
532      if( name )
533        fprintf( fid, "%s [ ", name );
534      else
535        fprintf( fid, "[ " );  
536      for( i=0; i<(n<30 ? n : 30); i++ )
537        if( array[i]!=-1 )
538          fprintf( fid, "%d ", array[i] );
539        else
540          fprintf( fid, "* " );
541      if( n>=30 )
542        fprintf( fid, "... " );
543      fprintf( fid, "]\n" );
544    }
545    #endif
546    
547  /*  /*
548   * Revision 1.8  2005/08/12 01:45:43  jgs   * Revision 1.8  2005/08/12 01:45:43  jgs
  * erge of development branch dev-02 back to main trunk on 2005-08-12  
549   *   *
550   * Revision 1.7.2.2  2005/09/07 06:26:22  gross   * Revision 1.7.2.2  2005/09/07 06:26:22  gross
551   * the solver from finley are put into the standalone package paso now   * the solver from finley are put into the standalone package paso now

Legend:
Removed from v.471  
changed lines
  Added in v.757

  ViewVC Help
Powered by ViewVC 1.1.26