0
def getPressAve(odbname):
odb=openOdb(odbname)
lastFrame=odb.steps['Step-1'].frames[-1]
pressure=lastFrame.fieldOutputs['CPRESS']
press=[[0,0]] # sets the first element to [0,0]
for n in pressure.values:
gridPt=part1.nodes.getFromLabel(n.nodeLabel)
coord=assemb.getCoordinates(gridPt)
press.append([n.nodeLabel,n.data,coord])
press=avePress=press[1:] # removes the first element
press.sort(Comp_X)
print ('pressure extracted')
index=0
while index<len(press):
sum=0
tally=0
if index!=0:
sum=sum+press[index-1][1]
tally=tally+1
if index!=1:
sum=sum+press[index-2][1]
tally=tally+1
if index!=2:
sum=sum+press[index][1]
tally=tally+1
if index<len(press)-1:
sum=sum+press[index+1][1]
tally=tally+1
if index<len(press)-2:
sum=sum+press[index+2][1]
tally=tally+1
average=sum/tally
avePress[index][1]=average
index=index+1
odb.close()
print ('pressure averaged')
return avePress
描述請 –