import numpy as np
import matplotlib.pyplot as plt
import sys

from fealpy.mesh.StructureQuadMesh import StructureQuadMesh
box = [0, 1, 0, 1]
n = 8
qmesh = StructureQuadMesh(box, n, n)
cell2cell = qmesh.ds.cell_to_cell()
print('cell2cell',cell2cell)

NN = qmesh.number_of_nodes()
NE = qmesh.number_of_edges()
NC = qmesh.number_of_cells()

#a = cell2cell[:NC:n,0]
#print('a',a)

X = np.zeros(NE + NC, dtype=np.float)

I = np.arange(NC, dtype=np.int)
J = I

fig = plt.figure()
axes = fig.gca()
qmesh.add_plot(axes)
qmesh.find_node(axes, showindex=True)
qmesh.find_edge(axes, showindex=False)
qmesh.find_cell(axes, showindex=False)
plt.show()
Exemple #2
0
val[isXEdge & isCutEdge, 0] = h[isXEdge[isCutEdge]]
val[isXEdge & isCutEdge, 1] = dx - h[isXEdge[isCutEdge]]
val[~isXEdge & isCutEdge, 0] = h[~isXEdge[isCutEdge]]
val[~isXEdge & isCutEdge, 1] = dy - h[~isXEdge[isCutEdge]]

dt = 0.45*pandas_groupby_minimum(edge.flatten(), val.flatten())

d = interface0(point) 


for i in range(500):
    phi1 = phi - dt*phiSign*(HG(mesh, phi, phiSign, h) - 1)
    phi2 = phi1 - dt*phiSign*(HG(mesh, phi1, phiSign, h) - 1)
    phi = (phi1 + phi2)/2
    print("Near interface:", np.max(np.abs(phi - d)[np.abs(phi) < 1.2*dx]))
    print("Whole error:", np.max(np.abs(phi - d)[phi > -0.8]))

fig = plt.figure()
ax = fig.gca(projection='3d')
X = point[:, 0].reshape(nx+1, ny+1)
Y = point[:, 1].reshape(nx+1, ny+1)
Z = phi.reshape(nx+1, ny+1) - d.reshape(nx+1, ny+1)
surf = ax.plot_surface(X, Y, Z, cmap=cm.coolwarm,
                       linewidth=0, antialiased=False)

fig = plt.figure()
axes = fig.gca() 
mesh.add_plot(axes, cellcolor=[0.5, 0.9, 0.45])
mesh.find_point(axes, point=cutPoint, markersize=30)
plt.show()