exchanged location of "graincount" in user block.

now matches wiki entry:
1. homogenization block
2. grain block
  (grain count
   sub-block[s] of crystallite and constitutive)
This commit is contained in:
Philip Eisenlohr 2011-11-23 09:09:00 +00:00
parent e8f5996a96
commit f685bbba0e
3 changed files with 68 additions and 60 deletions

View File

@ -558,25 +558,25 @@ subroutine materialpoint_postResults(dt)
integer(pInt) g,i,e,thePos,theSize,myNgrains,myCrystallite
!$OMP PARALLEL DO PRIVATE(myNgrains,myCrystallite,thePos,theSize)
do e = FEsolving_execElem(1),FEsolving_execElem(2) ! iterate over elements to be processed
do e = FEsolving_execElem(1),FEsolving_execElem(2) ! iterate over elements to be processed
myNgrains = homogenization_Ngrains(mesh_element(3,e))
myCrystallite = microstructure_crystallite(mesh_element(4,e))
do i = FEsolving_execIP(1,e),FEsolving_execIP(2,e) ! iterate over IPs of this element to be processed
do i = FEsolving_execIP(1,e),FEsolving_execIP(2,e) ! iterate over IPs of this element to be processed
thePos = 0_pInt
materialpoint_results(thePos+1,i,e) = myNgrains ! tell number of grains at materialpoint
thePos = thePos + 1_pInt
theSize = homogenization_sizePostResults(i,e)
materialpoint_results(thePos+1,i,e) = theSize ! tell size of homogenization results
thePos = thePos + 1_pInt
if (theSize > 0_pInt) then ! any homogenization results to mention?
if (theSize > 0_pInt) then ! any homogenization results to mention?
materialpoint_results(thePos+1:thePos+theSize,i,e) = homogenization_postResults(i,e) ! tell homogenization results
thePos = thePos + theSize
endif
do g = 1,myNgrains ! loop over all grains
materialpoint_results(thePos+1,i,e) = myNgrains ! tell number of grains at materialpoint
thePos = thePos + 1_pInt
do g = 1,myNgrains ! loop over all grains
theSize = (1 + crystallite_sizePostResults(myCrystallite)) + (1 + constitutive_sizePostResults(g,i,e))
materialpoint_results(thePos+1:thePos+theSize,i,e) = crystallite_postResults(dt,g,i,e) ! tell crystallite results
thePos = thePos + theSize

View File

@ -1,8 +1,10 @@
#!/usr/bin/env python
import pdb, os, sys, gc, math, re, threading, time, struct, string
import msc_tools
from optparse import OptionParser, OptionGroup, Option, SUPPRESS_HELP
fileExtensions = { \
'marc': ['.t16',],
'spectral': ['.spectralOut',],
@ -489,12 +491,15 @@ def ParseOutputFormat(filename,what,me):
# -----------------------------
def ParsePostfile(p,filename, outputFormat):
def ParsePostfile(p,filename, outputFormat, legacyFormat):
#
# parse postfile in order to get position and labels of outputs
# needs "outputFormat" for mapping of output names to postfile output indices
# -----------------------------
startVar = {True: 'GrainCount',
False:'HomogenizationCount'}
# --- build statistics
stat = { \
@ -529,47 +534,61 @@ def ParsePostfile(p,filename, outputFormat):
stat['IndexOfLabel'][label] = labelIndex
stat['LabelOfElementalTensor'][labelIndex] = label
if 'User Defined Variable 1' in stat['IndexOfLabel']:
stat['IndexOfLabel']['GrainCount'] = stat['IndexOfLabel']['User Defined Variable 1']
if 'User Defined Variable 1' in stat['IndexOfLabel']: # output format without dedicated names?
stat['IndexOfLabel'][startVar[legacyFormat]] = stat['IndexOfLabel']['User Defined Variable 1'] # adjust first named entry
if 'GrainCount' in stat['IndexOfLabel']: # does the result file contain relevant user defined output at all?
startIndex = stat['IndexOfLabel']['GrainCount'] - 1
if startVar[legacyFormat] in stat['IndexOfLabel']: # does the result file contain relevant user defined output at all?
startIndex = stat['IndexOfLabel'][startVar[legacyFormat]]
stat['LabelOfElementalScalar'][startIndex] = startVar[legacyFormat]
# We now have to find a mapping for each output label as defined in the .output* files to the output position in the post file
# Since we know where the user defined outputs start ("startIndex"), we can simply assign increasing indices to the labels
# given in the .output* file
offset = 1
if legacyFormat:
stat['LabelOfElementalScalar'][startIndex + offset] = startVar[not legacyFormat] # add HomogenizationCount as second
offset += 1
offset = 2
stat['LabelOfElementalScalar'][startIndex + offset] = 'HomogenizationCount'
for var in outputFormat['Homogenization']['outputs']:
if var[1] > 1:
for i in range(var[1]):
stat['IndexOfLabel']['%i_%s'%(i+1,var[0])] = startIndex + offset + (i+1)
else:
stat['IndexOfLabel']['%s'%(var[0])] = startIndex + offset + 1
offset += var[1]
for (name,N) in outputFormat['Homogenization']['outputs']:
for i in range(N):
label = {False: '%s'%( name),
True:'%i_%s'%(i+1,name)}[N > 1]
stat['IndexOfLabel'][label] = startIndex + offset
stat['LabelOfElementalScalar'][startIndex + offset] = label
offset += 1
if not legacyFormat:
stat['IndexOfLabel'][startVar[not legacyFormat]] = startIndex + offset
stat['LabelOfElementalScalar'][startIndex + offset] = startVar[not legacyFormat] # add GrainCount
offset += 1
if '(ngrains)' in outputFormat['Homogenization']['specials']:
for grain in range(outputFormat['Homogenization']['specials']['(ngrains)']):
stat['IndexOfLabel']['%i_CrystalliteCount'%(grain+1)] = startIndex + offset + 1
offset += 1
for var in outputFormat['Crystallite']['outputs']:
if var[1] > 1:
for i in range(var[1]):
stat['IndexOfLabel']['%i_%i_%s'%(grain+1,i+1,var[0])] = startIndex + offset + (i+1)
else:
stat['IndexOfLabel']['%i_%s'%(grain+1,var[0])] = startIndex + offset + 1
offset += var[1]
stat['IndexOfLabel']['%i_ConstitutiveCount'%(grain+1)] = startIndex + offset + 1
stat['IndexOfLabel']['%i_CrystalliteCount'%(grain+1)] = startIndex + offset # report crystallite count
stat['LabelOfElementalScalar'][startIndex + offset] = '%i_CrystalliteCount'%(grain+1) # add GrainCount
offset += 1
for var in outputFormat['Constitutive']['outputs']:
if var[1] > 1:
for i in range(var[1]):
stat['IndexOfLabel']['%i_%i_%s'%(grain+1,i+1,var[0])] = startIndex + offset + (i+1)
else:
stat['IndexOfLabel']['%i_%s'%(grain+1,var[0])] = startIndex + offset + 1
offset += var[1]
for (name,N) in outputFormat['Crystallite']['outputs']: # add crystallite outputs
for i in range(N):
label = {False: '%i_%s'%(grain+1, name),
True:'%i_%i_%s'%(grain+1,i+1,name)}[N > 1]
stat['IndexOfLabel'][label] = startIndex + offset
stat['LabelOfElementalScalar'][startIndex + offset] = label
offset += 1
stat['IndexOfLabel']['%i_ConstitutiveCount'%(grain+1)] = startIndex + offset # report constitutive count
stat['LabelOfElementalScalar'][startIndex + offset] = '%i_ConstitutiveCount'%(grain+1) # add GrainCount
offset += 1
for (name,N) in outputFormat['Constitutive']['outputs']: # add constitutive outputs
for i in range(N):
label = {False: '%i_%s'%(grain+1, name),
True:'%i_%i_%s'%(grain+1,i+1,name)}[N > 1]
stat['IndexOfLabel'][label] = startIndex + offset
stat['LabelOfElementalScalar'][startIndex + offset] = label
offset += 1
return stat
@ -619,6 +638,8 @@ of already processed data points for evaluation.
parser.add_option('-i','--info', action='store_true', dest='info', \
help='list contents of resultfile [%default]')
parser.add_option('-l','--legacy', action='store_true', dest='legacy', \
help='legacy user result block (starts with GrainCount) [%default]')
parser.add_option( '--prefix', dest='prefix', \
help='prefix to result file name [%default]')
parser.add_option('-d','--dir', dest='dir', \
@ -676,6 +697,7 @@ parser.add_option_group(group_general)
parser.add_option_group(group_special)
parser.set_defaults(info = False)
parser.set_defaults(legacy = False)
parser.set_defaults(sloppy = False)
parser.set_defaults(prefix = '')
parser.set_defaults(dir = 'postProc')
@ -726,27 +748,12 @@ if options.filetype not in ['marc','spectral']:
parser.error('file type "%s" not supported...'%options.filetype)
if options.filetype == 'marc':
try:
file = open('%s/../MSCpath'%os.path.dirname(os.path.realpath(sys.argv[0])))
MSCpath = os.path.normpath(file.readline().strip())
file.close()
except:
MSCpath = '/msc'
for release,subdirs in sorted(releases.items(),reverse=True):
for subdir in subdirs:
libPath = '%s/mentat%s/shlib/%s'%(MSCpath,release,subdir)
if os.path.exists(libPath):
sys.path.append(libPath)
break
else:
continue
break
sys.path.append(msc_tools.MSC_TOOLS().libraryPath(sys.argv[0],'../../'))
try:
from py_post import *
except:
print('error: no valid Mentat release found in %s'%MSCpath)
print('error: no valid Mentat release found')
sys.exit(-1)
else:
def post_open():
@ -803,7 +810,7 @@ for what in me:
bg.set_message('opening result file...')
p = OpenPostfile(filename+extension,options.filetype)
bg.set_message('parsing result file...')
stat = ParsePostfile(p, filename, outputFormat)
stat = ParsePostfile(p, filename, outputFormat,options.legacy)
if options.filetype == 'marc':
stat['NumberOfIncrements'] -= 1 # t16 contains one "virtual" increment (at 0)
@ -824,7 +831,7 @@ for opt in ['nodalScalar','elemScalar','elemTensor','homogenizationResult','crys
if options.info:
if options.filetype == 'marc':
print '\n\nMentat release %s'%release
print '\n\nMentat release %s'%msc_tools.MSC_TOOLS().version(sys.argv[0],'../../')
if options.filetype == 'spectral':
print '\n\n',p

View File

@ -105,14 +105,15 @@ for file in files:
print '\n'.join(map(lambda x:' '+x,outputFormat[what]['specials']['brothers']))
sys.exit(1)
UserVars = ['GrainCount']
UserVars += ['HomogenizationCount']
UserVars = ['HomogenizationCount']
for var in outputFormat['Homogenization']['outputs']:
if var[1] > 1:
UserVars += ['%i_%s'%(i+1,var[0]) for i in range(var[1])]
else:
UserVars += ['%s'%(var[0]) for i in range(var[1])]
UserVars += ['GrainCount']
for grain in range(outputFormat['Homogenization']['specials']['(ngrains)']):
UserVars += ['%i_CrystalliteCount'%(grain+1)]
for var in outputFormat['Crystallite']['outputs']: