Exemple #1
0
 def MakeMesh(self):
   """
   Builds the mesh
   """
   Ri = self.inner_radius
   Ro = self.outer_radius
   thickness = self.thickness
   Nr, Nt, Na = self.Nr, self.Nt, self.Na
   mesh = RegularQuadMesh(Nt, Nr, .25, Ro - Ri, name = self.elType)
   mesh.nodes.add_set_by_func('left_nodes', lambda x, y, z, labels: x == 0.)
   mesh.nodes.add_set_by_func('right_nodes', lambda x, y, z, labels: x == .25)
      
   def function(x, y, z, labels):
     theta = 2 * np.pi * (.25 - x)
     r = y + Ri
     ux = -x + r * np.cos(theta)
     uy = -y + r * np.sin(theta)
     uz = 0. * z
     return ux, uy, uz
   vectorField = mesh.nodes.eval_vectorFunction(function)
   mesh.nodes.apply_displacement(vectorField)
   nodes = mesh.nodes
   for i in xrange(len(nodes.labels)):
     if nodes.x[i] < 0.: 
       nodes.x[i] = 0. 
   
   mesh.add_set('all_elements', mesh.labels)
   mesh.add_set('surface_elements',range( Nt * (Nr-1)+1, Nt*Nr+1  ))
   mesh.add_surface('surface_faces',[ ('surface_elements',3) ])
   if self.is_3D:
      mesh = mesh.extrude(N = Na, l = thickness, mapping = {self.elType: self.elType})  
   self.mesh = mesh
Exemple #2
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()
Exemple #3
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()
Exemple #4
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()
Exemple #5
0
  def MakeInp(self):
    pattern = """**----------------------------------
**DISTRIBUTED MECHANICAL PROPERTIES
**----------------------------------
**HEADER
*Preprint, echo=NO, model=NO, history=NO, contact=NO
**----------------------------------
** PART "pSAMPLE" DEFINITION
*Part, name = pSample
#MESH
#SECTIONS
*End part
**----------------------------------
** ASSEMBLY
*Assembly, name = Assembly
*Instance, name=iSample, part=pSample
*End Instance
*End Assembly
**----------------------------------
** MATERIALS
#MATERIALS
**----------------------------------
** STEPS
*Step, Name=Loading0, Nlgeom=YES, Inc=1000000
*Static
#FRAME_DURATION, 1, 1e-08, #FRAME_DURATION
** BOUNDARY CONDITIONS
*Boundary
iSample.Bottom, 2, 2
iSample.BottomLeft, 1, 1#3DBOUNDARY
iSample.Top,    2, 2, #DISP
** RESTART OPTIONS 
*Restart, write, frequency=0
** FIELD OUTPUTS
*Output, field, frequency=999999
*Node Output
U
*Element Output, directions=YES
E, PE, EE, PEEQ, S
** HYSTORY OUTPUTS
*Output, history
*Energy Output
ALLPD, ALLSE, ALLWK
*Node Output, nset=iSample.Top
RF2
*Node Output, nset=iSample.TopLeft
U2
*Node Output, nset=iSample.Left
COOR1
*Node Output, nset=iSample.Right
COOR1
*Element Output, elset=iSample.allElements, directions=NO
EVOL
*End Step
  """
   
    Nx , Ny, Nz = self.Nx, self.Ny, self.Nz
    lx, ly, lz = self.lx, self.ly, self.lz
    elType = self.elType
    material = self.material
    disp = self.disp
    nFrames = self.nFrames
    if self.is_3D:
      Ne = Nx * Ny * Nz
    else:  
      Ne = Nx * Ny
    sections = ""
    matinp = ""
    if self.compart:
      section_pattern = "*Solid Section, elset=Elset{0}, material={1}\n*Elset, Elset=Elset{0}\n{0},\n"
      labels = [mat.labels[0] for mat in material]
      for i in xrange(Ne):
        sections += section_pattern.format(i+1, labels[i]) 
        matinp += material[i].dump2inp() + '\n'
    else:
      section_pattern = "*SOLID SECTION, ELSET = ALLELEMENTS, MATERIAL = {0}\n{1}"  
      label = material.labels[0]
      sections = section_pattern.format(label, self.lz)
      matinp = material.dump2inp() 
    m = RegularQuadMesh(Nx, Ny, l1= lx, l2 = ly, name = elType)
    m.add_set(label = "AllElements", elements = m.labels)
    nsets = copy.copy(m.nodes.sets) 
    if self.is_3D: 
       m = m.extrude(N = Nz, l = lz)
       m.nodes.sets['bottomleft'] = nsets['bottomleft']
       m.nodes.sets['bottomright'] = nsets['bottomright']
    pattern = pattern.replace("#MESH", m.dump2inp())
    pattern = pattern.replace("#SECTIONS", sections[:-1])
    pattern = pattern.replace("#MATERIALS", matinp[:-1])
    pattern = pattern.replace("#DISP", str(disp))
    pattern = pattern.replace("#FRAME_DURATION", str(1./nFrames))
    if self.is_3D:
      pattern = pattern.replace("#3DBOUNDARY", "\niSample.BottomLeft, 3, 3\niSample.BottomRight, 3, 3")
    else:  
      pattern = pattern.replace("#3DBOUNDARY", "")
    f = open(self.workdir + self.label + '.inp', 'wb')
    f.write(pattern)
    f.close()
Exemple #6
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 range(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')
Exemple #7
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()
Exemple #8
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()