from odbAccess import * from abaqusConstants import * import os os.chdir('f:\\shared\\fretting\\fretting_tests') odb = openOdb('fretting_model.odb') elems = {} assembly = odb.rootAssembly for name, instance in assembly.instances.items(): num_elem = len(instance.elements) for element in instance.elements: conn = [] # print element.type for nodeNum in element.connectivity: conn.append(nodeNum) elems[element.label] = conn fw = open('fretting_model.dtp','w') print >> fw, "NUM STEP", len(odb.steps.keys()) for step_name in odb.steps.keys(): step = odb.steps[step_name] step_num = step.number print >> fw, "LOADSTEP", step_num num_frames = len(odb.steps[step_name].frames) frame = odb.steps[step_name].frames[num_frames-1] #print frame.fieldOutputs.keys() for fk in frame.fieldOutputs.keys(): if len(fk) >= 1 and fk[0] == 'U' : print >> fw, "DISPLACEMENT" for foU in frame.fieldOutputs[fk].values: nid = foU.nodeLabel dsp = foU.data print >> fw, nid," ",float(dsp[0])," ",float(dsp[1])," ",float(dsp[2]) if len(fk) >= 4 and fk[0:4] == 'NT11' : print >> fw, "TEMPERATURE" for foT in frame.fieldOutputs[fk].values: nid = foT.nodeLabel tmp = foT.data print >> fw, nid," ",float(tmp) if len(fk) >= 1 and fk[0:1] == 'S' : # abaqus .inp file data: # *Output, field, variable=PRESELECT # *element output, position=NODES # S # print >> fw, "STRESS" # stress = frame.fieldOutputs['S'] # field = stress.getSubset(position=NODAL) # fieldValues = field.values # for foS in fieldValues: # strs = foS.data # print >> fw, foS.nodeLabel," ",float(strs[0])," ",float(strs[1])," ",float(strs[2])," ",float(strs[3])," ",float(strs[4])," ",float(strs[5]) print >> fw, "STRESS ELEMENT NODAL" elemStress = frame.fieldOutputs['S'] field = elemStress.getSubset(position=ELEMENT_NODAL) fieldValues = field.values nc = 0 el_id = 0 for foS in fieldValues: el = foS.elementLabel if el_id != el: el_id = el nc = 0 else: nc = nc + 1 conn = elems[el] strs = foS.data if len(strs) >= 6 : print >> fw, el," ",conn[nc]," ",float(strs[0])," ",float(strs[1])," ",float(strs[2])," ",float(strs[3])," ",float(strs[4])," ",float(strs[5]) if len(fk) >= 1 and fk[0:1] == 'E' : # abaqus .inp file data: # *Output, field, variable=PRESELECT # *element output, position=NODES # E # print >> fw, "STRAIN" # strain = frame.fieldOutputs['E'] # field = strain.getSubset(position=NODAL) # fieldValues = field.values # for foE in fieldValues: # strn = foE.data # print >> fw, foE.nodeLabel," ",float(strn[0])," ",float(strn[1])," ",float(strn[2])," ",float(strn[3])," ",float(strn[4])," ",float(strn[5]) print >> fw, "STRAIN ELEMENT NODAL" elemStrain = frame.fieldOutputs['E'] field = elemStrain.getSubset(position=ELEMENT_NODAL) fieldValues = field.values nc = 0 el_id = 0 for foS in fieldValues: el = foS.elementLabel if el_id != el: el_id = el nc = 0 else: nc = nc + 1 conn = elems[el] strn = foS.data if len(strn) >= 6 : print >> fw, el," ",conn[nc]," ",float(strn[0])," ",float(strn[1])," ",float(strn[2])," ",float(strn[3])," ",float(strn[4])," ",float(strn[5]) if len(fk) >= 7 and fk[0:7] == 'CSTATUS' : print >> fw, "STATUS" for foP in frame.fieldOutputs[fk].values: nid = foP.nodeLabel stat = foP.data print >> fw, nid," ",float(stat) if len(fk) >= 5 and fk[0:5] == 'COPEN' : print >> fw, "GAP" for foP in frame.fieldOutputs[fk].values: nid = foP.nodeLabel stat = foP.data print >> fw, nid," ",float(stat) if len(fk) >= 6 and fk[0:6] == 'CPRESS' : print >> fw, "PRESSURE" for foP in frame.fieldOutputs[fk].values: nid = foP.nodeLabel prs = foP.data print >> fw, nid," ",float(prs) if len(fk) >= 7 and fk[0:7] == 'CSHEAR1' : print >> fw, "SHEAR STRESS 1" for foS in frame.fieldOutputs[fk].values: nid = foS.nodeLabel shr = foS.data print >> fw, nid," ",float(shr) if len(fk) >= 7 and fk[0:7] == 'CSHEAR2' : print >> fw, "SHEAR STRESS 2" for foS in frame.fieldOutputs[fk].values: nid = foS.nodeLabel shr = foS.data print >> fw, nid," ",float(shr) if len(fk) >= 6 and fk[0:6] == 'CSLIP1' : print >> fw, "SLIP 1" for foS in frame.fieldOutputs[fk].values: nid = foS.nodeLabel slp = foS.data print >> fw, nid," ",float(slp) if len(fk) >= 6 and fk[0:6] == 'CSLIP2' : print >> fw, "SLIP 2" for foS in frame.fieldOutputs[fk].values: nid = foS.nodeLabel slp = foS.data print >> fw, nid," ",float(slp) fw.close()