/[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 888 by gross, Tue Nov 7 08:31:26 2006 UTC revision 1312 by ksteube, Mon Sep 24 06:18:44 2007 UTC
# Line 1  Line 1 
 /*  
  ************************************************************  
  *          Copyright 2006 by ACcESS MNRF                   *  
  *                                                          *  
  *              http://www.access.edu.au                    *  
  *       Primary Business: Queensland, Australia            *  
  *  Licensed under the Open Software License version 3.0    *  
  *     http://www.opensource.org/licenses/osl-3.0.php       *  
  *                                                          *  
  ************************************************************  
 */  
1    
2  /**************************************************************/  /* $Id$ */
3    
4  /*   Some utility routines: */  /*******************************************************
5     *
6     *           Copyright 2003-2007 by ACceSS MNRF
7     *       Copyright 2007 by University of Queensland
8     *
9     *                http://esscc.uq.edu.au
10     *        Primary Business: Queensland, Australia
11     *  Licensed under the Open Software License version 3.0
12     *     http://www.opensource.org/licenses/osl-3.0.php
13     *
14     *******************************************************/
15    
16  /**************************************************************/  /**************************************************************/
17    
18  /*   author: gross@access.edu.au */  /*   Some utility routines: */
 /*   Version: $Id$ */  
19    
20  /**************************************************************/  /**************************************************************/
21    
# Line 80  void Finley_Util_AddScatter(dim_t len,in Line 78  void Finley_Util_AddScatter(dim_t len,in
78     for (s=0;s<len;s++) {     for (s=0;s<len;s++) {
79         for(i=0;i<numData;i++) {         for(i=0;i<numData;i++) {
80            if( index[s]<upperBound ) {            if( index[s]<upperBound ) {
             #pragma omp atomic  
81              out[INDEX2(i,index[s],numData)]+=in[INDEX2(i,s,numData)];              out[INDEX2(i,index[s],numData)]+=in[INDEX2(i,s,numData)];
82        }        }
83         }         }
# Line 412  index_t Finley_Util_getMaxInt(dim_t dim, Line 409  index_t Finley_Util_getMaxInt(dim_t dim,
409     }     }
410     return out;     return out;
411  }  }
412    /**************************************************************/
413    
414    /* calculates the minimum value from a dim X N integer array */
415    
416    index_t Finley_Util_getFlaggedMinInt(dim_t dim,dim_t N,index_t* values, index_t ignore) {
417       dim_t i,j;
418       index_t out,out_local;
419       out=INDEX_T_MAX;
420       if (values!=NULL && dim*N>0 ) {
421         out=values[0];
422         #pragma omp parallel private(out_local)
423         {
424             out_local=out;
425             #pragma omp for private(i,j) schedule(static)
426             for (j=0;j<N;j++) {
427               for (i=0;i<dim;i++) if (values[INDEX2(i,j,dim)]!=ignore) out_local=MIN(out_local,values[INDEX2(i,j,dim)]);
428             }
429             #pragma omp critical
430             out=MIN(out_local,out);
431         }
432       }
433       return out;
434    }
435                                                                                                                                                      
436    /* calculates the maximum value from a dim X N integer array */
437    
438    index_t Finley_Util_getFlaggedMaxInt(dim_t dim,dim_t N,index_t* values, index_t ignore) {
439       dim_t i,j;
440       index_t out,out_local;
441       out=-INDEX_T_MAX;
442       if (values!=NULL && dim*N>0 ) {
443         out=values[0];
444         #pragma omp parallel private(out_local)
445         {
446             out_local=out;
447             #pragma omp for private(i,j) schedule(static)
448             for (j=0;j<N;j++) {
449                 for (i=0;i<dim;i++) if (values[INDEX2(i,j,dim)]!=ignore) out_local=MAX(out_local,values[INDEX2(i,j,dim)]);
450             }
451             #pragma omp critical
452             out=MAX(out_local,out);
453          }
454       }
455       return out;
456    }
457    
458  /* set the index of the positive entries in mask. The length of index is returned. */  /* set the index of the positive entries in mask. The length of index is returned. */
459    
# Line 477  index_t Finley_Util_cumsum(dim_t N,index Line 519  index_t Finley_Util_cumsum(dim_t N,index
519     return out;     return out;
520  }  }
521    
 void Finley_copyDouble(dim_t n,double* source, double* target) {  
   dim_t i;  
   for (i=0;i<n;i++) target[i]=source[i];  
 }  
522    
523  #ifdef PASO_MPI  #ifdef PASO_MPI
524  void Finley_printDoubleArray( FILE *fid, dim_t n, double *array, char *name  )  void Finley_printDoubleArray( FILE *fid, dim_t n, double *array, char *name  )
# Line 529  void Finley_printMaskArray( FILE *fid, d Line 567  void Finley_printMaskArray( FILE *fid, d
567    fprintf( fid, "]\n" );    fprintf( fid, "]\n" );
568  }  }
569  #endif  #endif
   
 /*  
  * Revision 1.8  2005/08/12 01:45:43  jgs  
  *  
  * Revision 1.7.2.2  2005/09/07 06:26:22  gross  
  * the solver from finley are put into the standalone package paso now  
  *  
  * Revision 1.7.2.1  2005/08/04 22:41:11  gross  
  * some extra routines for finley that might speed-up RHS assembling in some cases (not actived right now)  
  *  
  * Revision 1.7  2005/07/08 04:07:59  jgs  
  * Merge of development branch back to main trunk on 2005-07-08  
  *  
  * Revision 1.1.1.1.2.4  2005/06/29 02:34:57  gross  
  * some changes towards 64 integers in finley  
  *  
  * Revision 1.1.1.1.2.3  2005/03/02 23:35:06  gross  
  * reimplementation of the ILU in Finley. block size>1 still needs some testing  
  *  
  * Revision 1.1.1.1.2.2  2005/02/18 02:27:31  gross  
  * two function that will be used for a reimplementation of the ILU preconditioner  
  *  
  * Revision 1.1.1.1.2.1  2004/11/12 06:58:19  gross  
  * a lot of changes to get the linearPDE class running: most important change is that there is no matrix format exposed to the user anymore. the format is chosen by the Domain according to the solver and symmetry  
  *  
  * Revision 1.1.1.1  2004/10/26 06:53:57  jgs  
  * initial import of project esys2  
  *  
  * Revision 1.3  2004/08/26 12:03:52  gross  
  * Some other bug in Finley_Assemble_gradient fixed.  
  *  
  * Revision 1.2  2004/07/02 04:21:13  gross  
  * Finley C code has been included  
  *  
  * Revision 1.1.1.1  2004/06/24 04:00:40  johng  
  * Initial version of eys using boost-python.  
  *  
  *  
  */  

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

  ViewVC Help
Powered by ViewVC 1.1.26