How to unitization the solution in fenics

How about projecting:

u_uni = project(u/sqrt(dot(u,u)), V)

Note that this is not well defined if dot(u,u)=0, which can be encoded using a ufl.conditional, see for instance: How to implement function with condition? - #3 by dokken

1 Like