Exemplo n.º 1
0
from abapy.mesh import RegularQuadMesh
from matplotlib import pyplot as plt
# Creating a mesh
m = RegularQuadMesh(N1=2, N2=2)
x0, y0, z0 = m.get_edges()
# Finding the node located at x = y =0.:
nodes = m.nodes
for i in xrange(len(nodes.labels)):
    if nodes.x[i] == 0. and nodes.y[i] == 0.: node = nodes.labels[i]
# Removing this node
m.drop_node(node)
x1, y1, z1 = m.get_edges()
bbx, bby, bbz = m.nodes.boundingBox()
plt.figure()
plt.clf()
plt.gca().set_aspect('equal')
plt.axis('off')
plt.xlim(bbx)
plt.ylim(bby)
plt.plot(x0, y0, 'r-', linewidth=2., label='Removed element')
plt.plot(x1, y1, 'b-', linewidth=2., label='New mesh')
plt.legend()
plt.show()
Exemplo n.º 2
0
from abapy.mesh import RegularQuadMesh
from matplotlib import pyplot as plt
N1, N2 = 30, 5  # Number of elements
l1, l2 = 4., 1.  # Mesh size
fs = 20.  # fontsize
mesh = RegularQuadMesh(N1, N2, l1, l2)
plt.figure(figsize=(8, 3))
plt.gca().set_aspect('equal')
nodes = mesh.nodes
xn, yn, zn = nodes.x, nodes.y, nodes.z  # Nodes coordinates
xe, ye, ze = mesh.get_edges()  # Mesh edges
xb, yb, zb = mesh.get_border()  # Mesh border
plt.plot(xe, ye, 'r-', label='edges')
plt.plot(xb, yb, 'b-', label='border')
plt.plot(xn, yn, 'go', label='nodes')
plt.xlim([-.1 * l1, 1.1 * l1])
plt.ylim([-.1 * l2, 1.1 * l2])
plt.xticks([0, l1], ['$0$', '$l_1$'], fontsize=fs)
plt.yticks([0, l2], ['$0$', '$l_2$'], fontsize=fs)
plt.xlabel('$N_1$', fontsize=fs)
plt.ylabel('$N_2$', fontsize=fs)
plt.legend()
plt.show()
Exemplo n.º 3
0
from abapy.mesh import RegularQuadMesh
from matplotlib import pyplot as plt
N1,N2 = 20,20
l1, l2 = 1., 1.
mesh1 = RegularQuadMesh(N1 = N1, N2 = N2, l1 = l1, l2 = l2, name = 'mesh1_el')
mesh2 = RegularQuadMesh(N1 = N1, N2 = N2, l1 = l1, l2 = l2, name =  'mesh2_el')
mesh2.add_set('set2',[1,3])

mesh2.nodes.translate(x = l1, y = l2)

mesh1.union(mesh2)



plt.figure()
xe, ye, ze = mesh1.get_edges()
plt.plot(xe, ye)
plt.show()
Exemplo n.º 4
0
from abapy.mesh import RegularQuadMesh, Mesh
from matplotlib import pyplot as plt
from array import array
from abapy.indentation import IndentationMesh

m = RegularQuadMesh(N1 = 2, N2 =2)
m.connectivity[2] = array(m.dti,[5, 7, 4])
m.connectivity[3] = array(m.dti,[5, 6, 9])
m.add_set('el_set',[1,2])
m.add_set('el_set2',[2,4])
m.add_surface('my_surface',[('el_set',1),])
m2 = m.sweep(sweep_angle = 70., N = 2, extrude=True)
x,y,z = m.get_edges()
x2,y2,z2 = m2.get_edges()

# Adding some 3D "home made" perspective:
zx, zy = .3, .3
for i in xrange(len(x2)):
  if x2[i] != None:
    x2[i] += zx * z2[i]
    y2[i] += zy * z2[i]
    
# Plotting stuff
plt.figure()
plt.clf()
plt.gca().set_aspect('equal')
plt.axis('off')
plt.plot(x,y, 'b-', linewidth  = 4., label = 'Orginal Mesh')
plt.plot(x2,y2, 'r-', linewidth  = 1., label = 'Sweeped mesh')
plt.legend()
plt.show()
def function(x, y, z, labels):
  r0 = 1.
  theta = 2 * pi * x
  r = y + r0
  ux = -x + r * cos(theta)
  uy = -y + r * sin(theta)
  uz = 0. * z
  return ux, uy, uz
N1, N2 = 100, 25
l1, l2 = .75, 1.
Ncolor = 20
mesh = RegularQuadMesh(N1 = N1, N2 = N2, l1 = l1, l2 = l2)
vectorField = mesh.nodes.eval_vectorFunction(function)
mesh.nodes.apply_displacement(vectorField)
field = vectorField.get_coord(2) # we chose to plot coordinate 2
field2 = vectorField.get_coord(2) # we chose to plot coordinate 2
x,y,z = mesh.get_edges() # Mesh edges
X,Y,Z,tri = mesh.dump2triplot()
xb,yb,zb = mesh.get_border() # mesh borders
xe, ye, ze = mesh.get_edges()
fig = plt.figure(figsize=(10,10))
fig.gca().set_aspect('equal')
plt.axis('off')
plt.plot(xb,yb,'k-', linewidth = 2.)
plt.plot(xe, ye,'k-', linewidth = .5)
plt.tricontour(X,Y,tri,field.data, Ncolor, colors = 'black')
color = plt.tricontourf(X,Y,tri,field.data, Ncolor)
plt.colorbar(color)
plt.show()

Exemplo n.º 6
0
from abapy.mesh import RegularQuadMesh, Mesh
from matplotlib import pyplot as plt

m = RegularQuadMesh(N1=2, N2=2)
m.add_set('el_set', [1, 2])
m.add_surface('my_surface', [
    ('el_set', 2),
])
m2 = m.extrude(l=1., N=2)
x, y, z = m.get_edges()
x2, y2, z2 = m2.get_edges()

# Adding some 3D "home made" perspective:
zx, zy = .3, .3
for i in xrange(len(x2)):
    if x2[i] != None:
        x2[i] += zx * z2[i]
        y2[i] += zy * z2[i]

# Plotting stuff
plt.figure()
plt.clf()
plt.gca().set_aspect('equal')
plt.axis('off')
plt.plot(x, y, 'b-', linewidth=4., label='Orginal Mesh')
plt.plot(x2, y2, 'r-', linewidth=1., label='Extruded mesh')
plt.legend()
plt.show()
Exemplo n.º 7
0
ax.set_aspect('equal')
ax2.set_aspect('equal')
ax3.set_aspect('equal')
ax.set_xticks([])
ax.set_yticks([])
ax2.set_xticks([])
ax2.set_yticks([])
ax3.set_xticks([])
ax3.set_yticks([])
ax.set_frame_on(False)
ax2.set_frame_on(False)
ax3.set_frame_on(False)
ax.set_title('Orginal Mesh')
ax2.set_title('Triangularized Mesh')
ax3.set_title('Field')
x, y, z = mesh.get_edges()  # Mesh edges
xt, yt, zt = mesh.convert2tri3().get_edges()  # Triangular mesh edges
xb, yb, zb = mesh.get_border()
X, Y, Z, tri = mesh.dump2triplot()
ax.plot(x, y, 'k-')
ax2.plot(xt, yt, 'k-')
ax3.plot(xb, yb, 'k-', linewidth=2.)
ax3.tricontourf(X, Y, tri, field.data, Ncolor)
ax3.tricontour(X, Y, tri, field.data, Ncolor, colors='black')
ax.set_xlim([-.1 * l1, 1.1 * l1])
ax.set_ylim([-.1 * l2, 1.1 * l2])
ax2.set_xlim([-.1 * l1, 1.1 * l1])
ax2.set_ylim([-.1 * l2, 1.1 * l2])
ax3.set_xlim([-.1 * l1, 1.1 * l1])
ax3.set_ylim([-.1 * l2, 1.1 * l2])
plt.show()
Exemplo n.º 8
0
from abapy.mesh import RegularQuadMesh
from matplotlib import pyplot as plt
# Creating a mesh
m = RegularQuadMesh(N1 = 2, N2 = 2)
x0, y0, z0 = m.get_edges()
# Finding the node located at x = y =0.:
nodes = m.nodes
for i in xrange(len(nodes.labels)):
  if nodes.x[i] == 0. and nodes.y[i] == 0.: node = nodes.labels[i]
# Removing this node
m.drop_node(node)
x1, y1, z1 = m.get_edges()
bbx, bby, bbz = m.nodes.boundingBox()
plt.figure()
plt.clf()
plt.gca().set_aspect('equal')
plt.axis('off')
plt.xlim(bbx)
plt.ylim(bby)
plt.plot(x0,y0, 'r-', linewidth = 2., label = 'Removed element')
plt.plot(x1,y1, 'b-', linewidth = 2., label = 'New mesh')
plt.legend()
plt.show()


Exemplo n.º 9
0
from abapy.mesh import RegularQuadMesh
from matplotlib import pyplot as plt
N1, N2 = 20, 20
l1, l2 = 1., 1.
mesh1 = RegularQuadMesh(N1=N1, N2=N2, l1=l1, l2=l2, name='mesh1_el')
mesh2 = RegularQuadMesh(N1=N1, N2=N2, l1=l1, l2=l2, name='mesh2_el')
mesh2.add_set('set2', [1, 3])

mesh2.nodes.translate(x=l1, y=l2)

mesh1.union(mesh2)

plt.figure()
xe, ye, ze = mesh1.get_edges()
plt.plot(xe, ye)
plt.show()
Exemplo n.º 10
0
ax.set_aspect('equal')
ax2.set_aspect('equal')
ax3.set_aspect('equal')
ax.set_xticks([])
ax.set_yticks([])
ax2.set_xticks([])
ax2.set_yticks([])
ax3.set_xticks([])
ax3.set_yticks([])
ax.set_frame_on(False)
ax2.set_frame_on(False)
ax3.set_frame_on(False)
ax.set_title('Orginal Mesh')
ax2.set_title('Triangularized Mesh')
ax3.set_title('Field')
x,y,z = mesh.get_edges() # Mesh edges
xt,yt,zt = mesh.convert2tri3().get_edges() # Triangular mesh edges
xb,yb,zb = mesh.get_border()
X,Y,Z,tri = mesh.dump2triplot()
ax.plot(x,y,'k-')
ax2.plot(xt,yt,'k-')
ax3.plot(xb,yb,'k-', linewidth = 2.)
ax3.tricontourf(X,Y,tri,field.data, Ncolor)
ax3.tricontour(X,Y,tri,field.data, Ncolor, colors = 'black')
ax.set_xlim([-.1*l1,1.1*l1])
ax.set_ylim([-.1*l2,1.1*l2])
ax2.set_xlim([-.1*l1,1.1*l1])
ax2.set_ylim([-.1*l2,1.1*l2])
ax3.set_xlim([-.1*l1,1.1*l1])
ax3.set_ylim([-.1*l2,1.1*l2])
plt.show()