Skip to content

Commit 8cc89f5

Browse files
Correction of erroneous copy of pre-split tags to new split meshes (#34)
* First correction now allowing for the copy of fields from the original mesh to the 2 split meshes. But the indexes of fields are not correct yet for fracture mesh. * Module import paths update * Fields are now copied correctly for fracture_mesh. * Test case added to check the __copy_fields feature. * Invalid packages import for geos-mesh, impacting documentation (#32) Updating sphinx and sphinx-argparse solved the issue. * Correction for yapf valid format. * Had to make a workaround to avoid a weird yapf formatting suggestion. * Mistake correction * First correction now allowing for the copy of fields from the original mesh to the 2 split meshes. But the indexes of fields are not correct yet for fracture mesh. * Module import paths update * Fields are now copied correctly for fracture_mesh. * Test case added to check the __copy_fields feature. * Correction for yapf valid format. * Had to make a workaround to avoid a weird yapf formatting suggestion. * Mistake correction * First part of review corrections * Second part correction of reviews * Last part of correction review * Updated method when linking old cells to new cells ids to copy correctly the fields
1 parent 98680c5 commit 8cc89f5

File tree

4 files changed

+457
-297
lines changed

4 files changed

+457
-297
lines changed

geos-mesh/src/geos/mesh/doctor/checks/check_fractures.py

Lines changed: 18 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,14 @@
1-
from dataclasses import dataclass
21
import logging
3-
4-
from typing import (
5-
Collection,
6-
FrozenSet,
7-
Iterable,
8-
Sequence,
9-
Set,
10-
Tuple,
11-
)
12-
13-
from tqdm import tqdm
142
import numpy
15-
16-
from vtkmodules.vtkCommonDataModel import (
17-
vtkUnstructuredGrid,
18-
vtkCell,
19-
)
20-
from vtkmodules.vtkCommonCore import (
21-
vtkPoints, )
22-
from vtkmodules.vtkIOXML import (
23-
vtkXMLMultiBlockDataReader, )
24-
from vtkmodules.util.numpy_support import (
25-
vtk_to_numpy, )
26-
from vtk_utils import (
27-
vtk_iter, )
3+
from dataclasses import dataclass
4+
from typing import Collection, Iterable, Sequence
5+
from tqdm import tqdm
6+
from vtkmodules.vtkCommonDataModel import vtkUnstructuredGrid, vtkCell
7+
from vtkmodules.vtkCommonCore import vtkPoints
8+
from vtkmodules.vtkIOXML import vtkXMLMultiBlockDataReader
9+
from vtkmodules.util.numpy_support import vtk_to_numpy
10+
from geos.mesh.doctor.checks.vtk_utils import vtk_iter
11+
from geos.mesh.doctor.checks.generate_fractures import Coordinates3D
2812

2913

3014
@dataclass( frozen=True )
@@ -44,7 +28,7 @@ class Result:
4428

4529

4630
def __read_multiblock( vtk_input_file: str, matrix_name: str,
47-
fracture_name: str ) -> Tuple[ vtkUnstructuredGrid, vtkUnstructuredGrid ]:
31+
fracture_name: str ) -> tuple[ vtkUnstructuredGrid, vtkUnstructuredGrid ]:
4832
reader = vtkXMLMultiBlockDataReader()
4933
reader.SetFileName( vtk_input_file )
5034
reader.Update()
@@ -73,9 +57,9 @@ def format_collocated_nodes( fracture_mesh: vtkUnstructuredGrid ) -> Sequence[ I
7357

7458

7559
def __check_collocated_nodes_positions(
76-
matrix_points: Sequence[ Tuple[ float, float, float ] ], fracture_points: Sequence[ Tuple[ float, float, float ] ],
77-
g2l: Sequence[ int ], collocated_nodes: Iterable[ Iterable[ int ] ]
78-
) -> Collection[ Tuple[ int, Iterable[ int ], Iterable[ Tuple[ float, float, float ] ] ] ]:
60+
matrix_points: Sequence[ Coordinates3D ], fracture_points: Sequence[ Coordinates3D ], g2l: Sequence[ int ],
61+
collocated_nodes: Iterable[ Iterable[ int ] ]
62+
) -> Collection[ tuple[ int, Iterable[ int ], Iterable[ Coordinates3D ] ] ]:
7963
issues = []
8064
for li, bucket in enumerate( collocated_nodes ):
8165
matrix_nodes = ( fracture_points[ li ], ) + tuple( map( lambda gi: matrix_points[ g2l[ gi ] ], bucket ) )
@@ -98,14 +82,14 @@ def my_iter( ccc ):
9882

9983
def __check_neighbors( matrix: vtkUnstructuredGrid, fracture: vtkUnstructuredGrid, g2l: Sequence[ int ],
10084
collocated_nodes: Sequence[ Iterable[ int ] ] ):
101-
fracture_nodes: Set[ int ] = set()
85+
fracture_nodes: set[ int ] = set()
10286
for bucket in collocated_nodes:
10387
for gi in bucket:
10488
fracture_nodes.add( g2l[ gi ] )
10589
# For each face of each cell,
10690
# if all the points of the face are "made" of collocated nodes,
10791
# then this is a fracture face.
108-
fracture_faces: Set[ FrozenSet[ int ] ] = set()
92+
fracture_faces: set[ frozenset[ int ] ] = set()
10993
for c in range( matrix.GetNumberOfCells() ):
11094
cell: vtkCell = matrix.GetCell( c )
11195
for f in range( cell.GetNumberOfFaces() ):
@@ -116,7 +100,7 @@ def __check_neighbors( matrix: vtkUnstructuredGrid, fracture: vtkUnstructuredGri
116100
# Finding the cells
117101
for c in tqdm( range( fracture.GetNumberOfCells() ), desc="Finding neighbor cell pairs" ):
118102
cell: vtkCell = fracture.GetCell( c )
119-
cns: Set[ FrozenSet[ int ] ] = set() # subset of collocated_nodes
103+
cns: set[ frozenset[ int ] ] = set() # subset of collocated_nodes
120104
point_ids = frozenset( vtk_iter( cell.GetPointIds() ) )
121105
for point_id in point_ids:
122106
bucket = collocated_nodes[ point_id ]
@@ -129,9 +113,8 @@ def __check_neighbors( matrix: vtkUnstructuredGrid, fracture: vtkUnstructuredGri
129113
if f in fracture_faces:
130114
found += 1
131115
if found != 2:
132-
logging.warning(
133-
f"Something went wrong since we should have found 2 fractures faces (we found {found}) for collocated nodes {cns}."
134-
)
116+
logging.warning( f"Something went wrong since we should have found 2 fractures faces (we found {found})" +
117+
f" for collocated nodes {cns}." )
135118

136119

137120
def __check( vtk_input_file: str, options: Options ) -> Result:

0 commit comments

Comments
 (0)