Exemplo n.º 1
0
def gridBetween2Curves(curve1,curve2,n):
    """Create a grid with quadrilaterals defined by two boundary curves
    
    The two curves should be (m,2,3) formices with the same number of elements!
    These curves should lay within the YZ plane if you want to use the sweepGrid definition!
    n is the number of elements between the two curves.
    """
    nc1 = append(curve1[:,0],curve1[-1,-1].reshape(-1,3),0)
    nc2 = append(curve2[:,0],curve2[-1,-1].reshape(-1,3),0)
    nodes = array([])
    elems = array([]).astype(int)
    for i in range(nc1.shape[0]):
        L = line(nc1[i],nc2[i],n)
        nL=append(L[:,0],L[-1,-1].reshape(-1,3),0)
        for j in nL:
            nodes = append(nodes,j)
    for i in range(n):
        for j in range(nc1.shape[0]-1):   
            elems = append(elems,[i+j*(n+1),i+1+j*(n+1),i+n+2+j*(n+1),i+n+1+j*(n+1)])
    return nodes.reshape(-1,3),elems.reshape(-1,4)
Exemplo n.º 2
0
def geometry():
    global M
    n = 16
    nshow = 4
    bcons = ['cantilever','simply supported']
    keep = False
    verbose = False

    res = askItems([
        _I('n',n,text='number of elements along beam'),
        _I('nshow',nshow,text='number of natural modes to show'),
        _I('bcon',bcons[0],text='beam boundary conditions',choices=bcons),
        _I('keep',keep,text='keep data and result files'),
        _I('verbose',verbose,text='show intermediate information'),
        ])
    if not res:
        return

    globals().update(res)
    F = simple.line([0.,0.,0.],[0.,1.,0.],n)
    M = F.toMesh()
    return M
Exemplo n.º 3
0
clear()
message('This is the set of nodes in natural coordinates')
draw(x1,color=blue)
message('This is the set of nodes in cartesian coordinates')
draw(x2,color=red)
drawNumbers(x2,color=red)
drawNumbers(x1)

n = 8
stype = ask("Select type of structure",['Cancel','1D','2D','3D'])
if stype == 'Cancel':
    exit()

sdim = int(stype[0])
if sdim == 1:
    F = simple.line([0.,0.,0.],[1.,1.,0.],10)
elif sdim == 2:
    F = simple.rectangle(1,1,1.,1.)
else:
    v = array(elements.Hex8.vertices)
    f = array(elements.Hex8.faces)
    F = Formex(v[f])

if sdim > 1:
    for i in range(sdim):
        F = F.replic(n,1.,dir=i)

if sdim < tdim:
    F = F.trl(2,0.5)
clear()
message('This is the initial Formex')
Exemplo n.º 4
0
bcons = ['cantilever','simply supported']
verbose = False

res = askItems([
   ('n',n,{'text':'number of elements along beam'}),
   ('nshow',nshow,{'text':'number of natural modes to show'}),
   ('bcon',bcons[0],{'text':'beam boundary conditions','choices':bcons}),
   ('verbose',verbose,{'text':'show intermediate information'}),
   ])
if not res:
   exit()

globals().update(res)
   

F = simple.line([0.,0.,0.],[0.,1.,0.],n)
M = F.toMesh()

draw(M)



nnod = M.ncoords()
nel = M.nelems()
nmat = 1
iout = 1


# init
s=""";calix script written by pyFormex (example BeamFreq)
start
Exemplo n.º 5
0
def run():
    # GEOMETRICAL PARAMETERS FOR HE200B wide flange beam
    h = 200. #beam height
    b = 200. #flange width 
    tf = 15. #flange thickness
    tw = 9.  #body thickness
    l = 400. #beam length
    r = 18.  #filling radius

    # MESH PARAMETERS
    el = 20 #number of elements along the length
    etb = 2 #number of elements over half of the thickness of the body
    ehb = 5 #number of elements over half of the height of the body
    etf = 5 #number of elements over the thickness of the flange
    ewf = 8 #number of elements over half of the width of the flange
    er = 6  #number of elements in the circular segment

    Body = simple.rectangle(etb,ehb,tw/2.,h/2.-tf-r)
    Flange1 =  simple.rectangle(er/2,etf-etb,tw/2.+r,tf-tw/2.).translate([0.,h/2.-(tf-tw/2.),0.])
    Flange2 =  simple.rectangle(ewf,etf-etb,b/2.-r-tw/2.,tf-tw/2.).translate([tw/2.+r,h/2.-(tf-tw/2.),0.])
    Flange3 =  simple.rectangle(ewf,etb,b/2.-r-tw/2.,tw/2.).translate([tw/2.+r,h/2.-tf,0.])
    c1a = simple.line([0,h/2-tf-r,0],[0,h/2-tf+tw/2,0],er/2)
    c1b = simple.line([0,h/2-tf+tw/2,0],[tw/2+r,h/2-tf+tw/2,0],er/2)
    c1 = c1a + c1b
    c2 = simple.circle(90./er,0.,90.).reflect(0).scale(r).translate([tw/2+r,h/2-tf-r,0])
    Filled = simple.connectCurves(c2,c1,etb)
    Quarter = Body + Filled + Flange1 + Flange2 + Flange3
    Half = Quarter + Quarter.reflect(1).reverse()
    Full = Half + Half.reflect(0).reverse()
    Section = Full.toMesh()

    clear()
    draw(Section,color=red)
    #return

    #pause()

    method = ask("Choose extrude method:",['Cancel','Sweep','Connect','Extrude','ExtrudeQuadratic','Revolve','RevolveLoop'])

    import timer
    t = timer.Timer()
    if method == 'Sweep':
        L = simple.line([0,0,0],[0,0,l],el)
        x = concatenate([L.coords[:,0],L.coords[-1:,1]])
        path = curve.PolyLine(x)
        Beam = Section.sweep(path,normal=[0.,0.,1.],upvector=[0.,1.,0.])

    elif method == 'Connect':
        Section1 = Section.trl([0,0,l])
        Beam = Section.connect(Section1,el)

    elif method == 'Extrude':
        Beam = Section.extrude(el,step=l/el,dir=2)

    elif method == 'ExtrudeQuadratic':
        Section = Section.convert('quad9')
        Beam = Section.extrude(el,step=l/el,dir=2,degree=2)

    elif method == 'Revolve':
        Beam = Section.revolve(el,axis=1,angle=60.,around=[-l,0.,0.])

    elif method == 'RevolveLoop':
        Beam = Section.revolve(el,axis=1,angle=240.,around=[-l,0.,0.],loop=True)

    else:
        return

    print("Computing: %s seconds" % t.seconds())
    #print Beam.prop
    #print Beam.elems.shape

    t.reset()
    clear()
    #draw(Beam,color='red',linewidth=2)
    draw(Beam.getBorderMesh(),color='red',linewidth=2)
    print("Drawing: %s seconds" % t.seconds())
    export({'Beam':Beam})
Exemplo n.º 6
0
l = 400. #beam length
r = 18.  #filling radius

# MESH PARAMETERS
el = 20 #number of elements along the length
etb = 2 #number of elements over half of the thickness of the body
ehb = 5 #number of elements over half of the height of the body
etf = 5 #number of elements over the thickness of the flange
ewf = 8 #number of elements over half of the width of the flange
er = 6  #number of elements in the circular segment

Body = simple.rectangle(etb,ehb,tw/2.,h/2.-tf-r)
Flange1 =  simple.rectangle(er/2,etf-etb,tw/2.+r,tf-tw/2.).translate([0.,h/2.-(tf-tw/2.),0.])
Flange2 =  simple.rectangle(ewf,etf-etb,b/2.-r-tw/2.,tf-tw/2.).translate([tw/2.+r,h/2.-(tf-tw/2.),0.])
Flange3 =  simple.rectangle(ewf,etb,b/2.-r-tw/2.,tw/2.).translate([tw/2.+r,h/2.-tf,0.])
c1a = simple.line([0,h/2-tf-r,0],[0,h/2-tf+tw/2,0],er/2)
c1b = simple.line([0,h/2-tf+tw/2,0],[tw/2+r,h/2-tf+tw/2,0],er/2)
c1 = c1a + c1b
c2 = simple.circle(90./er,0.,90.).reflect(0).scale(r).translate([tw/2+r,h/2-tf-r,0])
Filled = simple.connectCurves(c2,c1,etb)
Quarter = Body + Filled + Flange1 + Flange2 + Flange3
Half = Quarter + Quarter.reflect(1).reverse()
Full = Half + Half.reflect(0).reverse()
Section = Full.toMesh()

clear()
draw(Section,color=red)
#exit()

#pause()
Exemplo n.º 7
0
tw = 9. #body thickness
l = 400. #beam length
r = 18. #filling radius

# MESH PARAMETERS
el = 20 #number of elements along the length
etb = 2 #number of elements over half of the thickness of the body
ehb = 5 #number of elements over half of the height of the body
etf = 5 #number of elements over the thickness of the flange
ewf = 8 #number of elements over half of the width of the flange
er = 6#number of elements in the circular segment

nbody,ebody = mesh.gridRectangle(etb,ehb,tw/2.,h/2.-tf-r)
Body = Formex(nbody[ebody].reshape(-1,4,3)).translate([0,tw/4.,h/4.-tf/2.-r/2.])

c1a = line([0,0,h/2-tf-r],[0,0,h/2-tf+tw/2],er/2)
c1b = line([0,0,h/2-tf+tw/2],[0,tw/2+r,h/2-tf+tw/2],er/2)
c1 = c1a + c1b
c2 = circle(90./er,90./er,90.).scale(r).rotate(-90.,1).rotate(90.,0).translate([0,tw/2+r,h/2-tf-r])
nfilled,efilled = mesh.gridBetween2Curves(c1,c2,etb)
Filled = Formex(nfilled[efilled].reshape(-1,4,3))

nflange1,eflange1 = mesh.gridRectangle(er/2,etf-etb,tw/2.+r,tf-tw/2.)
Flange1 = Formex(nflange1[eflange1].reshape(-1,4,3)).translate([0,tw/4.+r/2.,h/2.-(tf-tw/2.)/2.])

nflange2,eflange2 = mesh.gridRectangle(ewf,etf-etb,b/2.-r-tw/2.,tf-tw/2.)
Flange2 = Formex(nflange2[eflange2].reshape(-1,4,3)).translate([0,tw/2.+r+(b/2.-r-tw/2.)/2.,h/2.-(tf-tw/2.)/2.])

nflange3,eflange3 = mesh.gridRectangle(ewf,etb,b/2.-r-tw/2.,tw/2.)
Flange3 = Formex(nflange3[eflange3].reshape(-1,4,3)).translate([0,tw/2.+r+(b/2.-r-tw/2.)/2.,h/2.-tf+tw/4.])
Exemplo n.º 8
0
def run():
    # GEOMETRICAL PARAMETERS FOR HE200B wide flange beam
    h = 200.  #beam height
    b = 200.  #flange width
    tf = 15.  #flange thickness
    tw = 9.  #body thickness
    l = 400.  #beam length
    r = 18.  #filling radius

    # MESH PARAMETERS
    el = 20  #number of elements along the length
    etb = 2  #number of elements over half of the thickness of the body
    ehb = 5  #number of elements over half of the height of the body
    etf = 5  #number of elements over the thickness of the flange
    ewf = 8  #number of elements over half of the width of the flange
    er = 6  #number of elements in the circular segment

    Body = simple.rectangle(etb, ehb, tw / 2., h / 2. - tf - r)
    Flange1 = simple.rectangle(er / 2, etf - etb, tw / 2. + r,
                               tf - tw / 2.).translate(
                                   [0., h / 2. - (tf - tw / 2.), 0.])
    Flange2 = simple.rectangle(ewf, etf - etb, b / 2. - r - tw / 2.,
                               tf - tw / 2.).translate(
                                   [tw / 2. + r, h / 2. - (tf - tw / 2.), 0.])
    Flange3 = simple.rectangle(ewf, etb, b / 2. - r - tw / 2., tw /
                               2.).translate([tw / 2. + r, h / 2. - tf, 0.])
    c1a = simple.line([0, h / 2 - tf - r, 0], [0, h / 2 - tf + tw / 2, 0],
                      er / 2)
    c1b = simple.line([0, h / 2 - tf + tw / 2, 0],
                      [tw / 2 + r, h / 2 - tf + tw / 2, 0], er / 2)
    c1 = c1a + c1b
    c2 = simple.circle(90. / er, 0., 90.).reflect(0).scale(r).translate(
        [tw / 2 + r, h / 2 - tf - r, 0])
    Filled = simple.connectCurves(c2, c1, etb)
    Quarter = Body + Filled + Flange1 + Flange2 + Flange3
    Half = Quarter + Quarter.reflect(1).reverse()
    Full = Half + Half.reflect(0).reverse()
    Section = Full.toMesh()

    clear()
    draw(Section, color=red)
    #return

    #pause()

    method = ask("Choose extrude method:", [
        'Cancel', 'Sweep', 'Connect', 'Extrude', 'ExtrudeQuadratic', 'Revolve',
        'RevolveLoop'
    ])

    import timer
    t = timer.Timer()
    if method == 'Sweep':
        L = simple.line([0, 0, 0], [0, 0, l], el)
        x = concatenate([L.coords[:, 0], L.coords[-1:, 1]])
        path = curve.PolyLine(x)
        Beam = Section.sweep(path, normal=[0., 0., 1.], upvector=[0., 1., 0.])

    elif method == 'Connect':
        Section1 = Section.trl([0, 0, l])
        Beam = Section.connect(Section1, el)

    elif method == 'Extrude':
        Beam = Section.extrude(el, step=l / el, dir=2)

    elif method == 'ExtrudeQuadratic':
        Section = Section.convert('quad9')
        Beam = Section.extrude(el, step=l / el, dir=2, degree=2)

    elif method == 'Revolve':
        Beam = Section.revolve(el, axis=1, angle=60., around=[-l, 0., 0.])

    elif method == 'RevolveLoop':
        Beam = Section.revolve(el,
                               axis=1,
                               angle=240.,
                               around=[-l, 0., 0.],
                               loop=True)

    else:
        return

    print("Computing: %s seconds" % t.seconds())
    #print Beam.prop
    #print Beam.elems.shape

    t.reset()
    clear()
    #draw(Beam,color='red',linewidth=2)
    draw(Beam.getBorderMesh(), color='red', linewidth=2)
    print("Drawing: %s seconds" % t.seconds())
    export({'Beam': Beam})