/[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

trunk/esys2/finley/src/finleyC/Util.c revision 147 by jgs, Fri Aug 12 01:45:47 2005 UTC trunk/finley/src/Util.c revision 751 by bcumming, Mon Jun 26 01:46:34 2006 UTC
# Line 1  Line 1 
1  /* $Id$ */  /*
2     ************************************************************
3     *          Copyright 2006 by ACcESS MNRF                   *
4     *                                                          *
5     *              http://www.access.edu.au                    *
6     *       Primary Business: Queensland, Australia            *
7     *  Licensed under the Open Software License version 3.0    *
8     *     http://www.opensource.org/licenses/osl-3.0.php       *
9     *                                                          *
10     ************************************************************
11    */
12    
13  /**************************************************************/  /**************************************************************/
14    
# Line 6  Line 16 
16    
17  /**************************************************************/  /**************************************************************/
18    
 /*   Copyrights by ACcESS Australia, 2003 */  
19  /*   author: gross@access.edu.au */  /*   author: gross@access.edu.au */
20  /*   Version: $Id$ */  /*   Version: $Id$ */
21    
22  /**************************************************************/  /**************************************************************/
23    
 #include "Common.h"  
24  #include "Finley.h"  #include "Finley.h"
25  #include "Util.h"  #include "Util.h"
26  #ifdef _OPENMP  #ifdef _OPENMP
# Line 75  void Finley_Util_AddScatter(dim_t len,in Line 83  void Finley_Util_AddScatter(dim_t len,in
83     }     }
84  }  }
85    
86    #ifdef PASO_MPI
87    /* same as AddScatter(), but checks that value index[] is below an upper bound upperBound before  
88       addition. This is used to ensure that only the influence of local DOF is added */
89    /*        out(1:numData,index[p])+=in(1:numData,p)
90            where p = {k=1...len , index[k]<upperBound}*/
91    void Finley_Util_AddScatter_upperBound(dim_t len,index_t* index,dim_t numData,double* in,double * out, index_t upperBound){
92       dim_t i,s;
93       for (s=0;s<len;s++) {
94           for(i=0;i<numData;i++) {
95              //#pragma omp atomic
96              if( index[s]<upperBound )
97                out[INDEX2(i,index[s],numData)]+=in[INDEX2(i,s,numData)];
98           }
99       }
100    }  
101    
102    
103    #endif
104    
105  /*    multiplies two matrices */  /*    multiplies two matrices */
106    
107  /*          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 124  void Finley_Util_InvertSmallMat(dim_t le Line 151  void Finley_Util_InvertSmallMat(dim_t le
151                 D=1./D;                 D=1./D;
152                 invA[q]=D;                 invA[q]=D;
153              } else {              } else {
154                 Finley_ErrorCode=ZERO_DIVISION_ERROR;                 Finley_setError(ZERO_DIVISION_ERROR,"__FILE__: Non-regular matrix");
                sprintf(Finley_ErrorMsg,"Non-regular matrix");  
155                 return;                 return;
156              }              }
157           }           }
# Line 147  void Finley_Util_InvertSmallMat(dim_t le Line 173  void Finley_Util_InvertSmallMat(dim_t le
173                 invA[INDEX3(0,1,q,2,2)]=-A12*D;                 invA[INDEX3(0,1,q,2,2)]=-A12*D;
174                 invA[INDEX3(1,1,q,2,2)]= A11*D;                 invA[INDEX3(1,1,q,2,2)]= A11*D;
175              } else {              } else {
176                 Finley_ErrorCode=ZERO_DIVISION_ERROR;                 Finley_setError(ZERO_DIVISION_ERROR,"__FILE__: Non-regular matrix");
                sprintf(Finley_ErrorMsg,"Non-regular matrix");  
177                 return;                 return;
178              }              }
179           }           }
# Line 180  void Finley_Util_InvertSmallMat(dim_t le Line 205  void Finley_Util_InvertSmallMat(dim_t le
205                 invA[INDEX3(1,2,q,3,3)]=(A13*A21-A11*A23)*D;                 invA[INDEX3(1,2,q,3,3)]=(A13*A21-A11*A23)*D;
206                 invA[INDEX3(2,2,q,3,3)]=(A11*A22-A12*A21)*D;                 invA[INDEX3(2,2,q,3,3)]=(A11*A22-A12*A21)*D;
207              } else {              } else {
208                 Finley_ErrorCode=ZERO_DIVISION_ERROR;                 Finley_setError(ZERO_DIVISION_ERROR,"__FILE__: Non-regular matrix");
                sprintf(Finley_ErrorMsg,"Non-regular matrix");  
209                 return;                 return;
210              }              }
211           }           }
# Line 251  void  Finley_NormalVector(dim_t len, dim Line 275  void  Finley_NormalVector(dim_t len, dim
275              A21=A[INDEX3(1,0,q,2,dim1)];              A21=A[INDEX3(1,0,q,2,dim1)];
276              length = sqrt(A11*A11+A21*A21);              length = sqrt(A11*A11+A21*A21);
277              if (! length>0) {              if (! length>0) {
278                 Finley_ErrorCode=ZERO_DIVISION_ERROR;                 Finley_setError(ZERO_DIVISION_ERROR,"__FILE__: area equals zero.");
                sprintf(Finley_ErrorMsg,"area equals zero.");  
279                 return;                 return;
280              } else {              } else {
281                 invlength=1./length;                 invlength=1./length;
# Line 274  void  Finley_NormalVector(dim_t len, dim Line 297  void  Finley_NormalVector(dim_t len, dim
297              CO_A33=A11*A22-A21*A12;              CO_A33=A11*A22-A21*A12;
298              length=sqrt(CO_A13*CO_A13+CO_A23*CO_A23+CO_A33*CO_A33);              length=sqrt(CO_A13*CO_A13+CO_A23*CO_A23+CO_A33*CO_A33);
299              if (! length>0) {              if (! length>0) {
300                 Finley_ErrorCode=ZERO_DIVISION_ERROR;                 Finley_setError(ZERO_DIVISION_ERROR,"__FILE__: area equals zero.");
                sprintf(Finley_ErrorMsg,"area equals zero.");  
301                 return;                 return;
302              } else {              } else {
303                 invlength=1./length;                 invlength=1./length;
# Line 472  void Finley_copyDouble(dim_t n,double* s Line 494  void Finley_copyDouble(dim_t n,double* s
494    for (i=0;i<n;i++) target[i]=source[i];    for (i=0;i<n;i++) target[i]=source[i];
495  }  }
496    
497    #ifdef PASO_MPI
498    void Finley_printDoubleArray( FILE *fid, dim_t n, double *array, char *name  )
499    {
500      index_t i;
501      
502      if( name )
503        fprintf( fid, "%s [ ", name );
504      else
505        fprintf( fid, "[ " );  
506      for( i=0; i<(n<30 ? n : 30); i++ )
507        fprintf( fid, "%g ", array[i] );
508      if( n>=30 )
509        fprintf( fid, "... " );
510      fprintf( fid, "]\n" );
511    }
512    void Finley_printIntArray( FILE *fid, dim_t n, int *array, char *name  )
513    {
514      index_t i;
515      
516      if( name )
517        fprintf( fid, "%s [ ", name );
518      else
519        fprintf( fid, "[ " );  
520      for( i=0; i<(n<30 ? n : 30); i++ )
521        fprintf( fid, "%d ", array[i] );
522      if( n>=30 )
523        fprintf( fid, "... " );
524      fprintf( fid, "]\n" );
525    }
526    void Finley_printMaskArray( FILE *fid, dim_t n, int *array, char *name  )
527    {
528      index_t i;
529      
530      if( name )
531        fprintf( fid, "%s [ ", name );
532      else
533        fprintf( fid, "[ " );  
534      for( i=0; i<(n<30 ? n : 30); i++ )
535        if( array[i]!=-1 )
536          fprintf( fid, "%d ", array[i] );
537        else
538          fprintf( fid, "* " );
539      if( n>=30 )
540        fprintf( fid, "... " );
541      fprintf( fid, "]\n" );
542    }
543    #endif
544    
545  /*  /*
  * $Log$  
546   * Revision 1.8  2005/08/12 01:45:43  jgs   * Revision 1.8  2005/08/12 01:45:43  jgs
547   * erge of development branch dev-02 back to main trunk on 2005-08-12   *
548     * Revision 1.7.2.2  2005/09/07 06:26:22  gross
549     * the solver from finley are put into the standalone package paso now
550   *   *
551   * Revision 1.7.2.1  2005/08/04 22:41:11  gross   * Revision 1.7.2.1  2005/08/04 22:41:11  gross
552   * some extra routines for finley that might speed-up RHS assembling in some cases (not actived right now)   * some extra routines for finley that might speed-up RHS assembling in some cases (not actived right now)

Legend:
Removed from v.147  
changed lines
  Added in v.751

  ViewVC Help
Powered by ViewVC 1.1.26