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, 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 #3
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()
def function(x, y, z, labels):
  r0 = 1.
  theta = .5 * np.pi * x
  r = y + r0
  ux = -x + r * np.cos(theta**2)
  uy = -y + r * np.sin(theta**2)
  uz = 0. * z
  return ux, uy, uz
N1, N2, N3 = 10, 10, 5
l1, l2, l3 = .75, 1., 1.



m = RegularQuadMesh(N1 = N1, N2 = N2, l1 = l1, l2 = l2)
m = m.extrude(l = l3, N = N3 )
vectorField = m.nodes.eval_vectorFunction(function)
m.nodes.apply_displacement(vectorField)
patches = m.dump2polygons(use_3D = True, 
                          face_color = None, 
                          edge_color = "black")
bb = m.nodes.boundingBox()
patches.set_linewidth(1.)

fig = plt.figure(0)
plt.clf()
ax = a3.Axes3D(fig)
ax.set_aspect("equal")
ax.add_collection3d(patches)
plt.xlim(bb[0])
plt.ylim(bb[1])
Exemple #5
0
def function(x, y, z, labels):
    r0 = 1.
    theta = .5 * np.pi * x
    r = y + r0
    ux = -x + r * np.cos(theta**2)
    uy = -y + r * np.sin(theta**2)
    uz = 0. * z
    return ux, uy, uz


N1, N2, N3 = 10, 10, 5
l1, l2, l3 = .75, 1., 1.

m = RegularQuadMesh(N1=N1, N2=N2, l1=l1, l2=l2)
m = m.extrude(l=l3, N=N3)
vectorField = m.nodes.eval_vectorFunction(function)
m.nodes.apply_displacement(vectorField)
patches = m.dump2polygons(use_3D=True, face_color=None, edge_color="black")
bb = m.nodes.boundingBox()
patches.set_linewidth(1.)

fig = plt.figure(0)
plt.clf()
ax = a3.Axes3D(fig)
ax.set_aspect("equal")
ax.add_collection3d(patches)
plt.xlim(bb[0])
plt.ylim(bb[1])
plt.xlabel("$x$ position")
plt.ylabel("$y$ position")
Exemple #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()