From 615ff4ed06544f698ba7001fbaa8f8c327b06dac Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Fri, 31 May 2019 23:26:32 +0200 Subject: [PATCH] [skip ci] vectorized --- processing/pre/geom_fromMinimalSurface.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/processing/pre/geom_fromMinimalSurface.py b/processing/pre/geom_fromMinimalSurface.py index 19686f763..ab42ce5af 100755 --- a/processing/pre/geom_fromMinimalSurface.py +++ b/processing/pre/geom_fromMinimalSurface.py @@ -76,15 +76,13 @@ parser.set_defaults(type = minimal_surfaces[0], name = None if filename == [] else filename[0] damask.util.report(scriptName,name) -X = options.periods*2.0*np.pi*(np.arange(options.grid[0])+0.5)/options.grid[0] -Y = options.periods*2.0*np.pi*(np.arange(options.grid[1])+0.5)/options.grid[1] -Z = options.periods*2.0*np.pi*(np.arange(options.grid[2])+0.5)/options.grid[2] +x,y,z = np.meshgrid(options.periods*2.0*np.pi*(np.arange(options.grid[0])+0.5)/options.grid[0], + options.periods*2.0*np.pi*(np.arange(options.grid[1])+0.5)/options.grid[1], + options.periods*2.0*np.pi*(np.arange(options.grid[2])+0.5)/options.grid[2], + indexing='xy',sparse=True) -microstructure = np.empty(options.grid,dtype=int) -for x in range(options.grid[0]): - for y in range(options.grid[1]): - for z in range(options.grid[2]): - microstructure[x,y,z]=options.microstructure[int(options.threshold < surface[options.type](X[x],Y[y],Z[z]))] +microstructure = np.where(options.threshold < surface[options.type](x,y,z), + options.microstructure[1],options.microstructure[0]) geom=damask.Geom(microstructure,options.size, homogenization=options.homogenization,