示例#1
0
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()
示例#2
0
import numpy as np
import mpl_toolkits.mplot3d as a3
import matplotlib.colors as colors
import pylab as pl

import sys

from fealpy.mesh.TetrahedronMesh import TetrahedronMesh
from fealpy.functionspace.tools import function_space

degree = int(sys.argv[1])

ax0 = a3.Axes3D(pl.figure())

point = np.array([[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1], [0, 0, -1]],
                 dtype=np.float)

cell = np.array([[0, 1, 2, 3], [2, 1, 0, 4]], dtype=np.int)

mesh = TetrahedronMesh(point, cell)
V = function_space(mesh, 'Lagrange', degree)
cell2dof = V.cell_to_dof()
ipoints = V.interpolation_points()
mesh.add_plot(ax0)
mesh.find_point(ax0, point=ipoints, showindex=True)
mesh.print()
print('cell2dof:\n', cell2dof)
pl.show()
示例#3
0
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()