本文整理汇总了Python中mesh.Mesh.extend方法的典型用法代码示例。如果您正苦于以下问题:Python Mesh.extend方法的具体用法?Python Mesh.extend怎么用?Python Mesh.extend使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mesh.Mesh
的用法示例。
在下文中一共展示了Mesh.extend方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_mesh
# 需要导入模块: from mesh import Mesh [as 别名]
# 或者: from mesh.Mesh import extend [as 别名]
def test_mesh():
'''Basic test of the Mesh factory method and mesh extending'''
ox, dx, nx = 0., 10., 5
mesh = Mesh(type='uniform', ox=ox, lx=dx, nx=nx, block='B1')
assert mesh.num_elem == nx
assert mesh.boundary_nodes == [1, nx+1]
assert np.allclose(mesh.boundary, [ox, dx])
# verify extending the mesh
dxb, nb = 4., 2
mesh.extend(dxb, nb, block='B2')
assert mesh.num_elem == nx + nb
assert mesh.boundary_nodes == [1, nx+nb+1]
assert np.allclose(mesh.boundary, [0., dx+dxb])
assert len(mesh.nodes) == len(mesh.vertices)
示例2: alpha
# 需要导入模块: from mesh import Mesh [as 别名]
# 或者: from mesh.Mesh import extend [as 别名]
el = self.V.element_from_label(label)
ij = self.V.mesh.dof_map(el.connect)
el.update(self.vector[ij])
for (i, v) in enumerate(el.var_names):
data.setdefault(v, []).append(el.variables[i])
# save the outputs
for (key, values) in data.items():
field = frame.FieldOutput(key, SCALAR, ELEMENT, self.V.mesh, s=1)
field.add_data(eb.elements, [(a,) for a in values])
self.time += increment
return self
def alpha(self):
fo = self.steps.values()[0].frames[0].field_outputs
return (self.V.mesh.dimension, self.V.mesh.num_node, self.V.mesh.nodes,
self.V.mesh.vertices, self.V.mesh.num_elem, self.V.mesh.elements,
self.V.mesh.connect, self.V.mesh.element_blocks, fo)
if __name__ == '__main__':
from mesh import Mesh
from element import Element
mesh = Mesh(type='uniform', ox=0., lx=1., nx=10)
mesh.ElementBlock(name='Block-1', elements='all')
mesh.extend(1., 10, block='Block-2')
V = FunctionSpace(mesh, {'Block-1': Element(type='link2'),
'Block-2': Element(type='link2')})
u = Function(V)