Time derivative of the analytical velocity expression

Good morning,

if I want to derive the expression for the force term knowing the analytical solution in the case of the steady Stoke equation is enough to write:

f = -nu*ufl.div(ufl.grad(uD)) + ufl.grad(p_true)

where uD and p_true are the analytical solution for the velocity and the pressure.
In the unsteady case how can I derive the derivative with respect to time od the velocity? For the moment I derive it manually and add to the expression above, the example code is the following:

x = ufl.SpatialCoordinate(mesh)
dudt = ufl.as_vector([-ufl.sin(2*ufl.pi*x[1])*ufl.cos(2*ufl.pi*t)*2*ufl.pi,ufl.sin(2*ufl.pi*x[0])*ufl.cos(2*ufl.pi*t)*2*ufl.pi, 0])
f = -nu*ufl.div(ufl.grad(uD)) + ufl.grad(p_true) + dudt

is it correct? And there exist nicer ways to do this?

Thanks in advance.

Michele Barucca.

You can use ufl.variable and ufl.diff as for instance done in:

1 Like