当前位置: 首页>>代码示例>>Python>>正文


Python Quadrature.basisDerivRef方法代码示例

本文整理汇总了Python中pylith.feassemble.Quadrature.Quadrature.basisDerivRef方法的典型用法代码示例。如果您正苦于以下问题:Python Quadrature.basisDerivRef方法的具体用法?Python Quadrature.basisDerivRef怎么用?Python Quadrature.basisDerivRef使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pylith.feassemble.Quadrature.Quadrature的用法示例。


在下文中一共展示了Quadrature.basisDerivRef方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_initialize

# 需要导入模块: from pylith.feassemble.Quadrature import Quadrature [as 别名]
# 或者: from pylith.feassemble.Quadrature.Quadrature import basisDerivRef [as 别名]
  def test_initialize(self):
    """
    Test initialize().
    """
    cell = FIATSimplex()
    cell.inventory.dimension = 2
    cell.inventory.order = 1
    cell._configure()

    scalarType = None
    from pylith.utils.utils import sizeofPylithScalar
    if 8 == sizeofPylithScalar():
      scalarType = numpy.float64
    elif 4 == sizeofPylithScalar():
      scalarType = numpy.float32
    else:
      raise ValueError("Unknown size for PylithScalar.")

    verticesE = numpy.array([ [-1.0, -1.0],
                              [+1.0, -1.0],
                              [-1.0, +1.0] ])
    quadPtsE = numpy.array( [[-1.0/3.0, -1.0/3.0]], dtype=scalarType )
    quadWtsE = numpy.array( [2.0], dtype=scalarType )

    # Compute basis functions and derivatives at quadrature points
    basisE = numpy.zeros( (1, 3), dtype=scalarType)
    basisDerivE = numpy.zeros( (1, 3, 2), dtype=scalarType)
    iQuad = 0
    for x in quadPtsE:
      basisE[iQuad] = numpy.array([N0(x), N1(x), N2(x)], dtype=scalarType).reshape( (3,) )
      deriv = numpy.array([[N0p(x), N0q(x)], [N1p(x), N1q(x)], [N2p(x), N2q(x)]], dtype=scalarType)      
      basisDerivE[iQuad] = deriv.reshape((1, 3, 2))
      iQuad += 1

    quadrature = Quadrature()
    quadrature.inventory.cell = cell
    quadrature._configure()

    quadrature.preinitialize(spaceDim=2)
    quadrature.initialize()

    self.assertEqual(2, quadrature.cellDim())
    self.assertEqual(2, quadrature.spaceDim())
    self.assertEqual(3, quadrature.numBasis())
    self.assertEqual(1, quadrature.numQuadPts())

    from pylith.utils.utils import TestArray_checkScalar

    self.failUnless(TestArray_checkScalar(basisE.ravel(), quadrature.basis()))
    self.failUnless(TestArray_checkScalar(basisDerivE.ravel(), quadrature.basisDerivRef()))
    self.failUnless(TestArray_checkScalar(quadPtsE.ravel(), quadrature.quadPtsRef()))
    self.failUnless(TestArray_checkScalar(quadWtsE.ravel(), quadrature.quadWts()))

    quadrature.initializeGeometry()
    return
开发者ID:jjle,项目名称:pylith,代码行数:57,代码来源:TestMeshQuadrature.py


注:本文中的pylith.feassemble.Quadrature.Quadrature.basisDerivRef方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。