unified options to enable automated parsing for documentation

This commit is contained in:
Martin Diehl 2015-11-16 10:52:56 +00:00
parent f0d0d03cfb
commit 24382ed827
10 changed files with 105 additions and 149 deletions

View File

@ -72,32 +72,28 @@ Or have an existing set of user variables copied over from another *.inp file.
""", version= scriptID) """, version= scriptID)
parser.add_option('-n','--number', dest='number', type='int', \ parser.add_option('-m', dest='number', type='int', metavar = 'int',
help='maximum requested User Defined Variable [%default]') help='maximum requested User Defined Variable [%default]')
parser.add_option('--homogenization', dest='homog', \ parser.add_option('--homogenization', dest='homog', metavar = 'string',
help='homogenization identifier (as string or integer [%default])') help='homogenization name or index [%default]')
parser.add_option('--crystallite', dest='cryst', \ parser.add_option('--crystallite', dest='cryst', metavar = 'string',
help='crystallite identifier (as string or integer [%default])') help='crystallite identifier name or index [%default]')
parser.add_option('--phase', dest='phase', \ parser.add_option('--phase', dest='phase', metavar = 'string',
help='phase identifier (as string or integer [%default])') help='phase identifier name or index [%default]')
parser.add_option('--use', dest='useFile', \ parser.add_option('--use', dest='useFile', metavar = 'string',
help='Optionally parse output descriptors from '+ help='optionally parse output descriptors from '+
'different <model_job>.outputZZZ file. Saves the effort '+ 'outputXXX files of given name')
'to start a calculation for each job [%default])') parser.add_option('--option', dest='damaskOption', metavar = 'string',
parser.add_option('--option', dest='damaskOption', \ help='Add DAMASK option to input file, e.g. "periodic x z"')
help='Add damask option to input file '+
'for example: "periodic x z" [%default]') parser.set_defaults(number = 0,
parser.set_defaults(number = 0) homog = '1',
parser.set_defaults(homog = '1') cryst = '1',
parser.set_defaults(cryst = '1') phase = '1')
parser.set_defaults(phase = '1')
parser.set_defaults(useFile = '')
parser.set_defaults(damaskOption = '')
(options, files) = parser.parse_args() (options, files) = parser.parse_args()
if not files: if not files:
parser.print_help()
parser.error('no file(s) specified...') parser.error('no file(s) specified...')
me = { 'Homogenization': options.homog, me = { 'Homogenization': options.homog,
@ -108,7 +104,7 @@ me = { 'Homogenization': options.homog,
for file in files: for file in files:
print '\033[1m'+scriptName+'\033[0m: '+file+'\n' print '\033[1m'+scriptName+'\033[0m: '+file+'\n'
if options.useFile != '': if options.useFile:
formatFile = os.path.splitext(options.useFile)[0] formatFile = os.path.splitext(options.useFile)[0]
else: else:
formatFile = os.path.splitext(file)[0] formatFile = os.path.splitext(file)[0]

View File

@ -21,11 +21,11 @@ Changes the (three-dimensional) canvas of a spectral geometry description.
parser.add_option('-g', '--grid', parser.add_option('-g', '--grid',
dest = 'grid', dest = 'grid',
type = 'string', nargs = 3, metavar = ' '.join(['string']*3), type = 'string', nargs = 3, metavar = ' '.join(['string']*3),
help = 'a,b,c grid of hexahedral box [unchanged]') help = 'a,b,c grid of hexahedral box [auto]')
parser.add_option('-o', '--offset', parser.add_option('-o', '--offset',
dest = 'offset', dest = 'offset',
type = 'int', nargs = 3, metavar = ' '.join(['int']*3), type = 'int', nargs = 3, metavar = ' '.join(['int']*3),
help = 'a,b,c offset from old to new origin of grid %default') help = 'a,b,c offset from old to new origin of grid [%default]')
parser.add_option('-f', '--fill', parser.add_option('-f', '--fill',
dest = 'fill', dest = 'fill',
type = 'int', metavar = 'int', type = 'int', metavar = 'int',

View File

@ -92,11 +92,11 @@ boundaries, triple lines, and quadruple points.
parser.add_option('-t','--type', parser.add_option('-t','--type',
dest = 'type', dest = 'type',
action = 'extend', metavar = '<string LIST>', action = 'extend', metavar = '<string LIST>',
help = 'feature type (%s) '%(', '.join(map(lambda x:'|'.join(x['alias']),features))) ) help = 'feature type {%s} '%(', '.join(map(lambda x:'|'.join(x['alias']),features))) )
parser.add_option('-n','--neighborhood', parser.add_option('-n','--neighborhood',
dest = 'neighborhood', dest = 'neighborhood',
choices = neighborhoods.keys(), metavar = 'string', choices = neighborhoods.keys(), metavar = 'string',
help = 'type of neighborhood (%s) [neumann]'%(', '.join(neighborhoods.keys()))) help = 'type of neighborhood {%s} [neumann]'%(', '.join(neighborhoods.keys())))
parser.add_option('-s', '--scale', parser.add_option('-s', '--scale',
dest = 'scale', dest = 'scale',
type = 'float', metavar = 'float', type = 'float', metavar = 'float',

View File

@ -55,10 +55,6 @@ parser.add_option('--m',
dest = 'microstructure', dest = 'microstructure',
type = 'int', nargs = 2, metavar = 'int int', type = 'int', nargs = 2, metavar = 'int int',
help = 'two microstructure indices to be used [%default]') help = 'two microstructure indices to be used [%default]')
parser.add_option('-1', '--onedimensional',
dest = 'oneD',
action = 'store_true',
help = 'output geom file with two-dimensional data arrangement [%default]')
parser.set_defaults(type = minimal_surfaces[0], parser.set_defaults(type = minimal_surfaces[0],
threshold = 0.0, threshold = 0.0,
periods = 1, periods = 1,
@ -66,7 +62,6 @@ parser.set_defaults(type = minimal_surfaces[0],
size = (1.0,1.0,1.0), size = (1.0,1.0,1.0),
homogenization = 1, homogenization = 1,
microstructure = (1,2), microstructure = (1,2),
oneD = False,
) )
(options,filenames) = parser.parse_args() (options,filenames) = parser.parse_args()
@ -135,9 +130,6 @@ for name in filenames:
table.data_clear() table.data_clear()
for x in xrange(options.grid[0]): for x in xrange(options.grid[0]):
table.data_append(options.microstructure[options.threshold < surface[options.type](X[x],Y[y],Z[z])]) table.data_append(options.microstructure[options.threshold < surface[options.type](X[x],Y[y],Z[z])])
if options.oneD:
table.data_write()
table.data_clear()
table.data_write() table.data_write()
table.close() table.close()

View File

@ -30,7 +30,7 @@ parser.add_option('--crystallite', dest='crystallite', type='int', metavar = 'in
parser.add_option('--compress', dest='compress', action='store_true', parser.add_option('--compress', dest='compress', action='store_true',
help='lump identical microstructure and texture information [%default]') help='lump identical microstructure and texture information [%default]')
parser.add_option('-p', '--precision', dest='precision', choices=['0','1','2','3'], metavar = 'int', parser.add_option('-p', '--precision', dest='precision', choices=['0','1','2','3'], metavar = 'int',
help = 'euler angles decimal places for output format and compressing (0,1,2,3) [2]') help = 'euler angles decimal places for output format and compressing {0,1,2,3} [2]')
parser.set_defaults(column = 7) parser.set_defaults(column = 7)
parser.set_defaults(threshold = 1.0) parser.set_defaults(threshold = 1.0)

View File

@ -113,11 +113,11 @@ Generate geometry description and material configuration by standard Voronoi tes
parser.add_option('-g', '--grid', parser.add_option('-g', '--grid',
dest = 'grid', dest = 'grid',
type = 'int', nargs = 3, metavar = ' '.join(['int']*3), type = 'int', nargs = 3, metavar = ' '.join(['int']*3),
help = 'a,b,c grid of hexahedral box [from seeds file]') help = 'a,b,c grid of hexahedral box [auto]')
parser.add_option('-s', '--size', parser.add_option('-s', '--size',
dest = 'size', dest = 'size',
type = 'float', nargs = 3, metavar=' '.join(['float']*3), type = 'float', nargs = 3, metavar=' '.join(['float']*3),
help = 'x,y,z size of hexahedral box [from seeds file or 1.0 along largest grid point number]') help = 'x,y,z size of hexahedral box [auto]')
parser.add_option('-o', '--origin', parser.add_option('-o', '--origin',
dest = 'origin', dest = 'origin',
type = 'float', nargs = 3, metavar=' '.join(['float']*3), type = 'float', nargs = 3, metavar=' '.join(['float']*3),
@ -141,7 +141,7 @@ parser.add_option('-e', '--eulers',
parser.add_option('--axes', parser.add_option('--axes',
dest = 'axes', dest = 'axes',
type = 'string', nargs = 3, metavar = ' '.join(['string']*3), type = 'string', nargs = 3, metavar = ' '.join(['string']*3),
help = 'orientation coordinate frame in terms of position coordinate frame [same]') help = 'orientation coordinate frame in terms of position coordinate frame')
parser.add_option('--homogenization', parser.add_option('--homogenization',
dest = 'homogenization', dest = 'homogenization',
type = 'int', metavar = 'int', type = 'int', metavar = 'int',
@ -165,7 +165,7 @@ parser.add_option('--secondphase',
parser.add_option('-l', '--laguerre', parser.add_option('-l', '--laguerre',
dest = 'laguerre', dest = 'laguerre',
action = 'store_true', action = 'store_true',
help = 'use Laguerre (weighted Voronoi) tessellation [%default]') help = 'use Laguerre (weighted Voronoi) tessellation')
parser.add_option('--cpus', parser.add_option('--cpus',
dest = 'cpus', dest = 'cpus',
type = 'int', metavar = 'int', type = 'int', metavar = 'int',
@ -173,12 +173,9 @@ parser.add_option('--cpus',
parser.add_option('--nonperiodic', parser.add_option('--nonperiodic',
dest = 'nonperiodic', dest = 'nonperiodic',
action = 'store_true', action = 'store_true',
help = 'use nonperiodic tessellation [%default]') help = 'use nonperiodic tessellation')
parser.set_defaults(grid = None, parser.set_defaults(position = 'pos',
size = None,
origin = None,
position = 'pos',
weight = 'weight', weight = 'weight',
microstructure = 'microstructure', microstructure = 'microstructure',
eulers = 'eulerangles', eulers = 'eulerangles',

View File

@ -15,16 +15,9 @@ scriptName = os.path.splitext(scriptID.split()[1])[0]
parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [file[s]]', description = """ parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [file[s]]', description = """
Unpack geometry files containing ranges "a to b" and/or "n of x" multiples (exclusively in one line). Unpack geometry files containing ranges "a to b" and/or "n of x" multiples (exclusively in one line).
""", version = scriptID) """, version = scriptID)
parser.add_option('-1', '--onedimensional',
dest = 'oneD',
action = 'store_true',
help = 'output geom file with one-dimensional data arrangement [%default]')
parser.set_defaults(oneD = False,
)
(options, filenames) = parser.parse_args() (options, filenames) = parser.parse_args()
# --- loop over input files ------------------------------------------------------------------------- # --- loop over input files -------------------------------------------------------------------------
@ -76,8 +69,7 @@ for name in filenames:
microstructure = table.microstructure_read(info['grid']) # read microstructure microstructure = table.microstructure_read(info['grid']) # read microstructure
formatwidth = int(math.floor(math.log10(microstructure.max())+1)) # efficient number printing format formatwidth = int(math.floor(math.log10(microstructure.max())+1)) # efficient number printing format
table.data = microstructure if options.oneD else \ table.data = microstructure.reshape((info['grid'][0],info['grid'][1]*info['grid'][2]),order='F').transpose()
microstructure.reshape((info['grid'][0],info['grid'][1]*info['grid'][2]),order='F').transpose()
table.data_writeArray('%%%ii'%(formatwidth),delimiter = ' ') table.data_writeArray('%%%ii'%(formatwidth),delimiter = ' ')
#--- output finalization -------------------------------------------------------------------------- #--- output finalization --------------------------------------------------------------------------

View File

@ -23,28 +23,22 @@ def func(seq):
#-------------------------------------------------------------------------------------------------- #--------------------------------------------------------------------------------------------------
parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [file[s]]', description = """ parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [file[s]]', description = """
Recognize bounding surfaces and append them as physical sufaces in the geo file. """, version = scriptID) Recognize bounding surfaces and append them as physical sufaces in the geo file.
parser.add_option('-n','--numvol', dest = 'N', \
type='int',\ """, version = scriptID)
metavar='int',\
parser.add_option('-n','--numvol', dest = 'N', type='int', metavar='int',
help='number of physical volumes' ) help='number of physical volumes' )
parser.add_option('-f','--faces', dest = 'surfaces', \ parser.add_option('-f','--faces', dest = 'surfaces', action = 'extend', type = 'string', metavar = '<string LIST>',
action = 'extend', \ help = 'surfaces to tag {x, y, z}')
type = 'string', \ parser.add_option('-s','--size', dest = 'size', type='float', metavar='float',
metavar = '<string LIST>', \ help='mesh size [%default]' )
help = 'surfaces to tag (x, y, and/or z)') parser.add_option('-d','--dim', dest = 'dimension', type='int', metavar='int',
parser.add_option('-s','--size', dest = 'size', \ help='dimension of geometry [%default]' )
type='float',\
metavar='float',\
help='mesh size' )
parser.add_option('-d','--dim', dest = 'dimension', \
type='int',\
metavar='float',\
help='dimension of geometry' )
(options, filename) = parser.parse_args() (options, filename) = parser.parse_args()
parser.set_defaults(size = 0.1) parser.set_defaults(size = 0.1,
parser.set_defaults(dimension = 3) dimension = 3)
my_geofile = filename[0] my_geofile = filename[0]
numVol = options.N numVol = options.N
@ -200,5 +194,3 @@ elif (options.dimension == 2):
f.write('Background Field = 1;\n') f.write('Background Field = 1;\n')
f.close() f.close()

View File

@ -201,17 +201,19 @@ def TothVanHoutteSTAT (ODF,nSamples):
# -------------------------------------------------------------------- # --------------------------------------------------------------------
parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [file[s]]', description = """ parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [file[s]]', description = """
Transform linear binned ODF data into given number of orientations. Transform linear binned ODF data into given number of orientations.
IA: integral approximation, STAT: Van Houtte, MC: Monte Carlo
""", version = scriptID) """, version = scriptID)
algorithms = ['IA', 'STAT','MC']
parser.add_option('-n', '--nsamples', parser.add_option('-n', '--nsamples',
dest = 'number', dest = 'number',
type = 'int', metavar = 'int', type = 'int', metavar = 'int',
help = 'number of orientations to be generated [%default]') help = 'number of orientations to be generated [%default]')
parser.add_option('-a','--algorithm', parser.add_option('-a','--algorithm',
dest = 'algorithm', dest = 'algorithm',
type = 'string', metavar = 'string', choices = algorithms, metavar = 'string',
help = 'sampling algorithm. IA: integral approximation, STAT: Van Houtte, MC: Monte Carlo. [%default].') #make choice help = 'sampling algorithm {%s} [IA]'%(', '.join(algorithms)))
parser.add_option('-p','--phase', parser.add_option('-p','--phase',
dest = 'phase', dest = 'phase',
type = 'int', metavar = 'int', type = 'int', metavar = 'int',

View File

@ -787,78 +787,63 @@ reconstructed boundary file
""", version = scriptID) """, version = scriptID)
parser.add_option("-o", "--output", action='extend', dest='output', \ meshes=['dt_planar_trimesh','af_planar_trimesh','af_planar_quadmesh']
help="types of output [image, mentat, procedure, spectral]") parser.add_option('-o', '--output', action='extend', dest='output', metavar = '<string LIST>',
parser.add_option("-p", "--port", type="int",\ help='types of output {image, mentat, procedure, spectral}')
dest="port",\ parser.add_option('-p', '--port', type='int', metavar = 'int',
help="Mentat connection port [%default]") dest='port', help='Mentat connection port [%default]')
parser.add_option("-2", "--twodimensional", action="store_true",\ parser.add_option('-2', '--twodimensional', action='store_true',
dest="twoD",\ dest='twoD',help='use 2D model')
help="twodimensional model [%default]") parser.add_option('-s','--patchsize', type='float', metavar = 'float',
parser.add_option("-s","--patchsize", type="float",\ dest='size', help='height of patch [%default]')
dest="size",\ parser.add_option('-e', '--strain', type='float', metavar = 'float',
help="height of patch [%default]") dest='strain', help='final strain to reach in simulation [%default]')
parser.add_option("-e", "--strain", type="float",\ parser.add_option('--rate', type='float', metavar = 'float',
dest="strain",\ dest='strainrate', help='engineering strain rate to simulate [%default]')
help="final strain to reach in simulation [%default]") parser.add_option('-N', '--increments', type='int', metavar = 'int',
parser.add_option("--rate", type="float",\ dest='increments', help='number of increments to take [%default]')
dest="strainrate",\ parser.add_option('-t', '--tolerance', type='float', metavar = 'float',
help="(engineering) strain rate to simulate [%default]") dest='tolerance', help='relative tolerance of pixel positions to be swept [%default]')
parser.add_option("-N", "--increments", type="int",\ parser.add_option('-m', '--mesh', choices = meshes,
dest="increments",\ metavar = '<string LIST>', dest='mesh',
help="number of increments to take [%default]") help='algorithm and element type for automeshing {%s} [dt_planar_trimesh]'%(', '.join(meshes)))
parser.add_option("-t", "--tolerance", type="float",\ parser.add_option('-x', '--xmargin', type='float', metavar = 'float',
dest="tolerance",\ dest='xmargin',help='margin in x in units of patch size [%default]')
help="relative tolerance of pixel positions to be swept [%default]") parser.add_option('-y', '--ymargin', type='float', metavar = 'float',
parser.add_option("-m", "--mesh", choices=['dt_planar_trimesh','af_planar_trimesh','af_planar_quadmesh'],\ dest='ymargin', help='margin in y in units of patch size [%default]')
dest="mesh",\ parser.add_option('-r', '--resolution', type='int', metavar = 'int',
help="algorithm and element type for automeshing (dt_planar_trimesh, af_planar_trimesh, af_planar_quadmesh) [%default]") dest='resolution',help='number of Fourier points/Finite Elements across patch size + x_margin [%default]')
parser.add_option("-x", "--xmargin", type="float",\ parser.add_option('-z', '--extrusion', type='int', metavar = 'int',
dest="xmargin",\ dest='extrusion', help='number of repetitions in z-direction [%default]')
help="margin in x in units of patch size [%default]") parser.add_option('-i', '--imagesize', type='int', metavar = 'int',
parser.add_option("-y", "--ymargin", type="float",\ dest='imgsize', help='size of PNG image [%default]')
dest="ymargin",\ parser.add_option('-M', '--coordtransformation', type='float', nargs=4, metavar = ' '.join(['float']*4),
help="margin in y in units of patch size [%default]") dest='M', help='2x2 transformation from rcb to Euler coords [%default]')
parser.add_option("-r", "--resolution", type="int",\ parser.add_option('--scatter', type='float', metavar = 'float',
dest="resolution",\ dest='scatter',help='orientation scatter [%default]')
help="number of Fourier points/Finite Elements across patch size + x_margin [%default]") parser.add_option('--segment', type='int', metavar = 'int', dest='segmentcolumn',
parser.add_option("-z", "--extrusion", type="int",\ help='column holding the first entry for the segment end points in the rcb file [%default]')
dest="extrusion",\ parser.add_option('--id', type='int', dest='idcolumn', metavar = 'int',
help="number of repetitions in z-direction [%default]") help='column holding the right hand grain ID in the rcb file [%default]')
parser.add_option("-i", "--imagesize", type="int",\
dest="imgsize",\
help="size of PNG image [%default]")
parser.add_option("-M", "--coordtransformation", type="float", nargs=4, \
dest="M",\
help="2x2 transformation from rcb to Euler coords [%default]")
parser.add_option("--scatter", type="float",\
dest="scatter",\
help="orientation scatter %default")
parser.add_option("--segment", type="int",\
dest="segmentcolumn",\
help="column holding the first entry for the segment end points in the rcb file [%default]")
parser.add_option("--id", type="int",\
dest="idcolumn",\
help="column holding the right hand grain ID in the rcb file [%default]")
parser.set_defaults(output = []) parser.set_defaults(output = [],
parser.set_defaults(size = 1.0) size = 1.0,
parser.set_defaults(port = 40007) port = 40007,
parser.set_defaults(xmargin = 0.0) xmargin = 0.0,
parser.set_defaults(ymargin = 0.0) ymargin = 0.0,
parser.set_defaults(resolution = 64) resolution = 64,
parser.set_defaults(extrusion = 2) extrusion = 2,
parser.set_defaults(imgsize = 512) imgsize = 512,
parser.set_defaults(M = [0.0,1.0,1.0,0.0]) # M_11, M_12, M_21, M_22. x,y in RCB is y,x of Eulers!! M = (0.0,1.0,1.0,0.0), # M_11, M_12, M_21, M_22. x,y in RCB is y,x of Eulers!!
parser.set_defaults(tolerance = 1.0e-3) tolerance = 1.0e-3,
parser.set_defaults(scatter = 0.0) scatter = 0.0,
parser.set_defaults(strain = 0.2) strain = 0.2,
parser.set_defaults(strainrate = 1.0e-3) strainrate = 1.0e-3,
parser.set_defaults(increments = 200) increments = 200,
parser.set_defaults(mesh = 'dt_planar_trimesh') mesh = 'dt_planar_trimesh',
parser.set_defaults(twoD = False) twoD = False,
parser.set_defaults(segmentcolumn = 9) segmentcolumn = 9,
parser.set_defaults(idcolumn = 13) idcolumn = 13)
(options, args) = parser.parse_args() (options, args) = parser.parse_args()