Solve a Boundary Value Problem

Start with solving a boundary value problem as you would usually do with Ferrite. It is crucial that you safe your used DofHandler and solution vector because we need to pass those objects to MakiePlotter.


Plotting Functions

Currently, FerriteViz.solutionplot, FerriteViz.wireframe, FerriteViz.surface, FerriteViz.arrows and their mutating analogues with ! are defined for MakiePlotter. Due to the nature of the documentation we need WGLMakie, however, you can simply exchange any WGLMakie call by GLMakie.

Mesh utilities

You can start by plotting your mesh

import FerriteViz
using Ferrite
import WGLMakie #activating the backend, switch to GLMakie or CairoMakie (for 2D) locally

grid = generate_grid(Hexahedron,(3,3,3))

FerriteViz.jl also supports showing labels for Ferrite.AbstractGrid entities, such as node- and celllabels, as well as plotting cellsets.

grid = generate_grid(Quadrilateral,(3,3))

Solution field of a boundary value problem

If you solve some boundary value problem with Ferrite.jl keep in mind to safe your dh::DofHandler and solution vector u::Vector{T} in some variable. With them, we create the MakiePlotter struct that dispatches on the plotting functions.

include("ferrite-examples/incompressible-elasticity.jl") #defines variables dh_quadratic and u_quadratic

plotter = FerriteViz.MakiePlotter(dh_quadratic,u_quadratic)

Per default, all plotting functions grab the first field in the DofHandler, but of course you can plot a different field as well. The next plot will show the pressure instead of the displacement


For certain 2D problems it makes sense to visualize the result as a surface plot. To showcase the combination with the mutating versions of the plotting functions, the solutionplot function is plotted below the surface plot


Deformed mesh for mechanical boundary value problem

However, in structural mechanics we often would like to see the deformed configuration, which can be achieved by providing a deformation_field::Symbol as a keyword argument.

include("ferrite-examples/plasticity.jl") #only defines solving function
u, dh, uhistory, σ, κ = solve()
plotter = FerriteViz.MakiePlotter(dh,u)


Showing per-cell data

FerriteViz.jl also supports to plot cell data, such as the averaged von-Mises stress or the drag stress of the plasticity example.

u, dh, uhistory, σ, κ = solve()

For a more granular investigation of the stress field consult the advanced tutorial.

Interior of a 3D domain

For 3D problems we can also inspect the interior of the domain. Currenly we only have crinkle clipping implemented and it can be used as follows:

clip_plane = FerriteViz.ClipPlane(Vec((0.0,0.5,0.5)), 0.7)
clipped_plotter = FerriteViz.crinkle_clip(plotter, clip_plane)

Note that we can replace the plane withs some other object or a decision function. Such a function takes the grid and a cell index as input and returns a boolean which decides whether a cell is visible or not.

What's next?

Further, this package provides an interactive viewer that you can call with ferriteviewer(plotter) and ferriteviewer(plotter,u_history) for time dependent views, respectively. If you want to live plot your solution while solving some finite element system, consider to take a look at the advanced topics page.