store microstructure as integers

This commit is contained in:
Martin Diehl 2020-03-20 06:24:41 +01:00
parent 3caad0bdf4
commit 0f45559271
2 changed files with 21 additions and 22 deletions

View File

@ -64,8 +64,8 @@ for name in filenames:
damask.util.croak('poking {} x {} x {} in box {} {} {}...'.format(Nx,Ny,Nz,*box)) damask.util.croak('poking {} x {} x {} in box {} {} {}...'.format(Nx,Ny,Nz,*box))
seeds = np.zeros((Nx*Ny*Nz,4),'d') seeds = np.zeros((Nx*Ny*Nz,4))
g = np.zeros(3,'i') g = np.zeros(3,dtype=np.int)
n = 0 n = 0
for i in range(Nx): for i in range(Nx):
@ -84,12 +84,13 @@ for name in filenames:
comments = geom.comments \ comments = geom.comments \
+ [scriptID + ' ' + ' '.join(sys.argv[1:]), + [scriptID + ' ' + ' '.join(sys.argv[1:]),
"poking\ta {}\tb {}\tc {}".format(Nx,Ny,Nz), 'poking\ta {}\tb {}\tc {}'.format(Nx,Ny,Nz),
"grid\ta {}\tb {}\tc {}".format(*geom.grid), 'grid\ta {}\tb {}\tc {}'.format(*geom.grid),
"size\tx {}\ty {}\tz {}".format(*geom.size), 'size\tx {}\ty {}\tz {}'.format(*geom.size),
"origin\tx {}\ty {}\tz {}".format(*geom.origin), 'origin\tx {}\ty {}\tz {}'.format(*geom.origin),
"homogenization\t{}".format(geom.homogenization)] 'homogenization\t{}'.format(geom.homogenization)]
table = damask.Table(seeds,{'pos':(3,),'microstructure':(1,)},comments) table = damask.Table(seeds,{'pos':(3,),'microstructure':(1,)},comments)
table.set('microstructure',table.get('microstructure').astype(np.int))
table.to_ASCII(sys.stdout if name is None else \ table.to_ASCII(sys.stdout if name is None else \
os.path.splitext(name)[0]+'_poked_{}.seeds'.format(options.N)) os.path.splitext(name)[0]+'_poked_{}.seeds'.format(options.N))

View File

@ -145,19 +145,17 @@ for name in filenames:
eulers = np.random.rand(options.N,3) # create random Euler triplets eulers = np.random.rand(options.N,3) # create random Euler triplets
eulers[:,0] *= 360.0 # phi_1 is uniformly distributed eulers[:,0] *= 360.0 # phi_1 is uniformly distributed
eulers[:,1] = np.degrees(np.arccos(2*eulers[:,1]-1)) # cos(Phi) is uniformly distributed eulers[:,1] = np.degrees(np.arccos(2*eulers[:,1]-1.0)) # cos(Phi) is uniformly distributed
eulers[:,2] *= 360.0 # phi_2 is uniformly distributed eulers[:,2] *= 360.0 # phi_2 is uniformly distributed
if not options.selective: if not options.selective:
n = np.maximum(np.ones(3),np.array(grid*fraction),dtype=int,casting='unsafe') # find max grid indices within fraction n = np.maximum(np.ones(3),np.array(grid*fraction),dtype=int,casting='unsafe') # find max grid indices within fraction
meshgrid = np.meshgrid(*map(np.arange,n),indexing='ij') # create a meshgrid within fraction meshgrid = np.meshgrid(*map(np.arange,n),indexing='ij') # create a meshgrid within fraction
coords = np.vstack((meshgrid[0],meshgrid[1],meshgrid[2])).reshape(n.prod(),3) # assemble list of 3D coordinates coords = np.vstack((meshgrid[0],meshgrid[1],meshgrid[2])).reshape(n.prod(),3) # assemble list of 3D coordinates
seeds = (random.sample(coords.tolist(),options.N)+np.random.rand(options.N,3))\ seeds = (random.sample(coords.tolist(),options.N)+np.random.rand(options.N,3))/(n/fraction) # pick options.N of those, rattle position,
/ \
(n/fraction) # pick options.N of those, rattle position,
# and rescale to fall within fraction # and rescale to fall within fraction
else: else: # and rescale to fall within fraction
seeds = np.zeros((options.N,3)) # seed positions array seeds = np.empty((options.N,3)) # seed positions array
seeds[0] = np.random.random(3)*grid/max(grid) seeds[0] = np.random.random(3)*grid/max(grid)
i = 1 # start out with one given point i = 1 # start out with one given point
if i%(options.N/100.) < 1: damask.util.croak('.',False) if i%(options.N/100.) < 1: damask.util.croak('.',False)