rebl-AMR
definitions.h
Go to the documentation of this file.
1 #ifndef _DEFINITIONS_H_
2 #define _DEFINITIONS_H_
3 #include <algorithm>
4 #include <bitset>
5 #include <cstdint>
6 #include <cstdio>
7 #include <cstdlib>
8 #include <functional>
9 #include <iostream>
10 #include <stack>
11 #include <unordered_map>
12 #include <vector>
13 #include <list>
14 #include <unistd.h>
15 #include <mpi.h>
16 #include <memory>
17 #include <time.h>
18 #include <stdexcept>
19 #include "zoltan.h"
20 #include <cstddef>
21 #include <string>
22 #include <fstream>
23 #include <sstream>
24 #include <string>
25 #include <unordered_set>
26 #include <utility>
27 #include <iomanip>
28 #include <cmath>
29 #include <assert.h>
30 #include "params.h"
31 #include <locale>
32 
33 #define hash 0
34 #define nonnative 1
37 using real = double;
38 using uint = unsigned int;
39 using integer = int;
40 using namespace std;
41 
42 // Major data structure used in this research
43 
44 template <size_t N>
45 using morton = std::bitset<N>;
47 #if(nonnaitive)
48 #if ( hash )
49 template <size_t N>
50 class morton_hash
51 {
52  public:
53  size_t operator()( const morton<N> key ) const // <-- don't forget const, means this function is not allowed to modify the object
54  {
55  morton<N> kt;
56  /*
57  for(uint i=0;i<N;i++)
58  {
59  kt[i]=key[N-i-1];
60  }
61  */
62  // kt=key;
63  size_t hashval = 0;
64  hashval = key.to_ulong();
65  return hashval;
66  }
67 };
68 
69 template <size_t N, typename value>
70 using bitmap = std::unordered_map<morton<N>, value *, morton_hash<N>>;
73 #else
74 
75 template <size_t N>
76 class compare
77 {
78  public:
79  bool operator()( const morton<N> &a, const morton<N> &b ) const
80  {
81  return a.to_ullong() < b.to_ullong();
82  }
83 };
84 
85 template <size_t N, typename value>
86 using bitmap = std::map<morton<N>, value *, compare<N>>;
88 #endif
89 // using bitmapgeom=std::unordered_map<morton , uint >; /*! \var typedef unordered_map used in amrMesh Class*/
90 
91 #else
92 template <size_t N, typename value>
93 using bitmap = std::unordered_map<morton<N>, value *>;
96 #endif
97 
98 template <size_t M>
99 using bitlist = std::list<morton<M>>;
101 template <size_t N>
102 using bitvector = std::vector<morton<N>>;
103 
104 template <size_t N>
105 using bitunorderedset = std::unordered_set<morton<N>>;
106 
107 /*
108  * \brief function to put commas in the output, e.g. 1000 >> 1,000
109  *
110  * */
111 template<class T>
112 std::string FormatWithCommas(T value)
113 {
114  std::stringstream ss;
115  ss.imbue(std::locale(""));
116  ss << std::fixed << value;
117  return ss.str();
118 }
119 
120 
121 
122 
123 
124 #define RED "\033[01;31m"
125 #define GREEN "\033[22;32m"
126 #define YELLOW "\033[22;33m"
127 #define BLUE "\033[22;34m"
128 #define MAGENTA "\033[22;35m"
129 #define CYAN "\033[22;36m"
130 #define RESET "\033[22;0m"
131 
132 #endif
std::list< morton< M > > bitlist
Definition: definitions.h:99
int integer
Definition: definitions.h:39
std::unordered_set< morton< N > > bitunorderedset
Definition: definitions.h:105
std::vector< morton< N > > bitvector
Definition: definitions.h:102
std::unordered_map< morton< N >, value * > bitmap
Definition: definitions.h:93
std::bitset< N > morton
Definition: definitions.h:45
unsigned int uint
Definition: definitions.h:38
std::string FormatWithCommas(T value)
Definition: definitions.h:112