Beispiel #1
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()
Beispiel #2
0
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_point(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
isFace = np.zeros(len(face), dtype=np.bool)
Beispiel #3
0
import sys

from fealpy.mesh.TetrahedronMesh import TetrahedronMesh

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], [0, 2, 1, 4]], dtype=np.int)

mesh = TetrahedronMesh(point, cell)
c, _ = mesh.circumcenter()
mesh.add_plot(ax0)
mesh.find_point(ax0, point=c)
mesh.print()

#ax1 = a3.Axes3D(pl.figure())
#
#point = 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([