How do I project stresses from displacements?

Please format your code using the three backtick syntax (also available in the GUI editor as the </> symbol) like so:

``` your code here ```

The way your code is currently formatted is time intensive to try to reformat and run

What are you expecting to see in the stress distribution? Can you write out in a bit more detail what you mean by:

… unfortunately this does not provide the correct stresses.

Additionally, one should note that in finite element analysis, convergence rates are typically different for displacements and stresses (with the former being higher order convergence). I would also try comparing what you expect to see with a more resolved mesh as a coarse mesh might not show you much.

Another thing you might also note is the difference in the ufl function div() vs nabla_div() and nabla_grad() vs grad(). dokken’s excellent FEniCSx tutorial covers this difference here

A final footnote: If you plan are working with the new version of FEniCS, FEniCSx, you will notice that the “project” function no longer exits. See this link for more information on the reason why that was done. At this point, I would highly suggest all new work you do to be in FEniCSx/Dolfinx. This link will be the closest to the legacy fenics code you have been working with.

1 Like