diff --git a/processing/pre/seeds_fromPokes.py b/processing/pre/seeds_fromPokes.py index a7b3a2c41..fdc345717 100755 --- a/processing/pre/seeds_fromPokes.py +++ b/processing/pre/seeds_fromPokes.py @@ -23,10 +23,10 @@ parser.add_option('-N', '--points', dest = 'N', type = 'int', metavar = 'int', help = 'number of poking locations [%default]') -parser.add_option('-z', '--planes', - dest = 'z', - type = 'float', nargs = 2, metavar='float float', - help = 'top and bottom z plane') +parser.add_option('-b', '--box', + dest = 'box', + type = 'float', nargs = 6, metavar = ' '.join(['float']*6), + help = 'bounding box as fraction in x, y, and z directions') parser.add_option('-x', action = 'store_true', dest = 'x', @@ -42,13 +42,15 @@ parser.add_option('-p','--position', parser.set_defaults(x = False, y = False, - z = [0.0,1.0], + box = [0.0,1.0,0.0,1.0,0.0,1.0], N = 16, position = 'pos', ) (options,filenames) = parser.parse_args() +options.box = np.array(options.box).reshape(3,2) + # --- loop over output files ------------------------------------------------------------------------- if filenames == []: filenames = [None] @@ -90,24 +92,26 @@ for name in filenames: newInfo = { 'microstructures': 0, } + offset = (np.amin(options.box, axis=1)*info['grid']/info['size']).astype(int) + box = np.amax(options.box, axis=1) - np.amin(options.box, axis=1) - Nx = int(options.N/math.sqrt(options.N*info['size'][1]/info['size'][0])) - Ny = int(options.N/math.sqrt(options.N*info['size'][0]/info['size'][1])) - Nz = int((max(options.z)-min(options.z))/info['size'][2]*info['grid'][2]) - offset = int(min(options.z)/info['size'][2]*info['grid'][2]) # offset due to lower z-plane + Nx = int(options.N/math.sqrt(options.N*info['size'][1]*box[1]/info['size'][0]/box[0])) + Ny = int(options.N/math.sqrt(options.N*info['size'][0]*box[0]/info['size'][1]/box[1])) + Nz = int(box[2]*info['grid'][2]) - damask.util.croak('poking {} x {} x {}...'.format(Nx,Ny,Nz)) + damask.util.croak('poking {} x {} x {} in box {} {} {}...'.format(Nx,Ny,Nz,*box)) seeds = np.zeros((Nx*Ny*Nz,4),'d') grid = np.zeros(3,'i') n = 0 for i in xrange(Nx): - grid[0] = round((i+0.5)*info['grid'][0]/Nx-0.5) for j in xrange(Ny): - grid[1] = round((j+0.5)*info['grid'][1]/Ny-0.5) + grid[0] = round((i+0.5)*box[0]*info['grid'][0]/Nx-0.5)+offset[0] + grid[1] = round((j+0.5)*box[1]*info['grid'][1]/Ny-0.5)+offset[1] + damask.util.croak('x,y coord on surface: {},{}...'.format(*grid[:2])) for k in xrange(Nz): - grid[2] = offset + k + grid[2] = k + offset[2] grid %= info['grid'] seeds[n,0:3] = (0.5+grid)/info['grid'] # normalize coordinates to box seeds[n, 3] = microstructure[grid[0],grid[1],grid[2]] @@ -128,9 +132,9 @@ for name in filenames: table.info_append(extra_header+[ scriptID + ' ' + ' '.join(sys.argv[1:]), "poking\ta {}\tb {}\tc {}".format(Nx,Ny,Nz), - "grid\ta {grid[0]}\tb {grid[1]}\tc {grid[2]}".format(grid=info['grid']), - "size\tx {size[0]}\ty {size[1]}\tz {size[2]}".format(size=info['size']), - "origin\tx {origin[0]}\ty {origin[1]}\tz {origin[2]}".format(origin=info['origin']), + "grid\ta {}\tb {}\tc {}".format(*info['grid']), + "size\tx {}\ty {}\tz {}".format(*info['size']), + "origin\tx {}\ty {}\tz {}".format(*info['origin']), "homogenization\t{}".format(info['homogenization']), "microstructures\t{}".format(newInfo['microstructures']), ])