How to implement function with condition?

You can use a ufl conditional, see: Using Conditional function inside a Project function - #4 by dokken
and Form language — Unified Form Language (UFL) 2021.1.0 documentation

2 Likes