本文整理汇总了Python中mesh.Mesh.link方法的典型用法代码示例。如果您正苦于以下问题:Python Mesh.link方法的具体用法?Python Mesh.link怎么用?Python Mesh.link使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mesh.Mesh
的用法示例。
在下文中一共展示了Mesh.link方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: polygon
# 需要导入模块: from mesh import Mesh [as 别名]
# 或者: from mesh.Mesh import link [as 别名]
def polygon (nb_sides) :
"""Create a regular polygonal 2D mesh
"""
#create mesh
m = Mesh()
#create points
pids = []
for i in range(nb_sides) :
pid = m.add_dart(0)
vec = (cos(2 * pi * i / nb_sides), sin(2 * pi * i / nb_sides) )
m.set_position(pid, vec)
pids.append(pid)
#create segments
eids = []
for i in range(nb_sides) :
eid = m.add_dart(1)
m.link(eid, pids[i])
m.link(eid, pids[(i + 1) % nb_sides])
eids.append(eid)
#create face
fid = m.add_dart(2)
for eid in eids :
m.link(fid, eid)
#return
return m
示例2: line
# 需要导入模块: from mesh import Mesh [as 别名]
# 或者: from mesh.Mesh import link [as 别名]
def line (nb_segments) :
"""Create a 1D mesh along a single line
made of nb segments
"""
#create mesh
m = Mesh()
#create points
pids = []
for i in range(nb_segments + 1) :
pid = m.add_dart(0)
m.set_position(pid, float(i) )
pids.append(pid)
#create segments
for i in range(nb_segments) :
did = m.add_dart(1)
m.link(did, pids[i])
m.link(did, pids[i + 1])
#return
return m
示例3: _regular_grid2D
# 需要导入模块: from mesh import Mesh [as 别名]
# 或者: from mesh.Mesh import link [as 别名]
def _regular_grid2D (shape) :
cell_grid = Grid(shape)
point_grid = Grid( (i + 1 for i in shape) )
imax,jmax = shape
#create mesh
m = Mesh()
#create cells
cell = [m.add_dart(2) for ind in cell_grid]
#create points
point = [m.add_dart(0) for ind in point_grid]
for i,pid in enumerate(point) :
m.set_position(pid, point_grid.coordinates(i) )
#create vertical walls
for i in xrange(imax + 1) :
for j in xrange(jmax) :
wid = m.add_dart(1)
m.link(wid, point[point_grid.index( (i,j) )])
m.link(wid, point[point_grid.index( (i,j + 1) )])
if i > 0 :
m.link(cell[cell_grid.index( (i - 1,j) )], wid)
if i < imax :
m.link(cell[cell_grid.index( (i,j) )], wid)
#create horizontal walls
for i in xrange(imax) :
for j in xrange(jmax + 1) :
wid = m.add_dart(1)
m.link(wid, point[point_grid.index( (i,j) )])
m.link(wid, point[point_grid.index( (i + 1,j) )])
if j > 0 :
m.link(cell[cell_grid.index( (i,j - 1) )], wid)
if j < jmax :
m.link(cell[cell_grid.index( (i,j) )], wid)
#return
return m
示例4: _regular_grid3D
# 需要导入模块: from mesh import Mesh [as 别名]
# 或者: from mesh.Mesh import link [as 别名]
def _regular_grid3D (shape) :
cell_grid = Grid(shape)
point_grid = Grid( (i + 1 for i in shape) )
imax,jmax,kmax = shape
#create mesh
m = Mesh()
#create cells
cell = [m.add_dart(3) for ind in cell_grid]
#create points
point = [m.add_dart(0) for ind in point_grid]
for i,pid in enumerate(point) :
m.set_position(pid, point_grid.coordinates(i) )
#create edges
point_to_edge = {}
#between i and i + 1
for i in xrange(imax) :
for j in xrange(jmax + 1) :
for k in xrange(kmax + 1) :
eid = m.add_dart(1)
pid1 = point[point_grid.index( (i,j,k) )]
pid2 = point[point_grid.index( (i + 1,j,k) )]
m.link(eid, pid1)
m.link(eid, pid2)
key = (min(pid1, pid2), max(pid1, pid2) )
point_to_edge[key] = eid
#between j and j + 1
for i in xrange(imax + 1) :
for j in xrange(jmax) :
for k in xrange(kmax + 1) :
eid = m.add_dart(1)
pid1 = point[point_grid.index( (i,j,k) )]
pid2 = point[point_grid.index( (i,j + 1,k) )]
m.link(eid, pid1)
m.link(eid, pid2)
key = (min(pid1, pid2), max(pid1,pid2) )
point_to_edge[key] = eid
#between k and k + 1
for i in xrange(imax + 1) :
for j in xrange(jmax + 1) :
for k in xrange(kmax) :
eid = m.add_dart(1)
pid1 = point[point_grid.index( (i,j,k) )]
pid2 = point[point_grid.index( (i,j,k + 1) )]
m.link(eid, pid1)
m.link(eid, pid2)
key = (min(pid1, pid2), max(pid1,pid2) )
point_to_edge[key] = eid
#create walls
#in the (i,j) plane, k constant
for k in xrange(kmax + 1) :
for i in xrange(imax) :
for j in xrange(jmax) :
wid = m.add_dart(2)
pids = (point[point_grid.index( (i,j,k) )],
point[point_grid.index( (i + 1,j,k) )],
point[point_grid.index( (i + 1,j + 1,k) )],
point[point_grid.index( (i,j + 1,k) )] )
for ind in xrange(4) :
pid1 = pids[ind]
pid2 = pids[(ind + 1) % 4]
eid = point_to_edge[(min(pid1, pid2), max(pid1, pid2) )]
m.link(wid, eid)
if k > 0 :
m.link(cell[cell_grid.index( (i,j,k - 1) )], wid)
if k < kmax :
m.link(cell[cell_grid.index( (i,j,k) )], wid)
#in the (j,k) plane, i constant
for i in xrange(imax + 1) :
for j in xrange(jmax) :
for k in xrange(kmax) :
wid = m.add_dart(2)
pids = (point[point_grid.index( (i,j,k) )],
point[point_grid.index( (i,j + 1,k) )],
point[point_grid.index( (i,j + 1,k + 1) )],
point[point_grid.index( (i,j,k + 1) )] )
for ind in xrange(4) :
pid1 = pids[ind]
pid2 = pids[(ind + 1) % 4]
eid = point_to_edge[(min(pid1, pid2), max(pid1, pid2) )]
m.link(wid, eid)
if i > 0 :
m.link(cell[cell_grid.index( (i - 1,j,k) )], wid)
if i < imax :
m.link(cell[cell_grid.index( (i,j,k) )], wid)
#in the (k,i) plane, j constant
for j in xrange(jmax + 1) :
for k in xrange(kmax) :
for i in xrange(imax) :
wid = m.add_dart(2)
pids = (point[point_grid.index( (i,j,k) )],
point[point_grid.index( (i,j,k + 1) )],
point[point_grid.index( (i + 1,j,k + 1) )],
point[point_grid.index( (i + 1,j,k) )] )
#.........这里部分代码省略.........