From 9f6892303862a19d6c07267e93529e538610f0c5 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Wed, 29 May 2019 07:38:11 +0200 Subject: [PATCH] restored old behavior save some ressources by avoiding copies. much slower than old version, better cast formula into meshgrid again --- processing/pre/geom_addPrimitive.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/processing/pre/geom_addPrimitive.py b/processing/pre/geom_addPrimitive.py index 38cce2d65..b8b1ddf6e 100755 --- a/processing/pre/geom_addPrimitive.py +++ b/processing/pre/geom_addPrimitive.py @@ -34,9 +34,10 @@ parser.add_option('-d', '--dimension', parser.add_option('-e', '--exponent', dest='exponent', type='float', nargs = 3, metavar=' '.join(['float']*3), - help='i,j,k exponents for axes - 0 gives octahedron (|x|^(2^0) + |y|^(2^0) + |z|^(2^0) < 1), \ - 1 gives a sphere (|x|^(2^1) + |y|^(2^1) + |z|^(2^1) < 1), \ - large values produce boxes, negative turn concave.') + help='i,j,k exponents for axes: '+ + '0 gives octahedron (|x|^(2^0) + |y|^(2^0) + |z|^(2^0) < 1), '+ + '1 gives a sphere (|x|^(2^1) + |y|^(2^1) + |z|^(2^1) < 1), '+ + 'large values produce boxes, negative turn concave.') parser.add_option('-f', '--fill', dest='fill', type='float', metavar = 'int', @@ -97,7 +98,6 @@ for name in filenames: geom = damask.Geom.from_file(StringIO(''.join(sys.stdin.read())) if name is None else name) grid = geom.get_grid() size = geom.get_size() - microstructure = geom.get_microstructure() # scale to box of size [1.0,1.0,1.0] if options.realspace: @@ -114,7 +114,7 @@ for name in filenames: # High exponents can cause underflow & overflow - okay here, just compare to 1, so +infinity and 0 are fine np.seterr(over='ignore', under='ignore') - e = np.array(options.exponent) + e = 2.0**np.array(options.exponent) for x in range(grid[0]): for y in range(grid[1]): for z in range(grid[2]): @@ -124,13 +124,11 @@ for name in filenames: if options.periodic: shift = ((offset-center)*grid).astype(int) mask = np.roll(mask,shift,(0,1,2)) - - + if options.inside: mask = np.logical_not(mask) - fill = np.nanmax(microstructure)+1 if options.fill is None else options.fill - microstructure = np.where(mask,microstructure,fill) + fill = np.nanmax(geom.microstructure)+1 if options.fill is None else options.fill - damask.util.croak(geom.update(microstructure)) + damask.util.croak(geom.update(np.where(mask,geom.microstructure,fill))) geom.add_comments(scriptID + ' ' + ' '.join(sys.argv[1:])) if name is None: