Skip to content

Conversation

@RomainBaville
Copy link
Contributor

@RomainBaville RomainBaville commented Oct 31, 2025

This pr aims to:

  • Move GeosBlockMerge from geos-posp to geos-processing
  • Refactor GeosBlockMerge to be coherent with the rest of the code

The implementation of the tests for GeosBlockMerge will be make later with a clean of all the tests and the data. See more clean test

@RomainBaville RomainBaville self-assigned this Oct 31, 2025
@paloma-martinez paloma-martinez changed the title refactor: Move GeosBlockMerge from geos-prop to geos-processing refactor: Move GeosBlockMerge to geos-processing Nov 3, 2025
@RomainBaville RomainBaville added the test-geos-integration Triggers the testing of geosPythonPackages import and integration in GEOS CI label Nov 4, 2025
@@ -0,0 +1,238 @@
# SPDX-License-Identifier: Apache-2.0
# # SPDX-FileCopyrightText: Copyright 2023-2024 TotalEnergies.
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
# # SPDX-FileCopyrightText: Copyright 2023-2024 TotalEnergies.
# SPDX-FileCopyrightText: Copyright 2023-2024 TotalEnergies.

from geos.mesh.utils.genericHelpers import ( computeNormals, computeTangents )

__doc__ = """
GeosBlockMerge is a vtk filter that allows to merge for a GEOS domain the ranks per region, identify "Fluids" and "Rock" phases and rename "Rock" attributes.
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
GeosBlockMerge is a vtk filter that allows to merge for a GEOS domain the ranks per region, identify "Fluids" and "Rock" phases and rename "Rock" attributes.
GeosBlockMerge is a vtk filter that acts on each region of a GEOS output domain (volume, fault, wells):
- Ranks are merged.
- "Fluids" and "Rock" phases are identified.
- "Rock" attributes are renamed depending on the phase they refer to for more clarity.
- Volume meshes are converted to surface if needed.

It was unclear, feel free to reformulate again if this is not accurate.

Comment on lines +26 to +28
.. Important::
This filter deals with the domain mesh of GEOS. This domain needs to be extracted before.
See geos-processing/src/geos/processing/post_processing/GeosBlockExtractor.py to see the type of input requires by this filter.
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
.. Important::
This filter deals with the domain mesh of GEOS. This domain needs to be extracted before.
See geos-processing/src/geos/processing/post_processing/GeosBlockExtractor.py to see the type of input requires by this filter.
.. Important::
This filter cannot be used directly on GEOS output. The domain needs to be extracted with the help of `GeosBlockExtractor` filter. Please refer to the `documentation <https://geosx-geosx.readthedocs-hosted.com/projects/geosx-geospythonpackages/en/latest/geos_processing_docs/post_processing.html>`_ for more information.

Comment on lines +69 to +72
for all the composite blocks of the input mesh:
- Ranks are merged
- "Rock" attributes are renamed
- Volume mesh are convert to surface if needed
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 all the composite blocks of the input mesh:
- Ranks are merged
- "Rock" attributes are renamed
- Volume mesh are convert to surface if needed
For each composite block of the input mesh:
- Ranks are merged.
- "Rock" attributes are renamed.
- Volume meshes are converted to surface if requested.


Args:
inputMesh (vtkMultiBlockDataSet): The mesh with the blocks to merge.
convertFaultToSurface (bool, optional): True if the merged block need to be convert to vtp, False otherwise.
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
convertFaultToSurface (bool, optional): True if the merged block need to be convert to vtp, False otherwise.
convertFaultToSurface (bool, optional): If True, merged blocks are converted to surface (vtp), False otherwise.

Comment on lines +216 to +238
def convertBlockToSurface( self: Self, block: vtkUnstructuredGrid ) -> vtkPolyData:
"""Convert vtkUnstructuredGrid to a surface vtkPolyData.

.. WARNING:: work only with triangulated surfaces

.. TODO:: need to convert quadrangular to triangulated surfaces first

Args:
block (vtkUnstructuredGrid): block from which to extract the surface

Returns:
vtkPolyData: extracted surface
"""
extractSurfaceFilter: vtkDataSetSurfaceFilter = vtkDataSetSurfaceFilter()
extractSurfaceFilter.SetInputData( block )
# fast mode should be used for rendering only
extractSurfaceFilter.FastModeOff()
# Delegation activated allow to accelerate the processing with unstructured mesh
# see https://vtk.org/doc/nightly/html/classvtkDataSetSurfaceFilter.html
extractSurfaceFilter.DelegationOn()
extractSurfaceFilter.Update()
output: vtkPolyData = extractSurfaceFilter.GetOutput()
return output
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
def convertBlockToSurface( self: Self, block: vtkUnstructuredGrid ) -> vtkPolyData:
"""Convert vtkUnstructuredGrid to a surface vtkPolyData.
.. WARNING:: work only with triangulated surfaces
.. TODO:: need to convert quadrangular to triangulated surfaces first
Args:
block (vtkUnstructuredGrid): block from which to extract the surface
Returns:
vtkPolyData: extracted surface
"""
extractSurfaceFilter: vtkDataSetSurfaceFilter = vtkDataSetSurfaceFilter()
extractSurfaceFilter.SetInputData( block )
# fast mode should be used for rendering only
extractSurfaceFilter.FastModeOff()
# Delegation activated allow to accelerate the processing with unstructured mesh
# see https://vtk.org/doc/nightly/html/classvtkDataSetSurfaceFilter.html
extractSurfaceFilter.DelegationOn()
extractSurfaceFilter.Update()
output: vtkPolyData = extractSurfaceFilter.GetOutput()
return output
def convertBlockToSurface( self: Self, block: vtkUnstructuredGrid ) -> vtkPolyData:
"""Convert vtkUnstructuredGrid to a surface vtkPolyData.
.. WARNING:: work only with triangulated surfaces
.. TODO:: need to convert quadrangular to triangulated surfaces first
Args:
block (vtkUnstructuredGrid): Input mesh block
Returns:
vtkPolyData: Extracted surface
"""
extractSurfaceFilter: vtkDataSetSurfaceFilter = vtkDataSetSurfaceFilter()
extractSurfaceFilter.SetInputData( block )
# fast mode should be used for rendering only
extractSurfaceFilter.FastModeOff()
# Delegation activated allow to accelerate the processing with unstructured mesh
# see https://vtk.org/doc/nightly/html/classvtkDataSetSurfaceFilter.html
extractSurfaceFilter.DelegationOn()
extractSurfaceFilter.Update()
output: vtkPolyData = extractSurfaceFilter.GetOutput()
return output

This function can be moved to geos-mesh generciHelpers, as it is not specific to this filter.
It would be helpul to implement the VTKError handling method.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you check if this function really needs triangulated surfaces only ? I think this comment was misplaced and is only useful for the compute tangents part of this filter

Comment on lines +157 to +162
surfaceMesh: vtkPolyData = self.convertBlockToSurface( volumeMesh )
assert surfaceMesh is not None, "Surface extraction from block failed."
surfaceMesh.ShallowCopy( computeNormals( surfaceMesh, logger=self.logger ) )
assert surfaceMesh is not None, "Normal calculation failed."
surfaceMesh.ShallowCopy( computeTangents( surfaceMesh, logger=self.logger ) )
assert surfaceMesh is not None, "Tangent calculation failed."
Copy link
Collaborator

Choose a reason for hiding this comment

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

These three assert can be handled in the except.

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

Labels

flag: ready for review test-geos-integration Triggers the testing of geosPythonPackages import and integration in GEOS CI type: refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants