Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from vtkmodules.vtkCommonDataModel import vtkDataSet, vtkMultiBlockDataSet
from geos.mesh.utils.arrayModifiers import transferAttributeWithElementMap
from geos.mesh.utils.arrayHelpers import ( computeElementMapping, getAttributeSet, isAttributeGlobal )
from geos.utils.Logger import ( getLogger, Logger, CountWarningHandler, isHandlerInLogger, getLoggerHandlerType )
from geos.utils.Logger import ( getLogger, Logger, CountVerbosityHandler, isHandlerInLogger, getLoggerHandlerType )
from geos.utils.pieceEnum import Piece

__doc__ = """
Expand Down Expand Up @@ -111,8 +111,8 @@ def __init__(
self.logger.setLevel( logging.INFO )
self.logger.propagate = False

counter: CountWarningHandler = CountWarningHandler()
self.counter: CountWarningHandler
counter: CountVerbosityHandler = CountVerbosityHandler()
self.counter: CountVerbosityHandler
self.nbWarnings: int = 0
try:
self.counter = getLoggerHandlerType( type( counter ), self.logger )
Expand Down Expand Up @@ -209,6 +209,7 @@ def applyFilter( self: Self ) -> None:
else:
self.logger.info( f"{ result }." )

# Keep number of warnings logged during the filter application and reset the warnings count in case the filter is applied again.
self.nbWarnings = self.counter.warningCount
self.counter.resetWarningCount()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from vtkmodules.vtkCommonTransforms import vtkLandmarkTransform
from vtkmodules.vtkFiltersGeneral import vtkTransformFilter

from geos.utils.Logger import ( getLogger, Logger, CountWarningHandler, isHandlerInLogger, getLoggerHandlerType )
from geos.utils.Logger import ( getLogger, Logger, CountVerbosityHandler, isHandlerInLogger, getLoggerHandlerType )
from geos.mesh.utils.genericHelpers import getMultiBlockBounds

__doc__ = """
Expand Down Expand Up @@ -237,8 +237,8 @@ def __init__( self, speHandler: bool = False, **properties: str ) -> None:
self.logger.setLevel( logging.INFO )
self.logger.propagate = False

counter: CountWarningHandler = CountWarningHandler()
self.counter: CountWarningHandler
counter: CountVerbosityHandler = CountVerbosityHandler()
self.counter: CountVerbosityHandler
self.nbWarnings: int = 0
try:
self.counter = getLoggerHandlerType( type( counter ), self.logger )
Expand All @@ -259,6 +259,7 @@ def Update( self ) -> None: # type: ignore[override]
else:
self.logger.info( f"{ result }." )

# Keep number of warnings logged during the filter application and reset the warnings count in case the filter is applied again.
self.nbWarnings = self.counter.warningCount
self.counter.resetWarningCount()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from vtkmodules.vtkCommonDataModel import vtkMultiBlockDataSet, vtkDataSet

from geos.utils.pieceEnum import Piece
from geos.utils.Logger import ( getLogger, Logger, CountWarningHandler, isHandlerInLogger, getLoggerHandlerType )
from geos.utils.Logger import ( getLogger, Logger, CountVerbosityHandler, isHandlerInLogger, getLoggerHandlerType )
from geos.mesh.utils.arrayHelpers import ( getArrayInObject, getComponentNames, getAttributePieceInfo,
getVtkArrayTypeInObject, getNumberOfComponents, checkValidValuesInObject )
from geos.mesh.utils.arrayModifiers import ( createAttribute, createConstantAttribute )
Expand Down Expand Up @@ -129,8 +129,8 @@ def __init__(
self.logger.setLevel( logging.INFO )
self.logger.propagate = False

counter: CountWarningHandler = CountWarningHandler()
self.counter: CountWarningHandler
counter: CountVerbosityHandler = CountVerbosityHandler()
self.counter: CountVerbosityHandler
self.nbWarnings: int = 0
try:
self.counter = getLoggerHandlerType( type( counter ), self.logger )
Expand Down Expand Up @@ -407,6 +407,7 @@ def _logOutputMessage( self: Self, trueIndexes: list[ Any ] ) -> None:
else:
self.logger.info( f"{ result }." )

# Keep number of warnings logged during the filter application and reset the warnings count in case the filter is applied again.
self.nbWarnings = self.counter.warningCount
self.counter.resetWarningCount()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from typing import Union, Any

from geos.utils.pieceEnum import Piece
from geos.utils.Logger import ( getLogger, Logger, CountWarningHandler, isHandlerInLogger, getLoggerHandlerType )
from geos.utils.Logger import ( getLogger, Logger, CountVerbosityHandler, isHandlerInLogger, getLoggerHandlerType )
from geos.mesh.utils.arrayModifiers import fillPartialAttributes
from geos.mesh.utils.arrayHelpers import getAttributePieceInfo

Expand Down Expand Up @@ -98,8 +98,8 @@ def __init__(
self.logger.setLevel( logging.INFO )
self.logger.propagate = False

counter: CountWarningHandler = CountWarningHandler()
self.counter: CountWarningHandler
counter: CountVerbosityHandler = CountVerbosityHandler()
self.counter: CountVerbosityHandler
self.nbWarnings: int = 0
try:
self.counter = getLoggerHandlerType( type( counter ), self.logger )
Expand Down Expand Up @@ -162,6 +162,7 @@ def applyFilter( self: Self ) -> None:
else:
self.logger.info( f"{ result }." )

# Keep number of warnings logged during the filter application and reset the warnings count in case the filter is applied again.
self.nbWarnings = self.counter.warningCount
self.counter.resetWarningCount()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from typing_extensions import Self

from geos.utils.Logger import ( getLogger, Logger, CountWarningHandler, isHandlerInLogger, getLoggerHandlerType )
from geos.utils.Logger import ( getLogger, Logger, CountVerbosityHandler, isHandlerInLogger, getLoggerHandlerType )
from geos.mesh.utils.multiblockModifiers import mergeBlocks

from vtkmodules.vtkCommonDataModel import vtkMultiBlockDataSet, vtkUnstructuredGrid
Expand Down Expand Up @@ -91,8 +91,8 @@ def __init__(
self.logger.setLevel( logging.INFO )
self.logger.propagate = False

counter: CountWarningHandler = CountWarningHandler()
self.counter: CountWarningHandler
counter: CountVerbosityHandler = CountVerbosityHandler()
self.counter: CountVerbosityHandler
self.nbWarnings: int = 0
try:
self.counter = getLoggerHandlerType( type( counter ), self.logger )
Expand Down Expand Up @@ -134,6 +134,7 @@ def applyFilter( self: Self ) -> None:
else:
self.logger.info( f"{ result }." )

# Keep number of warnings logged during the filter application and reset the warnings count in case the filter is applied again.
self.nbWarnings = self.counter.warningCount
self.counter.resetWarningCount()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
VTK_POLYHEDRON, VTK_POLYGON )
from vtkmodules.util.numpy_support import numpy_to_vtk, vtk_to_numpy

from geos.utils.Logger import ( getLogger, Logger, CountWarningHandler, isHandlerInLogger, getLoggerHandlerType )
from geos.utils.Logger import ( getLogger, Logger, CountVerbosityHandler, isHandlerInLogger, getLoggerHandlerType )
from geos.processing.pre_processing.CellTypeCounterEnhanced import CellTypeCounterEnhanced
from geos.mesh.model.CellTypeCounts import CellTypeCounts

Expand Down Expand Up @@ -86,13 +86,13 @@ def __init__( self, inputMesh: vtkUnstructuredGrid, speHandler: bool = False ) -
handlers: list[ logging.Handler ] = self.logger.handlers
# Get the handler to specify if the logger already exist and has it
for handler in handlers:
# The CountWarningHandler can't be the handler to specify
if type( handler ) is not type( CountWarningHandler() ):
# The CountVerbosityHandler can't be the handler to specify
if type( handler ) is not type( CountVerbosityHandler() ):
self.handler = handler
break

counter: CountWarningHandler = CountWarningHandler()
self.counter: CountWarningHandler
counter: CountVerbosityHandler = CountVerbosityHandler()
self.counter: CountVerbosityHandler
self.nbWarnings: int = 0
try:
self.counter = getLoggerHandlerType( type( counter ), self.logger )
Expand Down Expand Up @@ -196,6 +196,7 @@ def applyFilter( self: Self ) -> None:
else:
self.logger.info( f"{ result }." )

# Keep number of warnings logged during the filter application and reset the warnings count in case the filter is applied again.
self.nbWarnings = self.counter.warningCount
self.counter.resetWarningCount()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from geos.mesh.utils.arrayHelpers import ( getArrayInObject, isAttributeInObject )

from geos.utils.pieceEnum import Piece
from geos.utils.Logger import ( getLogger, Logger, CountWarningHandler, isHandlerInLogger, getLoggerHandlerType )
from geos.utils.Logger import ( getLogger, Logger, CountVerbosityHandler, isHandlerInLogger, getLoggerHandlerType )
from geos.utils.GeosOutputsConstants import ( AttributeEnum, ComponentNameEnum, GeosMeshOutputsEnum,
PostProcessingOutputsEnum )
from geos.utils.PhysicalConstants import ( DEFAULT_FRICTION_ANGLE_RAD, DEFAULT_GRAIN_BULK_MODULUS,
Expand Down Expand Up @@ -712,8 +712,8 @@ def __init__(
self.logger.setLevel( logging.INFO )
self.logger.propagate = False

counter: CountWarningHandler = CountWarningHandler()
self.counter: CountWarningHandler
counter: CountVerbosityHandler = CountVerbosityHandler()
self.counter: CountVerbosityHandler
self.nbWarnings: int = 0
try:
self.counter = getLoggerHandlerType( type( counter ), self.logger )
Expand Down Expand Up @@ -768,6 +768,7 @@ def applyFilter( self: Self ) -> None:
else:
self.logger.info( f"{ result }." )

# Keep number of warnings logged during the filter application and reset the warnings count in case the filter is applied again.
self.nbWarnings = self.counter.warningCount
self.counter.resetWarningCount()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from dataclasses import dataclass
from typing_extensions import Self

from geos.utils.Logger import ( getLogger, Logger, CountWarningHandler, isHandlerInLogger, getLoggerHandlerType )
from geos.utils.Logger import ( getLogger, Logger, CountVerbosityHandler, isHandlerInLogger, getLoggerHandlerType )
from geos.utils.GeosOutputsConstants import GeosDomainNameEnum
from geos.mesh.utils.arrayHelpers import getCellDimension
from geos.mesh.utils.multiblockHelpers import getBlockIndexFromName
Expand Down Expand Up @@ -193,8 +193,8 @@ def __init__(
self.logger.setLevel( logging.INFO )
self.logger.propagate = False

counter: CountWarningHandler = CountWarningHandler()
self.counter: CountWarningHandler
counter: CountVerbosityHandler = CountVerbosityHandler()
self.counter: CountVerbosityHandler
self.nbWarnings: int = 0
try:
self.counter = getLoggerHandlerType( type( counter ), self.logger )
Expand Down Expand Up @@ -245,6 +245,7 @@ def applyFilter( self: Self ) -> None:
else:
self.logger.info( f"{ result }." )

# Keep number of warnings logged during the filter application and reset the warnings count in case the filter is applied again.
self.nbWarnings = self.counter.warningCount
self.counter.resetWarningCount()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from vtkmodules.vtkCommonDataModel import vtkCompositeDataSet, vtkMultiBlockDataSet, vtkPolyData, vtkUnstructuredGrid

from geos.utils.pieceEnum import Piece
from geos.utils.Logger import ( getLogger, Logger, CountWarningHandler, isHandlerInLogger, getLoggerHandlerType )
from geos.utils.Logger import ( getLogger, Logger, CountVerbosityHandler, isHandlerInLogger, getLoggerHandlerType )
from geos.utils.GeosOutputsConstants import ( PHASE_SEP, PhaseTypeEnum, FluidPrefixEnum, PostProcessingOutputsEnum,
getRockSuffixRenaming )

Expand Down Expand Up @@ -111,8 +111,8 @@ def __init__(
self.logger.setLevel( logging.INFO )
self.logger.propagate = False

counter: CountWarningHandler = CountWarningHandler()
self.counter: CountWarningHandler
counter: CountVerbosityHandler = CountVerbosityHandler()
self.counter: CountVerbosityHandler
self.nbWarnings: int = 0
try:
self.counter = getLoggerHandlerType( type( counter ), self.logger )
Expand Down Expand Up @@ -198,6 +198,7 @@ def applyFilter( self: Self ) -> None:
else:
self.logger.info( f"{ result }." )

# Keep number of warnings logged during the filter application and reset the warnings count in case the filter is applied again.
self.nbWarnings = self.counter.warningCount
self.counter.resetWarningCount()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from geos.mesh.utils.genericHelpers import ( getLocalBasisVectors, convertAttributeFromLocalToXYZForOneCell )
import geos.geomechanics.processing.geomechanicsCalculatorFunctions as fcts
from geos.utils.pieceEnum import Piece
from geos.utils.Logger import ( getLogger, Logger, CountWarningHandler, isHandlerInLogger, getLoggerHandlerType )
from geos.utils.Logger import ( getLogger, Logger, CountVerbosityHandler, isHandlerInLogger, getLoggerHandlerType )
from geos.utils.PhysicalConstants import ( DEFAULT_FRICTION_ANGLE_RAD, DEFAULT_ROCK_COHESION )
from geos.utils.GeosOutputsConstants import ( ComponentNameEnum, GeosMeshOutputsEnum, PostProcessingOutputsEnum )

Expand Down Expand Up @@ -65,7 +65,7 @@
# Do calculations
try:
sg.applyFilter()
except ( ValueError, VTKError, AttributeError, AssertionError ) as e:
except ( ValueError, VTKError, AttributeError, AssertionError, TypeError ) as e:
sg.logger.error( f"The filter { sg.logger.name } failed due to: { e }" )
except Exception as e:
mess: str = f"The filter { sg.logger.name } failed due to: { e }"
Expand Down Expand Up @@ -119,8 +119,8 @@ def __init__(
self.logger.setLevel( logging.INFO )
self.logger.propagate = False

counter: CountWarningHandler = CountWarningHandler()
self.counter: CountWarningHandler
counter: CountVerbosityHandler = CountVerbosityHandler()
self.counter: CountVerbosityHandler
self.nbWarnings: int = 0
try:
self.counter = getLoggerHandlerType( type( counter ), self.logger )
Expand All @@ -131,9 +131,6 @@ def __init__(

self.logger.addHandler( self.counter )

# Input surfacic mesh
if not surfacicMesh.IsA( "vtkPolyData" ):
self.logger.error( f"Input surface is expected to be a vtkPolyData, not a { type( surfacicMesh ) }." )
self.inputMesh: vtkPolyData = surfacicMesh
# Identification of the input surface (logging purpose)
self.name: Union[ str, None ] = None
Expand Down Expand Up @@ -241,13 +238,18 @@ def applyFilter( self: Self ) -> None:
"""Compute Geomechanical properties on input surface.

Raises:
TypeError: Error with the type of the input mesh.
ValueError: Errors during the creation of an attribute.
VTKError: Error raises during the call of VTK function.
AttributeError: Attributes must be on cell.
AssertionError: Something went wrong during the shearCapacityUtilization computation.
"""
self.logger.info( f"Apply filter { self.logger.name }." )

# Input surfacic mesh
if not self.inputMesh.IsA( "vtkPolyData" ):
raise TypeError( f"Input surface is expected to be a vtkPolyData, not a { type( self.inputMesh ) }." )

self.outputMesh = vtkPolyData()
self.outputMesh.ShallowCopy( self.inputMesh )

Expand All @@ -265,6 +267,7 @@ def applyFilter( self: Self ) -> None:
else:
self.logger.info( f"{ result }." )

# Keep number of warnings logged during the filter application and reset the warnings count in case the filter is applied again.
self.nbWarnings = self.counter.warningCount
self.counter.resetWarningCount()

Expand Down Expand Up @@ -352,6 +355,9 @@ def __computeXYZCoordinates(

Returns:
npt.NDArray[np.float64]: Vector of new coordinates of the attribute.

Raises:
ValueError: Error with the shape of attrArray or the computation of the attribute coordinates.
"""
attrXYZ: npt.NDArray[ np.float64 ] = np.full_like( attrArray, np.nan )

Expand All @@ -369,17 +375,12 @@ def __computeXYZCoordinates(
attrXYZ[ i ] = convertAttributeFromLocalToXYZForOneCell( cellAttribute, cellLocalBasis )

if not np.any( np.isfinite( attrXYZ ) ):
self.logger.error( "Attribute new coordinate calculation failed." )
raise ValueError( "Attribute new coordinates calculation failed." )

return attrXYZ

def computeShearCapacityUtilization( self: Self ) -> None:
"""Compute the shear capacity utilization (SCU) on surface.

Raises:
ValueError: Something went wrong during the creation of an attribute.
AssertionError: Something went wrong during the shearCapacityUtilization computation.
"""
"""Compute the shear capacity utilization (SCU) on surface."""
SCUAttributeName: str = PostProcessingOutputsEnum.SCU.attributeName

if not isAttributeInObject( self.outputMesh, SCUAttributeName, self.attributePiece ):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from geos.mesh.model.CellTypeCounts import CellTypeCounts
from geos.mesh.stats.meshQualityMetricHelpers import getAllCellTypes
from geos.utils.Logger import ( getLogger, Logger, CountWarningHandler, isHandlerInLogger, getLoggerHandlerType )
from geos.utils.Logger import ( getLogger, Logger, CountVerbosityHandler, isHandlerInLogger, getLoggerHandlerType )

__doc__ = """
CellTypeCounterEnhanced module is a vtk filter that computes cell type counts.
Expand Down Expand Up @@ -77,8 +77,8 @@ def __init__(
self.logger.setLevel( logging.INFO )
self.logger.propagate = False

counter: CountWarningHandler = CountWarningHandler()
self.counter: CountWarningHandler
counter: CountVerbosityHandler = CountVerbosityHandler()
self.counter: CountVerbosityHandler
self.nbWarnings: int = 0
try:
self.counter = getLoggerHandlerType( type( counter ), self.logger )
Expand Down Expand Up @@ -139,6 +139,7 @@ def applyFilter( self: Self ) -> None:
else:
self.logger.info( f"{ result }." )

# Keep number of warnings logged during the filter application and reset the warnings count in case the filter is applied again.
self.nbWarnings = self.counter.warningCount
self.counter.resetWarningCount()

Expand Down
Loading