/[escript]/trunk/finley/src/Util.h
ViewVC logotype

Annotation of /trunk/finley/src/Util.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6651 - (hide annotations)
Wed Feb 7 02:12:08 2018 UTC (22 months ago) by jfenwick
File MIME type: text/plain
File size: 3573 byte(s)
Make everyone sad by touching all the files

Copyright dates update

1 elspeth 626
2 jfenwick 3981 /*****************************************************************************
3 ksteube 1811 *
4 jfenwick 6651 * Copyright (c) 2003-2018 by The University of Queensland
5 jfenwick 3981 * http://www.uq.edu.au
6 ksteube 1811 *
7     * Primary Business: Queensland, Australia
8 jfenwick 6112 * Licensed under the Apache License, version 2.0
9     * http://www.apache.org/licenses/LICENSE-2.0
10 ksteube 1811 *
11 jfenwick 3981 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 jfenwick 4657 * Development 2012-2013 by School of Earth Sciences
13     * Development from 2014 by Centre for Geoscience Computing (GeoComp)
14 jfenwick 3981 *
15     *****************************************************************************/
16 ksteube 1312
17 caltinay 6156 /// Some utility routines
18 ksteube 1811
19 caltinay 4441 #ifndef __FINLEY_UTIL_H__
20     #define __FINLEY_UTIL_H__
21 jgs 82
22 jgs 150 #include "Finley.h"
23    
24 caltinay 4441 #include <escript/Data.h>
25 jgs 82
26 caltinay 4441 namespace finley {
27     namespace util {
28 jgs 82
29 caltinay 6156 typedef std::pair<index_t,index_t> IndexPair;
30     typedef std::vector<IndexPair> ValueAndIndexList;
31 jgs 82
32 caltinay 6156 /// orders a ValueAndIndexList by value.
33 caltinay 4441 void sortValueAndIndex(ValueAndIndexList& array);
34 jgs 102
35 caltinay 4441 /// returns true if the data object is defined on reduced element types
36     inline bool hasReducedIntegrationOrder(const escript::Data& in)
37     {
38     const int fs = in.getFunctionSpace().getTypeCode();
39     return (fs == FINLEY_REDUCED_ELEMENTS || fs == FINLEY_REDUCED_FACE_ELEMENTS
40     || fs == FINLEY_REDUCED_CONTACT_ELEMENTS_1
41     || fs == FINLEY_REDUCED_CONTACT_ELEMENTS_2);
42     }
43 bcumming 751
44 caltinay 6156 /// gathers values into array `out` from array `in` using `index`:
45     /// out(1:numData, 1:len) := in(1:numData, index(1:len))
46     void gather(int len, const index_t* index, int numData, const double* in,
47 caltinay 4441 double* out);
48 gross 1716
49 caltinay 6156 /// adds array `in` into `out` using an `index`:
50     /// out(1:numData,index[p])+=in(1:numData,p) where
51     /// p={k=1...len, index[k]<upperBound}
52 caltinay 6355 template<typename Scalar>
53 caltinay 6156 void addScatter(int len, const index_t* index, int numData,
54 caltinay 6355 const Scalar* in, Scalar* out, index_t upperBound);
55 jgs 82
56 caltinay 6156 /// multiplies two matrices: A(1:A1,1:A2) := B(1:A1,1:B2)*C(1:B2,1:A2)
57 caltinay 4499 void smallMatMult(int A1, int A2, double* A, int B2,
58     const std::vector<double>& B,
59     const std::vector<double>& C);
60 jgs 82
61 caltinay 6156 /// multiplies a set of matrices with a single matrix:
62     /// A(1:A1,1:A2,i)=B(1:A1,1:B2,i)*C(1:B2,1:A2) for i=1,len
63 caltinay 6566 template<typename Scalar>
64     void smallMatSetMult1(int len, int A1, int A2, Scalar* A, int B2,
65     const std::vector<Scalar>& B,
66 caltinay 4499 const std::vector<double>& C);
67 jgs 123
68 caltinay 4441 void invertSmallMat(int len, int dim, const double* A, double *invA,
69     double* det);
70    
71 caltinay 6156 /// returns the normalized vector normal[dim,len] orthogonal to A(:,0,q) and
72     /// A(:,1,q) in the case of dim=3, or the vector A(:,0,q) in the case of dim=2
73 caltinay 4441 void normalVector(int len, int dim, int dim1, const double* A, double* Normal);
74    
75 caltinay 5692 index_t getMinInt(int dim, dim_t N, const index_t* values);
76 caltinay 4441
77 caltinay 5692 index_t getMaxInt(int dim, dim_t N, const index_t* values);
78 caltinay 4441
79 caltinay 6156 /// calculates the minimum and maximum value from an integer array of length
80     /// N x dim
81     IndexPair getMinMaxInt(int dim, dim_t N, const index_t* values);
82 caltinay 4441
83 caltinay 6156 /// calculates the minimum and maximum value from an integer array of length N
84     /// disregarding the value `ignore`
85     IndexPair getFlaggedMinMaxInt(dim_t N, const index_t* values, index_t ignore);
86 caltinay 4441
87 caltinay 6156 /// extracts the positive entries in `mask` returning a contiguous vector of
88     /// those entries
89 caltinay 5692 std::vector<index_t> packMask(const std::vector<short>& mask);
90 caltinay 4441
91 caltinay 6156 void setValuesInUse(const int* values, dim_t numValues,
92     std::vector<int>& valuesInUse, escript::JMPI mpiInfo);
93 caltinay 4441
94     } // namespace util
95     } // namespace finley
96    
97     #endif // __FINLEY_UTIL_H__
98    

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26