Skip to content

Render fieldcompare diff visualizations - #883

Open
PranjalManhgaye wants to merge 3 commits into
precice:developfrom
PranjalManhgaye:issue-441-visualize-diffs
Open

Render fieldcompare diff visualizations#883
PranjalManhgaye wants to merge 3 commits into
precice:developfrom
PranjalManhgaye:issue-441-visualize-diffs

Conversation

@PranjalManhgaye

Copy link
Copy Markdown
Collaborator

Summary

  • Render archived fieldcompare diff VTK files as PNG images when result comparison fails.

  • Generate one image per numeric point field using distinct sphere glyphs and a generic automatically selected view.

  • Store images under diff-results/visualizations/ in the system-test artifacts.

  • Keep visualization best-effort so rendering errors do not hide the original fieldcompare failure.

Fixes #441.

Test plan

  • Generated PNGs from synthetic scalar and vector VTK fields.

  • Verified the archive-to-visualization failure path locally.

  • Rendered five real CI diff VTK files, producing 13 PNGs.

  • Checked zero and non-zero differences visually.

  • Ran pre-commit checks successfully.

@MakisH MakisH left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR! Some first comments, I will continue once I can run it.

Comment thread changelog-entries/441.md Outdated
Comment thread tools/tests/requirements.txt
Comment thread tools/tests/visualize_fieldcompare_diffs.py
Run diff PNG rendering through a dedicated Docker stage with libosmesa6 so local and CI follow the same headless path, and include generated PNGs in the _logs artifact with a job-summary link.
@PranjalManhgaye
PranjalManhgaye requested a review from MakisH July 28, 2026 08:52
Comment thread changelog-entries/441.md Outdated
Comment thread tools/tests/README.md Outdated
Comment thread tools/tests/README.md Outdated
Comment thread tools/tests/visualize_fieldcompare_diffs.py Outdated
Comment thread tools/tests/dockerfiles/ubuntu_2404/Dockerfile
@PranjalManhgaye
PranjalManhgaye requested a review from MakisH August 4, 2026 17:57
Comment on lines +99 to +107
max_abs_value = float(np.max(np.abs(values)))
color_limit = max_abs_value if max_abs_value > 0 else 1.0
plotter.add_mesh(
glyphs,
scalars=scalar_name,
cmap="coolwarm",
clim=(-color_limit, color_limit),
scalar_bar_args={"title": field_name},
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this run, fieldcompare complained about the force in the last time window:

field-compare-1  | Comparing '/runs/perpendicular-flap_fluid-openfoam-solid-calculix_2026-08-05-084014/precice-exports/Solid-Mesh-Solid.dt500.vtu'
field-compare-1  |       and '/runs/perpendicular-flap_fluid-openfoam-solid-calculix_2026-08-05-084014/reference-results-unpacked/fluid-openfoam_solid-calculix/Solid-Mesh-Solid.dt500.vtu'
field-compare-1  |   Reading '/runs/perpendicular-flap_fluid-openfoam-solid-calculix_2026-08-05-084014/precice-exports/Solid-Mesh-Solid.dt500.vtu'
field-compare-1  |   Reading '/runs/perpendicular-flap_fluid-openfoam-solid-calculix_2026-08-05-084014/reference-results-unpacked/fluid-openfoam_solid-calculix/Solid-Mesh-Solid.dt500.vtu'
field-compare-1  |    -- Comparing the field 'Force': FAILED
field-compare-1  |      -- Report: Deviation above tolerance detected -> [ 8.05858e-03 -5.47671e-05  0.00000e+00] vs. [ 8.05464e-03 -5.46938e-05  0.00000e+00] ([ 0.05 -0.13   inf] %)
field-compare-1  |      -- Predicate: DefaultEquality (abs_tol: 0., rel_tol: 3.e-07)
field-compare-1  |   Wrote diff into '/runs/perpendicular-flap_fluid-openfoam-solid-calculix_2026-08-05-084014/precice-exports/diff_Solid-Mesh-Solid.dt500.vtu.vtu'
field-compare-1  |   File comparison FAILED with 2 PASSED / 1 FAILED / 0 SKIPPED

but looking at the image, this difference is not clearly visible:

Image

The [-1.0,1.0] range is a bit arbitrary. Why is that being picked? I would generally rely on the color scale and range to understand how large a regression is.

Also, if the difference is visualized (and not the absolute value of it), why have the range symmetric? There must be a minimum value and a maximum value.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Notes from our discussion:

  • We should show the range of the diff files
  • Even if the values tend to zero, if that doesn't cause any issues, let's have the real values: seeing a range -1.23e-33 to +4.56e-33 is also clear, and it is how ParaView does it
  • We noticed that the visualizations for the Solid participant are missing from the picture.



SUPPORTED_SUFFIXES = {".vtk", ".vtp", ".vtu"}
WINDOW_SIZE = (1024, 768)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In some cases, this resolution is a bit small. See a run for the heat exchanger:

Image

Can pyvista export PDF files (vector graphics)? If we cannot include PNG files in the GHA summary, then PDF files would also do, and maybe they would make the archive smaller.

runs/*/system-tests-run.log
runs/*/system-tests-compare.log
runs/*/*/system-tests_*.log
runs/*/diff-results/visualizations/**/*.png

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It now looks like the _logs archive is several MB large, which defeats the original purpose of having something small to download for inspection on a bad connection.

Let's move these to a new archive (_diffs).

Comment on lines +108 to +112
plotter.add_text(
f"{source_file.name}\npoint field: {field_name}",
font_size=10,
color="black",
)

@MakisH MakisH Aug 5, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An additional useful text here would be what the exact field operation is: Difference: computed - reference or Difference: reference - computed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Needs review

Development

Successfully merging this pull request may close these issues.

Archive diff files in the reports

2 participants