Example #1
0
m.nodes[8] = Node( (1., 0., 0.) )
m.nodes[9] = Node( (2., 3., 0.) )
m.nodes[10] = Node( (2., 2., 0.) )


m.elements[1] = Quad4(conn = (1,8,7,6))
m.elements[2] = Quad4(conn = (2,6,5,3))
m.elements[3] = Tri3(conn = (1,6,2))
m.elements[4] = Tri3(conn = (3,5,4))
m.elements[5] = Tri3(conn = (6,7,10))
m.elements[6] = Quad4(conn = (5,6,10,9))

for k, v in m.elements.iteritems():
  print k, v.volume()
  
def transformation(x, y, z):
  theta = np.pi / 4.  * z
  r = x.copy()
  x = r * np.cos(theta)
  z = r * np.sin(theta)
  
  return x, y, z

m = m.extrude(translation = [0, 0, 1], layers = 1)
m = m.transform(transformation)  

for k, v in m.elements.iteritems():
  print k, v.volume()
  
writeMsh(m, "volume.msh")  
Example #2
0
m.nodes[8] = Node( (1., 0., 0.) )
m.nodes[9] = Node( (2., 3., 0.) )
m.nodes[10] = Node( (2., 2., 0.) )


m.elements[1] = Quad4(conn = (1,8,7,6))
m.elements[2] = Quad4(conn = (2,6,5,3))
m.elements[3] = Tri3(conn = (1,6,2))
m.elements[4] = Tri3(conn = (3,5,4))
m.elements[5] = Tri3(conn = (6,7,10))
m.elements[6] = Quad4(conn = (5,6,10,9))

for k, v in m.elements.iteritems():
  print k, v.volume(), v.centroid()

writeMsh(m, "volume_2D.msh")  
  
def transformation(x, y, z):
  theta = np.pi / 4.  * z
  r = x.copy()
  x = r * np.cos(theta)
  z = r * np.sin(theta)
  
  return x, y, z

m = m.extrude(translation = [0, 0, 1], layers = 1)
#m = m.transform(transformation)  

for k, v in m.elements.iteritems():
  print k, v.volume(), v.centroid()
  
Example #3
0
m.nodes[9] = Node((2., 3., 0.))
m.nodes[10] = Node((2., 2., 0.))

m.elements[1] = Quad4(conn=(1, 8, 7, 6))
m.elements[2] = Quad4(conn=(2, 6, 5, 3))
m.elements[3] = Tri3(conn=(1, 6, 2))
m.elements[4] = Tri3(conn=(3, 5, 4))
m.elements[5] = Tri3(conn=(6, 7, 10))
m.elements[6] = Quad4(conn=(5, 6, 10, 9))

for k, v in m.elements.items():
    print(k, v.volume())


def transformation(x, y, z):
    theta = np.pi / 4. * z
    r = x.copy()
    x = r * np.cos(theta)
    z = r * np.sin(theta)

    return x, y, z


m = m.extrude(translation=[0, 0, 1], layers=1)
m = m.transform(transformation)

for k, v in m.elements.items():
    print(k, v.volume())

writeMsh(m, "volume.msh")
Example #4
0
m.nodes[7] = Node((2., 1., 0.))
m.nodes[8] = Node((1., 0., 0.))
m.nodes[9] = Node((2., 3., 0.))
m.nodes[10] = Node((2., 2., 0.))

m.elements[1] = Quad4(conn=(1, 8, 7, 6))
m.elements[2] = Quad4(conn=(2, 6, 5, 3))
m.elements[3] = Tri3(conn=(1, 6, 2))
m.elements[4] = Tri3(conn=(3, 5, 4))
m.elements[5] = Tri3(conn=(6, 7, 10))
m.elements[6] = Quad4(conn=(5, 6, 10, 9))

for k, v in m.elements.iteritems():
    print k, v.volume(), v.centroid()

writeMsh(m, "volume_2D.msh")


def transformation(x, y, z):
    theta = np.pi / 4. * z
    r = x.copy()
    x = r * np.cos(theta)
    z = r * np.sin(theta)

    return x, y, z


m = m.extrude(translation=[0, 0, 1], layers=1)
#m = m.transform(transformation)

for k, v in m.elements.iteritems():
Example #5
0
m = m.extrude(translation = [0, 0, 1], layers = 1)

def transformation(x, y, z):
  theta =  np.pi / 2.  * z
  r = x.copy() 
  x = r * np.cos(theta)
  z = r * np.sin(theta)
  return x, y, z

m = m.transform(transformation)
mapping = m.overlapping_nodes()
m = m.merge_nodes(mapping)
m2 = m.copy()
"""
m2.elements.clear()
counter = 1
for label in m.elements.keys():
  el = m.elements[label]
  simplices = el.simplex_decomposition()
  for simplex in simplices:
    m2.elements[cunter] = simplex
    counter +=1
"""    
m2 = m2.clean_connectivity()


writeInp(m2, path = "clean_connectivity.inp", mapping = {"Tri3": "CAX3", "Quad4": "CAX4", "Hexa8": "C3D8", "Prism6":"C3D6", "Tetra4": "C3D4"})
writeMsh(m2, path = "clean_connectivity.msh")

Example #6
0
    z = r * np.sin(theta)
    return x, y, z


m = m.transform(transformation)
mapping = m.overlapping_nodes()
m = m.merge_nodes(mapping)
m2 = m.copy()
"""
m2.elements.clear()
counter = 1
for label in m.elements.keys():
  el = m.elements[label]
  simplices = el.simplex_decomposition()
  for simplex in simplices:
    m2.elements[cunter] = simplex
    counter +=1
"""
m2 = m2.clean_connectivity()

writeInp(m2,
         path="clean_connectivity.inp",
         mapping={
             "Tri3": "CAX3",
             "Quad4": "CAX4",
             "Hexa8": "C3D8",
             "Prism6": "C3D6",
             "Tetra4": "C3D4"
         })
writeMsh(m2, path="clean_connectivity.msh")