fixed bug.
introduced possibility for poke bounding box in all dimensions.
This commit is contained in:
parent
23987426e2
commit
2c6a6f6530
|
@ -23,10 +23,10 @@ parser.add_option('-N', '--points',
|
||||||
dest = 'N',
|
dest = 'N',
|
||||||
type = 'int', metavar = 'int',
|
type = 'int', metavar = 'int',
|
||||||
help = 'number of poking locations [%default]')
|
help = 'number of poking locations [%default]')
|
||||||
parser.add_option('-z', '--planes',
|
parser.add_option('-b', '--box',
|
||||||
dest = 'z',
|
dest = 'box',
|
||||||
type = 'float', nargs = 2, metavar='float float',
|
type = 'float', nargs = 6, metavar = ' '.join(['float']*6),
|
||||||
help = 'top and bottom z plane')
|
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',
|
||||||
|
@ -42,13 +42,15 @@ parser.add_option('-p','--position',
|
||||||
|
|
||||||
parser.set_defaults(x = False,
|
parser.set_defaults(x = False,
|
||||||
y = False,
|
y = False,
|
||||||
z = [0.0,1.0],
|
box = [0.0,1.0,0.0,1.0,0.0,1.0],
|
||||||
N = 16,
|
N = 16,
|
||||||
position = 'pos',
|
position = 'pos',
|
||||||
)
|
)
|
||||||
|
|
||||||
(options,filenames) = parser.parse_args()
|
(options,filenames) = parser.parse_args()
|
||||||
|
|
||||||
|
options.box = np.array(options.box).reshape(3,2)
|
||||||
|
|
||||||
# --- loop over output files -------------------------------------------------------------------------
|
# --- loop over output files -------------------------------------------------------------------------
|
||||||
|
|
||||||
if filenames == []: filenames = [None]
|
if filenames == []: filenames = [None]
|
||||||
|
@ -90,24 +92,26 @@ for name in filenames:
|
||||||
newInfo = {
|
newInfo = {
|
||||||
'microstructures': 0,
|
'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]))
|
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]/info['size'][1]))
|
Ny = int(options.N/math.sqrt(options.N*info['size'][0]*box[0]/info['size'][1]/box[1]))
|
||||||
Nz = int((max(options.z)-min(options.z))/info['size'][2]*info['grid'][2])
|
Nz = int(box[2]*info['grid'][2])
|
||||||
offset = int(min(options.z)/info['size'][2]*info['grid'][2]) # offset due to lower z-plane
|
|
||||||
|
|
||||||
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')
|
seeds = np.zeros((Nx*Ny*Nz,4),'d')
|
||||||
grid = np.zeros(3,'i')
|
grid = np.zeros(3,'i')
|
||||||
|
|
||||||
n = 0
|
n = 0
|
||||||
for i in xrange(Nx):
|
for i in xrange(Nx):
|
||||||
grid[0] = round((i+0.5)*info['grid'][0]/Nx-0.5)
|
|
||||||
for j in xrange(Ny):
|
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):
|
for k in xrange(Nz):
|
||||||
grid[2] = offset + k
|
grid[2] = k + offset[2]
|
||||||
grid %= info['grid']
|
grid %= info['grid']
|
||||||
seeds[n,0:3] = (0.5+grid)/info['grid'] # normalize coordinates to box
|
seeds[n,0:3] = (0.5+grid)/info['grid'] # normalize coordinates to box
|
||||||
seeds[n, 3] = microstructure[grid[0],grid[1],grid[2]]
|
seeds[n, 3] = microstructure[grid[0],grid[1],grid[2]]
|
||||||
|
@ -128,9 +132,9 @@ for name in filenames:
|
||||||
table.info_append(extra_header+[
|
table.info_append(extra_header+[
|
||||||
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 {grid[0]}\tb {grid[1]}\tc {grid[2]}".format(grid=info['grid']),
|
"grid\ta {}\tb {}\tc {}".format(*info['grid']),
|
||||||
"size\tx {size[0]}\ty {size[1]}\tz {size[2]}".format(size=info['size']),
|
"size\tx {}\ty {}\tz {}".format(*info['size']),
|
||||||
"origin\tx {origin[0]}\ty {origin[1]}\tz {origin[2]}".format(origin=info['origin']),
|
"origin\tx {}\ty {}\tz {}".format(*info['origin']),
|
||||||
"homogenization\t{}".format(info['homogenization']),
|
"homogenization\t{}".format(info['homogenization']),
|
||||||
"microstructures\t{}".format(newInfo['microstructures']),
|
"microstructures\t{}".format(newInfo['microstructures']),
|
||||||
])
|
])
|
||||||
|
|
Loading…
Reference in New Issue