store microstructure as integers
This commit is contained in:
parent
3caad0bdf4
commit
0f45559271
|
@ -32,7 +32,7 @@ parser.add_option('-b', '--box',
|
||||||
help = 'bounding box as fraction in x, y, and z directions')
|
help = 'bounding box as fraction in x, y, and z directions')
|
||||||
parser.add_option('-x',
|
parser.add_option('-x',
|
||||||
action = 'store_true',
|
action = 'store_true',
|
||||||
dest = 'x',
|
dest = 'x',
|
||||||
help = 'poke 45 deg along x')
|
help = 'poke 45 deg along x')
|
||||||
parser.add_option('-y',
|
parser.add_option('-y',
|
||||||
action = 'store_true',
|
action = 'store_true',
|
||||||
|
@ -53,20 +53,20 @@ options.box = np.array(options.box).reshape(3,2)
|
||||||
for name in filenames:
|
for name in filenames:
|
||||||
damask.util.report(scriptName,name)
|
damask.util.report(scriptName,name)
|
||||||
geom = damask.Geom.from_file(StringIO(''.join(sys.stdin.read())) if name is None else name)
|
geom = damask.Geom.from_file(StringIO(''.join(sys.stdin.read())) if name is None else name)
|
||||||
|
|
||||||
offset =(np.amin(options.box, axis=1)*geom.grid/geom.size).astype(int)
|
offset =(np.amin(options.box, axis=1)*geom.grid/geom.size).astype(int)
|
||||||
box = np.amax(options.box, axis=1) \
|
box = np.amax(options.box, axis=1) \
|
||||||
- np.amin(options.box, axis=1)
|
- np.amin(options.box, axis=1)
|
||||||
|
|
||||||
Nx = int(options.N/np.sqrt(options.N*geom.size[1]*box[1]/geom.size[0]/box[0]))
|
Nx = int(options.N/np.sqrt(options.N*geom.size[1]*box[1]/geom.size[0]/box[0]))
|
||||||
Ny = int(options.N/np.sqrt(options.N*geom.size[0]*box[0]/geom.size[1]/box[1]))
|
Ny = int(options.N/np.sqrt(options.N*geom.size[0]*box[0]/geom.size[1]/box[1]))
|
||||||
Nz = int(box[2]*geom.grid[2])
|
Nz = int(box[2]*geom.grid[2])
|
||||||
|
|
||||||
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):
|
||||||
for j in range(Ny):
|
for j in range(Ny):
|
||||||
|
@ -80,16 +80,17 @@ for name in filenames:
|
||||||
if options.x: g[0] += 1
|
if options.x: g[0] += 1
|
||||||
if options.y: g[1] += 1
|
if options.y: g[1] += 1
|
||||||
n += 1
|
n += 1
|
||||||
|
|
||||||
|
|
||||||
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))
|
||||||
|
|
|
@ -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)
|
||||||
|
|
Loading…
Reference in New Issue