コード例 #1
0
 def getOptimscale():
     """Determine an optimal scale for displaying the deformation"""
     siz0 = F.sizes()
     dF = Formex(displ[:,:,0][mesh.elems])
     #clear(); draw(dF,color=black)
     siz1 = dF.sizes()
     return niceNumber(1./(siz1/siz0).max())
コード例 #2
0
 def getOptimscale():
     """Determine an optimal scale for displaying the deformation"""
     siz0 = F.sizes()
     dF = Formex(displ[:,:,0][mesh.elems])
     #clear(); draw(dF,color=black)
     siz1 = dF.sizes()
     return niceNumber(1./(siz1/siz0).max())
コード例 #3
0
def postCalpy():
    """Show results from the Calpy analysis."""
    from plugins.postproc import niceNumber,frameScale
    from plugins.postproc_menu import showResults
    try:
        FE = named('fe_model')
        displ,frc = named('calpy_results')
    except:
        warning("I could not find the finite element model and/or the calpy results. Maybe you should try to first create them?")
        raise
        return
    
    # The frc array returns element forces and has shape
    #  (nelems,nforcevalues,nloadcases)
    # nforcevalues = 8 (Nx,Vy,Vz,Mx,My1,Mz1,My2,Mz2)
    # Describe the nforcevalues element results in frc.
    # For each result we give a short and a long description:
    frc_contents = [('Nx','Normal force'),
                    ('Vy','Shear force in local y-direction'),
                    ('Vz','Shear force in local z-direction'),
                    ('Mx','Torsional moment'),
                    ('My','Bending moment around local y-axis'),
                    ('Mz','Bending moment around local z-axis'),
                    ('None','No results'),
                    ]
    # split in two lists
    frc_keys = [ c[0] for c in frc_contents ]
    frc_desc = [ c[1] for c in frc_contents ]

    # Ask the user which results he wants
    res = askItems([('Type of result',None,'select',frc_desc),
                    ('Load case',0),
                    ('Autocalculate deformation scale',True),
                    ('Deformation scale',100.),
                    ('Show undeformed configuration',False),
                    ('Animate results',False),
                    ('Amplitude shape','linear','select',['linear','sine']),
                    ('Animation cycle','updown','select',['up','updown','revert']),
                    ('Number of cycles',5),
                    ('Number of frames',10),
                    ('Animation sleeptime',0.1),
                    ])
    if res:
        frcindex = frc_desc.index(res['Type of result'])
        loadcase = res['Load case']
        autoscale = res['Autocalculate deformation scale']
        dscale = res['Deformation scale']
        showref = res['Show undeformed configuration']
        animate = res['Animate results']
        shape = res['Amplitude shape']
        cycle = res['Animation cycle']
        count = res['Number of cycles']
        nframes = res['Number of frames']
        sleeptime = res['Animation sleeptime']

        dis = displ[:,0:3,loadcase]
        if autoscale:
            siz0 = Coords(FE.nodes).sizes()
            siz1 = Coords(dis).sizes()
            print siz0
            print siz1
            dscale = niceNumber(1./(siz1/siz0).max())

        if animate:
            dscale = dscale * frameScale(nframes,cycle=cycle,shape=shape) 
        
        # Get the scalar element result values from the frc array.
        val = val1 = txt = None
        if frcindex <= 5:
            val = frc[:,frcindex,loadcase]
            txt = frc_desc[frcindex]
            if frcindex > 3:
                # bending moment values at second node
                val1 = frc[:,frcindex+2,loadcase]

        showResults(FE.nodes,FE.elems,dis,txt,val,showref,dscale,count,sleeptime)
コード例 #4
0
    CL = ColorLegend(CS,100)
    CLA = decors.ColorLegend(CL,10,10,30,200) 
    GD.canvas.addDecoration(CLA)
    GD.canvas.update()


    clear()
    linewidth(1)
    draw(F,color=black)
    linewidth(3)

    siz0 = F.sizes()
    dF = Formex(displ[:,:,0][elems])
    #clear(); draw(dF,color=black)
    siz1 = dF.sizes()
    optimscale = niceNumber(1./(siz1/siz0).max())


    # Show a deformed plot
    def deformed_plot(dscale=100.):
        """Shows a deformed plot with deformations scaled with a factor scale."""
        dnodes = nodes + dscale * displ[:,:,0]
        deformed = Formex(dnodes[elems],F.p)
        # deformed structure
        FA = draw(deformed,bbox=None,wait=False)
        TA = decors.Text('Deformed geometry (scale %.2f)' % dscale,400,100,'tr24')
        decorate(TA)
        return FA,TA

    def animate_deformed_plot(amplitude,sleeptime=1,count=1):
        """Shows an animation of the deformation plot using nframes."""
コード例 #5
0
ファイル: Hesperia.py プロジェクト: gunnups/pyFormex
def postCalpy():
    """Show results from the Calpy analysis."""
    from plugins.postproc import niceNumber, frameScale
    from plugins.postproc_menu import showResults
    try:
        FE = named('fe_model')
        displ, frc = named('calpy_results')
    except:
        warning(
            "I could not find the finite element model and/or the calpy results. Maybe you should try to first create them?"
        )
        raise
        return

    # The frc array returns element forces and has shape
    #  (nelems,nforcevalues,nloadcases)
    # nforcevalues = 8 (Nx,Vy,Vz,Mx,My1,Mz1,My2,Mz2)
    # Describe the nforcevalues element results in frc.
    # For each result we give a short and a long description:
    frc_contents = [
        ('Nx', 'Normal force'),
        ('Vy', 'Shear force in local y-direction'),
        ('Vz', 'Shear force in local z-direction'),
        ('Mx', 'Torsional moment'),
        ('My', 'Bending moment around local y-axis'),
        ('Mz', 'Bending moment around local z-axis'),
        ('None', 'No results'),
    ]
    # split in two lists
    frc_keys = [c[0] for c in frc_contents]
    frc_desc = [c[1] for c in frc_contents]

    # Ask the user which results he wants
    res = askItems([
        ('Type of result', None, 'select', frc_desc),
        ('Load case', 0),
        ('Autocalculate deformation scale', True),
        ('Deformation scale', 100.),
        ('Show undeformed configuration', False),
        ('Animate results', False),
        ('Amplitude shape', 'linear', 'select', ['linear', 'sine']),
        ('Animation cycle', 'updown', 'select', ['up', 'updown', 'revert']),
        ('Number of cycles', 5),
        ('Number of frames', 10),
        ('Animation sleeptime', 0.1),
    ])
    if res:
        frcindex = frc_desc.index(res['Type of result'])
        loadcase = res['Load case']
        autoscale = res['Autocalculate deformation scale']
        dscale = res['Deformation scale']
        showref = res['Show undeformed configuration']
        animate = res['Animate results']
        shape = res['Amplitude shape']
        cycle = res['Animation cycle']
        count = res['Number of cycles']
        nframes = res['Number of frames']
        sleeptime = res['Animation sleeptime']

        dis = displ[:, 0:3, loadcase]
        if autoscale:
            siz0 = Coords(FE.nodes).sizes()
            siz1 = Coords(dis).sizes()
            print(siz0)
            print(siz1)
            dscale = niceNumber(1. / (siz1 / siz0).max())

        if animate:
            dscale = dscale * frameScale(nframes, cycle=cycle, shape=shape)

        # Get the scalar element result values from the frc array.
        val = val1 = txt = None
        if frcindex <= 5:
            val = frc[:, frcindex, loadcase]
            txt = frc_desc[frcindex]
            if frcindex > 3:
                # bending moment values at second node
                val1 = frc[:, frcindex + 2, loadcase]

        showResults(FE.nodes, FE.elems, dis, txt, val, showref, dscale, count,
                    sleeptime)