-
Notifications
You must be signed in to change notification settings - Fork 0
refactor: Move GeosBlockMerge to geos-processing #163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…github.com/GEOS-DEV/geosPythonPackages into pmartinez/refactor/moveSurfaceGeomechanics
Update to the last version of the main
| @@ -0,0 +1,238 @@ | |||
| # SPDX-License-Identifier: Apache-2.0 | |||
| # # SPDX-FileCopyrightText: Copyright 2023-2024 TotalEnergies. | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| # # 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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.
| .. 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| .. 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. |
| for all the composite blocks of the input mesh: | ||
| - Ranks are merged | ||
| - "Rock" attributes are renamed | ||
| - Volume mesh are convert to surface if needed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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. |
| 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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.
There was a problem hiding this comment.
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
| 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." |
There was a problem hiding this comment.
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.
This pr aims to:
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