phd-scripts/Unpublished/3D_Voxel_Assign/CorrosionFaces.py

31 lines
No EOL
1 KiB
Python

# Python Preprocessor Script for Abaqus Corrosion Model
# J. Grogan, D. Gastaldi - Created. 19-07-11
# Import abaqus modules
from abaqusConstants import *
from abaqus import *
import random
# Create Model, Assembly and Instance objects
modelNames=mdb.models.keys()
corModel=mdb.models[modelNames[0]]
corAssembly=corModel.rootAssembly
corSurf=corAssembly.surfaces['Corrode']
surfFaces=corSurf.faces
incFile=open('CorSurf.dat','w')
for i in range(0,len(surfFaces)):
eachFace=surfFaces[i]
elemFaces=eachFace.getElementFaces()
for j in range(0,len(elemFaces)):
eachElemFace=elemFaces[j]
faceNodes=eachElemFace.getNodes()
centx=0.
centy=0.
centz=0.
for k in range(0,len(faceNodes)):
centx=centx+faceNodes[k].coordinates[0]
centy=centy+faceNodes[k].coordinates[1]
centz=centz+faceNodes[k].coordinates[2]
centx=centx/float(len(faceNodes))
centy=centy/float(len(faceNodes))
centz=centz/float(len(faceNodes))
incFile.write ("%f %f %f \n"%(centx,centy,centz))
incFile.close()