當前位置: 首頁>>代碼示例>>Python>>正文


Python FieldVariable.set_data_from_qp方法代碼示例

本文整理匯總了Python中sfepy.discrete.FieldVariable.set_data_from_qp方法的典型用法代碼示例。如果您正苦於以下問題:Python FieldVariable.set_data_from_qp方法的具體用法?Python FieldVariable.set_data_from_qp怎麽用?Python FieldVariable.set_data_from_qp使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在sfepy.discrete.FieldVariable的用法示例。


在下文中一共展示了FieldVariable.set_data_from_qp方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: nodal_stress

# 需要導入模塊: from sfepy.discrete import FieldVariable [as 別名]
# 或者: from sfepy.discrete.FieldVariable import set_data_from_qp [as 別名]
def nodal_stress(out, pb, state, extend=False, integrals=None):
    '''
    Calculate stresses at nodal points.
    '''

    # Point load.
    mat = pb.get_materials()['Load']
    P = 2.0 * mat.get_data('special', 'val')[1]

    # Calculate nodal stress.
    pb.time_update()

    if integrals is None: integrals = pb.get_integrals()

    stress = pb.evaluate('ev_cauchy_stress.ivn.Omega(Asphalt.D, u)', mode='qp',
                         integrals=integrals, copy_materials=False)
    sfield = Field.from_args('stress', nm.float64, (3,),
                             pb.domain.regions['Omega'])
    svar = FieldVariable('sigma', 'parameter', sfield,
                         primary_var_name='(set-to-None)')
    svar.set_data_from_qp(stress, integrals['ivn'])

    print('\n==================================================================')
    print('Given load = %.2f N' % -P)
    print('\nAnalytical solution')
    print('===================')
    print('Horizontal tensile stress = %.5e MPa/mm' % (-2.*P/(nm.pi*150.)))
    print('Vertical compressive stress = %.5e MPa/mm' % (-6.*P/(nm.pi*150.)))
    print('\nFEM solution')
    print('============')
    print('Horizontal tensile stress = %.5e MPa/mm' % (svar()[0]))
    print('Vertical compressive stress = %.5e MPa/mm' % (-svar()[1]))
    print('==================================================================')
    return out
開發者ID:clazaro,項目名稱:sfepy,代碼行數:36,代碼來源:its2D_3.py

示例2: nodal_stress

# 需要導入模塊: from sfepy.discrete import FieldVariable [as 別名]
# 或者: from sfepy.discrete.FieldVariable import set_data_from_qp [as 別名]
def nodal_stress(out, pb, state, extend=False, integrals=None):
    """
    Calculate stresses at nodal points.
    """

    # Point load.
    mat = pb.get_materials()["Load"]
    P = 2.0 * mat.get_data("special", "val")[1]

    # Calculate nodal stress.
    pb.time_update()

    if integrals is None:
        integrals = pb.get_integrals()

    stress = pb.evaluate("ev_cauchy_stress.ivn.Omega(Asphalt.D, u)", mode="qp", integrals=integrals)
    sfield = Field.from_args("stress", nm.float64, (3,), pb.domain.regions["Omega"])
    svar = FieldVariable("sigma", "parameter", sfield, primary_var_name="(set-to-None)")
    svar.set_data_from_qp(stress, integrals["ivn"])

    print "\n=================================================================="
    print "Given load = %.2f N" % -P
    print "\nAnalytical solution"
    print "==================="
    print "Horizontal tensile stress = %.5e MPa/mm" % (-2.0 * P / (nm.pi * 150.0))
    print "Vertical compressive stress = %.5e MPa/mm" % (-6.0 * P / (nm.pi * 150.0))
    print "\nFEM solution"
    print "============"
    print "Horizontal tensile stress = %.5e MPa/mm" % (svar()[0][0])
    print "Vertical compressive stress = %.5e MPa/mm" % (-svar()[0][1])
    print "=================================================================="
    return out
開發者ID:logansorenson,項目名稱:sfepy,代碼行數:34,代碼來源:its2D_3.py


注:本文中的sfepy.discrete.FieldVariable.set_data_from_qp方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。