Cannot determine geometric dimension from expression

Please format your code as

```python
# add code here
```

Also, please search the forum for your error message, as there are many similar posts, including: Error while trying to find the derivative of user-defined expression ["ufl.log.UFLException: Cannot determine geometric dimension from expression."] - #2 by kamensky
which I believe has the solution to your problem.