本文整理匯總了Python中sfepy.discrete.FieldVariable.set_from_mesh_vertices方法的典型用法代碼示例。如果您正苦於以下問題:Python FieldVariable.set_from_mesh_vertices方法的具體用法?Python FieldVariable.set_from_mesh_vertices怎麽用?Python FieldVariable.set_from_mesh_vertices使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sfepy.discrete.FieldVariable
的用法示例。
在下文中一共展示了FieldVariable.set_from_mesh_vertices方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: prepare_variable
# 需要導入模塊: from sfepy.discrete import FieldVariable [as 別名]
# 或者: from sfepy.discrete.FieldVariable import set_from_mesh_vertices [as 別名]
def prepare_variable(filename, n_components):
from sfepy.discrete import FieldVariable
from sfepy.discrete.fem import Mesh, FEDomain, Field
mesh = Mesh.from_file(filename)
bbox = mesh.get_bounding_box()
dd = bbox[1, :] - bbox[0, :]
data = nm.sin(4.0 * nm.pi * mesh.coors[:, 0:1] / dd[0]) * nm.cos(4.0 * nm.pi * mesh.coors[:, 1:2] / dd[1])
domain = FEDomain("domain", mesh)
omega = domain.create_region("Omega", "all")
field = Field.from_args("field", nm.float64, n_components, omega, approx_order=2)
u = FieldVariable("u", "parameter", field, primary_var_name="(set-to-None)")
u.set_from_mesh_vertices(data * nm.arange(1, n_components + 1)[None, :])
return u
示例2: prepare_variable
# 需要導入模塊: from sfepy.discrete import FieldVariable [as 別名]
# 或者: from sfepy.discrete.FieldVariable import set_from_mesh_vertices [as 別名]
def prepare_variable(filename, n_components):
from sfepy.discrete import FieldVariable
from sfepy.discrete.fem import Mesh, FEDomain, Field
mesh = Mesh.from_file(filename)
bbox = mesh.get_bounding_box()
dd = bbox[1,:] - bbox[0,:]
data = (nm.sin(4.0 * nm.pi * mesh.coors[:,0:1] / dd[0])
* nm.cos(4.0 * nm.pi * mesh.coors[:,1:2] / dd[1]))
domain = FEDomain('domain', mesh)
omega = domain.create_region('Omega', 'all')
field = Field.from_args('field', nm.float64, n_components, omega,
approx_order=2)
u = FieldVariable('u', 'parameter', field,
primary_var_name='(set-to-None)')
u.set_from_mesh_vertices(nm.c_[tuple([data] * n_components)])
return u