I think you need to use a dolfinx Function
instead of a TrialFunction
, the same way it is done in your dolfiny
example.
This seems to be the equivalent of dolfiny
that you are trying to make:
import ufl
from mpi4py import MPI
from dolfinx import fem, mesh
import basix
from basix.ufl import mixed_element
domain = mesh.create_box(
MPI.COMM_WORLD,
[[0.0, 0.0, 0.0], [1.0, 1.0, 1.0]],
[1, 1, 1],
mesh.CellType.hexahedron,
)
Ue = basix.ufl.element("P", domain.basix_cell(), 1, shape=(domain.geometry.dim,))
He = basix.ufl.quadrature_element(domain.basix_cell(), value_shape=(), degree=1)
Te = basix.ufl.blocked_element(
He, shape=(domain.geometry.dim, domain.geometry.dim), symmetry=True
)
V_el = mixed_element([Ue, Te])
V = fem.functionspace(domain, V_el)
w = fem.Function(V)
u, P = ufl.split(w)
δw = ufl.TestFunction(V)
F = ufl.Identity(3) + ufl.grad(u)
δE = ufl.derivative(F, w, δw)
dx = ufl.Measure("dx", domain=domain)
form = (ufl.inner(δE, P)) * dx
forms = ufl.extract_blocks(form)