本文整理汇总了Python中meshpy.tet.MeshInfo.regions[1]方法的典型用法代码示例。如果您正苦于以下问题:Python MeshInfo.regions[1]方法的具体用法?Python MeshInfo.regions[1]怎么用?Python MeshInfo.regions[1]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类meshpy.tet.MeshInfo
的用法示例。
在下文中一共展示了MeshInfo.regions[1]方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: tag
# 需要导入模块: from meshpy.tet import MeshInfo [as 别名]
# 或者: from meshpy.tet.MeshInfo import regions[1] [as 别名]
return [[pt+increment for pt in facet] for facet in facets]
mesh_info.set_facets(
[[0,1,2,3]] # base
+box_without_minus_z # first box
+add_to_all_vertex_indices(box_without_minus_z, 4) # second box
)
# set the volume properties -- this is where the tet size constraints are
mesh_info.regions.resize(2)
mesh_info.regions[0] = [0,0,2, # point in volume -> first box
0, # region tag (user-defined number)
1e-1, # max tet volume in region
]
mesh_info.regions[1] = [0,0,7, # point in volume -> second box
0, # region tag (user-defined number, arbitrary)
1e-2, # max tet volume in region
]
mesh = build(mesh_info, volume_constraints=True)
# this is a no-op, but it shows how to access the output data
for point in mesh.points:
[x,y,z] = point
for element in mesh.elements:
[pt_1, pt_2, pt_3, pt_4] = element
# this writes the mesh as a vtk file, requires pyvtk
mesh.write_vtk("test.vtk")
示例2: make_extrusion_with_fine_core
# 需要导入模块: from meshpy.tet import MeshInfo [as 别名]
# 或者: from meshpy.tet.MeshInfo import regions[1] [as 别名]
def make_extrusion_with_fine_core(rz, inner_r,
max_volume_inner=1e-4, max_volume_outer=5e-2,
radial_subdiv=20):
min_z = min(rz_pt[1] for rz_pt in rz)
max_z = max(rz_pt[1] for rz_pt in rz)
from meshpy.tet import MeshInfo, build
from meshpy.geometry import generate_surface_of_revolution
MINUS_Z_MARKER = 1
PLUS_Z_MARKER = 2
inner_points, inner_facets, inner_holes, inner_markers = \
generate_surface_of_revolution(
[
(0, min_z),
(inner_r, min_z),
(inner_r, max_z),
(0, max_z),
],
ring_markers=[
MINUS_Z_MARKER,
0,
PLUS_Z_MARKER
],
radial_subdiv=radial_subdiv,
)
inner_point_indices = tuple(range(len(inner_points)))
outer_points, outer_facets, outer_holes, outer_markers = \
generate_surface_of_revolution(
[(inner_r,min_z)] + rz + [(inner_r, max_z)],
ring_markers=[MINUS_Z_MARKER] + [0]*(len(rz)-1) + [PLUS_Z_MARKER],
point_idx_offset=len(inner_points),
radial_subdiv=radial_subdiv,
ring_point_indices=
[ inner_point_indices[:radial_subdiv] ]
+ [None]*len(rz)
+ [inner_point_indices[radial_subdiv:]]
)
mesh_info = MeshInfo()
mesh_info.set_points(inner_points + outer_points)
mesh_info.set_facets_ex(
inner_facets + outer_facets,
inner_holes + outer_holes,
inner_markers + outer_markers,
)
# set regional max. volume
mesh_info.regions.resize(2)
mesh_info.regions[0] = [0, 0, (max_z+min_z)/2, 0,
max_volume_inner]
mesh_info.regions[1] = [inner_r+(rz[0][0]-inner_r)/2, 0, (max_z+min_z)/2, 0,
max_volume_outer]
# add periodicity
mesh_info.pbc_groups.resize(1)
pbcg = mesh_info.pbc_groups[0]
pbcg.facet_marker_1 = MINUS_Z_MARKER
pbcg.facet_marker_2 = PLUS_Z_MARKER
pbcg.set_transform(translation=[0,0,max_z-min_z])
mesh = build(mesh_info, verbose=True, volume_constraints=True)
#print "%d elements" % len(mesh.elements)
#mesh.write_vtk("gun.vtk")
fvi2fm = mesh.face_vertex_indices_to_face_marker
def zper_boundary_tagger(fvi, el, fn, points):
face_marker = fvi2fm[frozenset(fvi)]
if face_marker == MINUS_Z_MARKER:
return ["minus_z"]
elif face_marker == PLUS_Z_MARKER:
return ["plus_z"]
else:
return ["shell"]
vertices = numpy.asarray(mesh.points, dtype=float, order="C")
from hedge.mesh import make_conformal_mesh_ext
from hedge.mesh.element import Tetrahedron
return make_conformal_mesh_ext(
vertices,
[Tetrahedron(i, el_idx, vertices)
for i, el_idx in enumerate(mesh.elements)],
zper_boundary_tagger,
periodicity=[None, None, ("minus_z", "plus_z")])
示例3: tag
# 需要导入模块: from meshpy.tet import MeshInfo [as 别名]
# 或者: from meshpy.tet.MeshInfo import regions[1] [as 别名]
)
# figuring out what each of the volume constraints should be
# the edge length here is divided by four to make sure there are at least 3 nodes per layer
vc = lambda x: (x/4)**3/6
# set the volume properties -- this is where the tet size constraints are
mesh_info.regions.resize(3)
mesh_info.regions[0] = [0,0,1-delta_con/2,# point in volume -> first box
10, # region tag (user-defined number)
vc(delta_con), # max tet volume in region
]
mesh_info.regions[1] = [0,0,((1-delta_con)-delta_base/2), # point in volume -> second box
20, # region tag (user-defined number, arbitrary)
vc(delta_base), # max tet volume in region
]
mesh_info.regions[2] = [0,0,(1-delta_con-delta_base)/2, # point in volume -> second box
30, # region tag (user-defined number, arbitrary)
vc(1-delta_con-delta_base), # max tet volume in region
]
mesh = build(mesh_info, options=Options("pqnn"), volume_constraints=True, attributes=True)
for facet in mesh.facets:
print facets
# this is a no-op, but it shows how to access the output data
#for point in mesh.points:
# [x,y,z] = point