Created
March 17, 2015 05:42
-
-
Save mhogg/b0481d842253d12bb41d to your computer and use it in GitHub Desktop.
Getting ABAQUS element connectivities
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from abaqus import * | |
from abaqusConstants import * | |
from odbAccess import * | |
odb = session.viewports[session.currentViewportName].displayedObject | |
instName = 'MALE' | |
elements = odb.rootAssembly.instances[instName].elements | |
foutName = 'elementConnectivity.txt' | |
# Get element connectivity (elements connect to nodes) | |
elemConn = {} | |
for elem in elements: | |
e = elem.label | |
nconn = elem.connectivity | |
for n in nconn: | |
if not elemConn.has_key(n): | |
elemConn[n] = [] | |
elemConn[n].append(e) | |
# Now get list of all neighbouring elements for each element | |
elemNbr = {} | |
for elem in elements: | |
e = elem.label | |
nconn = elem.connectivity | |
if not elemNbr.has_key(e): | |
elemNbr[e] = {} | |
for n in nconn: | |
for ec in elemConn[n]: | |
elemNbr[e][ec] = 1 | |
# Delete element label from its keys of neighbours and convert to a list | |
for k in elemNbr.keys(): | |
del elemNbr[k][k] | |
elemNbr[k] = elemNbr[k].keys() | |
# Print to a file | |
fout = open(foutName,'w') | |
for k,v in sorted(elemNbr.items()): | |
fout.write('%10d%s\n' % (k, "".join(['%10d' % (i) for i in v]))) | |
fout.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, i have a question, what is there in elemConn?
I thought element number as a key and the connected nodes as a values, is this correct?