Hello,
I am solving a time-dependent problem using Mixed element space. However, it seems that my code is not updating the time parameter in mixed space. Can anyone help me with this issue?
My minimal code is attached below:
from dolfin import *
mesh = RectangleMesh(Point(-1,-1),Point(1,1), 4, 4)
CG1 = VectorElement("Lagrange", mesh.ufl_cell(), 2)
CG2 = VectorElement("Lagrange", mesh.ufl_cell(), 2)
element = MixedElement([CG1, CG2])
W = FunctionSpace(mesh, element)
dw = TrialFunction(W)
v = TestFunction(W)
w = Function(W)
y, d = split(w)
def right(x, on_boundary):
return abs(x[0] -1) < DOLFIN_EPS and on_boundary
load = Expression(("x[0]*(1+t)", "x[1]"), t=0, degree=1)
t, deltaT = 0, 1e-2
t += deltaT
load.t=t
BCS = [DirichletBC(W.sub(0), load, right)]
y0 = interpolate(load, W.sub(0).collapse())
d_initial = Constant((0,0))
d0 = interpolate(d_initial, W.sub(1).collapse())
assign(w, [y0, d0])
def W(y):
F = grad(y)
return 0.5*tr(F.T*F) + (det(F)-1)**2 -ln(det(F))
Pi = (1-dot(d, d) )*W(y) *dx
dPi = derivative(Pi, w, v)
ddPi = derivative(dPi, w, dw)
problem = NonlinearVariationalProblem(dPi, w, bcs= BCS, J= ddPi)
solver = NonlinearVariationalSolver(problem)
#t, deltaT = 0, 1e-2
#t += deltaT
#load.t=t
solver.solve()
Please note that if I comment lines 14-16, and use lines 30-32 instead, I will get differet initial starting values, which (I think) is because line y0 = interpolate(load, W.sub(0).collapse())
is Not being updated in this case.