本文整理汇总了Python中pylith.feassemble.Quadrature.Quadrature.initializeGeometry方法的典型用法代码示例。如果您正苦于以下问题:Python Quadrature.initializeGeometry方法的具体用法?Python Quadrature.initializeGeometry怎么用?Python Quadrature.initializeGeometry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pylith.feassemble.Quadrature.Quadrature
的用法示例。
在下文中一共展示了Quadrature.initializeGeometry方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_initialize
# 需要导入模块: from pylith.feassemble.Quadrature import Quadrature [as 别名]
# 或者: from pylith.feassemble.Quadrature.Quadrature import initializeGeometry [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