Hi,
I have prepared a code which is about a time-dependent problem. You can see this below:
____________________________
from dolfin import *
mesh = RectangleMesh(Point(0,0), Point(4,2),20,10,'crossed')
V=FunctionSpace(mesh, "Lagrange", 1)
u=Function(V)
v=TestFunction(V)
# Time variables
dt = Constant(0.3); t = float(dt); T = 1.8
g_expr = "1 + x[0]*x[0] + alpha*x[1]*x[1] + beta*t*t"
g = Expression(g_expr, alpha=3.0, beta=1.2, t=0, degree=2)
# Previous and current solution
u0 = interpolate(g, V); u1 = Function(V)
# Variational problem at each time
u = TrialFunction(V)
v = TestFunction(V)
f = Constant(2*1.2 - 2. - 2*3.0)
a = 2*u*v*dx + dt*dt*inner(grad(u), grad(v))*dx
L = (2*1.2+u0)*v*dx - dt*dt*f*v*dx
bc = DirichletBC(V, g, "on_boundary")
while t <= T:
g.t = t
solve(a == L, u1, bc)
u0.assign(u1)
t += float(dt)
plot(u1, interactive=True)
I want to know how I can get the result (U1 which is displacement) with respect to time. In other word, I am looking for a animation when I run this code to show me the displacements with respect to time. Thanks in advance for your help.