Add VTK plotting for unstructured meshes - #5689
Open
aabills wants to merge 19 commits into
Open
Conversation
This was referenced Jul 31, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5689 +/- ##
==========================================
- Coverage 98.24% 98.20% -0.05%
==========================================
Files 341 343 +2
Lines 33712 34465 +753
==========================================
+ Hits 33121 33845 +724
- Misses 591 620 +29 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
3 tasks
aabills
force-pushed
the
ufv-3-plotting
branch
from
September 3, 2026 19:31
e70d618 to
c6ca5bf
Compare
Add VTKQuickPlot, QuickPlot/dynamic_plot hooks, the vtk optional extra, and headless OSMesa CI setup for GIF export. Extracted from the unstructured finite-volume stack. Co-authored-by: Cursor <cursoragent@cursor.com>
Every panel was built from the FIRST spatial variable's mesh, so a 3-domain variable (e.g. electrolyte concentration) plotted alongside a 5-domain one was painted onto the larger grid: all values shifted by the leading domains' cell count, rendering electrolyte data on current-collector tabs. Build each panel's grid from that variable's own mesh, and make _set_cell/point_scalars raise on a length mismatch so this bug class errors instead of drawing a wrong picture. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The regular visualisation grid, mid-plane slices, quiver sampling and slice-plane positions used to live on the unstructured processed variables; the spatial-method PR now ships them as pure point interpolators. Add pybamm.plotting.unstructured_plot_grid with plot_grid, default_slice_positions, midplane_slices and quiver_data, and have QuickPlot own the grid and slice positions per plotted variable (the slice sliders update QuickPlot state). Meshes expose `vertices`, not `nodes`; fix plot_vtk and its test stand-ins. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
aabills
force-pushed
the
ufv-3-plotting
branch
from
September 5, 2026 00:27
c6ca5bf to
fcd4290
Compare
The CI matrix installs extras unlocked (prebuilt-solver-wheel mode uses uv pip install), so it picked up VTK 9.7.0, where the legacy AddActor2D name no longer exists. AddViewProp is the underlying method in every supported VTK. Lock VTK 9.7.0 so local environments test the same version. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
matplotlib 3.11 (which the unlocked CI matrix installs) emits a PendingDeprecationWarning for Colormap.set_bad, and the test suite treats warnings as errors. with_extremes(bad=...) has been available since 3.4. Lock matplotlib 3.11.1 so local runs see what CI sees. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Tests for dynamic_plot(backend="vtk"), the on-screen render window, the matplotlib-less lookup-table fallback, QuickPlot's 3D "tight" limits path and the wireframe helper's 3D guard. The interactive-only lines in VTKQuickPlot.dynamic_plot (interactor.Start and the render inside the slider callback) cannot run headless and are marked no cover, as QuickPlot already does for plt.show. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
… window Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
… numbers
VTK's automatic major ticks piled a dozen labels onto short or stretched
axes ("0.060.080.100.12") and the through-cell axis became a smear under
the 100x display stretch. Set three explicit labels per axis, print the
range of any axis thinner than 5% of the largest in its title instead of
ticks, drop the "(x10^-6)" label scaling, and format scalar-bar values
with %.4g so "1.27e+03" is no longer clipped to "1.27e+" and "303." loses
its dangling point. Slightly smaller axis and panel-title fonts.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Only unstructured-mesh scalars and 0D time series are plottable; vector fields and structured spatial variables used to fall through to the 0D chart path, crashing or silently plotting mesh node 0. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
ScikitFemSubMesh3D stores coordinates as nodes, not vertices, so the FEM path of VTKQuickPlot only worked against test fakes. The node-data fixture now mirrors the real mesh. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The VTK branch re-passed output_variables by keyword next to *args, so the positional form raised TypeError; unknown backends now raise OptionError instead of silently using matplotlib. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Slice position and axis ranges came from the first variable's mesh, so a panel on a sub-domain mesh was cut and labelled against the wrong extents. 2D meshes now map their (x, z) columns explicitly instead of indexing a missing third column. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The OSMesa packages and default window class were wired only into the reusable workflow, so the periodic matrix ran the unit suite without them. The env default now lives in noxfile.py for headless Linux, and the periodic workflow installs the same system packages. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Off-screen Linux no longer hard-codes the OSMesa window class, which crashed desktops without libOSMesa; headless hosts select it through VTK_DEFAULT_OPENGL_WINDOW instead. save_gif's PIL import is now an optional-dependency import backed by the vtk extra. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The 2D quiver, unstructured pcolormesh and 3D slice blocks were pasted into both methods; they now live in one helper each. The pcolormesh helper also replaces the previous frame's artists instead of stacking them, and the fixed-limits scan uses a single comprehension pair. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The plot_surface panels and the y/z slice sliders used raw metres with unit-less labels while every other panel honoured spatial_unit. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Points, connectivity and per-frame scalar updates went through per-element Python loops; they are now single vectorised copies, and the cell/point scalar setters share one implementation. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Log through pybamm.logger, raise OptionError/ShapeError/GeometryError instead of ValueError, import optional dependencies through import_optional_dependency, keep inline comments to two lines, add the future-annotations import and type hints on the public functions. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Contributor
|
| Project | PyBaMM |
| Branch | ufv-3-plotting |
| Testbed | bare-metal |
🐰 View full continuous benchmarking report in Bencher
⚠️ WARNING: Truncated view!The full continuous benchmarking report exceeds the maximum length allowed on this platform.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
VTKQuickPlot, QuickPlot/dynamic_plot hooks, optionalvtkextra, and headless OSMesa CI (Linux + Windows).Stack
Test plan
tests/unit/test_plotting/test_plot_vtk.py(18 passed locally)Also in this stack: #5691 deprecates
pybamm.Magnitude.