I'm solving a problem in solid mechanics, but I ran into problems when I tried to plot some stuff over the deformed mesh, because the plots are cut off. They end when the undeformed mesh ends.


pars = <|"MaterialModel" -> "NeoHookeanIsotropic", "LameParameter" -> 10^6, 
   "ShearModulus" -> 5000, "ModelForm" -> "PlaneStress", "Thickness" -> 0.01, 
   "InitialStress" -> {$MachineEpsilon, $MachineEpsilon}|>;
vars = {{u[x, y], v[x, y]}, {x, y}};
\[CapitalOmega] = Rectangle[{0, 0}, {1, 1}];
mesh = ToElementMesh[\[CapitalOmega]];

pde = {SolidMechanicsPDEComponent[vars, pars] == 
    SolidBoundaryLoadValue[x == 1, vars, 
     pars, <|"Pressure" -> {p, 0}|>], 
   SolidFixedCondition[x == 0, vars, pars]};
 displacement = 
    pde /. p -> 3000, {u[x, y], v[x, y]}, {x, y} \[Element] mesh];]

deformedMesh = 
  ElementMeshDeformation[mesh, displacement, "ScalingFactor" -> 1];

Now comes the plotting part:

F = Map[Grad[#, {x, y}] &, displacement];
h = Function[{x, y}, F . {{1}, {0}} // Flatten // Evaluate];
StreamPlot[h[x, y], {x, y} \[Element] deformedMesh, 
  StreamPoints -> Coarse, StreamScale -> None, 
  StreamColorFunction -> None, PlotRange -> All]

This gives the following result. In the background you can see the deformed mesh, but the lines are cut off at 1. They are plotted only over the undeformed mesh.


Same thing happens when I try to plot norm of Cauchy stress.

strain = SolidMechanicsStrain[vars, pars, displacement];
cauchyStress = SolidMechanicsStress[vars, pars, strain, displacement];
cauchyNorm = Norm[cauchyStress, "Frobenius"];
ContourPlot[cauchyNorm, {x, y} \[Element] deformedMesh, PlotLegends -> Automatic]

The plot is also cut off.


I tried to use ElementMeshInterpolation to interpolate to the deformed mesh. I tried to follow the examples in documentation:

values = Function[{x, y}, h] @@@ mesh["Coordinates"];
if = ElementMeshInterpolation[{mesh}, values];

But this results in error "Interpolation on unstructured grids is currently only supported for
machine numbers."

  • $\begingroup$ Have look in the solid mechanics tutorial, there are examples showing how to do this in the introduction art example section. You'd need to map the displacement to the deformed mesh. $\endgroup$
    – user21
    Commented Nov 5, 2022 at 6:18
  • $\begingroup$ Actually, all functions defined on $\Omega$, not on deformedMesh. It is why StreamPlot and ContourPlot cat off picture. We can use VectorDisplacementPlot to show h on deformedMesh. $\endgroup$ Commented Nov 5, 2022 at 16:42

1 Answer 1


You can use:

deformedH = 
    ElementMeshInterpolation[deformedMesh, #["ValuesOnGrid"]][x, 
       y] & /@ Flatten[F][[All, 0]], 2] . {1, 0};
StreamPlot[deformedH, {x, y} \[Element] deformedMesh, 
 StreamPoints -> Coarse, StreamScale -> None, 
 StreamColorFunction -> None, PlotRange -> All]

enter image description here


cauchyNorm2 = EvaluateOnElementMesh[{x, y}, cauchyNorm, mesh];
deformedCauchyNorm = 
ContourPlot[deformedCauchyNorm[x, y], {x, y} \[Element] deformedMesh, 
 PlotLegends -> Automatic(*,PlotRange->All*)]

enter image description here

If by, cut off, you mean the re-scaled plot then you can specify PlotRange->All to 'fix' that.

  • $\begingroup$ Thank you, I was stuck on it for a long time. $\endgroup$
    – lemurman
    Commented Nov 8, 2022 at 13:15
  • $\begingroup$ @lemurman Maybe, I should add more such examples in the documentation? $\endgroup$
    – user21
    Commented Nov 8, 2022 at 13:16
  • $\begingroup$ I think it would be useful. $\endgroup$
    – lemurman
    Commented Nov 8, 2022 at 16:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.