FEniCS UFL error in the perpendicular-flap tutorial

Hi all, I have a question regarding an error which is popping up. At first is was not a problem to run any of the provided tutorials. Right now errors occur, once I try to use the adapter from OpenFOAM and FEniCS. I did not modify any files in the dist-packages directory, but it seems an error is introduced with UFL. Actually it seems strange to be related to nabla_div(f), because it does not give any issues with nabla_grad(f). Could there be a specific reason, or should I change anything to get it proper functioning again? Lastly OpenFOAM was automatically upgraded in an Ubuntu 22.04 update, from v2212 to v2306. Maybe this could be related to the problem. Already thanks for your assistance.

---[precice]  iteration: 1 of 50, time-window: 1, time: 0 of 5, time-window-size: 0.01, max-timestep-length: 0.01, ongoing: yes, time-window-complete: no, write-iteration-checkpoint 
---[precice]  initializeData is skipped since no data has to be initialized.
Traceback (most recent call last):
File "/home/username/preCICE/tutorials/perpendicular-flap/solid-fenics/solid.py", line 163, in <module>
 res = m(avg(a_n, a_np1, alpha_m), v) + k(avg(u_n, du, alpha_f), v)
File "/home/username/preCICE/tutorials/perpendicular-flap/solid-fenics/solid.py", line 105, in k
 return inner(sigma(u), sym(grad(v))) * dx
File "/home/username/preCICE/tutorials/perpendicular-flap/solid-fenics/solid.py", line 95, in sigma
 return lambda_ * nabla_div(u) * Identity(dim) + 2 * mu * epsilon(u)
File "/usr/lib/python3/dist-packages/ufl/operators.py", line 426, in nabla_div
 f = as_ufl(f)
File "/usr/lib/python3/dist-packages/ufl/constantvalue.py", line 438, in as_ufl

raise UFLValueError("Invalid type conversion: %s can not be converted"
ufl.log.UFLValueError: Invalid type conversion: ({ A | A_{i_{20}} = f_14[i_{20}] * f_35 }) + ({ A | A_{i_{21}} = v_1[i_{21}] * (1 + -1 * f_35) }) can not be converted to any UFL type.
---[precice]  Implicitly finalizing in destructor
---[precice] ERROR:  The required actions write-iteration-checkpoint are not fulfilled. Did you forget to call "markActionFulfilled"?

Found out. It is due to the fact that ufl is not supported in FEniCS anymore.
Therefore ufl import in the solid.py files should be changed
from

from ufl import nabla_div

to

from ufl_legacy import nabla_div
import ufl_legacy as ufl

Over here is the link to the post in the discussion forum

2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.