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

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

Parent Directory Parent Directory | Revision Log Revision Log


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


1
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2020 by The University of Queensland
5 * http://www.uq.edu.au
6 *
7 * Primary Business: Queensland, Australia
8 * Licensed under the Apache License, version 2.0
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 * Development 2012-2013 by School of Earth Sciences
13 * Development from 2014-2017 by Centre for Geoscience Computing (GeoComp)
14 * Development from 2019 by School of Earth and Environmental Sciences
15 **
16 *****************************************************************************/
17
18 /// Some utility routines
19
20 #ifndef __FINLEY_UTIL_H__
21 #define __FINLEY_UTIL_H__
22
23 #include "Finley.h"
24
25 #include <escript/Data.h>
26
27 namespace finley {
28 namespace util {
29
30 typedef std::pair<index_t,index_t> IndexPair;
31 typedef std::vector<IndexPair> ValueAndIndexList;
32
33 /// orders a ValueAndIndexList by value.
34 void sortValueAndIndex(ValueAndIndexList& array);
35
36 /// 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
45 /// 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 double* out);
49
50 /// 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 template<typename Scalar>
54 void addScatter(int len, const index_t* index, int numData,
55 const Scalar* in, Scalar* out, index_t upperBound);
56
57 /// multiplies two matrices: A(1:A1,1:A2) := B(1:A1,1:B2)*C(1:B2,1:A2)
58 void smallMatMult(int A1, int A2, double* A, int B2,
59 const std::vector<double>& B,
60 const std::vector<double>& C);
61
62 /// 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 template<typename Scalar>
65 void smallMatSetMult1(int len, int A1, int A2, Scalar* A, int B2,
66 const std::vector<Scalar>& B,
67 const std::vector<double>& C);
68
69 void invertSmallMat(int len, int dim, const double* A, double *invA,
70 double* det);
71
72 /// 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 void normalVector(int len, int dim, int dim1, const double* A, double* Normal);
75
76 index_t getMinInt(int dim, dim_t N, const index_t* values);
77
78 index_t getMaxInt(int dim, dim_t N, const index_t* values);
79
80 /// 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
84 /// 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
88 /// extracts the positive entries in `mask` returning a contiguous vector of
89 /// those entries
90 std::vector<index_t> packMask(const std::vector<short>& mask);
91
92 void setValuesInUse(const int* values, dim_t numValues,
93 std::vector<int>& valuesInUse, escript::JMPI mpiInfo);
94
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