Main Content

pdemesh

Description

pdemesh(fegeometry) plots the mesh represented by the Mesh property of an fegeometry object.

example

pdemesh(mesh) plots the mesh represented by an FEMesh object.

example

pdemesh(model) plots the mesh contained in a 2-D or 3-D model object.

pdemesh(nodes,elements) plots the mesh defined by nodes and elements.

example

pdemesh(model,u) plots solution data u as a 3-D plot. This syntax is valid only for 2-D geometry.

pdemesh(___,Name,Value) plots the mesh or solution data using any of the arguments in the previous syntaxes and one or more Name,Value pair arguments.

example

pdemesh(p,e,t) plots the mesh specified by the mesh data p,e,t.

pdemesh(p,e,t,u) plots PDE node or triangle data u using a mesh plot. The function plots the node data if u is a column vector , and triangle data if u is a row vector.

If you want to have more control over your mesh plot, use pdeplot or pdeplot3D instead of pdemesh.

h = pdemesh(___) returns handles to the graphics, using any of the arguments of the previous syntaxes.

Examples

collapse all

Create a mesh plot and display the node and element labels of the mesh.

Import the geometry represented by the built-in function lshapeg.

gm = fegeometry(@lshapeg);

Generate and plot a mesh.

gm = generateMesh(gm);
pdemesh(gm)

Figure contains an axes object. The axes object contains 2 objects of type line.

Alternatively, you can plot a mesh by using the mesh itself as an input argument.

mesh = gm.Mesh;
pdemesh(mesh)

Figure contains an axes object. The axes object contains 2 objects of type line.

Another approach is to use the nodes and elements of the mesh as input arguments for pdemesh.

pdemesh(mesh.Nodes,mesh.Elements)

Figure contains an axes object. The axes object contains an object of type line.

Display node labels.

pdemesh(gm,NodeLabels="on")

Figure contains an axes object. The axes object contains 2 objects of type line.

Use xlim and ylim to zoom in on particular nodes.

xlim([-0.4,0.4])
ylim([-0.4,0.4])

Figure contains an axes object. The axes object contains 2 objects of type line.

Display element labels.

pdemesh(gm,ElementLabels="on")
xlim([-0.4,0.4])
ylim([-0.4,0.4])

Figure contains an axes object. The axes object contains 2 objects of type line.

Import a geometry of a plate.

gm = fegeometry("Plate10x10x1.stl");

Generate a mesh.

gm = generateMesh(gm,Hmax=5);

Plot the mesh setting the transparency to 0.5.

pdemesh(gm,FaceAlpha=0.5)

Figure contains an axes object. The hidden axes object contains 5 objects of type quiver, text, patch.

Find the elements associated with a geometric region.

Import and plot the geometry of the built-in function lshapeg.

gm = fegeometry(@lshapeg);
pdegplot(gm,FaceLabels="on",EdgeLabels="on")

Figure contains an axes object. The axes object contains 14 objects of type line, text.

Generate a mesh.

gm = generateMesh(gm,Hmax=0.5);

Find the elements associated with face 2.

mesh = gm.Mesh;
Ef2 = findElements(mesh,"region",Face=2);

Highlight these elements in green on the mesh plot.

figure
pdemesh(mesh,ElementLabels="on")
hold on
pdemesh(mesh.Nodes,mesh.Elements(:,Ef2),EdgeColor="green")

Figure contains an axes object. The axes object contains 3 objects of type line.

Input Arguments

collapse all

Geometry object for finite element analysis, specified as an fegeometry object. The pdemesh function plots the mesh from the Mesh property of the fegeometry object.

Mesh description, specified as an FEMesh object.

Model container, specified as an femodel object, PDEModel object, ThermalModel object, StructuralModel object, or ElectromagneticModel object.

Nodal coordinates, specified as a 2-by-NumNodes matrix for a 2-D mesh and 3-by-NumNodes matrix for a 3-D mesh. NumNodes is the number of nodes.

Element connectivity matrix in terms of node IDs, specified as an NodesPerElem-by-NumElements matrix. NodesPerElem is the number of nodes per element. Linear meshes contain only corner nodes, so there are three nodes per a 2-D element and four nodes per a 3-D element. Quadratic meshes contain corner nodes and nodes in the middle of each edge of an element. For quadratic meshes, there are six nodes per a 2-D element and 10 nodes per a 3-D element.

Nodes of a linear triangular element are numbered 1, 2, 3 counterclockwise, starting from the leftmost node. Nodes of a quadratic triangular element are the same, with the additional nodes in the middle of each edge numbered 4, 5, 6.

Nodes of a linear tetrahedral element are numbered as follows. Nodes at the base are 1, 2, 3 counterclockwise, starting from the leftmost node. Node 4 is at the top of the tetrahedron. The nodes of a quadratic tetrahedral element are the same, with the additional nodes in the middle of each edge. These nodes are numbered 5, 6, 7 at the base, and 8, 9, 10 at the sides of the tetrahedron.

PDE solution, specified as a vector or matrix.

Example: results = solvepde(model); u = results.NodalSolution;

Mesh points, specified as a 2-by-Np matrix of points, where Np is the number of points in the mesh. For a description of the (p,e,t) matrices, see Mesh Data as [p,e,t] Triples.

Typically, you use the p, e, and t data exported from the PDE Modeler app, or generated by initmesh or refinemesh.

Example: [p,e,t] = initmesh(gd)

Data Types: double

Mesh edges, specified as a 7-by-Ne matrix of edges, where Ne is the number of edges in the mesh. For a description of the (p,e,t) matrices, see Mesh Data as [p,e,t] Triples.

Typically, you use the p, e, and t data exported from the PDE Modeler app, or generated by initmesh or refinemesh.

Example: [p,e,t] = initmesh(gd)

Data Types: double

Mesh triangles, specified as a 4-by-Nt matrix of triangles, where Nt is the number of triangles in the mesh. For a description of the (p,e,t) matrices, see Mesh Data as [p,e,t] Triples.

Typically, you use the p, e, and t data exported from the PDE Modeler app, or generated by initmesh or refinemesh.

Example: [p,e,t] = initmesh(gd)

Data Types: double

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: pdemesh(model,NodeLabels="on")

Node labels, specified as "off" or "on".

pdemesh ignores NodeLabels when you plot solution data as a 3-D plot.

Example: NodeLabels="on"

Data Types: char | string

Element labels, specified as "off" or "on".

pdemesh ignores ElementLabels when you plot solution data as a 3-D plot.

Example: ElementLabels="on"

Data Types: char | string

Surface transparency for 3-D geometry, specified as a real number from 0 through 1. The default value 1 indicates no transparency. The value 0 indicates complete transparency.

Example: FaceAlpha=0.5

Data Types: double

Color of mesh edges, specified as a short or long color name or an RGB triplet. By default, for 2-D meshes the edges within one face are blue (RGB triplet [0 0 1]) and the edges between faces are red (RGB triplet [1 0 0]). For 3-D meshes, the default edge color is black (RGB triplet [0 0 0]).

The short names and long names are character vectors that specify one of eight predefined colors. The RGB triplet is a three-element row vector whose elements specify the intensities of the red, green, and blue components of the color; the intensities must be in the range [0 1]. The following table lists the predefined colors and their RGB triplet equivalents.

RGB Triplet

Short Name

Long Name

[1 1 0]

y

yellow

[1 0 1]

m

magenta

[0 1 1]

c

cyan

[1 0 0]

r

red

[0 1 0]

g

green

[0 0 1]

b

blue

[1 1 1]

w

white

[0 0 0]

k

black

Example: EdgeColor="green"

Data Types: double | char | string

Color of mesh faces for 3-D meshes, specified as a short or long color name or an RGB triplet. The default face color is cyan (RGB triplet [0 1 1]). For details about available colors, see EdgeColor.

Example: FaceColor="green"

Data Types: double | char | string

Output Arguments

collapse all

Handles to graphics objects, returned as a vector.

Version History

Introduced before R2006a

expand all

See Also

Functions

Topics