def plotmesh3ds01(): meshfile = gmsh.buildmesh3ds('demisphere5', 20) plt.close('all') plt.ion() DisplayFigures(nfig=4) Th = siMesh(meshfile) plt.figure(1) siplt.plotmesh(Th, legend=True) set_axes_equal() plt.figure(2) siplt.plotmesh(Th, color='LightGray', alpha=0.1) siplt.plotmesh(Th, d=1, legend=True, linewidth=2) plt.axis('off') set_axes_equal() plt.figure(3) siplt.plotmesh(Th, labels=[1, 10, 13, 12], facecolor=None) siplt.plotmesh(Th, labels=[11], edgecolor='black') plt.axis('off') set_axes_equal() plt.figure(4) siplt.plotmesh(Th, legend=True, labels=[10, 13, 12], edgecolor='black') siplt.plotmesh(Th, labels=[1, 11], color='LightGray', alpha=0.1) plt.axis('off') set_axes_equal() return Th
def plot2d01(N=25): meshfile = gmsh.buildmesh2d('condenser11', N) Th = siMesh(meshfile) u = Th.feval( lambda x, y: 5 * np.exp(-3 * (x**2 + y**2)) * np.cos(x) * np.sin(y)) plt.rcParams['text.usetex'] = True plt.rcParams['text.latex.unicode'] = True plt.close('all') plt.ion() DisplayFigures(nfig=4) fig = plt.figure(1) siplt.plot(Th, u) plt.colorbar() set_axes_equal() plt.figure(2) siplt.plot(Th, u, labels=[20, 2, 4, 6, 8]) siplt.plotmesh(Th, labels=10, color='LightGray') set_axes_equal() plt.axis('off') plt.figure(3) #plt.set_cmap(plt.cm.get_cmap(name='jet')) h = siplt.plot(Th, u, plane=False, colormap='jet') siplt.plotmesh(Th, d=1, color='Black', z=u) plt.colorbar(h) set_axes_equal() plt.figure(4) h = siplt.plot(Th, u, d=1, plane=False, linewidth=3) plt.colorbar(h) siplt.plotmesh(Th, labels=10, color='LightGray', z=u) set_axes_equal() plt.axis('off') return Th
def plotmesh3d02(): meshfile = gmsh.buildmesh3d('cylinderkey', 5) Th = siMesh(meshfile) plt.close('all') plt.ion() DisplayFigures(nfig=4) plt.figure(1) siplt.plotmesh(Th, legend=True) #siplt.plotmesh(Th,d=1,color='black',linewidth=3) set_axes_equal() plt.figure(2) siplt.plotmesh(Th, d=2, legend=True) plt.axis('off') set_axes_equal() plt.figure(3) siplt.plotmesh(Th, d=2, labels=[1, 1000, 1020, 1021], color='LightGray', alpha=0.05) siplt.plotmesh(Th, d=2, labels=[10, 11, 31, 2000, 2020, 2021], legend=True, alpha=1) plt.axis('off') set_axes_equal() plt.figure(4) siplt.plotmesh(Th, d=2, color='LightGray', alpha=0.05) siplt.plotmesh(Th, d=1, legend=True, linewidth=3) plt.axis('off') set_axes_equal() return Th
def plotmesh3d01(): meshfile = gmsh.buildmesh3d('cylinder3holes', 10, force=True, verbose=1) Th = siMesh(meshfile, dim=3) plt.close('all') plt.ion() DisplayFigures(nfig=2) plt.figure(1) siplt.plotmesh(Th, legend=True) siplt.plotmesh(Th, d=1, color='black') set_axes_equal() plt.figure(2) siplt.plotmesh(Th, d=2, labels=[10, 20, 21, 100, 101], legend=True) set_axes_equal() plt.axis('off') return Th
def plotmesh2d01(): meshfile = gmsh.buildmesh2d('disk5holes.geo', 20, force=True, verbose=1) Th = siMesh(meshfile, dim=2) plt.close('all') plt.ion() DisplayFigures(nfig=2) plt.figure(1) siplt.plotmesh(Th, legend=True) set_axes_equal() plt.figure(2) siplt.plotmesh(Th, color='LightGray') siplt.plotmesh(Th, d=1, linewidth=2, legend=True) plt.axis('off') set_axes_equal() return Th
def plot3ds01(N=30): meshfile = gmsh.buildmesh3ds('demisphere5', N) Th = siMesh(meshfile) u = Th.feval(lambda x, y, z: 3 * x**2 - y**3 + z**2 + x * y) plt.close('all') plt.ion() DisplayFigures(nfig=2) plt.figure(1) h = siplt.plot(Th, u) set_axes_equal() plt.colorbar(h) plt.figure(2) h2 = siplt.plot(Th, u, labels=[10, 12]) siplt.plotmesh(Th, labels=[1, 11], color='LightGray', linewidth=0.5) plt.colorbar(h2) return Th
def plotiso2d01(N=15): meshfile = gmsh.buildmesh2d('condenser11', N) Th = siMesh(meshfile) u = Th.feval( lambda x, y: 5 * np.exp(-3 * (x**2 + y**2)) * np.cos(x) * np.sin(y)) plt.close('all') plt.ion() DisplayFigures(nfig=4) fig = plt.figure(1) siplt.plotiso(Th, u, niso=15) siplt.plotmesh(Th, d=1, color='Black') set_axes_equal() plt.colorbar() fig = plt.figure(2) isos = np.linspace(-1, 1, 21) siplt.plotiso(Th, u, niso=15, color='LightGray', isorange=isos, linestyles=':') siplt.plotmesh(Th, d=1, color='Black') plt.axis('off') set_axes_equal() fig = plt.figure(3) siplt.plotiso(Th, u, labels=10, niso=15, linewidths=1) plt.colorbar() siplt.plotmesh(Th, labels=10, color='LightGray', linewidth=1, alpha=0.05) siplt.plotiso(Th, u, labels=[2, 4, 6, 8, 20], niso=15, color='Gray', linewidths=1) siplt.plot(Th, u, labels=[2, 4, 6, 8, 20]) siplt.plotiso(Th, u, isorange=0, color='Black', linewidths=2) plt.axis('off') set_axes_equal() fig = plt.figure(4) siplt.plotiso(Th, u, labels=10, niso=15, linewidths=1, color='White') siplt.plot(Th, u, labels=10) siplt.plotiso(Th, u, labels=[2, 4, 6, 8, 20], niso=15, linewidths=1) cb = plt.colorbar() cb.lines[0].set_linewidth(4) plt.axis('off') set_axes_equal() return Th
def quiver3d01(N=10): meshfile = gmsh.buildmesh3d('cylinder3dom', N, force=True) plt.close('all') Th = siMesh(meshfile) u = Th.feval(lambda x, y, z: 3 * x**2 - y**3 + z**2 + x * y) w = [ lambda x, y, z: y * np.cos(-(x**2 + y**2) / 10), lambda x, y, z: -x * np.cos(-(x**2 + y**2) / 10), lambda x, y, z: z / 5 ] W = np.array([Th.feval(w[0]), Th.feval(w[1]), Th.feval(w[2])]) scale = 20 plt.ion() DisplayFigures(nfig=4) plt.figure(1) sq = siplt.quiver(Th, W, nvec=3000, scale=scale) siplt.plotmesh(Th, d=2, color='LightGray', alpha=0.05) plt.colorbar(sq) set_axes_equal() plt.figure(2) sq = siplt.quiver(Th, W, scalars=u, nvec=3000, scale=scale) siplt.plotmesh(Th, d=2, color='LightGray', alpha=0.05) plt.colorbar(sq) plt.axis('off') set_axes_equal() plt.figure(3) sq = siplt.quiver(Th, W, labels=[10, 11], nvec=3000, scale=scale) siplt.plotmesh(Th, d=2, color='LightGray', alpha=0.05) plt.axis('off') set_axes_equal() plt.colorbar(sq) plt.figure(4) sq = siplt.quiver(Th, W, scalars=u, labels=[10, 11], nvec=3000, scale=scale) siplt.plotmesh(Th, d=2, color='LightGray', alpha=0.05) plt.axis('off') set_axes_equal() plt.colorbar(sq) plt.show() return Th
def quiver2d01(N=15): meshfile = gmsh.buildmesh2d('condenser11', N) plt.close('all') DisplayFigures(nfig=4) Th = siMesh(meshfile) u = Th.feval( lambda x, y: 5 * np.exp(-3 * (x**2 + y**2)) * np.cos(x) * np.sin(y)) w = [ lambda x, y: y * np.cos(-(x**2 + y**2) / 10), lambda x, y: -x * np.cos(-(x**2 + y**2) / 10) ] W = np.array([Th.feval(w[0]), Th.feval(w[1])]) plt.ion() plt.figure(1) siplt.quiver(Th, W, scale=50, nvec=3000) siplt.plotmesh(Th, d=1, color='black') set_axes_equal() plt.colorbar() plt.figure(2) siplt.quiver(Th, W, scalars=u, scale=50, nvec=3000) siplt.plotmesh(Th, d=1, color='black') plt.axis('off') set_axes_equal() plt.colorbar() plt.figure(3) siplt.quiver(Th, W, labels=[2, 4, 6, 8, 20], nvec=1000, scale=50) siplt.plotmesh(Th, d=1, color='black') plt.axis('off') set_axes_equal() plt.colorbar() plt.figure(4) siplt.quiver(Th, W, labels=[2, 4, 6, 8, 20], scalars=u, scale=50, nvec=1000) siplt.plotmesh(Th, d=1, color='black') plt.axis('off') set_axes_equal() plt.colorbar() plt.show() return Th
def plot3d01(N=15): meshfile = gmsh.buildmesh3d('cylinderkey', N) Th = siMesh(meshfile) plt.close('all') plt.ion() DisplayFigures(nfig=4) u = Th.feval(lambda x, y, z: 3 * x**2 - y**3 + z**2 + x * y) plt.figure(1) h = siplt.plot(Th, u, s=2) plt.colorbar(h) plt.axis('off') set_axes_equal() plt.figure(2) h2 = siplt.plot(Th, u, d=2, labels=[1000, 1020, 1021, 2000, 2020, 2021]) siplt.plot(Th, u, d=2, labels=[10, 11, 31], edgecolor='black', linewidth=0.5) plt.colorbar(h2) plt.axis('off') set_axes_equal() plt.figure(3) h2 = siplt.plot(Th, u, d=2, labels=[2000, 2020, 2021]) h1 = siplt.plot(Th, u, d=1, labels=[1075, 1077, 1078, 1081], linewidth=3) siplt.plotmesh(Th, d=2, labels=[10, 11, 31], color='LightGray', alpha=0.2) plt.colorbar(h1) plt.axis('off') set_axes_equal() plt.figure(4) siplt.plot(Th, u, d=2, labels=[1], alpha=0.1) siplt.plot(Th, u, d=2, labels=[2000, 2020, 2021]) siplt.plot(Th, u, d=1, labels=[1075, 1077, 1078, 1081], linewidth=3) siplt.plotmesh(Th, d=2, labels=[10, 11, 31], color='LightGray', alpha=0.2) siplt.plotmesh(Th, d=1, labels=[1080, 1079], color='black', linewidth=2) plt.axis('off') set_axes_equal() return Th