Amirsmol Amirsmol - 7 months ago 49
Python Question

How to print the connectivity in abaqus python matrix using writeFieldReport

I am trying to print the connectivity matrix for specific element sets.
I know how to do this using probe value in abaqus/viewer and probe value.
Unfortunately, the probe value function does not record anything on the report file.
Does any one know how to print connectivity matrix for specific element sets using
writeFieldReport?
I am looking for an out put like this

Part Instance Element ID Type Attached nodes
--------------------------------------------------------------------------------
PART-1-1 167 C3D8 3309 3310 3198 3197

309 310 198 197


Thanks

Answer

This script will export node connectivity info from an assembly level element set. Just set the user variables as indicated in the script below and it'll export a text file in the same directory as the odb.

from abaqusConstants import *
from viewerModules import *
import os

# User variables ------------------
elementSetName='fix'
outPutFileName='tmp.txt'
# ---------------------------------

currView=session.viewports[session.currentViewportName]
cOdbD=currView.odbDisplay
odb = session.odbs[cOdbD.name]
odbRootA=odb.rootAssembly

directory=os.path.split(odb.path)[0]

with open(os.path.join(directory,outPutFileName),"w") as f:  

    f.write("%s\n" % ('  Part Instance  Element ID        Type  Attached nodes'))
    f.write("%s\n" % ('--------------------------------------------------------------------------------'))   

    for element in odbRootA.elementSets[elementSetName.upper()].elements[0]: 

        f.write("%s" % ('    ' + element.instanceName + '         ' + str(element.label) + '        ' + element.type))

        nodeNum=0
        for node in element.connectivity:
            nodeNum+=1
            if nodeNum>4:
                f.write("\n%s\n" % (''))
                nodeNum=-4

            f.write("%s" % ('        ' + str(node)))
        f.write("\n")
        f.write("\n")