tpreallocate arrays - sphere - GPU-based 3D discrete element method algorithm w… | |
git clone git://src.adamsgaard.dk/sphere | |
Log | |
Files | |
Refs | |
LICENSE | |
--- | |
commit 220a48e1d79afa0ec97dba98f0fa4cdbe65a0131 | |
parent 3650114c55663dbb380a6c60844a6a34bf920054 | |
Author: Anders Damsgaard <[email protected]> | |
Date: Wed, 13 Aug 2014 11:53:38 +0200 | |
preallocate arrays | |
Diffstat: | |
M python/permeability-results.py | 10 ++++++---- | |
1 file changed, 6 insertions(+), 4 deletions(-) | |
--- | |
diff --git a/python/permeability-results.py b/python/permeability-results.py | |
t@@ -15,13 +15,15 @@ sids = [ | |
'permeability-dp=4000.0-c_phi=1.0-c_grad_p=0.5', | |
'permeability-dp=4000.0'] | |
-K = numpy.array([]) | |
-c_grad_p = numpy.array([]) | |
+K = numpy.empty(len(sids)) | |
+c_grad_p = numpy.empty_like(K) | |
+i = 0 | |
for sid in sids: | |
pc = PermeabilityCalc(sid) | |
- K.append(pc.conductivity()) | |
- c_grad_p.append(pc.c_grad_p()) | |
+ K[i] = pc.conductivity() | |
+ c_grad_p[i] = pc.c_grad_p() | |
+ i += 1 | |
fig = plt.figure() | |
plt.xlabel('Pressure gradient coefficient $c$ [-]') |