wbox.h 5.09 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
#include <complex.h> // todo: create gcc g++ compatibility. See wdata, winterp, wderiv for template
#include <stdio.h>
#include <stdlib.h>

typedef struct
{
    int ix;
    int iy;
    int iz;
} wbox_insert_t;
Andrzej MakowskI's avatar
Andrzej MakowskI committed
11
12
13
14
15
16
17
18
19
20
21
22
23
24

typedef struct
{
    int nx;
    int ny;
    int nz;

    int dim;

    void *data;
} wbox_md_t;

// SUCCESS
#define WBOX_SUCCESS_INIT EXIT_SUCCESS
25

Andrzej MakowskI's avatar
Andrzej MakowskI committed
26
#define WBOX_SUCCESS_INSERT EXIT_SUCCESS
27
28
#define WBOX_SUCCESS_INSERT_CHECK EXIT_SUCCESS

Andrzej MakowskI's avatar
Andrzej MakowskI committed
29
#define WBOX_SUCCESS_MERGE EXIT_SUCCESS
30

Andrzej MakowskI's avatar
Andrzej MakowskI committed
31
32
33
34
#define WBOX_SUCCESS_ROTATE EXIT_SUCCESS

// ERRORS
#define WBOX_ERR_INIT_DIM 0001
35
36
#define WBOX_ERR_INIT_DATATYPE_NOT_IMPLEMENTED 0002

Andrzej MakowskI's avatar
Andrzej MakowskI committed
37
#define WBOX_ERR_INSERT 1000
38

Andrzej MakowskI's avatar
Andrzej MakowskI committed
39
#define WBOX_ERR_MERGE 2000
40

Andrzej MakowskI's avatar
Andrzej MakowskI committed
41
42
#define WBOX_ERR_ROTATE 3000

43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/**
 * @brief Function to initialize latice
 *
 * @param wbmd [out] - pointer to WBox metadata structure. Each WBox structure is responsible for only one variable, like rho_a
 * @param nx [in] - number of lattice points in OX direction {int}
 * @param ny [in] - number of lattice points in OY direction
 * @param nz [in] - number of lattice points in OZ direction
 * @param datatype [in] - character describing type of data. Can be 'i'nteger, 'r'eal (double), 'c'omplex (double complex)
 * @param data [in] - pointer to a data of `datatype` type
 * @return `WBOX_SUCCESS_INIT` or `WBOX_ERR_INIT` with help description
 */
int wbox_init(wbox_md_t *wbmd, const int nx, const int ny, const int nz, const char datatype, const void *data);

/**
 * @brief Function that inserts data from smaller 1D box (`wmbd`) into the 1D bigger box(`wmbd_big`) that is anchored in `wbox_insert`.
 * Function checks the anchor placements.
 *
 * @param wbmd [in] - `wbox_md_t` type that stores the information about data from small box
 * @param wbox_insert [in] - `wbox_insert_t` type that stores the information about the anchor point
 * @param wbmd_big [out] - `wbox_md_t` type that stores the information about data from big box
 * @return `WBOX_SUCCESS_INSERT` or `WBOX_ERR_INSERT` with help description
 */
int wbox_insert_1d(const wbox_md_t *wbmd, const wbox_insert_t wbox_insert, wbox_md_t *wbmd_big);

/**
 * @brief Function that inserts data from smaller 2D box (`wmbd`) into the 2D bigger box(`wmbd_big`) that is anchored in `wbox_insert`.
 * Function checks the anchor placements.
 *
 * @param wbmd [in] - `wbox_md_t` type that stores the information about data from small box
 * @param wbox_insert [in] - `wbox_insert_t` type that stores the information about the anchor point
 * @param wbmd_big [out] - `wbox_md_t` type that stores the information about data from big box
 * @return `WBOX_SUCCESS_INSERT` or `WBOX_ERR_INSERT` with help description
 */
int wbox_insert_2d(const wbox_md_t *wbmd, const wbox_insert_t wbox_insert, wbox_md_t *wbmd_big);
Andrzej MakowskI's avatar
Andrzej MakowskI committed
77

78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/**
 * @brief Function that inserts data from smaller 3D box (`wmbd`) into the 3D bigger box(`wmbd_big`) that is anchored in `wbox_insert`.
 * Function checks the anchor placements.
 *
 * @param wbmd [in] - `wbox_md_t` type that stores the information about data from small box
 * @param wbox_insert [in] - `wbox_insert_t` type that stores the information about the anchor point
 * @param wbmd_big [out] - `wbox_md_t` type that stores the information about data from big box
 * @return `WBOX_SUCCESS_INSERT` or `WBOX_ERR_INSERT` with help description
 */
int wbox_insert_3d(const wbox_md_t *wbmd, const wbox_insert_t wbox_insert, wbox_md_t *wbmd_big);

/**
 * @brief Master function that inserts data from smaller box (`wmbd`) into the bigger box(`wmbd_big`) that is anchored in `wbox_insert`.
 * Function checks the anchor placements. First checks the dimension of box and places calls adequate insert function
 *
 * @param wbmd [in] - `wbox_md_t` type that stores the information about data from small box
 * @param wbox_insert [in] - `wbox_insert_t` type that stores the information about the anchor point
 * @param wbmd_big [out] - `wbox_md_t` type that stores the information about data from big box
 * @return `WBOX_SUCCESS_INSERT` or `WBOX_ERR_INSERT` with help description
 */
int wbox_insert(const wbox_md_t *wbmd, const wbox_insert_t wbox_insert, wbox_md_t *wbmd_big);

/**
 * @brief Function that checks the possible errors for inserting a data from small box into big box.
 *
 * @param wbmd [in] - `wbox_md_t` type that stores the information about data from small box
 * @param wbox_insert [in] - `wbox_insert_t` type that stores the information about the anchor point
 * @param wbmd_big [out] - `wbox_md_t` type that stores the information about data from big box
 * @return `WBOX_SUCCESS_INSERT_CHECK` or `WBOX_ERR_INSERT_CHECK` with help description
 */
int wbox_insert_check(const wbox_md_t *wbmd, const wbox_insert_t wbox_insert, wbox_md_t *wbmd_big);
Andrzej MakowskI's avatar
Andrzej MakowskI committed
109
110
111
112
113
114
115
116
117

int wbox_merge1d(const wbox_md_t *wbmd_one, const wbox_md_t *wbmd_two, wbox_md_t *wbmd_result);
int wbox_merge2d(const wbox_md_t *wbmd_one, const wbox_md_t *wbmd_two, wbox_md_t *wbmd_result);
int wbox_merge3d(const wbox_md_t *wbmd_one, const wbox_md_t *wbmd_two, wbox_md_t *wbmd_result);
int wbox_merge(const wbox_md_t *wbmd_one, const wbox_md_t *wbmd_two, wbox_md_t *wbmd_result);

int wbox_rotate2d(wbox_md_t *wbmd);
int wbox_rotate3d(wbox_md_t *wbmd);
int wbox_rotate(wbox_md_t *wbmd);