unifying scripts
This commit is contained in:
parent
4acfc73fa1
commit
8593fb3ed7
|
@ -94,7 +94,7 @@ me = { 'Homogenization': options.homog,
|
||||||
|
|
||||||
for myFile in files:
|
for myFile in files:
|
||||||
damask.util.report(scriptName,myFile)
|
damask.util.report(scriptName,myFile)
|
||||||
if options.useFile:
|
if options.useFile is not None:
|
||||||
formatFile = os.path.splitext(options.useFile)[0]
|
formatFile = os.path.splitext(options.useFile)[0]
|
||||||
else:
|
else:
|
||||||
formatFile = os.path.splitext(myFile)[0]
|
formatFile = os.path.splitext(myFile)[0]
|
||||||
|
@ -146,7 +146,7 @@ for myFile in files:
|
||||||
inFile.close()
|
inFile.close()
|
||||||
output = open(myFile,'w')
|
output = open(myFile,'w')
|
||||||
thisSection = ''
|
thisSection = ''
|
||||||
if options.damaskOption:
|
if options.damaskOption is not None:
|
||||||
output.write('$damask {0}\n'.format(options.damaskOption))
|
output.write('$damask {0}\n'.format(options.damaskOption))
|
||||||
for line in input:
|
for line in input:
|
||||||
#Abaqus keyword line begins with: *keyword, argument1, ...
|
#Abaqus keyword line begins with: *keyword, argument1, ...
|
||||||
|
@ -165,4 +165,3 @@ for myFile in files:
|
||||||
if (thisSection.upper() != '*DEPVAR' or not re.match('\s*\d',line)):
|
if (thisSection.upper() != '*DEPVAR' or not re.match('\s*\d',line)):
|
||||||
output.write(line)
|
output.write(line)
|
||||||
output.close()
|
output.close()
|
||||||
|
|
||||||
|
|
|
@ -48,9 +48,9 @@ def ParseOutputFormat(filename,what,me):
|
||||||
format['outputs'].append([output,length])
|
format['outputs'].append([output,length])
|
||||||
return format
|
return format
|
||||||
|
|
||||||
parser = OptionParser(option_class=damask.extendableOption, usage='%prog [option(s)] Marc.Inputfile(s)', description="""
|
parser = OptionParser(option_class=damask.extendableOption, usage='%prog [option(s)] Marc.Inputfile(s)', description = """
|
||||||
Transfer the output variables requested in the material.config to
|
Transfer the output variables requested in the material.config to
|
||||||
properly labelled user defined variables within the Marc input file (*.dat).
|
properly labelled user-defined variables within the Marc input file (*.dat).
|
||||||
|
|
||||||
Requires the files
|
Requires the files
|
||||||
<modelname_jobname>.output<Homogenization/Crystallite/Constitutive>
|
<modelname_jobname>.output<Homogenization/Crystallite/Constitutive>
|
||||||
|
@ -61,40 +61,29 @@ Or have an existing set of user variables copied over from another *.dat file.
|
||||||
|
|
||||||
""", version = scriptID)
|
""", version = scriptID)
|
||||||
|
|
||||||
|
parser.add_option('-m', dest='number', type='int', metavar = 'int',
|
||||||
parser.add_option('-n','--number', 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',
|
||||||
metavar='string',
|
help='homogenization name or index [%default]')
|
||||||
help='homogenization identifier (as string or integer [%default])')
|
parser.add_option('--crystallite', dest='cryst', metavar = 'string',
|
||||||
parser.add_option('--crystallite', dest='cryst', \
|
help='crystallite identifier name or index [%default]')
|
||||||
metavar='string',
|
parser.add_option('--phase', dest='phase', metavar = 'string',
|
||||||
help='crystallite identifier (as string or integer [%default])')
|
help='phase identifier name or index [%default]')
|
||||||
parser.add_option('--phase', dest='phase', \
|
parser.add_option('--use', dest='useFile', metavar = 'string',
|
||||||
metavar='string',
|
help='optionally parse output descriptors from '+
|
||||||
help='phase identifier (as string or integer [%default])')
|
'outputXXX files of given name')
|
||||||
parser.add_option('--use', dest='useFile', \
|
parser.add_option('--option', dest='damaskOption', metavar = 'string',
|
||||||
metavar='string',
|
help='Add DAMASK option to input file, e.g. "periodic x z"')
|
||||||
help='Optionally parse output descriptors from '+
|
|
||||||
'different <model_job>.outputZZZ file. Saves the effort '+
|
parser.set_defaults(number = 0,
|
||||||
'to start a calculation for each job)')
|
homog = '1',
|
||||||
parser.add_option('--option', dest='damaskOption', \
|
cryst = '1',
|
||||||
metavar='string',
|
phase = '1')
|
||||||
help='Add damask option to input file '+
|
|
||||||
'for example: "periodic x z"')
|
|
||||||
parser.set_defaults(number = 0)
|
|
||||||
parser.set_defaults(homog = '1')
|
|
||||||
parser.set_defaults(cryst = '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,
|
||||||
'Crystallite': options.cryst,
|
'Crystallite': options.cryst,
|
||||||
|
@ -103,8 +92,8 @@ me = { 'Homogenization': options.homog,
|
||||||
|
|
||||||
|
|
||||||
for myFile in files:
|
for myFile in files:
|
||||||
print('\033[1m'+scriptName+'\033[0m: '+myFile+'\n')
|
damask.util.report(scriptName,myFile)
|
||||||
if options.useFile != '':
|
if options.useFile is not None:
|
||||||
formatFile = os.path.splitext(options.useFile)[0]
|
formatFile = os.path.splitext(options.useFile)[0]
|
||||||
else:
|
else:
|
||||||
formatFile = os.path.splitext(myFile)[0]
|
formatFile = os.path.splitext(myFile)[0]
|
||||||
|
@ -113,7 +102,7 @@ for myFile in files:
|
||||||
print('{} not found'.format(myFile))
|
print('{} not found'.format(myFile))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
print('Scanning format files of: %s'%formatFile)
|
print('Scanning format files of: {}'.format(formatFile))
|
||||||
|
|
||||||
if options.number < 1:
|
if options.number < 1:
|
||||||
outputFormat = {}
|
outputFormat = {}
|
||||||
|
@ -121,7 +110,7 @@ for myFile in files:
|
||||||
for what in me:
|
for what in me:
|
||||||
outputFormat[what] = ParseOutputFormat(formatFile,what,me[what])
|
outputFormat[what] = ParseOutputFormat(formatFile,what,me[what])
|
||||||
if '_id' not in outputFormat[what]['specials']:
|
if '_id' not in outputFormat[what]['specials']:
|
||||||
print("'{}' not found in <{}>"%(me[what],what))
|
print("'{}' not found in <{}>".format(me[what],what))
|
||||||
print('\n'.join(map(lambda x:' '+x,outputFormat[what]['specials']['brothers'])))
|
print('\n'.join(map(lambda x:' '+x,outputFormat[what]['specials']['brothers'])))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
@ -150,13 +139,13 @@ for myFile in files:
|
||||||
UserVars += ['%i_%s'%(grain+1,var[0]) for i in range(var[1])]
|
UserVars += ['%i_%s'%(grain+1,var[0]) for i in range(var[1])]
|
||||||
|
|
||||||
# Now change *.dat file(s)
|
# Now change *.dat file(s)
|
||||||
print('Adding labels to: %s'%myFile)
|
print('Adding labels to: {}'.format(myFile))
|
||||||
inFile = open(myFile)
|
inFile = open(myFile)
|
||||||
input = inFile.readlines()
|
input = inFile.readlines()
|
||||||
inFile.close()
|
inFile.close()
|
||||||
output = open(myFile,'w')
|
output = open(myFile,'w')
|
||||||
thisSection = ''
|
thisSection = ''
|
||||||
if options.damaskOption:
|
if options.damaskOption is not None:
|
||||||
output.write('$damask {0}\n'.format(options.damaskOption))
|
output.write('$damask {0}\n'.format(options.damaskOption))
|
||||||
for line in input:
|
for line in input:
|
||||||
m = re.match('(\w+)\s',line)
|
m = re.match('(\w+)\s',line)
|
||||||
|
|
Loading…
Reference in New Issue