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
34
35
36
37
38
39
40
41
42
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
77
78
79
80
81
82
83
84
85
86
|
/******************************************************************************
*
* MantaFlow fluid solver framework
* Copyright 2017 Steffen Wiewel, Moritz Baecher, Rachel Chu
*
* This program is free software, distributed under the terms of the
* Apache License, Version 2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Convert mantaflow grids to/from numpy arrays
*
******************************************************************************/
#ifdef _PCONVERT_H
# ifndef _NUMPYCONVERT_H
# define _NUMPYCONVERT_H
enum NumpyTypes {
N_BOOL = 0,
N_BYTE,
N_UBYTE,
N_SHORT,
N_USHORT,
N_INT,
N_UINT,
N_LONG,
N_ULONG,
N_LONGLONG,
N_ULONGLONG,
N_FLOAT,
N_DOUBLE,
N_LONGDOUBLE,
N_CFLOAT,
N_CDOUBLE,
N_CLONGDOUBLE,
N_OBJECT = 17,
N_STRING,
N_UNICODE,
N_VOID,
/*
* New 1.6 types appended, may be integrated
* into the above in 2.0.
*/
N_DATETIME,
N_TIMEDELTA,
N_HALF,
N_NTYPES,
N_NOTYPE,
N_CHAR, /* special flag */
N_USERDEF = 256, /* leave room for characters */
/* The number of types not including the new 1.6 types */
N_NTYPES_ABI_COMPATIBLE = 21
};
namespace Manta {
class PyArrayContainer {
public:
/// Constructors
PyArrayContainer(void *_pParentPyArray);
PyArrayContainer(const PyArrayContainer &_Other);
~PyArrayContainer();
/// Operators
PyArrayContainer &operator=(const PyArrayContainer &_Other);
private:
void ExtractData(void *_pParentPyArray);
public:
void *pData;
NumpyTypes DataType;
unsigned int TotalSize;
std::vector<long> Dims;
private:
void *pParentPyArray;
};
// template<> PyArrayContainer* fromPyPtr<PyArrayContainer>(PyObject* obj, std::vector<void*>*
// tmp);
template<> PyArrayContainer fromPy<PyArrayContainer>(PyObject *obj);
} // namespace Manta
# endif
#endif
|