Linear Elasticity Tutorial w/ Quadratic Tetrahedrals

Hey,

Quick one. Just need some guidance editing the Linear Elasticity Tutorial for Second Order Tetrahedrals.

I have edited the setup as follows:

domain = mesh.create_box(
        MPI.COMM_WORLD, 
        [np.array([0, 0, 0]), np.array([L, W, W])],
        [20, 6, 6], 
        cell_type=mesh.CellType.tetrahedron
    )
V = fem.VectorFunctionSpace(domain, ("Lagrange", 2))   

But am encountering this error:

RuntimeError: Degree of output Function must be same as mesh degree. Maybe the Function needs to be interpolated?

Referring to XDMF File export:

  with io.XDMFFile(domain.comm, "deformation.xdmf", "w") as xdmf:
      xdmf.write_mesh(domain)
      uh.name = "Deformation"
      xdmf.write_function(uh)

Besides this the code is identical to that in the tutorial.

Thank you in advance.

Use dolfinx.io.VTXWriter instead of xdmffile if you are not using isoparametric elements.

1 Like