Skip to content

Commit 8d2304a

Browse files
Merge branch 'main' into pmartinez/refactor/mohrCircleRefactor
2 parents 3dab338 + e752019 commit 8d2304a

File tree

21 files changed

+408
-508
lines changed

21 files changed

+408
-508
lines changed

docs/geos_posp_docs/filters.rst

Lines changed: 0 additions & 12 deletions
This file was deleted.

docs/geos_posp_docs/modules.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,4 @@ Processing
44
.. toctree::
55
:maxdepth: 5
66

7-
filters
8-
97
pyvistaTools

docs/geos_processing_docs/post_processing.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,12 @@ geos.processing.post_processing.GeosBlockExtractor module
4444
:members:
4545
:undoc-members:
4646
:show-inheritance:
47+
48+
49+
geos.processing.post_processing.GeosBlockMerge module
50+
-----------------------------------------------------
51+
52+
.. automodule:: geos.processing.post_processing.GeosBlockMerge
53+
:members:
54+
:undoc-members:
55+
:show-inheritance:

geos-ats/src/geos/ats/main.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import sys
1+
import sys
22
import os
33
import shutil
44
import signal
@@ -116,7 +116,7 @@ def getLogDirBaseName():
116116

117117
def create_log_directory( options ):
118118
"""
119-
When the action will run tests (e.g. "run", "rerun", "check", "continue", then the
119+
When the action will run tests (e.g. "run", "rerun", "check", "continue"), then the
120120
LogDir is numbered, and saved. When the action does not run
121121
tests, the LogDir is temporary, and only sticks around if geos_ats
122122
exited abnormally.
@@ -150,10 +150,8 @@ def create_log_directory( options ):
150150
logger.error( "unable to name a symlink to to logdir" )
151151

152152
else:
153-
if options.action in test_actions:
154-
options.logs = "%s.%s" % ( getLogDirBaseName(), options.action )
155-
elif options.info:
156-
options.logs = "%s.info" % ( getLogDirBaseName() )
153+
# For non-test actions (list, report, etc.)
154+
options.logs = "%s.%s" % ( getLogDirBaseName(), options.action )
157155
else:
158156
if not os.path.join( options.logs ):
159157
os.mkdir( options.logs )

geos-ats/src/geos/ats/test_case.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,13 @@ def initialize( self, name, desc, label=None, labels=None, steps=[], batch=Batch
9393
logger.debug( e )
9494
raise Exception()
9595

96+
# Setup labels
97+
if labels is None:
98+
labels = []
99+
if label is not None:
100+
labels = labels + [ label ]
101+
self.labels = labels
102+
96103
# Setup other parameters
97104
self.dictionary = {}
98105
self.dictionary.update( kw )

geos-mesh/src/geos/mesh/doctor/actions/checkFractures.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def formatCollocatedNodes( fractureMesh: vtkUnstructuredGrid ) -> Sequence[ Iter
5252
Returns:
5353
Sequence[ Iterable[ int ] ]: An iterable over all the buckets of collocated nodes.
5454
"""
55-
collocatedNodes: numpy.ndarray = vtk_to_numpy( fractureMesh.GetPointData().GetArray( "collocatedNodes" ) )
55+
collocatedNodes: numpy.ndarray = vtk_to_numpy( fractureMesh.GetPointData().GetArray( "collocated_nodes" ) )
5656
if len( collocatedNodes.shape ) == 1:
5757
collocatedNodes: numpy.ndarray = collocatedNodes.reshape( ( collocatedNodes.shape[ 0 ], 1 ) )
5858
generator = ( tuple( sorted( bucket[ bucket > -1 ] ) ) for bucket in collocatedNodes )

geos-mesh/src/geos/mesh/doctor/actions/generateFractures.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,8 @@ def __generateFractureMesh( oldMesh: vtkUnstructuredGrid, fractureInfo: Fracture
521521
for j, val in enumerate( bucket ):
522522
collocatedNodes[ i, j ] = val
523523
array = numpy_to_vtk( collocatedNodes, array_type=VTK_ID_TYPE )
524-
array.SetName( "collocatedNodes" )
524+
array.SetName( "collocated_nodes" ) # Following the hardcoded naming convention used in GEOS for now:
525+
# src/coreComponents/mesh/generators/CollocatedNodes.cpp: string const COLLOCATED_NODES = "collocated_nodes";
525526

526527
fractureMesh = vtkUnstructuredGrid() # We could be using vtkPolyData, but it's not supported by GEOS for now.
527528
fractureMesh.SetPoints( points )

geos-mesh/src/geos/mesh/utils/genericHelpers.py

Lines changed: 117 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,24 @@
11
# SPDX-License-Identifier: Apache-2.0
22
# SPDX-FileCopyrightText: Copyright 2023-2024 TotalEnergies.
33
# SPDX-FileContributor: Martin Lemay, Paloma Martinez
4-
import numpy as np
54
import logging
5+
import numpy as np
66
import numpy.typing as npt
7-
from typing import Iterator, List, Sequence, Any, Union, Tuple
7+
from typing import ( Iterator, List, Sequence, Any, Union, Tuple )
8+
89
from vtkmodules.util.numpy_support import ( numpy_to_vtk, vtk_to_numpy )
910
from vtkmodules.vtkCommonCore import vtkIdList, vtkPoints, reference, vtkDataArray, vtkLogger, vtkFloatArray
10-
from vtkmodules.vtkCommonDataModel import (
11-
vtkUnstructuredGrid,
12-
vtkMultiBlockDataSet,
13-
vtkPolyData,
14-
vtkDataSet,
15-
vtkDataObject,
16-
vtkPlane,
17-
vtkCellTypes,
18-
vtkIncrementalOctreePointLocator,
19-
)
11+
from vtkmodules.vtkCommonDataModel import ( vtkUnstructuredGrid, vtkMultiBlockDataSet, vtkPolyData, vtkDataSet,
12+
vtkDataObject, vtkPlane, vtkCellTypes, vtkIncrementalOctreePointLocator,
13+
VTK_TRIANGLE )
2014
from vtkmodules.vtkFiltersCore import ( vtk3DLinearGridPlaneCutter, vtkPolyDataNormals, vtkPolyDataTangents )
2115
from vtkmodules.vtkFiltersTexture import vtkTextureMapToPlane
16+
from vtkmodules.vtkFiltersGeometry import vtkDataSetSurfaceFilter
17+
from vtkmodules.vtkFiltersGeneral import vtkDataSetTriangleFilter
2218

2319
from geos.mesh.utils.multiblockHelpers import ( getBlockElementIndexesFlatten, getBlockFromFlatIndex )
2420

25-
from geos.utils.algebraFunctions import (
26-
getAttributeMatrixFromVector,
27-
getAttributeVectorFromMatrix,
28-
)
21+
from geos.utils.algebraFunctions import ( getAttributeMatrixFromVector, getAttributeVectorFromMatrix )
2922
from geos.utils.geometryFunctions import ( getChangeOfBasisMatrix, CANONICAL_BASIS_3D )
3023
from geos.utils.Logger import ( getLogger, Logger, VTKCaptureLog, RegexExceptionFilter )
3124
from geos.utils.Errors import VTKError
@@ -40,6 +33,114 @@
4033
"""
4134

4235

36+
def isTriangulate( dataSet: vtkUnstructuredGrid ) -> bool:
37+
"""Check if the mesh is fully triangulated.
38+
39+
Args:
40+
dataSet (vtkUnstructuredGrid): The mesh to check
41+
42+
Returns:
43+
bool: True if the mesh is triangulate only, False otherwise.
44+
"""
45+
cellTypes: vtkCellTypes = vtkCellTypes()
46+
dataSet.GetCellTypes( cellTypes )
47+
48+
return all( cellTypes.GetCellType( cell ) == VTK_TRIANGLE for cell in range( cellTypes.GetNumberOfTypes() ) )
49+
50+
51+
def triangulateMesh(
52+
dataSet: vtkUnstructuredGrid,
53+
logger: Union[ Logger, None ] = None,
54+
) -> vtkUnstructuredGrid:
55+
"""Triangulate any type of dataset.
56+
57+
Args:
58+
dataSet (vtkUnstructuredGrid): The mesh to triangulate
59+
logger (Union[Logger, None], optional): A logger to manage the output messages.
60+
Defaults to None, an internal logger is used.
61+
62+
Returns:
63+
vtkUnstructuredGrid: Triangulated mesh
64+
"""
65+
if logger is None:
66+
logger = getLogger( "Triangulate", True )
67+
# Creation of a child logger to deal with VTKErrors without polluting parent logger
68+
vtkErrorLogger: Logger = getLogger( f"{logger.name}.vtkErrorLogger", True )
69+
vtkErrorLogger.propagate = False
70+
71+
vtkLogger.SetStderrVerbosity( vtkLogger.VERBOSITY_ERROR )
72+
73+
vtkErrorLogger.addFilter( RegexExceptionFilter() ) # will raise VTKError if captured VTK Error
74+
vtkErrorLogger.setLevel( logging.DEBUG )
75+
76+
with VTKCaptureLog() as capturedLog:
77+
triangulateMeshFilter: vtkDataSetTriangleFilter = vtkDataSetTriangleFilter()
78+
triangulateMeshFilter.SetInputData( dataSet )
79+
triangulateMeshFilter.Update()
80+
81+
capturedLog.seek( 0 )
82+
captured = capturedLog.read().decode()
83+
84+
vtkErrorLogger.debug( captured.strip() )
85+
86+
triangulatedMesh: vtkUnstructuredGrid = triangulateMeshFilter.GetOutput()
87+
88+
if triangulatedMesh.GetCellData() is None:
89+
raise VTKError( "Something went wrong with VTK triangulation of the mesh." )
90+
91+
return triangulatedMesh
92+
93+
94+
def convertUnstructuredGridToPolyData(
95+
dataSet: vtkUnstructuredGrid,
96+
logger: Union[ Logger, None ] = None,
97+
) -> vtkPolyData:
98+
"""Convert vtkUnstructuredGrid to vtkPolyData.
99+
100+
..Warning:: Work only with triangulated mesh
101+
102+
Args:
103+
dataSet (vtkUnstructuredGrid): Input mesh block
104+
logger (Union[Logger, None], optional): A logger to manage the output messages.
105+
Defaults to None, an internal logger is used.
106+
107+
Returns:
108+
vtkPolyData: Extracted surface
109+
"""
110+
if logger is None:
111+
logger = getLogger( "ConvertVtkUnstructuredGridToVtkPolyData.", True )
112+
# Creation of a child logger to deal with VTKErrors without polluting parent logger
113+
vtkErrorLogger: Logger = getLogger( f"{logger.name}.vtkErrorLogger", True )
114+
vtkErrorLogger.propagate = False
115+
116+
vtkLogger.SetStderrVerbosity( vtkLogger.VERBOSITY_ERROR )
117+
118+
vtkErrorLogger.addFilter( RegexExceptionFilter() ) # will raise VTKError if captured VTK Error
119+
vtkErrorLogger.setLevel( logging.DEBUG )
120+
121+
with VTKCaptureLog() as capturedLog:
122+
extractSurfaceFilter: vtkDataSetSurfaceFilter = vtkDataSetSurfaceFilter()
123+
extractSurfaceFilter.SetInputData( dataSet )
124+
# fast mode should be used for rendering only
125+
extractSurfaceFilter.FastModeOff()
126+
# Delegation activated allow to accelerate the processing with unstructured mesh
127+
# see https://vtk.org/doc/nightly/html/classvtkDataSetSurfaceFilter.html
128+
extractSurfaceFilter.DelegationOn()
129+
extractSurfaceFilter.Update()
130+
131+
capturedLog.seek( 0 )
132+
captured = capturedLog.read().decode()
133+
134+
vtkErrorLogger.debug( captured.strip() )
135+
136+
extractedSurface: vtkPolyData = extractSurfaceFilter.GetOutput()
137+
138+
if extractedSurface is None:
139+
raise VTKError( "Something went wrong with VTK convert vtu to vtp." )
140+
141+
return extractedSurface
142+
143+
43144
def toVtkIdList( data: List[ int ] ) -> vtkIdList:
44145
"""Utility function transforming a list of ids into a vtkIdList.
45146

geos-mesh/tests/data/fracture_res5_id.vtp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PolyData>
44
<Piece NumberOfPoints="212" NumberOfVerts="0" NumberOfLines="0" NumberOfStrips="0" NumberOfPolys="156" >
55
<PointData GlobalIds="GLOBAL_IDS_POINTS">
6-
<DataArray type="Int64" IdType="1" Name="collocatedNodes" NumberOfComponents="2" format="appended" RangeMin="3905.8931117" RangeMax="5326.4624283" offset="0" >
6+
<DataArray type="Int64" IdType="1" Name="collocated_nodes" NumberOfComponents="2" format="appended" RangeMin="3905.8931117" RangeMax="5326.4624283" offset="0" >
77
<InformationKey name="L2_NORM_RANGE" location="vtkDataArray" length="2">
88
<Value index="0">
99
3905.8931117

geos-mesh/tests/data/fracture_res5_id.vtu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<UnstructuredGrid>
44
<Piece NumberOfPoints="212" NumberOfCells="156">
55
<PointData GlobalIds="GLOBAL_IDS_POINTS">
6-
<DataArray type="Int64" IdType="1" Name="collocatedNodes" NumberOfComponents="2" format="binary" RangeMin="3905.8931116967346" RangeMax="5326.462428291407">
6+
<DataArray type="Int64" IdType="1" Name="collocated_nodes" NumberOfComponents="2" format="binary" RangeMin="3905.8931116967346" RangeMax="5326.462428291407">
77
AQAAAACAAABADQAABgMAAA==eJwtyMVSFgAAhVFduHDh+Ah2d2GD2I0NdnchJnZiYmCLgYmtKHZid3djgo0dG2f8z918c27B7Jn+LyVzoIX4BBfmk1yET3FRPs3F+AwX57N8Tkv4S+p5fym+wKX5IpfhS1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