mesh = TetrahedronMesh(node, cell) fig = plt.figure() axes = fig.gca(projection='3d') axes.set_aspect('equal') axes.set_axis_off() edge0 = np.array([(0, 1), (0, 3), (1, 2), (1, 3), (2, 3)], dtype=np.int) lines = a3.art3d.Line3DCollection(point[edge0], color='k', linewidths=2) axes.add_collection3d(lines) edge1 = np.array([(0, 2)], dtype=np.int) lines = a3.art3d.Line3DCollection(point[edge1], color='gray', linewidths=2, alpha=0.5) axes.add_collection3d(lines) #mesh.add_plot(axes, alpha=0.3) mesh.find_node(axes, showindex=True, color='k', fontsize=20, markersize=100) V = LagrangeFiniteElementSpace(mesh, degree) ldof = V.number_of_local_dofs() ipoints = V.interpolation_points() cell2dof = V.dof.cell2dof[0] ipoints = ipoints[cell2dof] idx = np.arange(1, degree+2) idx = np.cumsum(np.cumsum(idx)) d = Delaunay(ipoints) mesh2 = TetrahedronMesh(ipoints, d.simplices) face = mesh2.ds.face
import numpy as np import mpl_toolkits.mplot3d as a3 import pylab as pl from fealpy.mesh.TetrahedronMesh import TetrahedronMesh 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.float) 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(2) mesh.print() fig = pl.figure() axes = a3.Axes3D(fig) mesh.add_plot(axes) mesh.find_node(axes, showindex=True) pl.show()
import numpy as np from fealpy.mesh.TetrahedronMesh import TetrahedronMesh import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D 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.float) 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.bisect() mesh.bisect() mesh.bisect() mesh.bisect() fig = plt.figure() axes = fig.gca(projection='3d') mesh.add_plot(axes, alpha=0, showedge=True) mesh.find_node(axes) mesh.find_edge(axes) mesh.find_cell(axes) plt.show()