Element Mesh Visualization

The element mesh wireframe visualizations are an efficient means of creating an approximate visualization of an ElementMesh. The visualization uses linear elements to visualize the mesh. For a more complete visualization of meshes, an ElementMesh should be converted to a MeshRegion; HighlightMesh could be used for more advanced visualization.

An ElementMesh is typically created with either ToBoundaryMesh or ToElementMesh.

To use the package, the FEM context needs to be loaded.

Wireframes

To inspect element meshes, it is convenient to look at their wireframes.

mesh["Wireframe"]show the edges making the mesh wireframe
mesh["Wireframe"[pos]]show the elements having positions corresponding to the list of positions pos.
mesh["Wirefame"[ElementMarker m]]show the elements having ElementMarker corresponding to the marker m.

ElementMesh wireframe commands.

Create a triangle element mesh with six triangle elements and markers.
Visualize the element mesh wireframe.
Convert to a MeshRegion.
Visualize the element mesh wireframe in green.
Visualize the element mesh in green.
Visualize the element mesh in green and the faces in red.
Visualize the element mesh wireframe with the element identification numbers in red.
Visualize the element mesh wireframe with the element markers in blue.
Find the position of elements that have a quality less than 0.9.

More information on mesh quality can be found in the Element Mesh Generation tutorial.

Visualize just those mesh elements as a wireframe.
Additionally, highlight the element markers in blue.
Find the position of elements that have a certain marker.
Visualize just those mesh elements as a wireframe.
Directly visualize mesh elements that contain markers as a wireframe.

All options presented so far work for all mesh elements: "MeshElements", "BoundaryElements" and "PointElements". For more details, please consult the documentation for ElementMesh.

Visualize the boundary element mesh wireframe.

Note that the interface between different mesh element markers forms an internal boundary.

Visualize the boundary element mesh wireframe with the element markers in blue.
Visualize the point element mesh wireframe.
Visualize a combination of different aspects of an element mesh.

Note that for the point elements, only the boundary incidents are visualized. If no point elements are given explicitly, then the point elements are derived from the incidents of the boundary elements.

Inspect the boundary and point elements.

One alternative way to visualize the mesh is by using MeshRegion.

Use MeshRegion and HighlightMesh for visualization.

If specific point elements are given, those will be used.

Create an element mesh with mesh elements, boundary elements and point elements.
Visualize the point elements in a mesh.

For mixed-type elements or multiple elements, the numbering of the elements is according to the position in the list.

Create a mixed-element mesh with element markers.
Visualize the element mesh wireframe with the element identification numbers.
Visualize the element mesh wireframe with continuous element identification numbers.
Visualize the element mesh wireframe with colored markers.

To color the element mesh, the number of "MeshElementStyle" components must match the number of markers.

Create a region.
Create a mesh with element markers and visualize them with colors.

A marker can also be part of boundary meshes.

Create a 2D boundary mesh with markers.
Visualize the boundary element identification numbers and markers, as well as the point element identification numbers and markers.
Visualize the boundary elements that have a marker 1 or 2.
Create a full mesh.
Visualize the boundary markers of the full mesh.

In 3D, the default wireframe to draw is the boundary mesh.

Construct coordinates on a circular perimeter.
These are the linear incidents.
Create a hexahedron element mesh.
Visualize the boundary element mesh wireframe.
Visualize the full element mesh wireframe.

Here is a summary of options:

"ContinuousElementID"displays elements with continuous numbers
"MeshElement"specifies which mesh element should be drawn
"MeshElementIDStyle"specifies the style with which the mesh element ID should be drawn
"MeshElementMarkerStyle"specifies the style with which the mesh element marker should be drawn
"MeshElementStyle"specifies the style with which the mesh element should be drawn

Options for "Wireframe" visualization of an ElementMesh.

STL files can be imported as boundary element meshes.

Import an STL file as a boundary element mesh and inspect the wireframe.

A wireframe in 3D displays all boundary elements by default. If components in the boundary mesh are finely resolved, the wireframe mesh may be excessively dense in those areas. As an alternative, an edge frame mesh can be used in 3D. Dominant edges are those edges where neighboring surfaces have a different normal.

Visualize the edge frame.
Visualize the edge frame with a different boundary grouping threshold and a directive for the edges.

"Edgeframe" has the same options as Graphics3D, with the following additions:

"BoundaryGroupingThreshold"controls the grouping of boundaries by normal direction
"EdgeframeDirective"specifies how edges should be drawn

Options for "Edgeframe" visualization of an ElementMesh.

Boundary markers are auto-created. They can be visualized by assigning different colors to them.

Create a region.
Generate the boundary ElementMesh.
Visualize the boundary mesh with boundary markers displayed with different colors.

Sometimes one wants to scroll though boundary markers or point markers to find a particular surface or boundary point where a boundary condition is to be applied.

Generate a boundary mesh from a Boolean region.
Use Manipulate to scroll through the surfaces.
Use Manipulate to scroll through the boundary points.
Generate a full mesh.

For more control over the point markers in a full element mesh, the option "PointMarkers""BoundaryDeduced" can be specified to ToElementMesh.

Use Manipulate to scroll through the boundary points.

Another option is to display all surfaces and add a legend.

Set up different colors for the point markers present in the mesh.
Visualize the geometry with faces colored and labeled.

A similar setup can be made for boundary points.

Issues

The intent of the wireframe visualization is to give an approximate visualization of an ElementMesh. The visualization uses linear elements to visualize the mesh.

Create a second-order ElementMesh.
Visualize part of the mesh and the boundary points.

Note that the mid-side nodes are on the curve of the Disk, but since the wireframe visualization is linear only, it appears as if the nodes are outside.

Visualizing Deformations

When analyzing structural mechanics with NDSolve, the deformation of objects under load is computed over a region. Sometimes it is convenient to visualize the region as if it were deformed by the load.

The exact physics in this example is not relevant here; it suffices to say that for structural mechanics applications computed with the finite element method with NDSolve, the number of dependent variables specifies the number of deformation functions.

Define a plane stress operator.
Set up the boundary conditions so that the beam is held fixed at the left.
Solve the equation.

NDSolve returned two interpolating functions, one for the deformation in the direction and one for the deformation in the direction. In order to show the deformed beam, an element mesh must be created for the beam at rest, which is deformed by the interpolating functions given.

Visualize the deformed mesh.

In cases where the deformation is not visible because the amount of deformation is small, a scaling factor can be specified.

ElementMeshDeformation can be used in 2D and 3D.

Here is a summary of options:

"ScalingFactor"scales the mesh deformation by a factor

Options for ElementMeshDeformation visualization of an ElementMesh.

The automatic scaling factor computation uses a relation between the smallest typical length and the largest deformation.

Compute the Automatic scaling factor used:

Converting ElementMesh

It is possible to convert ElementMesh into various other formats for visualization purposes. A conversion to a MeshRegion can be done as follows:

Create an example mesh and convert that to a MeshRegion.

It is also possible to convert ElementMesh to GraphicsComplex.

Convert an ElementMesh to a GraphicsComplex.

Special directives can be given.

Specify directives for the graphics complex.

Options for GraphicsComplex can be specified.

Specify options for the graphics complex.