Gradients of strain

I want to take the derivative of strain with respect to displacement without using the the shape functions and find the gradients in cells in gridap (I can not figure out this derivative mathematically). I used this gradient to find the gradient of energy wrt displacement.

function ψPos(ε_in)
   σ_elas = C_mat⊙ε_in
    if tr(ε_in) >= 0
        ψPlus = 0.5*(ε_in ⊙ σ_elas)
    elseif  tr(ε_in) < 0
        ψPlus = 0.5*((P_dev ⊙ σ_elas)⊙(P_dev⊙ε_in))
    return ψPlus