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.
"""FEniCS tutorial demo program: Diffusion of a Gaussian hill. u'= Laplace(u) + f in a square domain u = u_D on the boundary u = u_0 at t = 0 u_D = f = 0The initial condition u_0 is chosen as a Gaussian hill."""from __future__ importprint_functionfromdolfinimport*importtimeimportmatplotlib.pyplotaspltT=2.0# final timenum_steps=50# number of time stepsdt=T/num_steps# time step size# Create mesh and define function spacenx=ny=30mesh=RectangleMesh(Point(-2, -2), Point(2, 2), nx, ny)
V=FunctionSpace(mesh, 'P', 1)
# Define boundary conditiondefboundary(x, on_boundary):
returnon_boundarybc=DirichletBC(V, Constant(0), boundary)
# Define initial valueu_0=Expression('exp(-a*pow(x[0], 2) - a*pow(x[1], 2))',
degree=2, a=5)
u_n=interpolate(u_0, V)
# Define variational problemu=TrialFunction(V)
v=TestFunction(V)
f=Constant(0)
F=u*v*dx+dt*dot(grad(u), grad(v))*dx- (u_n+dt*f)*v*dxa, L=lhs(F), rhs(F)
# Create VTK file for saving solutionvtkfile=File('heat_gaussian/solution.pvd')
# Time-steppingu=Function(V)
t=0forninrange(num_steps):
# Update current timet+=dt# Compute solutionsolve(a==L, u, bc)
# Save to file and plot solutionvtkfile<< (u, t)
plot(u)
plt.savefig("u"+str(n)+".png")
plt.cla# Update previous solutionu_n.assign(u)
# Hold plot# 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.
The text was updated successfully, but these errors were encountered: