Gradient with respect to reference coordinates

Is there any way to get the gradient of test/trail functions with respect to reference coordinates? Lets say I have the following weak form:

W=\int_{\Omega} \nabla_X(u) \cdot \nabla_X(v) ~ d\Omega

where \nabla_X(\cdot) is the gradient with respect to initial (reference) coordinates and u and v are the test and trial functions. How can I write it in dolfinx form?

By “reference coordinates” do you mean the reference element? Or do you mean a solid body’s reference configuration, typically employed in computational mechanics?

If the latter, ufl.grad corresponds to the gradient with respect to the underlying mesh’s Cartesian geometry. See, e.g., dolfinx/python/demo/demo_elasticity.py at main · FEniCS/dolfinx · GitHub for an example in a linear elasticity formulation. See also dolfinx/cpp/demo/hyperelasticity at main · FEniCS/dolfinx · GitHub for an example of hyperelasticity.

Hi Nate, Thanks for the reply,

By reference coordinate I mean the initial configuration of the solid body in computational mechanics in which no deformation has occurred yet. Normally we know that the relationship between current configuration (\mathbf{x}) and initial configuration (\mathbf{X}) can be written as:

\mathbf{x} = \mathbf{X} + \mathbf{u}.

where \mathbf{u} is displacement. So for instance if one wants to obtain partial derivatives of any arbitrary field with respect to (\mathbf{X}) (which is very common in total Lagrangian formulations) then they should apply something like this

\frac{\partial f_i}{\partial X_k} = \frac{\partial f_i}{\partial x_j} \frac{\partial x_j}{\partial X_k}

from what I have seen in the demos, if I am not wrong, the ufl.grad() function corresponds to

ufl.grad(\mathbf{f}) = \frac{\partial f_i}{\partial x_j} .

I was wondering if there is any function that would directly correspond to

ufl.Function(\mathbf{f}) = \frac{\partial f_i}{\partial X_j} .