From bcf3650211f48479897876370be41c7e88199379 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sat, 21 Mar 2020 19:04:40 +0100 Subject: [PATCH] slightly shorter. w/o transpose, this seems to be more memory efficient --- python/damask/grid_filters.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/python/damask/grid_filters.py b/python/damask/grid_filters.py index e2390fc36..c454e3d00 100644 --- a/python/damask/grid_filters.py +++ b/python/damask/grid_filters.py @@ -103,10 +103,7 @@ def cell_coord0(grid,size,origin=np.zeros(3)): """ start = origin + size/grid*.5 end = origin + size - size/grid*.5 - x, y, z = np.meshgrid(*(np.linspace(start[i],end[i],grid[i]) for i in [2,1,0]), - indexing = 'ij') - - return np.concatenate((z[:,:,:,None],y[:,:,:,None],x[:,:,:,None]),axis = 3) + return np.mgrid[start[0]:end[0]:grid[0]*1j,start[1]:end[1]:grid[1]*1j,start[2]:end[2]:grid[2]*1j].T def cell_displacement_fluct(size,F): @@ -252,10 +249,9 @@ def node_coord0(grid,size,origin=np.zeros(3)): physical origin of the periodic field. Defaults to [0.0,0.0,0.0]. """ - x, y, z = np.meshgrid(*(np.linspace(origin[i],size[i]+origin[i],grid[i]+1) for i in [2,1,0]), - indexing = 'ij') - - return np.concatenate((z[:,:,:,None],y[:,:,:,None],x[:,:,:,None]),axis = 3) + return np.mgrid[origin[0]:size[0]+origin[0]:(grid[0]+1)*1j, + origin[1]:size[1]+origin[1]:(grid[1]+1)*1j, + origin[2]:size[2]+origin[2]:(grid[2]+1)*1j].T def node_displacement_fluct(size,F):