Where \hat{n} is the unit outward normal vector and Q is the stress tensor given by Q = \mu (\nabla {\bf v} + \nabla {\bf v}^T) -(p + (2 \mu/3) div({\bf v})) (so that -\nabla Q = 0 gives you the first equation above).
Now I take a vector test function \xi and a scalar test function q and write the following weak form: \int_{\Omega} \mu \nabla{\bf v} \cdot \nabla \xi \ dx - \int_{\Omega} p \ div(\xi) \ dx + (\mu/3) \int_{\Omega} div({\bf v}) \ div(\xi) \ dx + \int_{\Omega} div({\bf v}) \ q \ dx - \int_{\Omega} f \ q \ dx +\\ \int_{\partial \Omega} \kappa \hat{n} \cdot \xi \ dS=0
Is this weak form correct or am I missing something? Can this be implemented exactly like this in FEniCS with a mixed pressure-velocity space?
If you want -\boldsymbol{\kappa} to have the interpretation of flux \mathbf{Q}, you want to directly integrate the flux divergence form of the problem by parts:
I see. Thank you. Can this be directly implemented in Fenics using the following weak form? mu*inner(grad(v)+grad(v).T, grad(xi))*dx +p*div(xi)*dx+(2*mu/3)*div(v)*div(xi)*dx +dot(kappa*NORMAL,xi)*ds(1)+ div(v)*q*dx-f*q*dx
I know that I need a mixed function space for pressure and velocity and their respective test functions. But is there more to it?
Comparing with the formula for \mathbf{Q}, there are sign errors in the 2nd and 3rd terms, but, otherwise, yes, that looks like how you would translate it into UFL. You could also use an intermediate definition of Q like
I = Identity(len(v))
Q = 2*mu*sym(grad(v)) - (p + (2*mu/3)*div(v))*I
residual = inner(Q,grad(xi))*dx + dot(kappa*NORMAL,xi)*ds(1) + (div(v)-f)*q*dx
a = lhs(residual)
L = rhs(residual)
to avoid typos. The definitions of the bilinear form a and linear form L are assuming that v,p = TrialFunctions(V) for a mixed space V, so you can use the solve syntax for a linear problem, e.g.,