Hi everyone,
I'm very new to fenics, and am trying to put together a stokes flow model using a maxwell material model. The constitutive law requires a time derivative of the stress tensor. It seems straightforward enough to use a first order finite difference of the tensor for time-stepping, but I'm having trouble saving the tensor value for use in the next time step.
I tried initializing the tensor to zero for the first iteration:
sig1 = Constant(0.0)*Identity(mesh.ufl_domain().geometric_dimension())
and then updating it during each time step with the new solution:
...
for t in range(n_steps):
...
solve(A, U.vector(), b)
u, p = U.split()
sig1 = K*(sym(grad(u)) + sig1/(E*dt))
...
But that just extends the UFL representation to include the old sig1 value. After a few timesteps sig1 gets unreasonably huge and causes problems (of course).
Is there a way to project the tensor into the FE space, and store its numerical representation for use in the next time step, rather than its UFL form? I'm sure there's an obvious best practices (i.e. correct) way to deal with this, but I'm not sure what it is. Any tips would be appreciated.
Thanks in advance for your time!!