Hi, I am trying to define a function that would be in the weak form in FEniCS.
However the function’s derivative is quite complicated, I am wondering if there is any good way of defining it FEniCS.
The first function I need to define is
where u is the variable to be solved. (I am solving a nonlinear PDE).
I implement it in the following way
The second function I need to define is the derivative of the above function (wrt u).
I can compute the derivative and directly define it, which would be a long expression. This is one way. However, I am wondering if there is a better way, especially in case when the derivative becomes too complicated.
E.g. In computing the right hand side f(x,y) of a manufacture PDE, we can use sympy’s functionalities to get an expression for f(x,y), convert the expression to C++ code and then define it using fenics Expression which recognizes C++ language. Is there a similar method for the problem I encountered? This situation is a bit different because I am defining a nonlinear function in the variable u.
Thank you very much!