You are getting different results because your old DOLFIN code and DOLFINx code are using different meshes ("right/left"
for old DOLFIN and dolfinx.mesh.DiagonalType.right
for DOLFINx). See screenshot below
If you change your DOLFINx mesh generation code to the following, you should see that the solutions are identical
msh = mesh.create_rectangle(
MPI.COMM_WORLD,
((0.0, 0.0), (nelx, nely)),
(nelx, nely),
cell_type=mesh.CellType.triangle,
diagonal=mesh.DiagonalType.right_left,
)
As a final note, your code in old DOLFIN is also applying the traction to the entire right boundary, not a point load at the bottom right corner. The following statement marks all facets on the right boundary because x[1]<=2
is true for all points on the right boundary.
If you want to apply a point load at the bottom right corner, you should use PointSource
in old DOLFIN (see here and here). Unfortunately, the reimplementation in DOLFINx is not complete yet; see PointSource in dolfinx.