当前位置: 首页>>代码示例>>Python>>正文


Python Mesh.from_file方法代码示例

本文整理汇总了Python中mesh.Mesh.from_file方法的典型用法代码示例。如果您正苦于以下问题:Python Mesh.from_file方法的具体用法?Python Mesh.from_file怎么用?Python Mesh.from_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mesh.Mesh的用法示例。


在下文中一共展示了Mesh.from_file方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: from_conf

# 需要导入模块: from mesh import Mesh [as 别名]
# 或者: from mesh.Mesh import from_file [as 别名]
    def from_conf(conf, init_fields=True, init_variables=True, init_equations=True, init_solvers=True):

        mesh = Mesh.from_file(conf.filename_mesh)

        eldesc_dir = op.join(install_dir, "eldesc")
        domain = Domain.from_mesh(mesh, eldesc_dir)
        domain.setup_groups()
        domain.fix_element_orientation()
        domain.setup_neighbour_lists()

        obj = ProblemDefinition(conf=conf, domain=domain, eldesc_dir=eldesc_dir)

        # Default output file trunk and format.
        obj.ofn_trunk = io.get_trunk(conf.filename_mesh)
        obj.output_format = "vtk"

        obj.set_regions(conf.regions, conf.materials, conf.funmod)

        if init_fields:
            obj.set_fields(conf.fields)

            if init_variables:
                obj.set_variables(conf.variables)

                if init_equations:
                    obj.set_equations(conf.equations)

        if init_solvers:
            obj.set_solvers(conf.solvers, conf.options)

        obj.ts = None

        return obj
开发者ID:certik,项目名称:sfepy,代码行数:35,代码来源:problemDef.py

示例2: gen_mesh_from_voxels_mc

# 需要导入模块: from mesh import Mesh [as 别名]
# 或者: from mesh.Mesh import from_file [as 别名]
def gen_mesh_from_voxels_mc(voxels, voxelsize,
                            gmsh3d=False, scale_factor=0.25):
    import scipy.spatial as scsp

    tri = marching_cubes(voxels, voxelsize)

    nel, nnd, dim = tri.shape
    coors = tri.reshape((nel * nnd, dim))
    tree = scsp.ckdtree.cKDTree(coors)
    eps = nm.max(coors.max(axis=0) - coors.min(axis=0)) *1e-6
    dist, idx = tree.query(coors, k=24, distance_upper_bound=eps)

    uniq = set([])
    for ii in idx:
        ukey = ii[ii < tree.n]
        ukey.sort()
        uniq.add(tuple(ukey))

    ntri = nm.ones((nel * nnd,), dtype=nm.int32)
    nnod = len(uniq)
    ncoors = nm.zeros((nnod, 3), dtype=nm.float64)

    for ii, idxs in enumerate(uniq):
        ntri[nm.array(idxs)] = ii
        ncoors[ii] = coors[idxs[0]]

    mesh = Mesh.from_data('voxel_mc_data',
                          ncoors, nm.ones((nnod,), dtype=nm.int32),
                          {0: nm.ascontiguousarray(ntri.reshape((nel, nnd)))},
                          {0: nm.ones((nel,), dtype=nm.int32)},
                          {0: '%d_%d' % (2, 3)})

    if gmsh3d:
        from vtk2stl import vtk2stl
        import tempfile
        import os

        auxfile = os.path.join(tempfile.gettempdir(), 'dicom2fem_aux')
        vtk_fn = auxfile + '_surfmc.vtk'
        stl_fn = auxfile + '_surfmc.stl'
        geo_fn = auxfile + '_surf2vol.geo'
        mesh_fn = auxfile + '_volmv.mesh'
        mesh.write(vtk_fn)
        vtk2stl(vtk_fn, stl_fn)
        geofile = open(geo_fn, 'wt')
        geofile.write(gmsh3d_geo.replace('__INFILE__',
                                         stl_fn).replace('__SCFACTOR__',
                                                         str(scale_factor)))
        geofile.close()
        os.system('gmsh -3 -format mesh -o %s %s' % (mesh_fn, geo_fn))
        mesh = Mesh.from_file(mesh_fn)

    return mesh
开发者ID:adesam01,项目名称:dicom2fem,代码行数:55,代码来源:seg2fem.py

示例3: from_conf

# 需要导入模块: from mesh import Mesh [as 别名]
# 或者: from mesh.Mesh import from_file [as 别名]
    def from_conf(conf, init_fields=True, init_equations=True,
                  init_solvers=True):
        if conf.options.get_default_attr('absolute_mesh_path', False):
            conf_dir = None
        else:
            conf_dir = op.dirname(conf.funmod.__file__)

        functions = Functions.from_conf(conf.functions)

        mesh = Mesh.from_file(conf.filename_mesh, prefix_dir=conf_dir)

        trans_mtx = conf.options.get_default_attr('mesh_coors_transform', None)

        if trans_mtx is not None:
            mesh.transform_coors(trans_mtx)

        domain = Domain(mesh.name, mesh)
        if get_default_attr(conf.options, 'ulf', False):
            domain.mesh.coors_act = domain.mesh.coors.copy()

        obj = ProblemDefinition('problem_from_conf', conf=conf,
                                functions=functions, domain=domain,
                                auto_conf=False, auto_solvers=False)

        obj.set_regions(conf.regions, obj.functions)

        obj.clear_equations()

        if init_fields:
            obj.set_fields( conf.fields )

            if init_equations:
                obj.set_equations(conf.equations, user={'ts' : obj.ts})

        if init_solvers:
            obj.set_solvers( conf.solvers, conf.options )

        return obj
开发者ID:mikegraham,项目名称:sfepy,代码行数:40,代码来源:problemDef.py


注:本文中的mesh.Mesh.from_file方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。