### How to implement the following Heaviside function:

173

views

0

\( H=\left\{\begin{matrix}

0, \,\,\,\,\, if \,\,\,\,\, \phi \le -\epsilon\\

\frac{1}{2} \left(1 + \frac{\phi}{\epsilon} + \frac{sin(\frac{\pi\phi}{\epsilon})}{\pi} \right ), \,\,\,\,\, if \,\,\,\,\, -\epsilon\le\phi \le \epsilon\\

1, \,\,\,\,\, if \,\,\,\,\, \phi \ge\epsilon

\end{matrix}\right.\)

Thanks for your time.

0, \,\,\,\,\, if \,\,\,\,\, \phi \le -\epsilon\\

\frac{1}{2} \left(1 + \frac{\phi}{\epsilon} + \frac{sin(\frac{\pi\phi}{\epsilon})}{\pi} \right ), \,\,\,\,\, if \,\,\,\,\, -\epsilon\le\phi \le \epsilon\\

1, \,\,\,\,\, if \,\,\,\,\, \phi \ge\epsilon

\end{matrix}\right.\)

Thanks for your time.

Community: FEniCS Project

### 1 Answer

1

Use a

`Conditional`

structure.

https://fenicsproject.org/qa/8175/conditional-expression-ufl-condition-as-boolean/

Since you need a greater than, and less than conditional, I'd suggest you nest one inside the other.

Please login to add an answer/comment or follow this question.

https://fenicsproject.org/qa/7684/how-to-define-piecewise-function-on-more-pieces-of-the-domain/