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))
seeds = np.zeros((Nx*Ny*Nz,4),'d')
g = np.zeros(3,'i')
seeds = np.zeros((Nx*Ny*Nz,4))
g = np.zeros(3,dtype=np.int)
n = 0
for i in range(Nx):
@ -84,12 +84,13 @@ for name in filenames:
comments = geom.comments \
+ [scriptID + ' ' + ' '.join(sys.argv[1:]),
"poking\ta {}\tb {}\tc {}".format(Nx,Ny,Nz),
"grid\ta {}\tb {}\tc {}".format(*geom.grid),
"size\tx {}\ty {}\tz {}".format(*geom.size),
"origin\tx {}\ty {}\tz {}".format(*geom.origin),
"homogenization\t{}".format(geom.homogenization)]
'poking\ta {}\tb {}\tc {}'.format(Nx,Ny,Nz),
'grid\ta {}\tb {}\tc {}'.format(*geom.grid),
'size\tx {}\ty {}\tz {}'.format(*geom.size),
'origin\tx {}\ty {}\tz {}'.format(*geom.origin),
'homogenization\t{}'.format(geom.homogenization)]
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 \
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[:,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
if not options.selective:
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
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))\
/ \
(n/fraction) # pick options.N of those, rattle position,
seeds = (random.sample(coords.tolist(),options.N)+np.random.rand(options.N,3))/(n/fraction) # pick options.N of those, rattle position,
# and rescale to fall within fraction
else:
seeds = np.zeros((options.N,3)) # seed positions array
else: # and rescale to fall within fraction
seeds = np.empty((options.N,3)) # seed positions array
seeds[0] = np.random.random(3)*grid/max(grid)
i = 1 # start out with one given point
if i%(options.N/100.) < 1: damask.util.croak('.',False)