Reputation: 11
I cannot create elements with the Element() constructor of a Part Object in Abaqus. There is no problem with the Node() constructor but when you try to create the elements using the previously generated nodes, it shows you the following error warning:
Before running the script, the part mesh appears empty in the Abaqus CAE tree (part Recuadro) and after running the script is no longer empty, so I understand that the mesh has been generated.
Here it is my script:
import sys
import mesh
import part
from abaqus import *
from odbAccess import *
from abaqusConstants import *
from caeModules import *
from driverUtils import executeOnCaeStartup
#
# Función que da el número del nodo en función de las fila y columna de elementos
#
def nnodo(i,j,ne):
n = (2*ne+1)*(i-1)+j
return n
filecae= 'E:\ESI\Fatiga\Cotacto Cilindrico\ABQ\CC-Crack-0.cae'
openMdb(filecae)
# Coordenadas del arranque de la grieta en "Recuadro"
x0 =0.0
y0 = -0.002
z0 = 0.0
delta=[0]
# Dimensiones del recuadro x € [x0-a,x0+a] y € [y0-b, y0]
a=0.2
b=0.2
# Tamaño deseado de los elementos ~ le x le
le = 0.05
# Tamaño inicial de los elementos ~ dx x dy
Nex = 2*int(a/le)
Ney = int(b/le)
Nnx = 2*Nex+1
Nny = 2*Ney+1
dx = 2*a/Nex
dy = b/Ney
Nnodos = Nnx*Nny
Nelems = Nex*Ney
inod = range(Nnodos-1)
ielm = range(Nelems-1)
for i in range(Nny):
delta.append(0)
# Coordenadas de los nodos de la malla inicial
recuadro=mdb.models['P22'].parts['Recuadro']
recuadro1=mdb.models['P22'].rootAssembly.instances['Recuadro-1']
recuadro.generateMesh(regions=(recuadro.faces[0],))
for i in range(1,Nny+1):
dx1 = (Nex*dx/2 - delta[i])/Nex
dx2 = (Nex*dx/2 + delta[i])/Nex
y = y0 - (i-1)*dy/2
for j in range(1,Nnx+1):
if float(i)/2. <> int(float(i)/2. ) or float(j)/2. <>int(float(j)/2. ):
k = (2*Nex+1)*(i-1)+j
if j<=Nex+1:
x = x0 - Nex*dx/2 + (j-1)*dx1
else:
x = x0 - delta[i] + (j-Nex-1)*dx2
recuadro.Node(label = k, coordinates=(x, y, 0.))
# Conectividades de los elementos de la malla inicial
for i in range(1,Ney+1):
for j in range(1,Nex+1):
k = Nex*(i-1)+j
n1 = recuadro.nodes[nnodo(2*i+1, 2*j-1, Nex)]
n2 = recuadro.nodes[nnodo(2*i+1, 2*j , Nex)]
n3 = recuadro.nodes[nnodo(2*i+1, 2*j+1, Nex)]
n4 = recuadro.nodes[nnodo(2*i , 2*j+1, Nex)]
n5 = recuadro.nodes[nnodo(2*i-1, 2*j+1, Nex)]
n6 = recuadro.nodes[nnodo(2*i-1, 2*j , Nex)]
n7 = recuadro.nodes[nnodo(2*i-1, 2*j-1, Nex)]
n8 = recuadro.nodes[nnodo(2*i , 2*j-1, Nex)]
recuadro.Element(label = k, elemShape= QUAD8, nodes=(n1, n2, n3, n4, n5, n6, n7, n8))
Upvotes: 1
Views: 884
Reputation: 2347
I recall being confused by this issue as well. Well, here's the thing - a Part instance hasn't actually been assigned to the elements you just created. Try mdb.models[MODELNAME].parts[PARTNAME].elements[ELEMENTLABEL].instanceName
and you'll see it is None
since there is no return value. I'm not sure if this is by design, or if it's a bug. But basically, the Part object has a method to fix this:
p = mdb.models[MODELNAME].parts[PARTNAME].PartFromMesh(name=PARTNAME, copySets=True)
and you're done.
PS: I might add, though - looping to create Nodes and Elements this way for moderate to large meshes seems spectacularly slow to me. (Hint: there are faster ways!)
Upvotes: 1