Main Content

Solution Plots with pdeviz

This example how to create a PDE visualization object and plot the result by using the pdeviz function. You can interact with the resulting plot by changing the properties of this object. For example, you can change the transparency, mesh visibility, mesh deformation, axes labels, and so on. The plot reflects the new settings without requiring you to plot the same data repeatedly. For more information about the object properties, see PDEVisualization Properties.

The example uses the figure command to show each updated plot in a separate figure window. To see the updated plots in the same figure window, remove the figure commands.

Create an femodel object for structural analysis with a geometry representing a simple bracket.

model = femodel(AnalysisType="structuralStatic", ...
                Geometry="BracketWithHole.stl");

Plot the geometry with face labels.

pdegplot(model,FaceLabels="on", ...
               FaceAlpha=0.3)

Figure contains an axes object. The axes object contains 6 objects of type quiver, text, patch, line.

Specify Young's modulus and Poisson's ratio of the material.

model.MaterialProperties = ...
        materialProperties(YoungsModulus=200e9, ...
                           PoissonsRatio=0.3);

The problem has two boundary conditions: the back face (face 4) is fixed, and the front face (face 8) has an applied load. By default, all other boundary conditions are free boundaries.

model.FaceBC(4) = faceBC(Constraint="fixed");
model.FaceLoad(8) = faceLoad(SurfaceTraction=[0;0;-1e4]);

Generate a mesh.

model = generateMesh(model);

Create a PDEVisualization object and plot the mesh by calling pdeviz with the mesh data only.

figure
v = pdeviz(model.Mesh);
title("Mesh Only")

Figure contains an object of type pde.graphics.pdevisualization. The chart of type pde.graphics.pdevisualization has title Mesh Only.

Solve the problem.

result = solve(model);

Update the plot by adding the von Mises stress as the NodalData property of the PDEVisualization object v. Change the title of the plot by using the Title property. The plot now shows the von Mises stress and the mesh.

figure
v.NodalData = result.VonMisesStress;
v.Title = "Von Mises Stress with Mesh";

Figure contains an object of type pde.graphics.pdevisualization. The chart of type pde.graphics.pdevisualization has title Von Mises Stress with Mesh.

Update the plot by adding the displacement as the DeformationData property of the PDEVisualization object v. specify the level of mesh deformation by modifying the DeformationScaleFactor property. Also, hide the mesh and the colorbar by modifying the MeshVisible and ColorbarVisible properties, respectively. The plot shows the deformed shape with the von Mises stress.

figure
v.DeformationData = result.Displacement;
v.DeformationScaleFactor = 1000;
v.MeshVisible = "off";
v.ColorbarVisible = "off";
v.Title = "Von Mises Stress Without Mesh";

Figure contains an object of type pde.graphics.pdevisualization. The chart of type pde.graphics.pdevisualization has title Von Mises Stress Without Mesh.

Change the camera line of sight for the plot by modifying the View property of the PDEVisualization object v.

figure
v.View = [120 30];

Figure contains an object of type pde.graphics.pdevisualization. The chart of type pde.graphics.pdevisualization has title Von Mises Stress Without Mesh.