How to impose previous solution in as initial condition?

Hi,

I am trying to implement a linear elasticity solver which uses the solution (displacement or strain) from a previous iteration as an initial condition when solving for the new displacement. I don’t mean as an initial guess but rather using the previous solution to “pre-load” or “pre-strain” the structure before applying the force in the current iteration.

See for example the MWE:

from dolfin import *

def sigma(v):
    return 2.0*mu*sym(grad(v)) + lmbda*tr(sym(grad(v)))*Identity(len(v))

def eps(v):
    return sym(grad(v))
    

# Elasticity parameters
E = 2e4
nu = 0.3
mu = E/(2.0*(1.0 + nu))
lmbda = E*nu/((1.0 + nu)*(1.0 - 2.0*nu))

mesh = BoxMesh(Point(0,0, 0),Point(1,1,1), 10, 10, 10)

def left(x, on_boundary):
    return near(x[0], 0.)

vec_fun = VectorFunctionSpace(mesh, 'P', degree = 1)
bcs = DirichletBC(vec_fun, Constant((0.,0., 0.)), left)

displacement = Function(vec_fun) # displacement from current iteration
displacement_old = Function(vec_fun) # displacement from previous iteration

force = Constant((0,-1000, 0))

u = TrialFunction(vec_fun)
v = TestFunction(vec_fun)
a = inner(sigma(u), grad(v))*dx #need to include displacement_old in this expression?
L = inner(force, v)*dx

n_steps = 10

# Initial displacements are 0
displacement_old.vector()[:]

for i in range(n_steps):
    solve(a == L, displacement, bcs)
    displacement_old.assign(displacement)
    #Displacement should grow each iteration as it starts with larger and larger displacements

Any feedback is much appreciated!

Thanks,
Tom