changed from "coords" to "pos"

remind user about (creating a new) nodal output file
This commit is contained in:
Philip Eisenlohr 2016-04-27 09:28:43 -04:00
parent 0f0ca8cd71
commit b3e9877058
1 changed files with 13 additions and 12 deletions

View File

@ -101,7 +101,7 @@ parser.add_option('-f',
help = 'column label of deformation gradient [%default]') help = 'column label of deformation gradient [%default]')
parser.add_option('-p', parser.add_option('-p',
'--pos', '--position', '--pos', '--position',
dest = 'coords', dest = 'pos',
metavar = 'string', metavar = 'string',
help = 'label of coordinates [%default]') help = 'label of coordinates [%default]')
parser.add_option('--nodal', parser.add_option('--nodal',
@ -110,7 +110,7 @@ parser.add_option('--nodal',
help = 'output nodal (instad of cell-centered) displacements') help = 'output nodal (instad of cell-centered) displacements')
parser.set_defaults(defgrad = 'f', parser.set_defaults(defgrad = 'f',
coords = 'pos', pos = 'pos',
nodal = False, nodal = False,
) )
@ -121,13 +121,14 @@ parser.set_defaults(defgrad = 'f',
if filenames == []: filenames = [None] if filenames == []: filenames = [None]
for name in filenames: for name in filenames:
outname = (os.path.splitext(name)[0] +
'_nodal' +
os.path.splitext(name)[1]) if (options.nodal and name) else None
try: table = damask.ASCIItable(name = name, try: table = damask.ASCIItable(name = name,
outname = (os.path.splitext(name)[0] + outname = outname,
'_nodal' +
os.path.splitext(name)[1]) if (options.nodal and name) else None,
buffered = False) buffered = False)
except: continue except: continue
damask.util.report(scriptName,name) damask.util.report(scriptName,'{}{}'.format(name,' --> {}'.format(outname) if outname else ''))
# ------------------------------------------ read header ------------------------------------------ # ------------------------------------------ read header ------------------------------------------
@ -141,13 +142,13 @@ for name in filenames:
if table.label_dimension(options.defgrad) != 9: if table.label_dimension(options.defgrad) != 9:
errors.append('deformation gradient "{}" is not a 3x3 tensor.'.format(options.defgrad)) errors.append('deformation gradient "{}" is not a 3x3 tensor.'.format(options.defgrad))
coordDim = table.label_dimension(options.coords) coordDim = table.label_dimension(options.pos)
if not 3 >= coordDim >= 1: if not 3 >= coordDim >= 1:
errors.append('coordinates "{}" need to have one, two, or three dimensions.'.format(options.coords)) errors.append('coordinates "{}" need to have one, two, or three dimensions.'.format(options.pos))
elif coordDim < 3: elif coordDim < 3:
remarks.append('appending {} dimension{} to coordinates "{}"...'.format(3-coordDim, remarks.append('appending {} dimension{} to coordinates "{}"...'.format(3-coordDim,
's' if coordDim < 2 else '', 's' if coordDim < 2 else '',
options.coords)) options.pos))
if remarks != []: damask.util.croak(remarks) if remarks != []: damask.util.croak(remarks)
if errors != []: if errors != []:
@ -157,7 +158,7 @@ for name in filenames:
# --------------- figure out size and grid --------------------------------------------------------- # --------------- figure out size and grid ---------------------------------------------------------
table.data_readArray([options.defgrad,options.coords]) table.data_readArray([options.defgrad,options.pos])
table.data_rewind() table.data_rewind()
if len(table.data.shape) < 2: table.data.shape += (1,) # expand to 2D shape if len(table.data.shape) < 2: table.data.shape += (1,) # expand to 2D shape
@ -196,8 +197,8 @@ for name in filenames:
table.info_append(scriptID + '\t' + ' '.join(sys.argv[1:])) table.info_append(scriptID + '\t' + ' '.join(sys.argv[1:]))
table.labels_append((['{}_pos' .format(i+1) for i in xrange(3)] if options.nodal else []) + table.labels_append((['{}_pos' .format(i+1) for i in xrange(3)] if options.nodal else []) +
['{}_avg({}).{}' .format(i+1,options.defgrad,options.coords) for i in xrange(3)] + ['{}_avg({}).{}' .format(i+1,options.defgrad,options.pos) for i in xrange(3)] +
['{}_fluct({}).{}'.format(i+1,options.defgrad,options.coords) for i in xrange(3)] ) ['{}_fluct({}).{}'.format(i+1,options.defgrad,options.pos) for i in xrange(3)] )
table.head_write() table.head_write()
# ------------------------------------------ output data ------------------------------------------- # ------------------------------------------ output data -------------------------------------------