本文整理汇总了Python中sfepy.fem.Mesh.get_bounding_box方法的典型用法代码示例。如果您正苦于以下问题:Python Mesh.get_bounding_box方法的具体用法?Python Mesh.get_bounding_box怎么用?Python Mesh.get_bounding_box使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfepy.fem.Mesh
的用法示例。
在下文中一共展示了Mesh.get_bounding_box方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_interpolation_two_meshes
# 需要导入模块: from sfepy.fem import Mesh [as 别名]
# 或者: from sfepy.fem.Mesh import get_bounding_box [as 别名]
def test_interpolation_two_meshes(self):
from sfepy import data_dir
from sfepy.fem import Mesh, Domain, H1NodalVolumeField, Variables
m1 = Mesh('source mesh', data_dir + '/meshes/3d/block.mesh')
m2 = Mesh('target mesh', data_dir + '/meshes/3d/cube_medium_tetra.mesh')
m2.coors *= 2.0
bbox = m1.get_bounding_box()
dd = bbox[1,:] - bbox[0,:]
data = nm.sin(4.0 * nm.pi * m1.coors[:,0:1] / dd[0]) \
* nm.cos(4.0 * nm.pi * m1.coors[:,1:2] / dd[1])
variables1 = {
'u' : ('unknown field', 'scalar_tp', 0),
'v' : ('test field', 'scalar_tp', 'u'),
}
variables2 = {
'u' : ('unknown field', 'scalar_si', 0),
'v' : ('test field', 'scalar_si', 'u'),
}
d1 = Domain('d1', m1)
omega1 = d1.create_region('Omega', 'all')
field1 = H1NodalVolumeField('scalar_tp', nm.float64, (1,1), omega1,
approx_order=1)
ff1 = {field1.name : field1}
d2 = Domain('d2', m2)
omega2 = d2.create_region('Omega', 'all')
field2 = H1NodalVolumeField('scalar_si', nm.float64, (1,1), omega2,
approx_order=0)
ff2 = {field2.name : field2}
vv1 = Variables.from_conf(transform_variables(variables1), ff1)
u1 = vv1['u']
u1.set_from_mesh_vertices(data)
vv2 = Variables.from_conf(transform_variables(variables2), ff2)
u2 = vv2['u']
# Performs interpolation, if other field differs from self.field
# or, in particular, is defined on a different mesh.
u2.set_from_other(u1, strategy='interpolation', close_limit=0.1)
fname = in_dir(self.options.out_dir)
u1.save_as_mesh(fname('test_mesh_interp_block_scalar.vtk'))
u2.save_as_mesh(fname('test_mesh_interp_cube_scalar.vtk'))
return True
示例2: test_invariance_qp
# 需要导入模块: from sfepy.fem import Mesh [as 别名]
# 或者: from sfepy.fem.Mesh import get_bounding_box [as 别名]
def test_invariance_qp(self):
from sfepy import data_dir
from sfepy.fem import (Mesh, Domain, H1NodalVolumeField,
Variables, Integral)
from sfepy.terms import Term
from sfepy.fem.mappings import get_physical_qps
mesh = Mesh('source mesh', data_dir + '/meshes/3d/block.mesh')
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])
variables = {
'u' : ('unknown field', 'scalar_tp', 0),
'v' : ('test field', 'scalar_tp', 'u'),
}
domain = Domain('domain', mesh)
omega = domain.create_region('Omega', 'all')
field = H1NodalVolumeField('scalar_tp', nm.float64, 1, omega,
approx_order=1)
ff = {field.name : field}
vv = Variables.from_conf(transform_variables(variables), ff)
u = vv['u']
u.set_from_mesh_vertices(data)
integral = Integral('i', order=2)
term = Term.new('ev_volume_integrate(u)', integral, omega, u=u)
term.setup()
val1, _ = term.evaluate(mode='qp')
val1 = val1.ravel()
qps = get_physical_qps(omega, integral)
coors = qps.get_merged_values()
val2 = u.evaluate_at(coors).ravel()
self.report('max. difference:', nm.abs(val1 - val2).max())
ok = nm.allclose(val1, val2, rtol=0.0, atol=1e-12)
self.report('invariance in qp: %s' % ok)
return ok