Jacobi Determinant

#Test Jacobi Determinant
mesh = UnitSquareMesh(4, 4)
V = FunctionSpace(mesh, ‘CG’, 1)
u, v = TrialFunction(V), TestFunction(V)

F = dot(grad(u), grad(v))*dx
ul= Function(V)
J = derivative(F, ul)
invJ=inv(J)
detJ=det(J)
J_mat = assemble(J)
J_array = J_mat.array()
invJ=inv(J_array)
detJ=det(J_array)

Hi Community,

I want to compute the Jacobian matrix for this minimal example. It doesn’t run stops with ufl errors.
Whats wrong here?

Best, Markus

Since, J_array is a numpy.ndarray, we can use numpy inverse and determinant calculation functions as follows.

import numpy
#Test Jacobi Determinant
mesh = UnitSquareMesh(4, 4)
V = FunctionSpace(mesh, 'CG', 1)
u, v = TrialFunction(V), TestFunction(V)

F = dot(grad(u), grad(v))*dx
ul= Function(V)
F = action(F, ul)
J = derivative(F, ul)
#invJ=inv(J)
#detJ=det(J)
J_mat = assemble(J)
J_array = J_mat.array()
#invJ=inv(J_array)
#detJ=det(J_array)
invJ = numpy.linalg.inv(J_array)
detJ = numpy.linalg.det(J_array)