TensorFunctionSpace to FunctionSpace

Hello FEniCSx community!

I have been using TensorFunctionSpace to calculate stress values. But according to this post, I realized that it is discontinued from the dolfinx.fem module.

The way I used the TensorFunctionSpace is:

    Function_space_for_sigma = TensorFunctionSpace(mesh, ("DG", 1))

    expr= Expression(sigma(u_n,p_n),Function_space_for_sigma.element.interpolation_points())
    sigma_values = Function(Function_space_for_sigma)
    sigma_values.interpolate(expr)

This is very much similar to what they have done in: The von Mises stresses

My question is, if I only changed the first line to:
Function_space_for_sigma = FunctionSpace(mesh, ("DG", 1))
is the output exactly the same as it was in the case of:
Function_space_for_sigma = TensorFunctionSpace(mesh, ("DG", 1))

Thank you

If you read the first post you linked you will see it points you to the GitHub pull request that updates the process for both Vector and Tensor spaces. Reviewing Pull #2766 you can see that under changes to “python/test/unit/fem/test_assembler.py” the replacements for those spaces are provided. Therefore the answer is no, you need to modify the FunctionSpace appropriately as given in that example.

2 Likes

@Sven Thanks a lot for the proper direction on to the git page. With that help, I was able to get done!
My code will look like this:

    gdim = mesh.geometry.dim
    Function_space_for_sigma = FunctionSpace(mesh, ("DG", 1, (gdim, gdim)))
    
    expr= Expression(sigma(u_n,p_n), Function_space_for_sigma.element.interpolation_points())

    sigma_values = Function(Function_space_for_sigma)

    sigma_values.interpolate(expr)