本文整理匯總了Python中region.Region.can_cells方法的典型用法代碼示例。如果您正苦於以下問題:Python Region.can_cells方法的具體用法?Python Region.can_cells怎麽用?Python Region.can_cells使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類region.Region
的用法示例。
在下文中一共展示了Region.can_cells方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _region_leaf
# 需要導入模塊: from region import Region [as 別名]
# 或者: from region.Region import can_cells [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)
#.........這裏部分代碼省略.........
示例2: _region_leaf
# 需要導入模塊: from region import Region [as 別名]
# 或者: from region.Region import can_cells [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] )
#.........這裏部分代碼省略.........