tio_tests.py - sphere - GPU-based 3D discrete element method algorithm with optional fluid coupling
(HTM) git clone git://src.adamsgaard.dk/sphere
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) LICENSE
---
tio_tests.py (1154B)
---
1 #!/usr/bin/env python
2 from pytestutils import *
3 import sphere
4
5 #### Input/output tests ####
6 print("### Input/output tests ###")
7
8 # Generate data in python
9 orig = sphere.sim(np=100, nw=1, sid="test-initgrid")
10 orig.generateRadii(histogram=False)
11 orig.defaultParams()
12 orig.g[2] = 0.0
13 orig.initRandomGridPos()
14 orig.initTemporal(current=0.0, total=0.0)
15 orig.time_total=2.0*orig.time_dt
16 orig.time_file_dt = orig.time_dt
17 orig.writebin(verbose=False)
18
19 # Test the test
20 compare(orig, orig, "Comparison:")
21
22 # Test Python IO routines
23 py = sphere.sim()
24 py.readbin("../input/" + orig.sid + ".bin", verbose=False)
25 compare(orig, py, "Python IO:")
26
27 # Test C++ IO routines
28 #orig.run(verbose=True, hideinputfile=True)
29 orig.run(dry=True)
30 #orig.run(valgrind=True)
31 orig.run()
32 cpp = sphere.sim()
33 cpp.readbin("../output/" + orig.sid + ".output00000.bin", verbose=False)
34 compare(orig, cpp, "C++ IO: ")
35
36 # Test CUDA IO routines
37 cuda = sphere.sim()
38 cuda.readbin("../output/" + orig.sid + ".output00001.bin", verbose=False)
39 cuda.time_current = orig.time_current
40 cuda.time_step_count = orig.time_step_count
41 compare(orig, cuda, "CUDA IO: ")
42
43 # Remove temporary files
44 cleanup(orig)