MP-Gadget  5.0.1.dev1-76bc7d4726-dirty
Macros | Typedefs | Functions
peano.h File Reference
#include <stddef.h>
#include <stdint.h>
Include dependency graph for peano.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define BITS_PER_DIMENSION   21 /* for Peano-Hilbert order. Note: Maximum is 10 to fit in 32-bit integer ! */
 
#define PEANOCELLS   (((peano_t)1)<<(3*BITS_PER_DIMENSION))
 
#define DomainFac(len)   ( 1.0 / (len) * (((peano_t) 1) << (BITS_PER_DIMENSION)))
 

Typedefs

typedef uint64_t peano_t
 

Functions

peano_t peano_hilbert_key (int x, int y, int z, int bits)
 
static peano_t PEANO (double *Pos, double BoxSize)
 
void mysort_peano (void *b, size_t n, size_t s, int(*cmp)(const void *, const void *))
 
void init_peano_map (void)
 

Macro Definition Documentation

◆ BITS_PER_DIMENSION

#define BITS_PER_DIMENSION   21 /* for Peano-Hilbert order. Note: Maximum is 10 to fit in 32-bit integer ! */

Definition at line 9 of file peano.h.

◆ DomainFac

#define DomainFac (   len)    ( 1.0 / (len) * (((peano_t) 1) << (BITS_PER_DIMENSION)))

Definition at line 22 of file peano.h.

◆ PEANOCELLS

#define PEANOCELLS   (((peano_t)1)<<(3*BITS_PER_DIMENSION))

Definition at line 10 of file peano.h.

Typedef Documentation

◆ peano_t

typedef uint64_t peano_t

Definition at line 7 of file peano.h.

Function Documentation

◆ init_peano_map()

void init_peano_map ( void  )

◆ mysort_peano()

void mysort_peano ( void *  b,
size_t  n,
size_t  s,
int(*)(const void *, const void *)  cmp 
)

◆ PEANO()

static peano_t PEANO ( double *  Pos,
double  BoxSize 
)
inlinestatic

Definition at line 14 of file peano.h.

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 }
peano_t peano_hilbert_key(int x, int y, int z, int bits)
Definition: peano.c:119
uint64_t peano_t
Definition: peano.h:7
#define BITS_PER_DIMENSION
Definition: peano.h:9
#define DomainFac(len)
Definition: peano.h:22

References BITS_PER_DIMENSION, DomainFac, and peano_hilbert_key().

Referenced by do_density_test(), do_force_test(), do_tree_test(), init(), real_drift_particle(), and setup_particles().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ peano_hilbert_key()

peano_t peano_hilbert_key ( int  x,
int  y,
int  z,
int  bits 
)

This function computes a Peano-Hilbert key for an integer triplet (x,y,z), with x,y,z in the range between 0 and 2^bits-1.

Definition at line 119 of file peano.c.

120 {
121  int mask;
122  unsigned char rotation = 0;
123  peano_t key = 0;
124 
125  for(mask = 1 << (bits - 1); mask > 0; mask >>= 1)
126  {
127  unsigned char pix = ((x & mask) ? 4 : 0) | ((y & mask) ? 2 : 0) | ((z & mask) ? 1 : 0);
128 
129  key <<= 3;
130  key |= subpix3[rotation][pix];
131  rotation = rottable3[rotation][pix];
132  }
133 
134  return key;
135 }
const unsigned char subpix3[48][8]
Definition: peano.c:65
const unsigned char rottable3[48][8]
Definition: peano.c:14

References rottable3, and subpix3.

Referenced by force_create_node_for_topnode(), and PEANO().

Here is the caller graph for this function: