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