phd-scripts/ActaBiomat13/diff_pre_3.py

91 lines
3.1 KiB
Python
Raw Normal View History

2024-05-13 19:50:21 +00:00
# Import Neccesary Abaqus Modules
from abaqusConstants import *
from abaqus import *
aModel=mdb.models['Trial2']
aPart=aModel.parts['Mesh8']
incFile=open('NodeData4.inc','w')
# Cycle through all interface nodes
interfaceNodes=aPart.sets['InterfaceN'].nodes
interfaceElements=aPart.sets['InterfaceE'].elements
pstring=str(len(interfaceNodes))+' \n'
ic=0
for eachNode in interfaceNodes:
nodeLabel=eachNode.label
nodeFaces=eachNode.getElemFaces()
nodeEdges=eachNode.getElemEdges()
numFacets=len(nodeFaces)
nstring=' '
numFaces=0
for eachFace in nodeFaces:
# Check if face is on outer boundary
faceElems=eachFace.getElements()
bound=0
if len(faceElems)==1:
if faceElems[0] in interfaceElements:
bound=1
# Check if face is on interface
interface=0
faceNodes=eachFace.getNodes()
for eachFNode in faceNodes:
if eachFNode in interfaceNodes:
interface=interface+1
if interface==4 or bound==1:
facetNodes=[]
numFaces=numFaces+1
for eachFNode in eachFace.getNodes():
if eachFNode.label!=nodeLabel:
for eachEdge in eachFNode.getElemEdges():
if eachEdge in nodeEdges:
facetNodes.append(eachFNode)
nstring=nstring+str(facetNodes[0].label)+' '+str(facetNodes[1].label)+' \n'
faceElems=eachFace.getElements()
if bound==0:
if faceElems[0] in interfaceElements:
intNodes=faceElems[0].getNodes()
nbrElem=faceElems[1]
else:
nbrElem=faceElems[0]
intNodes=faceElems[1].getNodes()
nbrNodes=nbrElem.getNodes()
n1=eachNode
n2=facetNodes[0]
n3=facetNodes[1]
for eachFNode in faceNodes:
if eachFNode!=n1 and eachFNode!=n2 and eachFNode!=n3:
n4=eachFNode
break
for eachEEdge in n1.getElemEdges():
for eachENode in eachEEdge.getNodes():
if eachENode in nbrNodes and eachENode!=n1 and eachENode!=n2 and eachENode!=n3:
n5=eachENode
break
for eachEEdge in n2.getElemEdges():
for eachENode in eachEEdge.getNodes():
if eachENode in nbrNodes and eachENode!=n1 and eachENode!=n2 and eachENode!=n4:
n6=eachENode
break
for eachEEdge in n3.getElemEdges():
for eachENode in eachEEdge.getNodes():
if eachENode in nbrNodes and eachENode!=n1 and eachENode!=n4 and eachENode!=n3:
n7=eachENode
break
for eachEEdge in n4.getElemEdges():
for eachENode in eachEEdge.getNodes():
if eachENode in nbrNodes and eachENode!=n4 and eachENode!=n2 and eachENode!=n3:
n8=eachENode
break
nstring=nstring+str(n1.label)+' '+str(n2.label)+' '+str(n3.label)+' '+str(n4.label)+' '
nstring=nstring+str(n5.label)+' '+str(n6.label)+' '+str(n7.label)+' '+str(n8.label)+' '
nstring=nstring+'\n'
for eachNNode in intNodes:
nstring=nstring+str(eachNNode.label)+' '
else:
nstring=nstring+'0 0 0 0 0 0 0 0 \n'
for eachNNode in faceElems[0].getNodes():
nstring=nstring+str(eachNNode.label)+' '
nstring=nstring+'\n'
pstring=pstring+str(nodeLabel)+' '+str(numFaces)+' \n'+nstring
ic=ic+1
print ic,len(interfaceNodes)
incFile.write(pstring)
incFile.close()