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


Python MeshInfo.regions[0]方法代码示例

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


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

示例1: main

# 需要导入模块: from meshpy.tet import MeshInfo [as 别名]
# 或者: from meshpy.tet.MeshInfo import regions[0] [as 别名]
def main():
    #Test1: mesh testing
    MeshPoints = []
    MeshFacets = []
    with open('MeshFacets', 'rb') as input:
        MeshFacets = pickle.load(input)
    with open('MeshPoints', 'rb') as input:
        MeshPoints = pickle.load(input)

    mesh_info = MeshInfo()

    mesh_info.regions.resize(1)
    mesh_info.regions[0] = [
                            MeshPoints[0][0], MeshPoints[0][1], MeshPoints[0][2], # point in volume -> first box
                            0, # region tag (user-defined number)
                            1, # max tet volume in region
                            ]
    print "Building mesh from {} facets and {} points".format(len(MeshFacets), len(MeshPoints))
    try:
        mesh = build(mesh_info, options=Options(switches="pqT", epsilon=0.01), volume_constraints=True)
    except:
        pass
    try:
        mesh = build(mesh_info, options=Options(switches="pqT", epsilon=0.0001), volume_constraints=True)
    except:
        pass
    print "Created mesh with {} points, {} faces and {} elements.".format(len(mesh.points), len(mesh.faces), len(mesh.elements))
开发者ID:sdfsdffsdfsf,项目名称:DXFMapper,代码行数:29,代码来源:Tests.py

示例2: make_mesh_info_with_inner_tube

# 需要导入模块: from meshpy.tet import MeshInfo [as 别名]
# 或者: from meshpy.tet.MeshInfo import regions[0] [as 别名]
def make_mesh_info_with_inner_tube(rz, tube_r, radial_subdiv,
        max_inner_volume=1e-4):
    # chop off points with zero radius
    while rz[0][0] == 0:
        rz.pop(0)
    while rz[-1][0] == 0:
        rz.pop(-1)

    # construct outer cylinder
    first_z = rz[0][1]
    last_z = rz[-1][1]

    rz.insert(0, (tube_r, first_z))
    rz.append((tube_r, last_z))

    from meshpy.tet import MeshInfo
    from meshpy.geometry import EXT_OPEN, generate_surface_of_revolution

    outer_points, outer_facets, outer_facet_holestarts, outer_facet_markers = \
            generate_surface_of_revolution(rz,
                    closure=EXT_OPEN, radial_subdiv=radial_subdiv)

    outer_point_indices = tuple(range(len(outer_points)))

    inner_points, inner_facets, inner_facet_holestarts, inner_facet_markers = \
            generate_surface_of_revolution(
                    [(0,first_z),
                        (tube_r, first_z),
                        (tube_r, last_z),
                        (0, last_z)],
                    point_idx_offset=len(outer_points),
                    radial_subdiv=radial_subdiv,
                    ring_point_indices=[
                        None,
                        outer_point_indices[:radial_subdiv],
                        outer_point_indices[-radial_subdiv:],
                        None,
                        ]
                    )

    points = outer_points + inner_points
    facets = outer_facets + inner_facets
    facet_holestarts = outer_facet_holestarts + inner_facet_holestarts
    facet_markers = outer_facet_markers + inner_facet_markers

    mesh_info = MeshInfo()
    mesh_info.set_points(points)
    mesh_info.set_facets_ex(facets, facet_holestarts, facet_markers)

    # set regional max. volume
    mesh_info.regions.resize(1)
    mesh_info.regions[0] = [0, 0,(first_z+last_z)/2, 0,
            max_inner_volume]

    return mesh_info
开发者ID:gimac,项目名称:pyrticle,代码行数:57,代码来源:rzmesh.py

示例3: main

# 需要导入模块: from meshpy.tet import MeshInfo [as 别名]
# 或者: from meshpy.tet.MeshInfo import regions[0] [as 别名]
def main():
    import numpy
    from meshpy.tet import MeshInfo, build
    from meshpy.geometry import GeometryBuilder, Marker, make_box

    geob = GeometryBuilder()

    box_marker = Marker.FIRST_USER_MARKER
    extent_small = 0.3*numpy.ones(3, dtype=numpy.float64)
    points, facets, _, _ = \
            make_box(-extent_small, extent_small)

    geob.add_geometry(points, facets, facet_markers=box_marker)

    points, facets, _, facet_markers = \
            make_box(numpy.array([-1, -1, -1]), numpy.array([1, 1, 5]))

    geob.add_geometry(points, facets, facet_markers=facet_markers)

    mesh_info = MeshInfo()
    geob.set(mesh_info)
    #mesh_info.set_holes([(0, 0, 0)])

    # region attributes
    mesh_info.regions.resize(1)
    mesh_info.regions[0] = (
            # point in region
            [0, 0, 0] + [
                # region number
                1,
                # max volume in region
                0.001])

    mesh = build(mesh_info, max_volume=0.06,
            volume_constraints=True, attributes=True)
    print(("%d elements" % len(mesh.elements)))
    mesh.write_vtk("box-in-box.vtk")
开发者ID:OlegJakushkin,项目名称:meshpy,代码行数:39,代码来源:box-in-box.py

示例4: ProcessGlobalAction

# 需要导入模块: from meshpy.tet import MeshInfo [as 别名]
# 或者: from meshpy.tet.MeshInfo import regions[0] [as 别名]

#.........这里部分代码省略.........
                MeshPointsIndex[point] = PointIndex
                MeshPoints.append(False)
                MeshPoints[PointIndex] = NumberedPoints['points'][point]['point']
                PointIndex += 1

        
        saveobject(MeshFacets, r'MeshFacets')
        saveobject(MeshPoints, r'MeshPoints')            
        mesh_info.set_facets(MeshFacets)
        mesh_info.set_points(MeshPoints)
        #insertaddpoints
        
        #points = np.array([list(x) for x in MeshPoints])
        #qhull = scipy.spatial.Delaunay(points)
        #mesh_info.Options(switches='pq')
        #mesh_info.set_points([
        #    (0,0,0), (12,0,0), (12,12,0), (0,12,0),
        #    (0,0,12), (12,0,12), (12,12,12), (0,12,12),
        #    ])
        #mesh_info.set_facets([
        #    [0,1,2,3],
        #    [4,5,6,7],
        #    [0,4,5,1],
        #    [1,5,6,2],
        #    [2,6,7,3],
        #    [3,7,4,0],
        #    ])
        
        #opts = Options(switches='pq')
        #opts.maxvolume = 0.0001
        #opts.parse_switches()

        mesh_info.regions.resize(1)
        mesh_info.regions[0] = [
                                MeshPoints[0][0], MeshPoints[0][1], MeshPoints[0][2], # point in volume -> first box
                                0, # region tag (user-defined number)
                                Parameters['maxvolume'], # max tet volume in region
                                ]
        mesh = build(mesh_info, options=Options(switches="pqT", epsilon=Parameters['tolerance']), volume_constraints=True)
        print "Created mesh with {} points, {} faces and {} elements.".format(len(mesh.points), len(mesh.faces), len(mesh.elements))
        #mesh = build(mesh_info, options=Options(switches="pTi", epsilon=Parameters['tolerance'], insertaddpoints=True), volume_constraints=True, insert_points=additional_points)
        #mesh.write_vtk("test.vtk")
        #mesh.points
        #mesh.elements
        #mesh.faces
        filename = "test"
        #mesh.save_elements(filename)
        #mesh.save_nodes(filename)
        #mesh.save_elements(filename)
        #mesh.save_faces(filename)
        #mesh.save_edges(filename)
        #mesh.save_neighbors(filename)
        #mesh.save_poly(filename)
        #for element in qhull.simplices:
        #    Position = [list(qhull.points[x]) for x in element]
        #    Output.append({'element_type': '3DFACE', 'position': Position, 'layer': 'Elements'})
        #NumberedPoints['points'][compoundObject['points'][0]]['point']
        if not Boundaries: return False, False
        Precision = int(GlobalAction['Precision']) if 'Precision' in GlobalAction else 4

        if Semantic['output'].lower() == 'graphics':
            for face in mesh.faces:
                Position = [mesh.points[x] for x in face]
                Output.append({'element_type': '3DFACE', 'position': Position, 'layer': 'Faces'})
            for element in mesh.elements:
                Position = [mesh.points[x] for x in element]
开发者ID:sdfsdffsdfsf,项目名称:DXFMapper,代码行数:70,代码来源:REDOutput.py

示例5: make_extrusion_with_fine_core

# 需要导入模块: from meshpy.tet import MeshInfo [as 别名]
# 或者: from meshpy.tet.MeshInfo import regions[0] [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")])
开发者ID:gimac,项目名称:pyrticle,代码行数:95,代码来源:geometry.py

示例6: make_boxmesh

# 需要导入模块: from meshpy.tet import MeshInfo [as 别名]
# 或者: from meshpy.tet.MeshInfo import regions[0] [as 别名]
def make_boxmesh():
    from meshpy.tet import MeshInfo, build
    from meshpy.geometry import GeometryBuilder, Marker, make_box

    geob = GeometryBuilder()

    box_marker = Marker.FIRST_USER_MARKER
    extent_small = 0.1*numpy.ones(3, dtype=numpy.float64)

    geob.add_geometry(*make_box(-extent_small, extent_small))

    # make small "separator box" for region attribute

    geob.add_geometry(
            *make_box(
                -extent_small*4,
                numpy.array([4, 0.4, 0.4], dtype=numpy.float64)))

    geob.add_geometry(
            *make_box(
                numpy.array([-1, -1, -1], dtype=numpy.float64),
                numpy.array([5, 1, 1], dtype=numpy.float64)))

    mesh_info = MeshInfo()
    geob.set(mesh_info)
    mesh_info.set_holes([(0, 0, 0)])

    # region attributes
    mesh_info.regions.resize(1)
    mesh_info.regions[0] = (
            # point in region
            list(extent_small*2) + [
            # region number
            1,
            # max volume in region
            #0.0001
            0.005
            ])

    mesh = build(mesh_info, max_volume=0.02,
            volume_constraints=True, attributes=True)
    print "%d elements" % len(mesh.elements)
    #mesh.write_vtk("box-in-box.vtk")
    #print "done writing"

    fvi2fm = mesh.face_vertex_indices_to_face_marker

    face_marker_to_tag = {
            box_marker: "noslip",
            Marker.MINUS_X: "inflow",
            Marker.PLUS_X: "outflow",
            Marker.MINUS_Y: "inflow",
            Marker.PLUS_Y: "inflow",
            Marker.PLUS_Z: "inflow",
            Marker.MINUS_Z: "inflow"
            }

    def bdry_tagger(fvi, el, fn, all_v):
        face_marker = fvi2fm[fvi]
        return [face_marker_to_tag[face_marker]]

    from hedge.mesh import make_conformal_mesh
    return make_conformal_mesh(
            mesh.points, mesh.elements, bdry_tagger)
开发者ID:allansnielsen,项目名称:hedge,代码行数:66,代码来源:box-in-box.py

示例7: add_to_all_vertex_indices

# 需要导入模块: from meshpy.tet import MeshInfo [as 别名]
# 或者: from meshpy.tet.MeshInfo import regions[0] [as 别名]
    [3,7,4,0],
    ]

def add_to_all_vertex_indices(facets, increment):
    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
开发者ID:matthewdbray,项目名称:meshpy,代码行数:33,代码来源:tet-size-control.py

示例8: max

# 需要导入模块: from meshpy.tet import MeshInfo [as 别名]
# 或者: from meshpy.tet.MeshInfo import regions[0] [as 别名]
    facet_mrks.append(-(int(f == max(facets))))  # Finding the surface boundary facet and labeling negative

mesh_info.set_facets(facets, 
        facet_mrks   # Surface boundary conditions
    )

# 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:
开发者ID:matthewdbray,项目名称:create_airfields,代码行数:34,代码来源:create_airfields.py


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