Esempio n. 1
0
from abapy.mesh import Mesh, Nodes
mesh = Mesh()
nodes = mesh.nodes
# Adding some nodes
nodes.add_node(label=1, x=0., y=0., z=0.)
nodes.add_node(label=2, x=1., y=0., z=0.)
nodes.add_node(label=3, x=1., y=1., z=0.)
nodes.add_node(label=4, x=0., y=1., z=0.)
nodes.add_node(label=5, x=2., y=0., z=0.)
nodes.add_node(label=6, x=2., y=1., z=0.)
# Adding some elements
mesh.add_element(label=1,
                 connectivity=(1, 2, 3, 4),
                 space=2,
                 name='QUAD4',
                 toset='mySet')
mesh.add_element(label=2,
                 connectivity=(2, 5, 6, 3),
                 space=2,
                 name='QUAD4',
                 toset=['mySet', 'myOtherSet'])
print(mesh)
Esempio n. 2
0
from abapy.mesh import Mesh
from matplotlib import pyplot as plt
import numpy as np

N1, N2 = 10, 5  # Number of elements
l1, l2 = 4.0, 2.0  # Mesh size
fs = 20.0  # fontsize
mesh = Mesh()
nodes = mesh.nodes
nodes.add_node(label=1, x=0.0, y=0.0)
nodes.add_node(label=2, x=1.0, y=0.0)
nodes.add_node(label=3, x=0.0, y=1.0)
nodes.add_node(label=4, x=1.5, y=1.0)
nodes.add_node(label=5, x=1.0, y=2.0)
mesh.add_element(label=1, connectivity=[1, 2, 3], space=2)
mesh.add_element(label=2, connectivity=[2, 4, 5, 3], space=2)


centroids = mesh.centroids()

plt.figure(figsize=(8, 3))
plt.gca().set_aspect("equal")
nodes = mesh.nodes
xn, yn, zn = np.array(nodes.x), np.array(nodes.y), np.array(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")
Esempio n. 3
0
from abapy.mesh import Mesh, Nodes
mesh = Mesh()
nodes = mesh.nodes
# Adding some nodes
nodes.add_node(label=1, x=0., y=0., z=0.)
nodes.add_node(label=2, x=1., y=0., z=0.)
nodes.add_node(label=3, x=1., y=1., z=0.)
nodes.add_node(label=4, x=0., y=1., z=0.)
nodes.add_node(label=5, x=2., y=0., z=0.)
nodes.add_node(label=6, x=2., y=1., z=0.)
# Adding some elements
mesh.add_element(label=1, connectivity=(1, 2, 3, 4), space=2, name='QUAD4')
mesh.add_element(label=2, connectivity=(2, 5, 6, 3), space=2, name='QUAD4')
# Adding sets
mesh.add_set(label='niceSet', elements=1)
mesh.add_set(label='veryNiceSet', elements=[1, 2])
mesh.add_set(label='simplyTheBestSet', elements=1)
mesh.add_set(label='simplyTheBestSet', elements=2)
print(mesh)
Esempio n. 4
0
from abapy.mesh import Mesh
from matplotlib import pyplot as plt
import numpy as np

N1, N2 = 10, 5  # Number of elements
l1, l2 = 4., 2.  # Mesh size
fs = 20.  # fontsize
mesh = Mesh()
nodes = mesh.nodes
nodes.add_node(label=1, x=0., y=0.)
nodes.add_node(label=2, x=1., y=0.)
nodes.add_node(label=3, x=0., y=1.)
nodes.add_node(label=4, x=1.5, y=1.)
nodes.add_node(label=5, x=1., y=2.)
mesh.add_element(label=1, connectivity=[1, 2, 3], space=2)
mesh.add_element(label=2, connectivity=[2, 4, 5, 3], space=2)


centroids = mesh.centroids()

plt.figure(figsize=(8, 3))
plt.gca().set_aspect('equal')
nodes = mesh.nodes
xn, yn, zn = np.array(nodes.x), np.array(
    nodes.y), np.array(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')
Esempio n. 5
0
from abapy.mesh import Mesh, Nodes
mesh = Mesh()
nodes = mesh.nodes
# Adding some nodes
nodes.add_node(label = 1, x = 0. ,y = 0. , z = 0.)
nodes.add_node(label = 2, x = 1. ,y = 0. , z = 0.)
nodes.add_node(label = 3, x = 1. ,y = 1. , z = 0.)
nodes.add_node(label = 4, x = 0. ,y = 1. , z = 0.)
nodes.add_node(label = 5, x = 2. ,y = 0. , z = 0.)
nodes.add_node(label = 6, x = 2. ,y = 1. , z = 0.)
# Adding some elements
mesh.add_element(label=1, connectivity = (1,2,3,4), space =2, name = 'QUAD4')
mesh.add_element(label=2, connectivity = (2,5,6,3), space =2, name = 'QUAD4')
# Adding sets
mesh.add_set(label = 'veryNiceSet', elements = [1,2])
# Adding surfaces
mesh.add_surface(label = 'superNiceSurface', description = [ ('veryNiceSet', 2) ])
out = mesh.dump2inp()
Esempio n. 6
0
from abapy.mesh import Mesh, Nodes
mesh = Mesh()
nodes = mesh.nodes
# Adding some nodes
nodes.add_node(label = 1, x = 0. ,y = 0. , z = 0.)
nodes.add_node(label = 2, x = 1. ,y = 0. , z = 0.)
nodes.add_node(label = 3, x = 1. ,y = 1. , z = 0.)
nodes.add_node(label = 4, x = 0. ,y = 1. , z = 0.)
nodes.add_node(label = 5, x = 2. ,y = 0. , z = 0.)
nodes.add_node(label = 6, x = 2. ,y = 1. , z = 0.)
# Adding some elements
mesh.add_element(label=1, connectivity = (1,2,3,4), space =2, name = 'QUAD4', toset='mySet' )
mesh.add_element(label=2, connectivity = (2,5,6,3), space =2, name = 'QUAD4', toset = ['mySet','myOtherSet'] )
print mesh
Esempio n. 7
0
from abapy.mesh import Mesh, Nodes
mesh = Mesh()
nodes = mesh.nodes
# Adding some nodes
nodes.add_node(label = 1, x = 0. ,y = 0. , z = 0.)
nodes.add_node(label = 2, x = 1. ,y = 0. , z = 0.)
nodes.add_node(label = 3, x = 1. ,y = 1. , z = 0.)
nodes.add_node(label = 4, x = 0. ,y = 1. , z = 0.)
nodes.add_node(label = 5, x = 2. ,y = 0. , z = 0.)
nodes.add_node(label = 6, x = 2. ,y = 1. , z = 0.)
# Adding some elements
mesh.add_element(label=1, connectivity = (1,2,3,4), space =2, name = 'QUAD4')
mesh.add_element(label=2, connectivity = (2,5,6,3), space =2, name = 'QUAD4')
# Adding sets
mesh.add_set(label = 'niceSet', elements = 1)
mesh.add_set(label = 'veryNiceSet', elements = [1,2])
mesh.add_set(label = 'simplyTheBestSet', elements = 1)
mesh.add_set(label = 'simplyTheBestSet', elements = 2)
print mesh
Esempio n. 8
0
from abapy.postproc import FieldOutput
from abapy.mesh import Mesh, Nodes
x = [0.,1.,0.]
y = [0.,0.,1.]
z = [0.,0.,0.]
labels = [1,2,3]
nodes = Nodes(x=x,y=y,z=z, labels=labels)
mesh = Mesh(nodes=nodes)
mesh.add_element(label = 1 , connectivity = [1,2,3], space = 2 , name = 'tri3') # triangle element
nodeField = FieldOutput()
nodeField.add_data(data = 0., label = 1)
nodeField.add_data(data = 10., label = 2)
nodeField.add_data(data = 20., label = 3)
elementField = FieldOutput(position='element')
elementField.add_data(label = 1, data =10.)
out = ''
out+=mesh.dump2vtk()
out+=nodeField.dump2vtk('nodeField')
out+=elementField.dump2vtk('elementField')
f = open("FieldOutput-dump2vtk.vtk", "w")
f.write(out)
f.close()
Esempio n. 9
0
from abapy.postproc import FieldOutput
from abapy.mesh import Mesh, Nodes
x = [0., 1., 0.]
y = [0., 0., 1.]
z = [0., 0., 0.]
labels = [1, 2, 3]
nodes = Nodes(x=x, y=y, z=z, labels=labels)
mesh = Mesh(nodes=nodes)
mesh.add_element(label=1, connectivity=[1, 2, 3], space=2,
                 name='tri3')  # triangle element
nodeField = FieldOutput()
nodeField.add_data(data=0., label=1)
nodeField.add_data(data=10., label=2)
nodeField.add_data(data=20., label=3)
elementField = FieldOutput(position='element')
elementField.add_data(label=1, data=10.)
out = ''
out += mesh.dump2vtk()
out += nodeField.dump2vtk('nodeField')
out += elementField.dump2vtk('elementField')
f = open("FieldOutput-dump2vtk.vtk", "w")
f.write(out)
f.close()