1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
|
from odbAccess import*
from abaqusConstants import*
from odbMaterial import*
from odbSection import*
class Table(object):
def __init__(self):
# self.table est un tableau de cellules, donc bi-dimensionnel.
self.table=[]
self.height = 0
self.width = 0
def set_at(self, row, col, text):
# On agrandi self.table autant que nécessaire, dans les deux directions.
if col >= self.width:
for r in self.table:
r.extend(["" for i in range(col - self.width + 1)])
self.width = col + 1
if row >= self.height:
self.table.extend([["" for i in range(self.width)] for j in range(row - self.height + 1)])
self.height = row + 1
self.table[row][col] = text
def to_string(self, colsep = '\t'):
# Ici, la difficulté est de rajouter des espaces au contenu des cellules,
# de façon à avoir toujours le même nombre de signes dans une colonne
col_max_len = [max(map(len,e)) for e in zip(*self.table)]
ret = []
for r in self.table:
l = []
for i, c in enumerate(r):
l.append("".join((c, " "*(col_max_len[i]-len(c)))))
ret.append(colsep.join(l))
return "\n".join(ret)
output = Table()
odb = openOdb(path='hcf.odb')
myAssembly = odb.rootAssembly
for instanceName in odb.rootAssembly.instances.keys():
print 'Instance Name : ',instanceName
print 'Node sets = ',odb.rootAssembly.instances['V20110406-1-1'].nodeSets.keys()
print 'element sets = ',odb.rootAssembly.instances['V20110406-1-1'].elementSets.keys()
allMaterials = odb.materials
for materialName in allMaterials.keys():
print 'Material Name : ',materialName
allSections = odb.sections
for sectionName in allSections.keys():
print 'Section Name : ',sectionName
for mySection in allSections.values():
if type(mySection) == HomogeneousSolidSectionType:
print 'material name = ',mySection.material
instances = odb.rootAssembly.instances
row = 0
for instance in instances.values():
assignments = instance.sectionAssignments
print 'Instance : ',instance.name
for sa in assignments:
region = sa.region
elements = region.elements
print ' Elements associated with this section : '
for e in elements:
#print ' label : ',e.label
output.set_at(row, 0, 'Instance: %s'%instance.name)
output.set_at(row, 1, 'label: %6d'%e.label)
row += 1
for stepName in odb.steps.keys():
print stepName
#step1 = odb.steps.values()[0]
#print step1.name
lastFrame = odb.steps['Load'].frames[-1]
for fieldName in lastFrame.fieldOutputs.keys():
print fieldName
# for each field output value in the last frame, print the name, description, and type members.
for f in lastFrame.fieldOutputs.values():
print f.name,':', f.description
print 'type: ', f.type
displacement = lastFrame.fieldOutputs['U']
fieldValues = displacement.values
#for each displacement value, print the nodelabel and data members
row = 0
for v in fieldValues:
# print 'Node = %d, U[x] = %6.4f, U[y]= %6.4f' % (v.nodeLabel, v.data[0], v.data[1])
output.set_at(row, 2, 'Node: %d'%v.nodeLabel)
output.set_at(row, 3, 'U[x]: %6.4f'%v.data[0])
output.set_at(row, 4, 'U[y]: %6.4f'%v.data[1])
with open('hcf2.txt','w') as f:
f.write(output.to_string()) |