Plotting

Contents

Plotting#

Plotting with PyVista, on any number of processes.

Each process holds the cells it owns, so a plot of a distributed function gathers them on one process: gather_grid() builds a PyVista grid of the owned cells on each process, with the function’s values at its points, and merges the grids on one. PyVista is an optional dependency, imported when a grid is built.

sumfem.plotting.gather_grid(function, name=None, root=0)[source]#

A PyVista grid of a function, gathered on one process.

The grid has the cells of the function space, e.g. of degree two for a quadratic Lagrange space, and the function’s values at its points. Each process contributes the cells it owns, so every cell appears once. A vector is padded to three components, as PyVista expects, e.g. for warp_by_vector.

Every process must call this, as it is collective.

Parameters:
  • function (dolfinx.fem.Function) – A function on a Lagrange space, of any shape, on a mesh or a submesh, e.g. a multiplier on facets.

  • name (str | None) – Name of the values in the grid’s point_data. Defaults to the function’s name.

  • root (int) – The process to gather on.

Returns:

The grid on root, None on the other processes.

Return type:

pyvista.UnstructuredGrid | None