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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6939 - (hide annotations)
Mon Jan 20 03:37:18 2020 UTC (5 weeks, 4 days ago) by uqaeller
File MIME type: text/plain
File size: 3649 byte(s)
Updated the copyright header.


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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26