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

Function defined with a condition

+1 vote

Hello,
I am trying to program a finite element formulation that contains
the following stabilization term:

a is a vector, u a scalar function

\begin{equation}
\begin{array}{lcll}
a_{||} & = & \displaystyle \frac{(a\cdot \nabla u)}{|\nabla u|_2^2} \, \nabla u
& \hbox{if } \nabla u \ne 0
\ \
& = & 0 & \hbox{if } \nabla u = 0
\end{array}
\end{equation}

How can I program this object using python ?
Thanks

asked Mar 4, 2014 by micdup FEniCS User (1,120 points)

1 Answer

+1 vote

UFL has conditional. Check UFL manual.

answered Mar 5, 2014 by Jan Blechta FEniCS Expert (51,420 points)
...