Exemple #1
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()
import numpy as np
import matplotlib.pyplot as plt
import sys

from fealpy.mesh.StructureQuadMesh import StructureQuadMesh
box = [0, 1, 0, 1]
n = 2
qmesh = StructureQuadMesh(box, n, n)
qmesh.print()

fig = plt.figure()
axes = fig.gca()
qmesh.add_plot(axes)
qmesh.find_point(axes, showindex=True)
qmesh.find_edge(axes, showindex=True)
qmesh.find_cell(axes, showindex=True)
plt.show()