Beispiel #1
0
    def init_mesh(self, n=2, meshtype='tet'):
        node = np.array([[-1, -1, -1], [1, -1, -1], [1, 1, -1], [-1, 1, -1],
                         [-1, -1, 1], [1, -1, 1], [1, 1, 1], [-1, 1, 1]],
                        dtype=np.float64)

        cell = np.array([[0, 1, 2, 6], [0, 5, 1, 6], [0, 4, 5, 6],
                         [0, 7, 4, 6], [0, 3, 7, 6], [0, 2, 3, 6]],
                        dtype=np.int_)
        mesh = TetrahedronMesh(node, cell)
        for i in range(n):
            mesh.bisect()

        NN = mesh.number_of_nodes()
        node = mesh.entity('node')
        cell = mesh.entity('cell')
        bc = mesh.entity_barycenter('cell')
        isDelCell = ((bc[:, 0] > 0) & (bc[:, 1] < 0))
        cell = cell[~isDelCell]
        isValidNode = np.zeros(NN, dtype=np.bool)
        isValidNode[cell] = True
        node = node[isValidNode]

        idxMap = np.zeros(NN, dtype=mesh.itype)
        idxMap[isValidNode] = range(isValidNode.sum())
        cell = idxMap[cell]
        mesh = TetrahedronMesh(node, cell)
        mesh.label()  # 标记最长边

        return mesh
Beispiel #2
0
    def init_mesh(self, n=1, meshtype='tet'):
        node = np.array([[-1, -1, -1], [1, -1, -1], [1, 1, -1], [-1, 1, -1],
                         [-1, -1, 1], [1, -1, 1], [1, 1, 1], [-1, 1, 1]],
                        dtype=np.float64)

        cell = np.array([[0, 1, 2, 6], [0, 5, 1, 6], [0, 4, 5, 6],
                         [0, 7, 4, 6], [0, 3, 7, 6], [0, 2, 3, 6]],
                        dtype=np.int_)
        mesh = TetrahedronMesh(node, cell)
        mesh.uniform_refine(n)
        mesh.label()  # 标记最长边
        return mesh