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


Python Region.set_from_group方法代码示例

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


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

示例1: _region_leaf

# 需要导入模块: from region import Region [as 别名]
# 或者: from region.Region import set_from_group [as 别名]
    def _region_leaf( level, op ):

        token, details = op['token'], op['orig']

        if token != 'KW_Region':
            parse_def = token + '<' + ' '.join( details ) + '>'
            region = Region('leaf', rdef, domain, parse_def=parse_def)

        if token == 'KW_Region':
            details = details[1][2:]
            aux = regions.find( details )
            if not aux:
                raise ValueError, 'region %s does not exist' % details
            else:
                if rdef[:4] == 'copy':
                    region = aux.copy()
                else:
                    region = aux

        elif token == 'KW_All':
            region.set_vertices( nm.arange( domain.mesh.n_nod,
                                            dtype = nm.int32 ) )
        elif token == 'E_NIR':
            where = details[2]

            if where[0] == '[':
                out = nm.array( eval( where ), dtype = nm.int32 )
                assert_( nm.amin( out ) >= 0 )
                assert_( nm.amax( out ) < domain.mesh.n_nod )
            else:
                coors = domain.get_mesh_coors()
                x = coors[:,0]
                y = coors[:,1]
                if domain.mesh.dim == 3:
                    z = coors[:,2]
                else:
                    z = None
                coor_dict = {'x' : x, 'y' : y, 'z': z}

                out = nm.where( eval( where, {}, coor_dict ) )[0]
            region.set_vertices( out )

        elif token == 'E_NOS':

            if domain.fa: # 3D.
                fa = domain.fa
            else:
                fa = domain.ed

            flag = fa.mark_surface_facets()
            ii = nm.where( flag > 0 )[0]
            aux = nm.unique(fa.facets[ii])
            if aux[0] == -1: # Triangular faces have -1 as 4. point.
                aux = aux[1:]

            region.can_cells = False
            region.set_vertices( aux )

        elif token == 'E_NBF':
            where = details[2]

            coors = domain.get_mesh_coors()

            fun = functions[where]
            out = fun(coors, domain=domain)

            region.set_vertices( out )

        elif token == 'E_EBF':
            where = details[2]

            coors = domain.get_mesh_coors()

            fun = functions[where]
            out = fun(coors, domain=domain)

            region.set_cells( out )

        elif token == 'E_EOG':

            group = int( details[3] )

            ig = domain.mat_ids_to_i_gs[group]
            group = domain.groups[ig]
            region.set_from_group( ig, group.vertices, group.shape.n_el )

        elif token == 'E_NOG':

            try:
                group = int(details[3])
                group_nodes = nm.where(domain.mesh.ngroups == group)[0]

            except ValueError:
                try:
                    group_nodes = domain.mesh.nodal_bcs[details[3]]

                except KeyError:
                    msg = 'undefined nodal group! (%s)' % details[3]
                    raise ValueError(msg)

#.........这里部分代码省略.........
开发者ID:mikegraham,项目名称:sfepy,代码行数:103,代码来源:domain.py

示例2: _region_leaf

# 需要导入模块: from region import Region [as 别名]
# 或者: from region.Region import set_from_group [as 别名]
            def _region_leaf( level, op ):

                token, details = op['token'], op['orig']
                if token != 'KW_Region':
                    parse_def = token + '<' + ' '.join( details ) + '>'
##                     conns = [group.conn for group in domain.groups.itervalues()]
##                     vertex_groups = [group.vertices
##                                     for group in domain.groups.itervalues()]
                    region = Region( 'leaf', rdef, domain, parse_def )

                if token == 'KW_Region':
                    details = details[1][2:]
                    aux = regions.find( details )
                    if not aux:
                        raise ValueError, 'region %s does not exist' % details
                    else:
                        if rdef[:4] == 'copy':
                            region = aux.copy()
                        else:
                            region = aux

                elif token == 'KW_All':
                    region.set_vertices( nm.arange( domain.mesh.nod0.shape[0],
                                                   dtype = nm.int32 ) )
                elif token == 'E_NIR':
                    where = details[2]
                    
                    if where[0] == '[':
                        out = nm.array( eval( where ), dtype = nm.int32 )
                        assert_( nm.amin( out ) >= 0 )
                        assert_( nm.amax( out ) < domain.mesh.nod0.shape[0] )
                    else:
                        x = domain.mesh.nod0[:,0]
                        y = domain.mesh.nod0[:,1]
                        if domain.mesh.dim == 3:
                            z = domain.mesh.nod0[:,2]
                        else:
                            z = None
                        coor_dict = {'x' : x, 'y' : y, 'z': z}
                        
                        out = nm.where( eval( where, {}, coor_dict ) )[0]
                    region.set_vertices( out )
                    
                elif token == 'E_NOS':

                    if domain.fa: # 3D.
                        fa, nfa = domain.fa, domain.nfa
                    else:
                        fa, nfa = domain.ed, domain.ned
                        
                    flag = dm_mark_surface_faces( fa, nfa )
                    ii = nm.where( flag > 0 )[0]
                    aux = la.unique1d( fa.data[ii,3:].ravel() )
                    if aux[0] == -1: # Triangular faces have -1 as 4. point.
                        aux = aux[1:]
                    region.can_cells = False
                    region.set_vertices( aux )

                elif token == 'E_NBF':
                    where = details[2]
                    
                    x = domain.mesh.nod0[:,0]
                    if domain.shape.dim > 1:
                        y = domain.mesh.nod0[:,1]
                        if domain.shape.dim > 2:
                            z = domain.mesh.nod0[:,2]
                        else:
                            z = None
                    else:
                        y = None
                    aux = {'x' : x, 'y' : y, 'z': z}
                        
                    fun = 'funmod.' + where
#                    print fun
                    out = nm.where( eval( fun, {'funmod' : funmod}, aux ) )[0]

                    region.set_vertices( out )

                elif token == 'E_EBF':
                    where = details[2]
                    
                    aux = {'domain' : domain}
                        
                    fun = 'funmod.' + where
#                    print fun
                    out = eval( fun, {'funmod' : funmod}, aux )
                    print out
                    region.set_cells( out )

                elif token == 'E_EOG':

                    group = int( details[3] )

                    ig = domain.mat_ids_to_i_gs[group]
                    group = domain.groups[ig]
                    region.set_from_group( ig, group.vertices, group.shape.n_el )

                elif token == 'E_ONIR':
                    aux = regions[details[3][2:]]
                    region.set_vertices( aux.all_vertices[0:1] )
#.........这里部分代码省略.........
开发者ID:certik,项目名称:sfepy,代码行数:103,代码来源:domain.py


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