/[escript]/trunk/ripley/src/domainhelpers.h
ViewVC logotype

Contents of /trunk/ripley/src/domainhelpers.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6141 - (show annotations)
Wed Apr 6 03:51:30 2016 UTC (2 years, 6 months ago) by caltinay
File MIME type: text/plain
File size: 2180 byte(s)
more namespacing of defines.

1
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2016 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 by Centre for Geoscience Computing (GeoComp)
14 *
15 *****************************************************************************/
16 #ifndef _RIPLEY_DOMAINHELPERS_H_
17 #define _RIPLEY_DOMAINHELPERS_H_
18
19 #include <ripley/Ripley.h>
20 #include <escript/Data.h>
21
22 namespace ripley {
23
24 typedef std::map<std::string, escript::Data> DataMap;
25
26 /// returns the data associated with the string key or an empty data object
27 /// if the map does not contain the given key
28 inline const escript::Data unpackData(const std::string target,
29 const DataMap& mapping)
30 {
31 DataMap::const_iterator i = mapping.find(target);
32 return (i == mapping.end() ? escript::Data() : i->second);
33 }
34
35 /**
36 returns true if the given string is in the mapping AND the resulting
37 coefficient is not empty
38 */
39 inline bool isNotEmpty(const std::string target, const DataMap& mapping)
40 {
41 DataMap::const_iterator i = mapping.find(target);
42 return i != mapping.end() && !i->second.isEmpty();
43 }
44
45 /**
46 sets va[a] = b and vb[b] = a, used in constructing CSC and CSR matrix
47 formats simultaneously
48 */
49 inline void doublyLink(std::vector<ripley::IndexVector>& va,
50 std::vector<ripley::IndexVector>& vb, int a, int b)
51 {
52 va[a].push_back(b);
53 vb[b].push_back(a);
54 }
55
56 /**
57 factorises 'product' and inserts the factors into the vector 'factors'
58 in order of smallest to largest
59 */
60 void factorise(std::vector<int>& factors, int product);
61
62 #ifdef ESYS_HAVE_BOOST_IO
63 /**
64 converts the given gzip compressed char vector into an uncompressed form
65 */
66 std::vector<char> unzip(const std::vector<char>& compressed);
67 #endif // ESYS_HAVE_BOOST_IO
68
69 } // namespace ripley
70
71 #endif // _RIPLEY_DOMAINHELPERS_H_
72

  ViewVC Help
Powered by ViewVC 1.1.26