Pyvista4dolfinx

Library link: FEniCSx4Flow / pyvista4dolfinx · GitLab
Documentation: Pyvista for dolfinx — pyvista for dolfinx documentation
Version: PyPi
CI-status: test status

Installation instructions

pip install pyvista4dolfinx

Description

This package reintroduces simple plot and show functionality to FEniCSx, capable of plotting most common data-structures during both serial and parallel execution.

At a prototyping stage one often desires quick-and-dirty visualization with a simple interface. Yet, quite a bit of boiler-plate code is required to interface dolfinx and pyvista. To mitigate this, pyvista4dolfinx provides a single plot function that can be used to plot most of dolfinx’s visualizable data-structures; scalar- and vector-valued Function, Mesh, FacetMarker, and even integration Measure.

The plot function returns a pyvista.Plotter instance, such that the user still has full access to pyvista’s full range of capabilities.

Examples

Demo 1

A minimal example would be:

from dolfinx import fem,mesh
from mpi4py import MPI
import numpy as np
from pyvista4dolfinx import plot

domain = mesh.create_unit_square(MPI.COMM_WORLD,10,10)
V = fem.functionspace(domain, ("Lagrange", 2))
u = fem.Function(V, name='my_function')
u.interpolate(lambda x: np.sin(x[0]*np.pi)*np.sin(x[1]*np.pi))

# This is the single required plotting call:
plot(u, warp=True, show=True)

Which outputs:

Demo 2

A demo that illustrates a broader range of functionality can be found at:

Feedback

I’ll happily take feedback through responses to this post, PMs, or issues created on the gitlab page. In particular, I have only been able to perform limited across platforms, so I’d still be curious to learn how robust the package is.

1 Like

For comparison, libraries with similar goals are febug (cc @nate) and viskex (cc myself).

2 Likes