Nektar++
Main Page
Related Pages
+
Namespaces
Namespace List
+
Namespace Members
+
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Functions
_
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
w
z
+
Variables
_
a
b
c
d
e
f
g
i
k
l
m
n
o
p
r
s
t
u
v
w
x
+
Typedefs
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
+
Enumerations
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
+
Enumerator
e
g
m
r
s
x
y
z
+
Classes
Class List
Class Index
Class Hierarchy
+
Class Members
+
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
+
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
+
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Typedefs
a
b
c
d
e
f
g
i
m
n
o
p
r
s
t
v
Enumerations
+
Enumerator
e
s
t
Properties
+
Related Functions
a
c
d
i
k
l
m
n
o
t
+
Files
File List
+
File Members
+
All
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
r
s
t
v
w
+
Functions
a
b
c
d
e
g
l
m
n
o
p
r
s
t
Variables
Typedefs
Enumerations
Enumerator
+
Macros
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
r
s
t
v
w
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Pages
Static Public Member Functions
|
List of all members
OneDArrayToPython< T > Struct Template Reference
Static Public Member Functions
static PyObject *
convert
(
Array
<
OneD
, T > const &arr)
Detailed Description
template<typename T>
struct OneDArrayToPython< T >
Definition at line
60
of file
SharedArray.cpp
.
Member Function Documentation
◆
convert()
template<typename T >
static PyObject*
OneDArrayToPython
< T >::convert
(
Array
<
OneD
, T > const &
arr
)
inline
static
Definition at line
62
of file
SharedArray.cpp
.
63
{
64
// Create a Python capsule to hold a pointer that contains a lightweight
65
// copy of arr. That way we guarantee Python will still have access to
66
// the memory allocated inside arr even if arr is deallocated in C++.
67
#if PY_MAJOR_VERSION == 2
68
py::object capsule(
69
py::handle<>(PyCObject_FromVoidPtr(
70
new
Array<OneD, T>
(arr), CapsuleDestructor<T>)));
71
#else
72
py::object capsule(
73
py::handle<>(PyCapsule_New(
74
new
Array<OneD, T>
(arr), 0,
75
(PyCapsule_Destructor)&CapsuleDestructor<T>)));
76
#endif
77
PyObject *tmp = py::incref(
78
np::from_data(
79
arr.data(), np::dtype::get_builtin<T>(),
80
py::make_tuple(arr.num_elements()), py::make_tuple(
sizeof
(T)),
81
capsule).ptr());
82
83
return
tmp;
84
}
Nektar::Array
Definition:
SharedArray.hpp:53
Generated on Wed Jan 20 2021 03:33:47 for Nektar++ by
1.8.13