예제 #1
0
           14,
           savefig='tmp0.eps',
           title='Contour plot of u',
           clabels='on')
ev.figure()
ev.surf(u_box.grid.coorv[X],
        u_box.grid.coorv[Y],
        u_box.values,
        shading='interp',
        colorbar='on',
        title='surf plot of u',
        savefig='tmp3.eps')
ev.figure()
ev.mesh(u_box.grid.coorv[X],
        u_box.grid.coorv[Y],
        u_box.values,
        title='mesh plot of u',
        savefig='tmp4.eps')

# Extract and plot u along the line y=0.5
start = (0, 0.5)
x, uval, y_fixed, snapped = u_box.gridline(start, direction=X)
if snapped:
    print 'Line at %s adjusted (snapped) to y=%g' % (start, y_fixed)
ev.figure()
ev.plot(x, uval, 'r-', title='Solution', legend='finite element solution')

# Plot the numerical (projected) and exact flux along this line
ev.figure()
flux2_x = flux_x if flux_x.ufl_element().degree() == 1 else \
          interpolate(flux_x, FunctionSpace(mesh, 'Lagrange', 1))
예제 #2
0
파일: vcp2D.py 프로젝트: WeilinDeng/dolfin
        u2, mesh, (nx,ny), uniform_mesh=True)

# Write out u at mesh point (i,j)
i = nx; j = ny
print('u(%g,%g)=%g' % (u_box.grid.coor[X][i],
                       u_box.grid.coor[Y][j],
                       u_box.values[i,j]))
ev.contour(u_box.grid.coorv[X], u_box.grid.coorv[Y], u_box.values,
           14, savefig='tmp0.eps', title='Contour plot of u',
           clabels='on')
ev.figure()
ev.surf(u_box.grid.coorv[X], u_box.grid.coorv[Y], u_box.values,
        shading='interp', colorbar='on',
        title='surf plot of u', savefig='tmp3.eps')
ev.figure()
ev.mesh(u_box.grid.coorv[X], u_box.grid.coorv[Y], u_box.values,
        title='mesh plot of u', savefig='tmp4.eps')

# Extract and plot u along the line y=0.5
start = (0,0.5)
x, uval, y_fixed, snapped = u_box.gridline(start, direction=X)
if snapped:
    print('Line at %s adjusted (snapped) to y=%g' % (start, y_fixed))
ev.figure()
ev.plot(x, uval, 'r-', title='Solution',
        legend='finite element solution')

# Plot the numerical (projected) and exact flux along this line
ev.figure()
flux2_x = flux_x if flux_x.ufl_element().degree() == 1 else \
          interpolate(flux_x, FunctionSpace(mesh, 'Lagrange', 1))
flux_x_box = scitools.BoxField.dolfin_function2BoxField(
예제 #3
0
파일: Grid2D.py 프로젝트: arnabkd/inf3331
def plot_easyviz(grid, func_values):
    from scitools.easyviz import mesh
    mesh(grid.xcoorv, grid.ycoorv, func_values, indexing='ij')
h0 = 2277.  # Height of the top of the mountain (m)
R = 4.     # The radius of the mountain (km)

x = y = np.linspace(-10., 10., 41)
xv, yv = plt.ndgrid(x, y)
hv = h0/(1+(xv**2+yv**2)/(R**2))

s = np.linspace(0, 2*np.pi, 100)
curve_x = 10*(1 - s/(2*np.pi))*np.cos(s)
curve_y = 10*(1 - s/(2*np.pi))*np.sin(s)
curve_z = h0/(1 + 100*(1 - s/(2*np.pi))**2/(R**2))

# Simple plot of mountain
plt.figure(1)
plt.mesh(xv, yv, hv)

# Simple plot of mountain and parametric curve
plt.figure(2)
plt.surf(xv, yv, hv)
plt.hold('on')

# add the parametric curve. Last parameter controls color of the curve
plt.plot3(curve_x, curve_y, curve_z, 'b-')
# endsimpleplots

# Default two-dimensional contour plot
plt.figure(3)
plt.contour(xv, yv, hv)

# Default three-dimensional contour plot
예제 #5
0
파일: Grid2D.py 프로젝트: EJHortala/books-2
def plot_easyviz(grid, func_values):
    from scitools.easyviz import mesh
    mesh(grid.xcoorv, grid.ycoorv, func_values, indexing='ij')
h0 = 2277.  # Height of the top of the mountain (m)
R = 4.  # The radius of the mountain (km)

x = y = np.linspace(-10., 10., 41)
xv, yv = plt.ndgrid(x, y)
hv = h0 / (1 + (xv**2 + yv**2) / (R**2))

s = np.linspace(0, 2 * np.pi, 100)
curve_x = 10 * (1 - s / (2 * np.pi)) * np.cos(s)
curve_y = 10 * (1 - s / (2 * np.pi)) * np.sin(s)
curve_z = h0 / (1 + 100 * (1 - s / (2 * np.pi))**2 / (R**2))

# Simple plot of mountain
plt.figure(1)
plt.mesh(xv, yv, hv)

# Simple plot of mountain and parametric curve
plt.figure(2)
plt.surf(xv, yv, hv)
plt.hold('on')

# add the parametric curve. Last parameter controls color of the curve
plt.plot3(curve_x, curve_y, curve_z, 'b-')
# endsimpleplots

# Default two-dimensional contour plot
plt.figure(3)
plt.contour(xv, yv, hv)

# Default three-dimensional contour plot