Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correction of erroneous copy of pre-split tags to new split meshes #34

Merged
merged 20 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
53fd564
First correction now allowing for the copy of fields from the origina…
alexbenedicto Jul 24, 2024
4615f63
Module import paths update
alexbenedicto Jul 29, 2024
0f8c2ba
Fields are now copied correctly for fracture_mesh.
alexbenedicto Aug 1, 2024
4cee143
Test case added to check the __copy_fields feature.
alexbenedicto Aug 1, 2024
6759376
Invalid packages import for geos-mesh, impacting documentation (#32)
alexbenedicto Aug 5, 2024
a392c4b
Correction for yapf valid format.
alexbenedicto Aug 13, 2024
9cf4007
Had to make a workaround to avoid a weird yapf formatting suggestion.
alexbenedicto Aug 13, 2024
b8bc706
Mistake correction
alexbenedicto Aug 13, 2024
c64a6ba
First correction now allowing for the copy of fields from the origina…
alexbenedicto Jul 24, 2024
5343cf6
Module import paths update
alexbenedicto Jul 29, 2024
29f01a3
Fields are now copied correctly for fracture_mesh.
alexbenedicto Aug 1, 2024
269b09b
Test case added to check the __copy_fields feature.
alexbenedicto Aug 1, 2024
779ae68
Correction for yapf valid format.
alexbenedicto Aug 13, 2024
a6f1d68
Had to make a workaround to avoid a weird yapf formatting suggestion.
alexbenedicto Aug 13, 2024
2179463
Mistake correction
alexbenedicto Aug 13, 2024
278adc9
Merge branch 'origin/benedicto/bugfix/issue#31_pre_split_tags' of htt…
alexbenedicto Aug 14, 2024
8495595
First part of review corrections
alexbenedicto Sep 12, 2024
47b6380
Second part correction of reviews
alexbenedicto Sep 12, 2024
a4ff5e5
Last part of correction review
alexbenedicto Sep 13, 2024
b763288
Updated method when linking old cells to new cells ids to copy correc…
alexbenedicto Sep 20, 2024
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
3 changes: 2 additions & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
sphinx >= 7.4.7
sphinx_rtd_theme
sphinx-argparse
sphinx-argparse >= 0.5.2
sphinx-design
# Running CLI programs and capture outputs
sphinxcontrib-programoutput>=0.17
Expand Down
3 changes: 1 addition & 2 deletions geos-mesh/src/geos/mesh/conversion/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import argparse
import logging
import sys
from geos.mesh.conversion import abaqus_converter


def build_abaqus_converter_input_parser() -> argparse.ArgumentParser:
Expand All @@ -25,8 +26,6 @@ def main() -> None:
output (str): Output mesh file name
-v/--verbose (flag): Increase verbosity level
"""
from geosx_mesh_tools import abaqus_converter

# Parse the user arguments
parser = build_abaqus_converter_input_parser()
args = parser.parse_args()
Expand Down
1 change: 1 addition & 0 deletions geos-mesh/src/geos/mesh/doctor/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Empty
53 changes: 18 additions & 35 deletions geos-mesh/src/geos/mesh/doctor/checks/check_fractures.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,14 @@
from dataclasses import dataclass
import logging

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be creating our own logger instance that we can set verbosity level on:

import logging
logger = logging.getLogger('mesh_doctor')

# Use the specific logger throughout the code
logger.warning('Some warning message')

# Note: somewhere in the entry point of the code, we can accept a user argument to set the level
logger.setLevel('WARNING')

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can also do that in another PR because this is done also in all 'check' files

from typing import (
Collection,
FrozenSet,
Iterable,
Sequence,
Set,
Tuple,
)

from tqdm import tqdm
import numpy

from vtkmodules.vtkCommonDataModel import (
vtkUnstructuredGrid,
vtkCell,
)
from vtkmodules.vtkCommonCore import (
vtkPoints, )
from vtkmodules.vtkIOXML import (
vtkXMLMultiBlockDataReader, )
from vtkmodules.util.numpy_support import (
vtk_to_numpy, )
from vtk_utils import (
vtk_iter, )
from dataclasses import dataclass
from typing import Collection, Iterable, Sequence
from tqdm import tqdm
from vtkmodules.vtkCommonDataModel import vtkUnstructuredGrid, vtkCell
from vtkmodules.vtkCommonCore import vtkPoints
from vtkmodules.vtkIOXML import vtkXMLMultiBlockDataReader
from vtkmodules.util.numpy_support import vtk_to_numpy
from geos.mesh.doctor.checks.vtk_utils import vtk_iter
from geos.mesh.doctor.checks.generate_fractures import Coordinates3D


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


def __read_multiblock( vtk_input_file: str, matrix_name: str,
fracture_name: str ) -> Tuple[ vtkUnstructuredGrid, vtkUnstructuredGrid ]:
fracture_name: str ) -> tuple[ vtkUnstructuredGrid, vtkUnstructuredGrid ]:
reader = vtkXMLMultiBlockDataReader()
reader.SetFileName( vtk_input_file )
reader.Update()
Expand Down Expand Up @@ -73,9 +57,9 @@ def format_collocated_nodes( fracture_mesh: vtkUnstructuredGrid ) -> Sequence[ I


def __check_collocated_nodes_positions(
matrix_points: Sequence[ Tuple[ float, float, float ] ], fracture_points: Sequence[ Tuple[ float, float, float ] ],
g2l: Sequence[ int ], collocated_nodes: Iterable[ Iterable[ int ] ]
) -> Collection[ Tuple[ int, Iterable[ int ], Iterable[ Tuple[ float, float, float ] ] ] ]:
matrix_points: Sequence[ Coordinates3D ], fracture_points: Sequence[ Coordinates3D ], g2l: Sequence[ int ],
collocated_nodes: Iterable[ Iterable[ int ] ]
) -> Collection[ tuple[ int, Iterable[ int ], Iterable[ Coordinates3D ] ] ]:
issues = []
for li, bucket in enumerate( collocated_nodes ):
matrix_nodes = ( fracture_points[ li ], ) + tuple( map( lambda gi: matrix_points[ g2l[ gi ] ], bucket ) )
Expand All @@ -98,14 +82,14 @@ def my_iter( ccc ):

def __check_neighbors( matrix: vtkUnstructuredGrid, fracture: vtkUnstructuredGrid, g2l: Sequence[ int ],
collocated_nodes: Sequence[ Iterable[ int ] ] ):
fracture_nodes: Set[ int ] = set()
fracture_nodes: set[ int ] = set()
for bucket in collocated_nodes:
for gi in bucket:
fracture_nodes.add( g2l[ gi ] )
# For each face of each cell,
# if all the points of the face are "made" of collocated nodes,
# then this is a fracture face.
fracture_faces: Set[ FrozenSet[ int ] ] = set()
fracture_faces: set[ frozenset[ int ] ] = set()
for c in range( matrix.GetNumberOfCells() ):
cell: vtkCell = matrix.GetCell( c )
for f in range( cell.GetNumberOfFaces() ):
Expand All @@ -116,7 +100,7 @@ def __check_neighbors( matrix: vtkUnstructuredGrid, fracture: vtkUnstructuredGri
# Finding the cells
for c in tqdm( range( fracture.GetNumberOfCells() ), desc="Finding neighbor cell pairs" ):
cell: vtkCell = fracture.GetCell( c )
cns: Set[ FrozenSet[ int ] ] = set() # subset of collocated_nodes
cns: set[ frozenset[ int ] ] = set() # subset of collocated_nodes
point_ids = frozenset( vtk_iter( cell.GetPointIds() ) )
for point_id in point_ids:
bucket = collocated_nodes[ point_id ]
Expand All @@ -129,9 +113,8 @@ def __check_neighbors( matrix: vtkUnstructuredGrid, fracture: vtkUnstructuredGri
if f in fracture_faces:
found += 1
if found != 2:
logging.warning(
f"Something went wrong since we should have found 2 fractures faces (we found {found}) for collocated nodes {cns}."
)
logging.warning( f"Something went wrong since we should have found 2 fractures faces (we found {found})" +
f" for collocated nodes {cns}." )


def __check( vtk_input_file: str, options: Options ) -> Result:
Expand Down
Loading
Loading