box.h 737 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#ifndef BOX_H
#define BOX_H

enum dimension_aliases { X, Y, Z, N_DIMS };

typedef struct
{
   int coords[N_DIMS];
   int extents[N_DIMS];
   long volume;
} box_t;

// Meta-Information for MPI-Type creation
#define BOX_T_N_INT_MEMBERS 2 * N_DIMS
#define BOX_T_FIRST_INT_MEMBER coords[0]
#define BOX_T_N_LONG_MEMBERS 1
#define BOX_T_FIRST_LONG_MEMBER volume

void box_set_volume(box_t *b);

void box_intersect(const box_t *a, const box_t *b, box_t *intersection);

int box_is_empty(const box_t *b);

void box_split(const box_t *box, box_t *a, box_t *b);

void box_decompose(const box_t *original, int n_boxes, box_t *boxes);

void box_grow(box_t *box, int extra_width);

char *box_to_string(const box_t *box, char *buf, int size);

#endif