Skip to content

Conversation

@jafranc
Copy link
Collaborator

@jafranc jafranc commented Nov 27, 2025

Adding a diff filter in VTK and paraview that allows to

  • diff every common fields provided that the mesh is the same
  • report L1 norm as a new fields
  • report L2/Linf norm as report

@RomainBaville RomainBaville marked this pull request as ready for review January 5, 2026 17:01
__doc__ = """
Attributes Diff is a vtk that compute L1 and L2 differences between attributes shared by two identical meshes.

Input meshes cans be vtkDataSet or vtkMultiBlockDataSet.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
Input meshes cans be vtkDataSet or vtkMultiBlockDataSet.
Input meshes can be vtkDataSet or vtkMultiBlockDataSet.

Comment on lines +88 to +93
self.dicNbElements: dict[ Piece, int ] = {}

self.dicSharedAttributes: dict[ Piece, set[ str ] ] = {}
self.dicAttributesToCompare: dict[ Piece, set[ str ] ] = {}
self.dicAttributesDiffNames: dict[ Piece, list[ str ] ] = {}
self.dicAttributesArray: dict[ Piece, npt.NDArray[ np.float32 ] ] = {}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
self.dicNbElements: dict[ Piece, int ] = {}
self.dicSharedAttributes: dict[ Piece, set[ str ] ] = {}
self.dicAttributesToCompare: dict[ Piece, set[ str ] ] = {}
self.dicAttributesDiffNames: dict[ Piece, list[ str ] ] = {}
self.dicAttributesArray: dict[ Piece, npt.NDArray[ np.float32 ] ] = {}
self.dictNbElements: dict[ Piece, int ] = {}
self.dictSharedAttributes: dict[ Piece, set[ str ] ] = {}
self.dictAttributesToCompare: dict[ Piece, set[ str ] ] = {}
self.dictAttributesDiffNames: dict[ Piece, list[ str ] ] = {}
self.dictAttributesArray: dict[ Piece, npt.NDArray[ np.float32 ] ] = {}

I think we can afford the t of dict for these variables names :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

same for similar variables in the rest of the code

Comment on lines +251 to +257
def getDicAttributesToCompare( self: Self ) -> dict[ Piece, set[ str ] ]:
"""Getter of the dictionary of the attribute to compare per localization."""
return self.dicAttributesToCompare

def getDicAttributesDiffNames( self: Self ) -> dict[ Piece, list[ str ] ]:
"""Getter of the dictionary with the name of the attribute created with the calculated attributes diff."""
return self.dicAttributesDiffNames
Copy link
Collaborator

Choose a reason for hiding this comment

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

Missing return type docstring in these two functions

else:
listBlockId: list[ int ] = getBlockElementIndexesFlatten( self.outputMesh )
l2Max: Any = 0
for BlockId in listBlockId:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
for BlockId in listBlockId:
for blockId in listBlockId:

from geos.utils.pieceEnum import Piece

__doc__ = """
Attributes Diff is a vtk that compute L1 and L2 differences between attributes shared by two identical meshes.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
Attributes Diff is a vtk that compute L1 and L2 differences between attributes shared by two identical meshes.
Attributes Diff is a vtk filter that computes L1 and L2 differences between attributes shared by two identical meshes.

Comment on lines +19 to +20
# TODO: Create meshes for test
@pytest.mark.parametrize( "mesh1Name, mesh2Name", [] )
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
# TODO: Create meshes for test
@pytest.mark.parametrize( "mesh1Name, mesh2Name", [] )
# TODO: Create meshes for test
@pytest.mark.skip( "Add data for test" )
@pytest.mark.parametrize( "mesh1Name, mesh2Name", [] )

AttributesDiffFilter: AttributesDiff = AttributesDiff()
AttributesDiffFilter.setMeshes( [ mesh1, mesh2 ] )
AttributesDiffFilter.logSharedAttributeInfo()
dicAttributesToCompare: dict[ Piece, set[ str ] ] = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same remark for dic -> dict in variables names in this file

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants