Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
e7447e4
Move GeosBlockExtractor to geos-mesh
RomainBaville Sep 26, 2025
89c8f0c
Remove getBlockFromName
RomainBaville Sep 26, 2025
f9b2e3f
Refactor using vtkExtractBlock instead of vtkPythonAlgorithmBase
RomainBaville Sep 26, 2025
bcf5d59
Update and clean the doc
RomainBaville Sep 26, 2025
889f59a
Update file using GeosExtractBlock
RomainBaville Sep 26, 2025
22abd05
fix the ci
RomainBaville Oct 6, 2025
a524d2d
Merge branch 'main' into RomainBaville/refactor/MoveGeosBlockExtractor
RomainBaville Oct 8, 2025
063ee86
Merge branch 'main' into RomainBaville/refactor/MoveGeosBlockExtractor
RomainBaville Oct 15, 2025
e577e07
Use dataclass for the extracted domain
RomainBaville Oct 15, 2025
445711f
Update the doc
RomainBaville Oct 15, 2025
7d79d28
Update de doc
RomainBaville Oct 15, 2025
e5835d0
fix AddGeosDomainIndex function
RomainBaville Oct 15, 2025
57c29e2
Merge branch 'main' into RomainBaville/refactor/MoveGeosBlockExtractor
RomainBaville Oct 15, 2025
c81193d
Add the test file and the test mesh
RomainBaville Oct 15, 2025
c22e876
Clarify the variable names and the doc
RomainBaville Oct 22, 2025
70b9358
Merge branch 'main' into RomainBaville/refactor/MoveGeosBlockExtractor
RomainBaville Oct 22, 2025
6a922d3
Test CI labels identification and dispatch
alexbenedicto Oct 23, 2025
14ea06c
Merge branch 'main' into RomainBaville/refactor/MoveGeosBlockExtractor
alexbenedicto Oct 23, 2025
757732f
Fix docs
alexbenedicto Oct 23, 2025
323b315
Revert Test CI labels identification and dispatch to create a dedicat…
alexbenedicto Oct 24, 2025
4fbe721
add a mesh with a well only
RomainBaville Oct 24, 2025
354dae9
Add a function to get the cell dimension of a mesh
RomainBaville Oct 24, 2025
e782d7e
Apply Palomas and Jacques suggestion
RomainBaville Oct 24, 2025
86b09f5
Merge branch 'main' into RomainBaville/refactor/MoveGeosBlockExtractor
RomainBaville Oct 28, 2025
28122b5
move GeosExtractBlock in geos-processing
RomainBaville Oct 28, 2025
57fa533
fix bad move
RomainBaville Oct 28, 2025
0161e2b
update the doc files
RomainBaville Oct 28, 2025
70fcbfb
fix doc
RomainBaville Oct 28, 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
1 change: 1 addition & 0 deletions docs/geos_mesh_docs/processing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ geos.mesh.processing.FillPartialArrays filter
:undoc-members:
:show-inheritance:


geos.mesh.processing.meshQualityMetricHelpers module
-----------------------------------------------------

Expand Down
8 changes: 0 additions & 8 deletions docs/geos_posp_docs/filters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,6 @@ vtk Filters

This package defines vtk filters that allows to process Geos outputs.

geos_posp.filters.GeosBlockExtractor module
-----------------------------------------------

.. automodule:: geos_posp.filters.GeosBlockExtractor
:members:
:undoc-members:
:show-inheritance:

geos_posp.filters.GeosBlockMerge module
-------------------------------------------

Expand Down
10 changes: 9 additions & 1 deletion docs/geos_processing_docs/post_processing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,12 @@ geos.processing.post_processing.GeomechanicsCalculator module
.. automodule:: geos.processing.post_processing.GeomechanicsCalculator
:members:
:undoc-members:
:show-inheritance:
:show-inheritance:

geos.processing.post_processing.GeosBlockExtractor module
----------------------------------------------------------

.. automodule:: geos.processing.post_processing.GeosBlockExtractor
:members:
:undoc-members:
:show-inheritance:
52 changes: 52 additions & 0 deletions geos-mesh/src/geos/mesh/utils/arrayHelpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,58 @@
"""


def getCellDimension( mesh: Union[ vtkMultiBlockDataSet, vtkDataSet ] ) -> set[ int ]:
"""Get the set of the different cells dimension of a mesh.

Args:
mesh (Union[vtkMultiBlockDataSet, vtkDataSet]): The input mesh with the cells dimension to get.

Returns:
set[int]: The set of the different cells dimension in the input mesh.
"""
if isinstance( mesh, vtkDataSet ):
return getCellDimensionDataSet( mesh )
elif isinstance( mesh, vtkMultiBlockDataSet ):
return getCellDimensionMultiBlockDataSet( mesh )
else:
raise TypeError( "The input mesh must be a vtkMultiBlockDataSet or a vtkDataSet." )


def getCellDimensionMultiBlockDataSet( multiBlockDataSet: vtkMultiBlockDataSet ) -> set[ int ]:
"""Get the set of the different cells dimension of a multiBlockDataSet.

Args:
multiBlockDataSet (vtkMultiBlockDataSet): The input mesh with the cells dimension to get.

Returns:
set[int]: The set of the different cells dimension in the input multiBlockDataSet.
"""
cellDim: set[ int ] = set()
listFlatIdDataSet: list[ int ] = getBlockElementIndexesFlatten( multiBlockDataSet )
for flatIdDataSet in listFlatIdDataSet:
dataSet: vtkDataSet = vtkDataSet.SafeDownCast( multiBlockDataSet.GetDataSet( flatIdDataSet ) )
cellDim = cellDim.union( getCellDimensionDataSet( dataSet ) )
return cellDim


def getCellDimensionDataSet( dataSet: vtkDataSet ) -> set[ int ]:
"""Get the set of the different cells dimension of a dataSet.

Args:
dataSet (vtkDataSet): The input mesh with the cells dimension to get.

Returns:
set[int]: The set of the different cells dimension in the input dataSet.
"""
cellDim: set[ int ] = set()
cellIter = dataSet.NewCellIterator()
cellIter.InitTraversal()
while not cellIter.IsDoneWithTraversal():
cellDim.add( cellIter.GetCellDimension() )
cellIter.GoToNextCell()
return cellDim


def computeElementMapping(
meshFrom: Union[ vtkDataSet, vtkMultiBlockDataSet ],
meshTo: Union[ vtkDataSet, vtkMultiBlockDataSet ],
Expand Down
23 changes: 0 additions & 23 deletions geos-mesh/src/geos/mesh/utils/multiblockHelpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,29 +190,6 @@ def getBlockFromFlatIndex( multiBlockDataSet: Union[ vtkMultiBlockDataSet, vtkCo
return None


def getBlockFromName( multiBlockDataSet: Union[ vtkMultiBlockDataSet, vtkCompositeDataSet ],
blockName: str ) -> Union[ None, vtkDataObject ]:
"""Get the block named blockName from the vtkMultiBlockDataSet.

Args:
multiBlockDataSet (vtkMultiBlockDataSet | vtkCompositeDataSet): MultiBlockDataSet with the block to get.
blockName (str): The name of the block to get.

Returns:
Union[None, vtkDataObject]: The block name blockName if it exists, None otherwise
"""
# initialize data object tree iterator
iterator: vtkDataObjectTreeIterator = vtkDataObjectTreeIterator()
iterator.SetDataSet( multiBlockDataSet )
iterator.VisitOnlyLeavesOff()
iterator.GoToFirstItem()
while iterator.GetCurrentDataObject() is not None:
if iterator.GetCurrentMetaData().Get( vtkMultiBlockDataSet.NAME() ) == blockName:
return iterator.GetCurrentDataObject()
iterator.GoToNextItem()
return None


def extractBlock( multiBlockDataSet: vtkMultiBlockDataSet, blockIndex: int ) -> vtkMultiBlockDataSet:
"""Extract the block with index blockIndex from multiBlockDataSet.

Expand Down
6 changes: 5 additions & 1 deletion geos-mesh/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import numpy.typing as npt

from vtkmodules.vtkCommonDataModel import vtkDataSet, vtkMultiBlockDataSet, vtkPolyData
from vtkmodules.vtkIOXML import vtkXMLGenericDataObjectReader, vtkXMLMultiBlockDataReader
from vtkmodules.vtkIOXML import vtkXMLGenericDataObjectReader


@pytest.fixture
Expand Down Expand Up @@ -178,6 +178,10 @@ def _get_dataset( datasetType: str ) -> Union[ vtkMultiBlockDataSet, vtkPolyData
vtkFilename = "data/fracture_res5_id.vtp"
elif datasetType == "emptypolydata":
vtkFilename = "data/fracture_res5_id_empty.vtp"
elif datasetType == "meshGeosExtractBlockTmp":
vtkFilename = "data/meshGeosExtractBlockTmp.vtm"
elif datasetType == "well":
vtkFilename = "data/well.vtu"
datapath: str = os.path.join( os.path.dirname( os.path.realpath( __file__ ) ), vtkFilename )
reader.SetFileName( datapath )
reader.Update()
Expand Down
16 changes: 16 additions & 0 deletions geos-mesh/tests/data/meshGeosExtractBlockTmp.vtm
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0"?>
<VTKFile type="vtkMultiBlockDataSet" version="1.0">
<vtkMultiBlockDataSet>
<Block name="CellElementRegion">
<DataSet name="domain" file="domain_res5_id.vtu"/>
<DataSet name="emptyDomain" file="domain_res5_id_empty.vtu"/>
</Block>
<Block name="SurfaceElementRegion">
<DataSet name="fracture" file="fracture_res5_id.vtu"/>
<DataSet name="emptyFracture" file="fracture_res5_id_empty.vtu"/>
</Block>
<Block name="WellElementRegion">
<DataSet name="well" file="well.vtu"/>
</Block>
</vtkMultiBlockDataSet>
</VTKFile>
48 changes: 48 additions & 0 deletions geos-mesh/tests/data/well.vtu
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<VTKFile type="UnstructuredGrid" version="1.0" byte_order="LittleEndian" header_type="UInt64" compressor="vtkZLibDataCompressor">
<UnstructuredGrid>
<Piece NumberOfPoints="11" NumberOfCells="10">
<PointData>
<DataArray type="Float32" Name="DistanceToCenter" format="binary" RangeMin="0" RangeMax="5">
AQAAAAAAAAAAgAAAAAAAACwAAAAAAAAAIQAAAAAAAAA=eF5jYFjgwMDQAMQOQMwAYtszgAGYhoqD5Bc4AACHAgY/
</DataArray>
<DataArray type="Float32" Name="Polynomial" format="binary" RangeMin="1" RangeMax="11">
AQAAAAAAAAAAgAAAAAAAACwAAAAAAAAAKAAAAAAAAAA=eF5jYGiwZ2BgcAAiIG4A4gVAfACIHwAxgyMDgwAQKwCxgSMAmJ8GpA==
</DataArray>
</PointData>
<CellData>
</CellData>
<Points>
<DataArray type="Float32" Name="Points" NumberOfComponents="3" format="binary" RangeMin="0" RangeMax="10">
AQAAAAAAAAAAgAAAAAAAAIQAAAAAAAAAKQAAAAAAAAA=eF5jYEAGDfZIHAckJhK7AYm9AIl9AIn9AInN4IhgCiCxFeBsAJt9BjM=
<InformationKey name="L2_NORM_FINITE_RANGE" location="vtkDataArray" length="2">
<Value index="0">
0
</Value>
<Value index="1">
10
</Value>
</InformationKey>
<InformationKey name="L2_NORM_RANGE" location="vtkDataArray" length="2">
<Value index="0">
0
</Value>
<Value index="1">
10
</Value>
</InformationKey>
</DataArray>
</Points>
<Cells>
<DataArray type="Int64" Name="connectivity" format="binary" RangeMin="0" RangeMax="10">
AQAAAAAAAAAAgAAAAAAAAKAAAAAAAAAAJgAAAAAAAAA=eF5dxTkCABAMALA6i/8/2MCULIl4Cldu3Hnw5OTFm8//Ahb4AGU=
</DataArray>
<DataArray type="Int64" Name="offsets" format="binary" RangeMin="2" RangeMax="20">
AQAAAAAAAAAAgAAAAAAAAFAAAAAAAAAAIwAAAAAAAAA=eF5jYoAAFijNBqU5oDQXlOaB0nxQWgBKC0FpESgNAA4QAG8=
</DataArray>
<DataArray type="UInt8" Name="types" format="binary" RangeMin="3" RangeMax="3">
AQAAAAAAAAAAgAAAAAAAAAoAAAAAAAAACwAAAAAAAAA=eF5jZoYBAACvAB8=
</DataArray>
</Cells>
</Piece>
</UnstructuredGrid>
</VTKFile>
17 changes: 17 additions & 0 deletions geos-mesh/tests/test_arrayHelpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,23 @@
from geos.mesh.utils.arrayModifiers import createConstantAttribute


@pytest.mark.parametrize( "meshName, cellDimExpected", [
( "dataset", { 3 } ),
( "fracture", { 2 } ),
( "well", { 1 } ),
( "meshGeosExtractBlockTmp", { 3, 2, 1 } ),
] )
def test_getCellDimension(
dataSetTest: vtkDataSet,
meshName: str,
cellDimExpected: set[ int ],
) -> None:
"""Test getting the different cells dimension in a mesh."""
mesh: Union[ vtkDataSet, vtkMultiBlockDataSet ] = dataSetTest( meshName )
cellDimObtained: set[ int ] = arrayHelpers.getCellDimension( mesh )
assert cellDimObtained == cellDimExpected


@pytest.mark.parametrize( "meshFromName, meshToName, points", [
( "multiblock", "emptymultiblock", False ),
( "multiblock", "emptyFracture", False ),
Expand Down
10 changes: 4 additions & 6 deletions geos-posp/src/PVplugins/PVExtractMergeBlocksVolume.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
getAttributeToTransferFromInitialTime,
)
from geos.utils.Logger import ERROR, INFO, Logger, getLogger
from geos_posp.filters.GeosBlockExtractor import GeosBlockExtractor
from geos.processing.post_processing.GeosBlockExtractor import GeosBlockExtractor
from geos_posp.filters.GeosBlockMerge import GeosBlockMerge
from geos.mesh.utils.arrayModifiers import (
copyAttribute,
Expand Down Expand Up @@ -277,13 +277,11 @@ def doExtractAndMerge( self: Self, input: vtkMultiBlockDataSet, output: vtkMulti
bool: True if extraction and merge successfully eneded, False otherwise
"""
# extract blocks
blockExtractor: GeosBlockExtractor = GeosBlockExtractor()
blockExtractor.SetLogger( self.m_logger )
blockExtractor.SetInputDataObject( input )
blockExtractor.Update()
blockExtractor: GeosBlockExtractor = GeosBlockExtractor( input )
blockExtractor.applyFilter()

# recover output objects from GeosBlockExtractor filter
volumeBlockExtracted: vtkMultiBlockDataSet = blockExtractor.getOutputVolume()
volumeBlockExtracted: vtkMultiBlockDataSet = blockExtractor.extractedGeosDomain.volume
assert volumeBlockExtracted is not None, "Extracted Volume mesh is null."

# merge internal blocks
Expand Down
13 changes: 5 additions & 8 deletions geos-posp/src/PVplugins/PVExtractMergeBlocksVolumeSurface.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
getAttributeToTransferFromInitialTime,
)
from geos.utils.Logger import ERROR, INFO, Logger, getLogger
from geos_posp.filters.GeosBlockExtractor import GeosBlockExtractor
from geos.processing.post_processing.GeosBlockExtractor import GeosBlockExtractor
from geos_posp.filters.GeosBlockMerge import GeosBlockMerge
from geos.mesh.utils.arrayModifiers import (
copyAttribute,
Expand Down Expand Up @@ -292,15 +292,12 @@ def doExtractAndMerge(
bool: True if extraction and merge successfully eneded, False otherwise
"""
# extract blocks
blockExtractor: GeosBlockExtractor = GeosBlockExtractor()
blockExtractor.SetLogger( self.m_logger )
blockExtractor.SetInputDataObject( input )
blockExtractor.ExtractFaultsOn()
blockExtractor.Update()
blockExtractor: GeosBlockExtractor = GeosBlockExtractor( input, extractFault=True )
blockExtractor.applyFilter()

# recover output objects from GeosBlockExtractor filter
volumeBlockExtracted: vtkMultiBlockDataSet = blockExtractor.getOutputVolume()
faultBlockExtracted: vtkMultiBlockDataSet = blockExtractor.getOutputFaults()
volumeBlockExtracted: vtkMultiBlockDataSet = blockExtractor.extractedGeosDomain.volume
faultBlockExtracted: vtkMultiBlockDataSet = blockExtractor.extractedGeosDomain.fault

# rename attributes and merge blocks
assert volumeBlockExtracted is not None, "Extracted Volume mesh is null."
Expand Down
16 changes: 6 additions & 10 deletions geos-posp/src/PVplugins/PVExtractMergeBlocksVolumeSurfaceWell.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
getAttributeToTransferFromInitialTime,
)
from geos.utils.Logger import ERROR, INFO, Logger, getLogger
from geos_posp.filters.GeosBlockExtractor import GeosBlockExtractor
from geos.processing.post_processing.GeosBlockExtractor import GeosBlockExtractor
from geos_posp.filters.GeosBlockMerge import GeosBlockMerge
from geos.mesh.utils.arrayModifiers import (
copyAttribute,
Expand Down Expand Up @@ -316,23 +316,19 @@ def doExtractAndMerge(
bool: True if extraction and merge successfully eneded, False otherwise
"""
# extract blocks
blockExtractor: GeosBlockExtractor = GeosBlockExtractor()
blockExtractor.SetLogger( self.m_logger )
blockExtractor.SetInputDataObject( input )
blockExtractor.ExtractFaultsOn()
blockExtractor.ExtractWellsOn()
blockExtractor.Update()
blockExtractor: GeosBlockExtractor = GeosBlockExtractor( input, extractFaults=True, extractWells=True )
blockExtractor.applyFilter()

# recover output objects from GeosBlockExtractor filter and merge internal blocks
volumeBlockExtracted: vtkMultiBlockDataSet = blockExtractor.getOutputVolume()
volumeBlockExtracted: vtkMultiBlockDataSet = blockExtractor.extractedGeosDomain.volume
assert volumeBlockExtracted is not None, "Extracted Volume mesh is null."
outputCells.ShallowCopy( self.mergeBlocksFilter( volumeBlockExtracted, False ) )

faultBlockExtracted: vtkMultiBlockDataSet = blockExtractor.getOutputFaults()
faultBlockExtracted: vtkMultiBlockDataSet = blockExtractor.extractedGeosDomain.fault
assert faultBlockExtracted is not None, "Extracted Fault mesh is null."
outputFaults.ShallowCopy( self.mergeBlocksFilter( faultBlockExtracted, True ) )

wellBlockExtracted: vtkMultiBlockDataSet = blockExtractor.getOutputWells()
wellBlockExtracted: vtkMultiBlockDataSet = blockExtractor.extractedGeosDomain.well
assert wellBlockExtracted is not None, "Extracted Well mesh is null."
outputWells.ShallowCopy( self.mergeBlocksFilter( wellBlockExtracted, False ) )

Expand Down
14 changes: 5 additions & 9 deletions geos-posp/src/PVplugins/PVExtractMergeBlocksVolumeWell.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
getAttributeToTransferFromInitialTime,
)
from geos.utils.Logger import ERROR, INFO, Logger, getLogger
from geos_posp.filters.GeosBlockExtractor import GeosBlockExtractor
from geos.processing.post_processing.GeosBlockExtractor import GeosBlockExtractor
from geos_posp.filters.GeosBlockMerge import GeosBlockMerge
from geos.mesh.utils.arrayModifiers import (
copyAttribute,
Expand Down Expand Up @@ -302,19 +302,15 @@ def doExtractAndMerge(
bool: True if extraction and merge successfully eneded, False otherwise
"""
# extract blocks
blockExtractor: GeosBlockExtractor = GeosBlockExtractor()
blockExtractor.SetLogger( self.m_logger )
blockExtractor.SetInputDataObject( input )
blockExtractor.ExtractFaultsOff()
blockExtractor.ExtractWellsOn()
blockExtractor.Update()
blockExtractor: GeosBlockExtractor = GeosBlockExtractor( input, extractWells=True )
blockExtractor.applyFilter()

# recover output objects from GeosBlockExtractor filter and merge internal blocks
volumeBlockExtracted: vtkMultiBlockDataSet = blockExtractor.getOutputVolume()
volumeBlockExtracted: vtkMultiBlockDataSet = blockExtractor.extractedGeosDomain.volume
assert volumeBlockExtracted is not None, "Extracted Volume mesh is null."
outputCells.ShallowCopy( self.mergeBlocksFilter( volumeBlockExtracted, False ) )

wellBlockExtracted: vtkMultiBlockDataSet = blockExtractor.getOutputWells()
wellBlockExtracted: vtkMultiBlockDataSet = blockExtractor.extractedGeosDomain.well
assert wellBlockExtracted is not None, "Extracted Well mesh is null."
outputWells.ShallowCopy( self.mergeBlocksFilter( wellBlockExtracted, False ) )

Expand Down
Loading