You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I use FEniCS installed in WSL of Windows 10.
The version is 2019.01.
Then I update demo files in the tutorial.
I change the plot code because WSL cannot use GUI but it can save figure.
"""FEniCS tutorial demo program: Deflection of a membrane. -Laplace(w) = p in the unit circle w = 0 on the boundaryThe load p is a Gaussian function centered at (0, 0.6)."""from __future__ importprint_functionfromdolfinimport*frommshrimport*importnumpyasnp# Create mesh and define function spacedomain=Circle(Point(0, 0), 1)
mesh=generate_mesh(domain, 64)
V=FunctionSpace(mesh, 'P', 2)
# Define boundary conditionw_D=Constant(0)
defboundary(x, on_boundary):
returnon_boundarybc=DirichletBC(V, w_D, boundary)
# Define loadbeta=8R0=0.6p=Expression('4*exp(-pow(beta, 2)*(pow(x[0], 2) + pow(x[1] - R0, 2)))',
degree=1, beta=beta, R0=R0)
# Define variational problemw=TrialFunction(V)
v=TestFunction(V)
a=dot(grad(w), grad(v))*dxL=p*v*dx# Compute solutionw=Function(V)
solve(a==L, w, bc)
# Plot solutionp=interpolate(p, V)
# plot(w, title='Deflection')# plot(p, title='Load')importmatplotlib.pyplotaspltplot(w, title='Deflection')
plt.savefig('w.pdf')
plt.cla()
plot(p, title='Load')
plt.savefig('p.pdf')
plt.cla()
# Save solution to file in VTK formatvtkfile_w=File('poisson_membrane/deflection.pvd')
vtkfile_w<<wvtkfile_p=File('poisson_membrane/load.pvd')
vtkfile_p<<p# Curve plot along x = 0 comparing p and wimportnumpyasnptol=0.001# avoid hitting points outside the domainy=np.linspace(-1+tol, 1-tol, 101)
points= [(0, y_) fory_iny] # 2D pointsw_line=np.array([w(point) forpointinpoints])
p_line=np.array([p(point) forpointinpoints])
plt.plot(y, 50*w_line, 'k', linewidth=2) # magnify wplt.plot(y, p_line, 'b--', linewidth=2)
plt.grid(True)
plt.xlabel('$y$')
plt.legend(['Deflection ($\\times 50$)', 'Load'], loc='upper left')
plt.savefig('poisson_membrane/curves.pdf')
plt.savefig('poisson_membrane/curves.png')
# Hold plots# interactive()
The text was updated successfully, but these errors were encountered:
I use FEniCS installed in WSL of Windows 10.
The version is 2019.01.
Then I update demo files in the tutorial.
I change the plot code because WSL cannot use GUI but it can save figure.
The text was updated successfully, but these errors were encountered: