Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
Nektar
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
55
Issues
55
List
Boards
Labels
Milestones
Merge Requests
33
Merge Requests
33
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nektar
Nektar
Commits
4700e650
Commit
4700e650
authored
Jan 22, 2019
by
Kurt Sansom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
format tabs to spaces
parent
b2b972ab
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
104 additions
and
104 deletions
+104
-104
NekPy_MemoryTest_PythonToCpp_Address.py
library/Demos/Python/NekPy_MemoryTest_PythonToCpp_Address.py
+15
-15
NekPy_ReferenceTest_CppDeleteFirst.py
library/Demos/Python/NekPy_ReferenceTest_CppDeleteFirst.py
+43
-43
NekPy_ReferenceTest_PythonDeleteFirst.py
...ary/Demos/Python/NekPy_ReferenceTest_PythonDeleteFirst.py
+46
-46
No files found.
library/Demos/Python/NekPy_MemoryTest_PythonToCpp_Address.py
View file @
4700e650
...
...
@@ -6,27 +6,27 @@ import gc
import
sys
def
main
():
session_name
=
[
"memory-test-python-to-c-address.py"
,
"newsquare_2x2.xml"
]
session_name
=
[
"memory-test-python-to-c-address.py"
,
"newsquare_2x2.xml"
]
session
=
SessionReader
.
CreateInstance
(
session_name
)
graph
=
MeshGraph
.
Read
(
session
)
exp
=
ExpList2D
(
session
,
graph
)
session
=
SessionReader
.
CreateInstance
(
session_name
)
graph
=
MeshGraph
.
Read
(
session
)
exp
=
ExpList2D
(
session
,
graph
)
coords
=
exp
.
GetCoords
()
coords
=
coords
[
0
]
coords
=
exp
.
GetCoords
()
coords
=
coords
[
0
]
coords_data_address
=
str
(
hex
(
coords
.
ctypes
.
data
))
.
rstrip
(
'L'
)
coords_data_address
=
str
(
hex
(
coords
.
ctypes
.
data
))
.
rstrip
(
'L'
)
print
"The memory address of data is: {}
\n
"
.
format
(
coords_data_address
)
print
(
"The memory address of data is: {}
\n
"
.
format
(
coords_data_address
)
)
exp
.
SetPhysArray
(
coords
)
phys_data_address
=
exp
.
GetPhysAddress
()
print
"The memory address of array data is: {}
\n
"
.
format
(
phys_data_address
)
exp
.
SetPhysArray
(
coords
)
phys_data_address
=
exp
.
GetPhysAddress
()
print
(
"The memory address of array data is: {}
\n
"
.
format
(
phys_data_address
)
)
if
coords_data_address
==
phys_data_address
:
print
(
"Test successful!"
)
else
:
print
(
"Test unsuccessful"
)
if
coords_data_address
==
phys_data_address
:
print
(
"Test successful!"
)
else
:
print
(
"Test unsuccessful"
)
if
__name__
==
'__main__'
:
main
()
library/Demos/Python/NekPy_ReferenceTest_CppDeleteFirst.py
View file @
4700e650
...
...
@@ -7,51 +7,51 @@ import sys
import
numpy
as
np
def
get_refcount
(
coords_address
):
gc
.
collect
()
return
ctypes
.
c_long
.
from_address
(
coords_address
)
.
value
gc
.
collect
()
return
ctypes
.
c_long
.
from_address
(
coords_address
)
.
value
def
main
():
session_name
=
[
"memory-test-python-to-c-address.py"
,
"newsquare_2x2.xml"
]
expected_test_outcome
=
[
1
,
2
,
1
,
-
9.187094450483263e-15
]
actual_test_outcome
=
[]
session
=
SessionReader
.
CreateInstance
(
session_name
)
graph
=
MeshGraph
.
Read
(
session
)
exp
=
ExpList2D
(
session
,
graph
)
print
(
"Loaded session:
%
s"
%
session
.
GetSessionName
())
print
(
"Loaded MeshGraph of dimension:
%
d
\n
"
%
graph
.
GetMeshDimension
())
print
(
"Retrieving coordinates..."
)
coords
=
exp
.
GetCoords
()
coords_subs
=
coords
[
1
]
coords
=
coords
[
0
]
coords_address
=
id
(
coords
)
print
(
"Retrieved coordinates."
)
print
(
"Reference count for expansion coordinates:
%
d
\n
"
%
get_refcount
(
coords_address
))
actual_test_outcome
.
append
(
get_refcount
(
coords_address
))
print
(
"Setting PhysArray (exp.SetPhysArray())..."
)
exp
.
SetPhysArray
(
coords
)
print
(
"exp.SetPhysArray() completed."
)
print
(
"Reference count for expansion coordinates:
%
d
\n
"
%
get_refcount
(
coords_address
))
actual_test_outcome
.
append
(
get_refcount
(
coords_address
))
print
(
"Substituting the coordinates in m_phys..."
)
exp
.
SetPhysArray
(
coords_subs
)
print
(
"Substitution completed."
)
print
(
"Reference count for expansion coordinates:
%
d
\n
"
%
get_refcount
(
coords_address
))
actual_test_outcome
.
append
(
get_refcount
(
coords_address
))
print
(
"Attempting to access the coordinates in Python..."
)
print
(
"The sum of coordinates array entires is:
%
r"
%
sum
(
coords
))
actual_test_outcome
.
append
(
sum
(
coords
))
if
np
.
allclose
(
actual_test_outcome
,
expected_test_outcome
):
print
(
"Test successful!"
)
else
:
print
(
"Test unsuccessful"
)
session_name
=
[
"memory-test-python-to-c-address.py"
,
"newsquare_2x2.xml"
]
expected_test_outcome
=
[
1
,
2
,
1
,
-
9.187094450483263e-15
]
actual_test_outcome
=
[]
session
=
SessionReader
.
CreateInstance
(
session_name
)
graph
=
MeshGraph
.
Read
(
session
)
exp
=
ExpList2D
(
session
,
graph
)
print
(
"Loaded session:
%
s"
%
session
.
GetSessionName
())
print
(
"Loaded MeshGraph of dimension:
%
d
\n
"
%
graph
.
GetMeshDimension
())
print
(
"Retrieving coordinates..."
)
coords
=
exp
.
GetCoords
()
coords_subs
=
coords
[
1
]
coords
=
coords
[
0
]
coords_address
=
id
(
coords
)
print
(
"Retrieved coordinates."
)
print
(
"Reference count for expansion coordinates:
%
d
\n
"
%
get_refcount
(
coords_address
))
actual_test_outcome
.
append
(
get_refcount
(
coords_address
))
print
(
"Setting PhysArray (exp.SetPhysArray())..."
)
exp
.
SetPhysArray
(
coords
)
print
(
"exp.SetPhysArray() completed."
)
print
(
"Reference count for expansion coordinates:
%
d
\n
"
%
get_refcount
(
coords_address
))
actual_test_outcome
.
append
(
get_refcount
(
coords_address
))
print
(
"Substituting the coordinates in m_phys..."
)
exp
.
SetPhysArray
(
coords_subs
)
print
(
"Substitution completed."
)
print
(
"Reference count for expansion coordinates:
%
d
\n
"
%
get_refcount
(
coords_address
))
actual_test_outcome
.
append
(
get_refcount
(
coords_address
))
print
(
"Attempting to access the coordinates in Python..."
)
print
(
"The sum of coordinates array entires is:
%
r"
%
sum
(
coords
))
actual_test_outcome
.
append
(
sum
(
coords
))
if
np
.
allclose
(
actual_test_outcome
,
expected_test_outcome
):
print
(
"Test successful!"
)
else
:
print
(
"Test unsuccessful"
)
if
__name__
==
'__main__'
:
main
()
library/Demos/Python/NekPy_ReferenceTest_PythonDeleteFirst.py
View file @
4700e650
...
...
@@ -7,54 +7,54 @@ import sys
import
numpy
as
np
def
get_refcount
(
coords_address
):
gc
.
collect
()
return
ctypes
.
c_long
.
from_address
(
coords_address
)
.
value
gc
.
collect
()
return
ctypes
.
c_long
.
from_address
(
coords_address
)
.
value
def
main
():
session_name
=
[
"NekPy_ReferenceTest_PythonDeleteFirst.py"
,
"newsquare_2x2.xml"
]
expected_test_outcome
=
[
1
,
2
,
1
,
3.469446951953614e-17
]
actual_test_outcome
=
[]
session
=
SessionReader
.
CreateInstance
(
session_name
)
graph
=
MeshGraph
.
Read
(
session
)
exp
=
ExpList2D
(
session
,
graph
)
print
(
"Loaded session:
%
s"
%
session
.
GetSessionName
())
print
(
"Loaded MeshGraph of dimension:
%
d
\n
"
%
graph
.
GetMeshDimension
())
print
(
"Retrieving coordinates..."
)
coords
=
exp
.
GetCoords
()
coords
=
coords
[
0
]
coords_address
=
id
(
coords
)
print
(
"Retrieved coordinates."
)
print
(
"Reference count for expansion coordinates:
%
d
\n
"
%
get_refcount
(
coords_address
))
actual_test_outcome
.
append
(
get_refcount
(
coords_address
))
print
(
"Setting PhysArray (exp.SetPhysArray())..."
)
exp
.
SetPhysArray
(
coords
)
print
(
"exp.SetPhysArray() completed."
)
print
(
"Reference count for expansion coordinates:
%
d
\n
"
%
get_refcount
(
coords_address
))
actual_test_outcome
.
append
(
get_refcount
(
coords_address
))
print
(
"Deleting coordinates in Python..."
)
del
coords
print
(
"Coordinates deleted in Python."
)
print
(
"Reference count for expansion coordinates:
%
d
\n
"
%
get_refcount
(
coords_address
))
actual_test_outcome
.
append
(
get_refcount
(
coords_address
))
# Ensure we are in PhysState to avoid ASSERT inside ExpList.
exp
.
SetPhysState
(
True
)
print
(
"Attempting to calculate the integral..."
)
print
(
"Integral calculated to be:
%
r"
%
exp
.
PhysIntegral
())
actual_test_outcome
.
append
(
exp
.
PhysIntegral
())
if
np
.
allclose
(
actual_test_outcome
,
expected_test_outcome
):
print
(
"Test successful!"
)
else
:
print
(
"Test unsuccessful"
)
session_name
=
[
"NekPy_ReferenceTest_PythonDeleteFirst.py"
,
"newsquare_2x2.xml"
]
expected_test_outcome
=
[
1
,
2
,
1
,
3.469446951953614e-17
]
actual_test_outcome
=
[]
session
=
SessionReader
.
CreateInstance
(
session_name
)
graph
=
MeshGraph
.
Read
(
session
)
exp
=
ExpList2D
(
session
,
graph
)
print
(
"Loaded session:
%
s"
%
session
.
GetSessionName
())
print
(
"Loaded MeshGraph of dimension:
%
d
\n
"
%
graph
.
GetMeshDimension
())
print
(
"Retrieving coordinates..."
)
coords
=
exp
.
GetCoords
()
coords
=
coords
[
0
]
coords_address
=
id
(
coords
)
print
(
"Retrieved coordinates."
)
print
(
"Reference count for expansion coordinates:
%
d
\n
"
%
get_refcount
(
coords_address
))
actual_test_outcome
.
append
(
get_refcount
(
coords_address
))
print
(
"Setting PhysArray (exp.SetPhysArray())..."
)
exp
.
SetPhysArray
(
coords
)
print
(
"exp.SetPhysArray() completed."
)
print
(
"Reference count for expansion coordinates:
%
d
\n
"
%
get_refcount
(
coords_address
))
actual_test_outcome
.
append
(
get_refcount
(
coords_address
))
print
(
"Deleting coordinates in Python..."
)
del
coords
print
(
"Coordinates deleted in Python."
)
print
(
"Reference count for expansion coordinates:
%
d
\n
"
%
get_refcount
(
coords_address
))
actual_test_outcome
.
append
(
get_refcount
(
coords_address
))
# Ensure we are in PhysState to avoid ASSERT inside ExpList.
exp
.
SetPhysState
(
True
)
print
(
"Attempting to calculate the integral..."
)
print
(
"Integral calculated to be:
%
r"
%
exp
.
PhysIntegral
())
actual_test_outcome
.
append
(
exp
.
PhysIntegral
())
if
np
.
allclose
(
actual_test_outcome
,
expected_test_outcome
):
print
(
"Test successful!"
)
else
:
print
(
"Test unsuccessful"
)
if
__name__
==
'__main__'
:
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment