MP-Gadget  5.0.1.dev1-76bc7d4726-dirty
peano.h
Go to the documentation of this file.
1 #ifndef PEANO_H
2 #define PEANO_H
3 
4 #include <stddef.h>
5 #include <stdint.h>
6 
7 typedef uint64_t peano_t;
8 
9 #define BITS_PER_DIMENSION 21 /* for Peano-Hilbert order. Note: Maximum is 10 to fit in 32-bit integer ! */
10 #define PEANOCELLS (((peano_t)1)<<(3*BITS_PER_DIMENSION))
11 
12 peano_t peano_hilbert_key(int x, int y, int z, int bits);
13 
14 static inline peano_t PEANO(double *Pos, double BoxSize)
15 {
16  /*No reason known for the Box/2000 and 1.001 factors*/
17  const double DomainFac = 1.0 / (BoxSize*1.001) * (((peano_t) 1) << (BITS_PER_DIMENSION));
18  const double spos[3] = {Pos[0] + BoxSize/2000, Pos[1] + BoxSize/2000, Pos[2] + BoxSize/2000};
19  return peano_hilbert_key(spos[0]*DomainFac, spos[1]*DomainFac, spos[2]*DomainFac, BITS_PER_DIMENSION);
20 }
21 
22 #define DomainFac(len) ( 1.0 / (len) * (((peano_t) 1) << (BITS_PER_DIMENSION)))
23 
24 void mysort_peano(void *b, size_t n, size_t s, int (*cmp) (const void *, const void *));
25 
26 void init_peano_map(void);
27 
28 #endif
peano_t peano_hilbert_key(int x, int y, int z, int bits)
Definition: peano.c:119
void mysort_peano(void *b, size_t n, size_t s, int(*cmp)(const void *, const void *))
static peano_t PEANO(double *Pos, double BoxSize)
Definition: peano.h:14
void init_peano_map(void)
uint64_t peano_t
Definition: peano.h:7
#define BITS_PER_DIMENSION
Definition: peano.h:9
#define DomainFac(len)
Definition: peano.h:22