本文整理汇总了Python中sfepy.discrete.fem.Mesh.from_surface方法的典型用法代码示例。如果您正苦于以下问题:Python Mesh.from_surface方法的具体用法?Python Mesh.from_surface怎么用?Python Mesh.from_surface使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfepy.discrete.fem.Mesh
的用法示例。
在下文中一共展示了Mesh.from_surface方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from sfepy.discrete.fem import Mesh [as 别名]
# 或者: from sfepy.discrete.fem.Mesh import from_surface [as 别名]
def main():
parser = OptionParser(usage=usage, version="%prog " + sfepy.__version__)
parser.add_option("-m", "--mesh",
action="store_true", dest="save_mesh",
default=False,
help="save surface mesh")
parser.add_option("-n", "--no-surface",
action="store_true", dest="no_surface",
default=False,
help="do not output surface [default: %default]")
(options, args) = parser.parse_args()
if (len(args) == 2):
filename_in = args[0];
filename_out = args[1];
else:
parser.print_help(),
return
if (filename_in == '-'):
file_in = sys.stdin
else:
file_in = open(filename_in, "r");
mesh = Mesh.from_file(filename_in)
if (filename_in != '-'):
file_in.close()
domain = Domain('domain', mesh)
domain.setup_groups()
if domain.has_faces():
domain.fix_element_orientation()
lst, surf_faces = get_surface_faces(domain)
surf_mesh = Mesh.from_surface(surf_faces, mesh)
if options.save_mesh:
aux = edit_filename(filename_in, prefix='surf_', new_ext='.mesh')
surf_mesh.write(aux, io='auto')
if options.no_surface:
return
gr_s = surface_graph(surf_faces, mesh.n_nod)
n_comp, comps = surface_components(gr_s, surf_faces)
output('number of surface components:', n_comp)
ccs, comps = comps, nm.zeros((0,1), nm.int32)
for cc in ccs:
comps = nm.concatenate((comps, cc[:,nm.newaxis]), 0)
out = nm.concatenate((lst, comps), 1)
if (filename_out == '-'):
file_out = sys.stdout
else:
file_out = open(filename_out, "w");
for row in out:
file_out.write('%d %d %d\n' % (row[0], row[1], row[2]))
if (filename_out != '-'):
file_out.close()