本文整理汇总了Python中sfepy.fem.Mesh.from_surface方法的典型用法代码示例。如果您正苦于以下问题:Python Mesh.from_surface方法的具体用法?Python Mesh.from_surface怎么用?Python Mesh.from_surface使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfepy.fem.Mesh
的用法示例。
在下文中一共展示了Mesh.from_surface方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from sfepy.fem import Mesh [as 别名]
# 或者: from sfepy.fem.Mesh import from_surface [as 别名]
def main():
parser = OptionParser( usage = usage, version = "%prog " + version )
parser.add_option( "-m", "--mesh",
action = "store_true", dest = "save_mesh",
default = True,
help = "save surface mesh [default: %default]" )
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.from_mesh( mesh, op.join( init_sfepy.install_dir, 'eldesc' ) )
domain.setup_groups()
if domain.has_faces():
domain.fix_element_orientation()
domain.setup_neighbour_lists( create_edge_list = False )
lst, surf_faces = domain.surface_faces()
surf_mesh = Mesh.from_surface( surf_faces, mesh )
if options.save_mesh:
base, ext = op.splitext( op.basename( filename_in ) )
surf_mesh.write( "surf_" + base + '.mesh', io = 'auto' )
if options.no_surface:
return
n_nod = mesh.nod0.shape[0]
gr_s = surface_graph( surf_faces, n_nod )
## import sfepy.base.plotutils as plu
## plu.spy( gr_s )
## plu.pylab.show()
n_comp, comps = surface_components( gr_s, surf_faces )
# print '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 %d\n' % (row[0], row[1], row[2], row[3]) )
if (filename_out != '-'):
file_out.close()
示例2: main
# 需要导入模块: from sfepy.fem import Mesh [as 别名]
# 或者: from sfepy.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=True,
help="save surface mesh [default: %default]")
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()