Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
f4f9bc6
update logger generic processing tool
Nov 17, 2025
d0b2bfb
Refactor SplitMesh without PVPythonAlgorytmBase
Nov 17, 2025
e5823f3
Merge branch 'main' into RomainBaville/refactor/AddAndCheckLoggerForF…
Nov 17, 2025
be96ffd
Uniform logger of posp-processing filters
Nov 17, 2025
cbba20b
Uniform logger of generic-processing-tools filters
Nov 17, 2025
313469d
Refactor the filter without VTKPythonAlgorythmBase
Nov 17, 2025
97010df
Update with CellTypeCounterEnhanced changes
Nov 17, 2025
5bdc8e0
Refactor the filter without VTKPythonAlgorythmBase
Nov 17, 2025
479813a
Uniform the logger in the paraview plugin
Nov 17, 2025
e8159d3
Merge branch 'main' into RomainBaville/refactor/AddAndCheckLoggerForF…
Nov 17, 2025
ebe20dd
Merge branch 'main' into RomainBaville/refactor/AddAndCheckLoggerForF…
Nov 18, 2025
33e8249
clean ruff and yapf
Nov 18, 2025
94537cb
remove PVPythonAlgorythmBase
Nov 18, 2025
533fce1
update logger
Nov 19, 2025
1e935ed
Uniform the import
Nov 19, 2025
cf9a437
Refactor SplitMesh
Nov 20, 2025
fe04cb2
Refactor CellTypeCounterEnhanced
Nov 20, 2025
380a693
Refactor MeshQualityEnhanced
Nov 20, 2025
934f734
Update to the last version of the main
Nov 20, 2025
5b7a2af
clean test
Nov 20, 2025
e14a065
fix ruff
Nov 20, 2025
1966e36
add source for the paraview handler
Nov 20, 2025
6ac33ec
improve try - except strategy
Nov 21, 2025
c62097c
Update to the last version of the base branch
Nov 21, 2025
d7f69d8
Uniform applyFilter to log messages
Nov 21, 2025
c6c1c9d
fix ruff and yapf
Nov 21, 2025
64c5c21
Fix test
Nov 24, 2025
4eaef30
fix test
Nov 24, 2025
7edc6d4
first commit refactor attributeMapping
Nov 24, 2025
f72c213
Refactor CreateConstantAttributePerRegion
Nov 24, 2025
205bd9c
Refactor FillPartialArray
Nov 24, 2025
660ac27
Refator MergeBlockEnhanced
Nov 24, 2025
4ef951a
Update doc
Nov 24, 2025
0a9c240
Refactor SplitMesh
Nov 24, 2025
e57b5ae
refactor CellTypeCounterEnhanced
Nov 24, 2025
b2f7a88
Refactor MeshQualityEnhanced
Nov 24, 2025
4a1ac35
fix the doc
Nov 25, 2025
fd9886b
Refactor GeomechanicsCalculator
Nov 25, 2025
18fc324
fix except
Nov 25, 2025
6ad6eaa
Refactor GeosBlockMergeAndExtract
Nov 25, 2025
08692f7
Refactor SurfaceGeomechanic
Nov 25, 2025
e620020
Update PVGeomechanicsWorkflow
Nov 25, 2025
af6e564
Update to the last version of the main
Nov 25, 2025
c6adb4d
Apply Paloma's suggestions
Nov 27, 2025
134293d
Fix ci
Nov 27, 2025
fa79fd4
Update to the last version of the main
Nov 28, 2025
cdba9ee
Update to the last version of the base branch
Nov 28, 2025
7fa3dbe
Update to the last versino of the main and fix conflict
Dec 1, 2025
e929319
Fix mad merge
Dec 2, 2025
13cab15
fix yapf
Dec 2, 2025
607c75d
Typo
paloma-martinez Dec 4, 2025
c3255b2
Merge branch 'main' into RomainBaville/refactor/RefactorFilterWithout…
Dec 4, 2025
cf572ee
Update the test to take into account the modification of element mapping
Dec 4, 2025
8299f03
Merge branch 'main' into RomainBaville/refactor/RefactorFilterWithout…
Dec 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

.. code-block:: python

import logging
from geos.processing.generic_processing_tools.AttributeMapping import AttributeMapping

# Filter inputs.
Expand All @@ -57,7 +58,13 @@
attributeMappingFilter.setLoggerHandler( yourHandler )

# Do calculations.
attributeMappingFilter.applyFilter()
try:
attributeMappingFilter.applyFilter()
except( ValueError, AttributeError ) as e:
attributeMappingFilter.logger.error( f"The filter { attributeMappingFilter.logger.name } failed due to: { e }" )
except Exception as e:
mess: str = f"The filter { attributeMappingFilter.logger.name } failed due to: { e }"
attributeMappingFilter.logger.critical( mess, exc_info=True )
"""

loggerTitle: str = "Attribute Mapping"
Expand Down Expand Up @@ -130,70 +137,61 @@ def getElementMap( self: Self ) -> dict[ int, npt.NDArray[ np.int64 ] ]:
"""
return self.ElementMap

def applyFilter( self: Self ) -> bool:
def applyFilter( self: Self ) -> None:
"""Transfer global attributes from a source mesh to a final mesh.

Mapping the piece of the attributes to transfer.

Returns:
boolean (bool): True if calculation successfully ended, False otherwise.
Raises:
ValueError: Errors with the input attributeNames or the input mesh.
AttributeError: Errors with the attribute of the mesh.
"""
self.logger.info( f"Apply filter { self.logger.name }." )

try:
if len( self.attributeNames ) == 0:
raise ValueError( f"Please enter at least one { self.piece } attribute to transfer." )
if len( self.attributeNames ) == 0:
raise ValueError( f"Please enter at least one { self.piece } attribute to transfer." )

attributesInMeshFrom: set[ str ] = getAttributeSet( self.meshFrom, self.onPoints )
wrongAttributeNames: set[ str ] = self.attributeNames.difference( attributesInMeshFrom )
if len( wrongAttributeNames ) > 0:
raise AttributeError(
f"The { self.piece } attributes { wrongAttributeNames } are not present in the source mesh." )
attributesInMeshFrom: set[ str ] = getAttributeSet( self.meshFrom, self.onPoints )
wrongAttributeNames: set[ str ] = self.attributeNames.difference( attributesInMeshFrom )
if len( wrongAttributeNames ) > 0:
raise AttributeError(
f"The { self.piece } attributes { wrongAttributeNames } are not present in the source mesh." )

attributesInMeshTo: set[ str ] = getAttributeSet( self.meshTo, self.onPoints )
attributesAlreadyInMeshTo: set[ str ] = self.attributeNames.intersection( attributesInMeshTo )
if len( attributesAlreadyInMeshTo ) > 0:
raise AttributeError(
f"The { self.piece } attributes { attributesAlreadyInMeshTo } are already present in the final mesh." )

attributesInMeshTo: set[ str ] = getAttributeSet( self.meshTo, self.onPoints )
attributesAlreadyInMeshTo: set[ str ] = self.attributeNames.intersection( attributesInMeshTo )
if len( attributesAlreadyInMeshTo ) > 0:
if isinstance( self.meshFrom, vtkMultiBlockDataSet ):
partialAttributes: list[ str ] = []
for attributeName in self.attributeNames:
if not isAttributeGlobal( self.meshFrom, attributeName, self.onPoints ):
partialAttributes.append( attributeName )

if len( partialAttributes ) > 0:
raise AttributeError(
f"The { self.piece } attributes { attributesAlreadyInMeshTo } are already present in the final mesh."
)
f"All { self.piece } attributes to transfer must be global, { partialAttributes } are partials." )

if isinstance( self.meshFrom, vtkMultiBlockDataSet ):
partialAttributes: list[ str ] = []
for attributeName in self.attributeNames:
if not isAttributeGlobal( self.meshFrom, attributeName, self.onPoints ):
partialAttributes.append( attributeName )
self.ElementMap = computeElementMapping( self.meshFrom, self.meshTo, self.onPoints )
sharedElement: bool = False
for key in self.ElementMap:
if np.any( self.ElementMap[ key ] > -1 ):
sharedElement = True

if len( partialAttributes ) > 0:
raise AttributeError(
f"All { self.piece } attributes to transfer must be global, { partialAttributes } are partials."
)
if not sharedElement:
raise ValueError( f"The two meshes do not have any shared { self.piece }." )

self.ElementMap = computeElementMapping( self.meshFrom, self.meshTo, self.onPoints )
sharedElement: bool = False
for key in self.ElementMap:
if np.any( self.ElementMap[ key ] > -1 ):
sharedElement = True
for attributeName in self.attributeNames:
# TODO:: Modify arrayModifiers function to raise error.
if not transferAttributeWithElementMap( self.meshFrom, self.meshTo, self.ElementMap, attributeName,
self.onPoints, self.logger ):
raise ValueError( f"Fail to transfer the attribute { attributeName }." )

if not sharedElement:
raise ValueError( f"The two meshes do not have any shared { self.piece }." )
# Log the output message.
self._logOutputMessage()

for attributeName in self.attributeNames:
# TODO:: Modify arrayModifiers function to raise error.
if not transferAttributeWithElementMap( self.meshFrom, self.meshTo, self.ElementMap, attributeName,
self.onPoints, self.logger ):
raise

# Log the output message.
self._logOutputMessage()
except ( TypeError, ValueError, AttributeError ) as e:
self.logger.error( f"The filter { self.logger.name } failed.\n{ e }" )
return False
except Exception as e:
mess: str = f"The filter { self.logger.name } failed.\n{ e }"
self.logger.critical( mess, exc_info=True )
return False

return True
return

def _logOutputMessage( self: Self ) -> None:
"""Create and log result messages of the filter."""
Expand Down
Loading