/[escript]/branches/trilinos_from_5897/dudley/src/Util.h
ViewVC logotype

Diff of /branches/trilinos_from_5897/dudley/src/Util.h

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

revision 6078 by caltinay, Wed Mar 2 04:13:26 2016 UTC revision 6079 by caltinay, Mon Mar 21 12:22:38 2016 UTC
# Line 14  Line 14 
14  *  *
15  *****************************************************************************/  *****************************************************************************/
16    
17  /****************************************************************************/  /// Some utility routines
   
 /*   Some utility routines */  
   
 /****************************************************************************/  
18    
19  #ifndef __DUDLEY_UTIL_H__  #ifndef __DUDLEY_UTIL_H__
20  #define __DUDLEY_UTIL_H__  #define __DUDLEY_UTIL_H__
21    
22  #include "Dudley.h"  #include "Dudley.h"
23    
24    #include <escript/Data.h>
25    
26  namespace dudley {  namespace dudley {
27    namespace util {
28    
29    typedef std::pair<index_t,index_t> IndexPair;
30    typedef std::vector<IndexPair> ValueAndIndexList;
31    
32    /// orders a ValueAndIndexList by value.
33    void sortValueAndIndex(ValueAndIndexList& array);
34    
35  void Dudley_Util_Gather_double(dim_t len, index_t * index, dim_t numData, double *in, double *out);  /// gathers values into array `out` from array `in` using `index`:
36  void Dudley_Util_Gather_int(dim_t len, index_t * index, dim_t numData, index_t * in, index_t * out);  ///   out(1:numData, 1:len) := in(1:numData, index(1:len))
37  void Dudley_Util_AddScatter(const dim_t len, const index_t * index, const dim_t numData, const double *in, double *out, const index_t upperBound);  void gather(int len, const index_t* index, int numData, const double* in,
38  void Dudley_Util_SmallMatMult(dim_t A1, dim_t A2, double *A, dim_t B2, const double *B, const double *C);              double* out);
39  void Dudley_Util_SmallMatSetMult(dim_t len, dim_t A1, dim_t A2, double *A, dim_t B2, const double *B, const double *C);  
40  void Dudley_Util_SmallMatSetMult1(dim_t len, dim_t A1, dim_t A2, double *A, dim_t B2, const double *B, const double *C);  /// adds array `in` into `out` using an `index`:
41  void Dudley_Util_InvertSmallMat(dim_t len, dim_t dim, double *A, double *invA, double *det);  ///   out(1:numData,index[p])+=in(1:numData,p) where
42  void Dudley_Util_DetOfSmallMat(dim_t len, dim_t dim, double *A, double *det);  ///   p={k=1...len, index[k]<upperBound}
43  void Dudley_NormalVector(dim_t len, dim_t dim, dim_t dim1, double *A, double *Normal);  void addScatter(int len, const index_t* index, int numData,
44  void Dudley_LengthOfNormalVector(dim_t len, dim_t dim, dim_t dim1, double *A, double *length);                  const double* in, double *out, index_t upperBound);
45  void Dudley_Util_InvertMap(dim_t, index_t *, dim_t, index_t *);  
46  index_t Dudley_Util_getMaxInt(dim_t dim, dim_t N, index_t * values);  /// multiplies two matrices: A(1:A1,1:A2) := B(1:A1,1:B2)*C(1:B2,1:A2)
47  index_t Dudley_Util_getMinInt(dim_t dim, dim_t N, index_t * values);  void smallMatMult(int A1, int A2, double* A, int B2, const double* B,
48  index_t Dudley_Util_getFlaggedMaxInt(dim_t dim, dim_t N, index_t * values, index_t ignore);                    const double* C);
49  index_t Dudley_Util_getFlaggedMinInt(dim_t dim, dim_t N, index_t * values, index_t ignore);  
50  dim_t Dudley_Util_packMask(dim_t N, index_t * mask, index_t * index);  /// multiplies a set of matrices with a single matrix:
51  bool Dudley_Util_isAny(dim_t N, index_t * array, index_t value);  ///   A(1:A1,1:A2,i)=B(1:A1,1:B2,i)*C(1:B2,1:A2) for i=1,len
52  index_t Dudley_Util_cumsum(dim_t, index_t *);  void smallMatSetMult1(int len, int A1, int A2, double* A, int B2,
53  bool Dudley_Util_anyNonZeroDouble(dim_t N, double *values);                        const double* B, const double* C);
54  void Dudley_Util_setValuesInUse(const index_t* values, dim_t numValues, dim_t* numValuesInUse,  
55                                  index_t** valuesInUse, escript::JMPI& mpiinfo);  /// returns the normalized vector normal[dim,len] orthogonal to A(:,0,q) and
56    /// A(:,1,q) in the case of dim=3, or the vector A(:,0,q) in the case of dim=2
57  #ifdef ESYS_MPI  void normalVector(dim_t len, int dim, int dim1, const double* A, double* normal);
58  void Dudley_printDoubleArray(FILE * fid, dim_t n, double *array, char *name);  
59  void Dudley_printIntArray(FILE * fid, dim_t n, int *array, char *name);  /// calculates the minimum and maximum value from an integer array of length
60  void Dudley_printMaskArray(FILE * fid, dim_t n, int *array, char *name);  /// N x dim
61  #endif  IndexPair getMinMaxInt(int dim, dim_t N, const index_t* values);
62    
63  /* Dudley_Util_orderValueAndIndex is used to sort items by a value */  /// calculates the minimum and maximum value from an integer array of length N
64  /* index points to the location of the original item array. */  /// disregarding the value `ignore`
65  /* it can be used to reorder the array */  IndexPair getFlaggedMinMaxInt(dim_t N, const index_t* values, index_t ignore);
66  struct Dudley_Util_ValueAndIndex {  
67      index_t index;  /// extracts the positive entries in `mask` returning a contiguous vector of
68      index_t value;  /// those entries
69  };  std::vector<index_t> packMask(const std::vector<short>& mask);
 typedef struct Dudley_Util_ValueAndIndex Dudley_Util_ValueAndIndex;  
70    
71  void Dudley_Util_sortValueAndIndex(dim_t n, Dudley_Util_ValueAndIndex * array);  void setValuesInUse(const index_t* values, dim_t numValues,
72  int Dudley_Util_ValueAndIndex_compar(const void *, const void *);                      std::vector<int>& valuesInUse, escript::JMPI mpiInfo);
73    
74    } // namespace util
75  } // namespace dudley  } // namespace dudley
76    
77  #endif // __DUDLEY_UTIL_H__  #endif // __DUDLEY_UTIL_H__

Legend:
Removed from v.6078  
changed lines
  Added in v.6079

  ViewVC Help
Powered by ViewVC 1.1.26