This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Pointwise renormalization of vector fields with MixedFunctionSpaces

0 votes

I'm trying to simulate two unit vector fields vf1 and vf2 over the same mesh which are coupled together using a MixedFunctionSpace. After updating the vector fields I want to renormalize them so that at each point in space they again have unit magnitude.

For a single vector field vf of a regular VectorFunctionSpace I came up with an Expression that computes the renormalized vector field into a temp vector field, and then assign the temp vector field back to the original one:

expr = Expression(conditional(eq(inner(vf, vf), 0.), Constant((0., 0., 0.)), vf / sqrt(inner(vf, vf)))
assemble(inner(expr, v) * dP, tensor=tmp.vector())
vf.assign(tmp)

Can this approach work with MixedFunctionSpaces when I use split() to get the individual components vf1 and vf2? Like this:

expr1 = Expression(conditional(eq(inner(vf1, vf1), 0.), Constant((0., 0., 0.)), vf1 / sqrt(inner(vf1, vf1)))
assemble(inner(expr1, v) * dP, tensor=tmp1.vector())
vf1.assign(tmp1)

expr2 = Expression(conditional(eq(inner(vf2, vf2), 0.), Constant((0., 0., 0.)), vf2 / sqrt(inner(vf2, vf2)))
assemble(inner(expr2, v) * dP, tensor=tmp2.vector())
vf2.assign(tmp2)
asked Aug 4, 2016 by smiter FEniCS Novice (190 points)
...