diff --git a/.github/workflows/doc-test.yml b/.github/workflows/doc-test.yml index 43b968651..6d8877797 100644 --- a/.github/workflows/doc-test.yml +++ b/.github/workflows/doc-test.yml @@ -2,6 +2,11 @@ name: "Pull Request Docs Check" on: - pull_request +# Cancels in-progress workflows for a PR when updated +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: docs: runs-on: ubuntu-latest @@ -10,4 +15,4 @@ jobs: - uses: ammaraskar/sphinx-action@dev with: docs-folder: "docs/" - build-command: "sphinx-build -b html . _build" + build-command: "sphinx-build -b html . _build -W" diff --git a/docs/conf.py b/docs/conf.py index 6666c0e4b..91d1fb2e5 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -17,7 +17,7 @@ # Add python modules to be documented python_root = '..' -python_modules = ( 'geos-ats', 'geos-mesh', 'geos-posp', 'geos-timehistory', 'geos-utils', 'geos-xml-tools', 'hdf5-wrapper', 'pygeos-tools', 'geos-geomechanics' ) +python_modules = ( 'geos-ats', 'geos-geomechanics', 'geos-mesh', 'geos-posp', 'geos-timehistory', 'geos-utils', 'geos-xml-tools', 'geos-xml-viewer', 'hdf5-wrapper', 'pygeos-tools' ) for m in python_modules: sys.path.insert( 0, os.path.abspath( os.path.join( python_root, m, 'src' ) ) ) @@ -43,15 +43,15 @@ # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ - 'sphinx_design', 'sphinx_rtd_theme', 'sphinxarg.ext', 'sphinxcontrib.programoutput', 'sphinx.ext.autodoc', - 'sphinx.ext.doctest', 'sphinx.ext.mathjax', 'sphinx.ext.napoleon', 'sphinx.ext.todo', 'sphinx.ext.viewcode' + 'sphinx.ext.napoleon', 'sphinx_design', 'sphinx_rtd_theme', 'sphinxarg.ext', 'sphinxcontrib.programoutput', + 'sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.mathjax', 'sphinx.ext.todo', 'sphinx.ext.viewcode' ] autoclass_content = 'both' -autodoc_mock_imports = [ "ats", "h5py", "lxml", "paraview", "pygeosx", "pylvarray", "meshio", "mpi4py", "scipy" ] +autodoc_mock_imports = [ "ats", "colorcet", "h5py", "lxml", "meshio", "mpi4py", "scipy", "paraview", "pygeosx", "pylvarray", "vtk", "xmlschema", "xsdata" ] autodoc_typehints = 'none' autodoc_typehints_format = 'short' -suppress_warnings = [ "" ] +suppress_warnings = [ "autodoc.mocked_object" ] typehints_defaults = 'braces' # The suffix(es) of source filenames. diff --git a/docs/geos-geomechanics.rst b/docs/geos-geomechanics.rst index d3d12109c..923d6764f 100644 --- a/docs/geos-geomechanics.rst +++ b/docs/geos-geomechanics.rst @@ -1,4 +1,4 @@ -GEOS Post-Processing tools +GEOS Geomechanics tools ============================= .. toctree:: diff --git a/docs/geos-xml-viewer.rst b/docs/geos-xml-viewer.rst new file mode 100644 index 000000000..82cdc9a65 --- /dev/null +++ b/docs/geos-xml-viewer.rst @@ -0,0 +1,107 @@ +GEOS XML VIEWER +=============== + +The `geos-xml-viewer` python package defines tools to read, process, and visualize objects from GEOS input xml file. +See `Advanced XML Features `_ for a detailed description of the input format. + +This package defines multiple console scripts and a vtk ilter associated with a Paraview reader. + +Consol scripts +-------------- + +geos-exporter +^^^^^^^^^^^^^ + +Reads the xml file and writes a PartionedDataSetCollection file containing all the mesh objects (mesh, wells, boxes) defind in the xml. + +.. argparse:: + :module: geos_xml_viewer.bin.exporter + :func: parsing + :prog: geos-exporter + +geos-modifier +^^^^^^^^^^^^^ + +Rewrite wells into VTK file and modify the xml file accordingly. + +.. argparse:: + :module: geos_xml_viewer.bin.modifier + :func: parsing + :prog: geos-modifier + +geos-splitter +^^^^^^^^^^^^^ + +Extract Internal wells into VTK files. + +.. argparse:: + :module: geos_xml_viewer.bin.splitter + :func: parsing + :prog: geos-splitter + +geos-viewer +^^^^^^^^^^^^^ + +Viewer dedicated to xml mesh objects (mesh, wells, boxes). + +.. argparse:: + :module: geos_xml_viewer.bin.viewer + :func: parsing + :prog: geos-viewer + + +WIP consol scripts +------------------ + +geos-validate +^^^^^^^^^^^^^ + +Validate xml file according to GEOS scheme. + +.. argparse:: + :module: geos_xml_viewer.bin.validate + :func: parsing + :prog: geos-validate + + +vtk filter +---------- + +Geos deck reader +^^^^^^^^^^^^^^^^ + +Vtk reader of GEOS xml file to load or build vtk objects (mesh, wells, boxes). + +.. automodule:: geos_xml_viewer.filters.geosDeckReader + :members: + :undoc-members: + :show-inheritance: + + +Paraview plugin +---------------- + +Geos Deck Reader +^^^^^^^^^^^^^^^^ + +Paraview plugin of Geos Deck Reader. + +.. automodule:: PVPlugins.deckReader + :no-members: + :no-undoc-members: + +Utilities +--------- + +geos_xml_viewer.algorithms.deck +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. automodule:: geos_xml_viewer.algorithms.deck + :members: + :undoc-members: + +geos_xml_viewer.algorithms.write_wells +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +.. automodule:: geos_xml_viewer.algorithms.write_wells + :members: + :undoc-members: \ No newline at end of file diff --git a/docs/geos_geomechanics_docs/home.rst b/docs/geos_geomechanics_docs/home.rst index 794b98a55..dc0daa3b4 100644 --- a/docs/geos_geomechanics_docs/home.rst +++ b/docs/geos_geomechanics_docs/home.rst @@ -1,4 +1,4 @@ GEOS Geomechanics Tools -========================= +----------------------- This package contains geomechanics functions and data models. \ No newline at end of file diff --git a/docs/geos_geomechanics_docs/model.rst b/docs/geos_geomechanics_docs/model.rst index d1b98d41f..19615bf55 100644 --- a/docs/geos_geomechanics_docs/model.rst +++ b/docs/geos_geomechanics_docs/model.rst @@ -1,6 +1,7 @@ Geomechanics models ====================== -This + +This module defines data structures for geomechanics calculations. geos.geomechanics.model.MohrCircle module ------------------------------------------ diff --git a/docs/geos_geomechanics_docs/processing.rst b/docs/geos_geomechanics_docs/processing.rst index 78c9e462b..7e6b31202 100644 --- a/docs/geos_geomechanics_docs/processing.rst +++ b/docs/geos_geomechanics_docs/processing.rst @@ -1,6 +1,7 @@ Processing ============ -The processing part of `geos-geomechanics` package contains functions tools to compute geomechanical properties. + +The processing part of `geos-geomechanics` package contains the basis functions to compute geomechanical properties. geos.geomechanics.processing.geomechanicsCalculatorFunctions module --------------------------------------------------------------------- diff --git a/docs/geos_posp_docs/PVplugins.rst b/docs/geos_posp_docs/PVplugins.rst index 57687c6ad..4987b0584 100644 --- a/docs/geos_posp_docs/PVplugins.rst +++ b/docs/geos_posp_docs/PVplugins.rst @@ -10,122 +10,105 @@ The plugins include: * Processing plugins to compute additional geomechanical properties; * Visualization plugins to plot Mohr's circles and cross plots using Paraview Python View. -PVplugins.PVAttributeMapping module +PVAttributeMapping plugin ----------------------------------- .. automodule:: PVplugins.PVAttributeMapping - :members: - :undoc-members: -PVplugins.PVCreateConstantAttributePerRegion module + +PVCreateConstantAttributePerRegion plugin --------------------------------------------------- .. automodule:: PVplugins.PVCreateConstantAttributePerRegion - :members: - :undoc-members: -PVplugins.PVExtractMergeBlocksVolume module + +PVExtractMergeBlocksVolume plugin ------------------------------------------- .. automodule:: PVplugins.PVExtractMergeBlocksVolume - :members: - :undoc-members: -PVplugins.PVExtractMergeBlocksVolumeSurface module + +PVExtractMergeBlocksVolumeSurface plugin -------------------------------------------------- .. automodule:: PVplugins.PVExtractMergeBlocksVolumeSurface - :members: - :undoc-members: -PVplugins.PVExtractMergeBlocksVolumeSurfaceWell module + +PVExtractMergeBlocksVolumeSurfaceWell plugin ------------------------------------------------------ .. automodule:: PVplugins.PVExtractMergeBlocksVolumeSurfaceWell - :members: - :undoc-members: -PVplugins.PVExtractMergeBlocksVolumeWell module + +PVExtractMergeBlocksVolumeWell plugin ----------------------------------------------- .. automodule:: PVplugins.PVExtractMergeBlocksVolumeWell - :members: - :undoc-members: -PVplugins.PVGeomechanicsAnalysis module + +PVGeomechanicsAnalysis plugin --------------------------------------- .. automodule:: PVplugins.PVGeomechanicsAnalysis - :members: - :undoc-members: -PVplugins.PVGeomechanicsWorkflowVolume module + +PVGeomechanicsWorkflowVolume plugin --------------------------------------------- .. automodule:: PVplugins.PVGeomechanicsWorkflowVolume - :members: - :undoc-members: -PVplugins.PVGeomechanicsWorkflowVolumeSurface module + +PVGeomechanicsWorkflowVolumeSurface plugin ---------------------------------------------------- .. automodule:: PVplugins.PVGeomechanicsWorkflowVolumeSurface - :members: - :undoc-members: -PVplugins.PVGeomechanicsWorkflowVolumeSurfaceWell module + +PVGeomechanicsWorkflowVolumeSurfaceWell plugin -------------------------------------------------------- .. automodule:: PVplugins.PVGeomechanicsWorkflowVolumeSurfaceWell - :members: - :undoc-members: -PVplugins.PVGeomechanicsWorkflowVolumeWell module + +PVGeomechanicsWorkflowVolumeWell plugin ------------------------------------------------- .. automodule:: PVplugins.PVGeomechanicsWorkflowVolumeWell - :members: - :undoc-members: -PVplugins.PVGeosLogReader module + +PVGeosLogReader plugin -------------------------------- .. automodule:: PVplugins.PVGeosLogReader - :members: - :undoc-members: -PVplugins.PVMergeBlocksEnhanced module + +PVMergeBlocksEnhanced plugin -------------------------------------- .. automodule:: PVplugins.PVMergeBlocksEnhanced - :members: - :undoc-members: -PVplugins.PVMohrCirclePlot module + +PVMohrCirclePlot plugin --------------------------------- .. automodule:: PVplugins.PVMohrCirclePlot - :members: - :undoc-members: -PVplugins.PVPythonViewConfigurator module + +PVPythonViewConfigurator plugin ----------------------------------------- .. automodule:: PVplugins.PVPythonViewConfigurator - :members: - :undoc-members: -PVplugins.PVSurfaceGeomechanics module + +PVSurfaceGeomechanics plugin -------------------------------------- .. automodule:: PVplugins.PVSurfaceGeomechanics - :members: - :undoc-members: -PVplugins.PVTransferAttributesVolumeSurface module + +PVTransferAttributesVolumeSurface plugin -------------------------------------------------- .. automodule:: PVplugins.PVTransferAttributesVolumeSurface - :members: - :undoc-members: + diff --git a/docs/geos_posp_docs/home.rst b/docs/geos_posp_docs/home.rst index 3ddeed4fd..9f109466d 100644 --- a/docs/geos_posp_docs/home.rst +++ b/docs/geos_posp_docs/home.rst @@ -1,5 +1,5 @@ Home -==== +----- **Geos-posp** is a Python library to read, process and visualize GEOS simulation software outputs. diff --git a/docs/geos_posp_docs/processing.rst b/docs/geos_posp_docs/processing.rst index 9da336b9e..a05fb0bd4 100644 --- a/docs/geos_posp_docs/processing.rst +++ b/docs/geos_posp_docs/processing.rst @@ -3,15 +3,6 @@ Processing functions This package define functions to process data. - -geos_posp.processing.geomechanicsCalculatorFunctions module ---------------------------------------------------------------- - -.. automodule:: geos_posp.processing.geomechanicsCalculatorFunctions - :members: - :undoc-members: - :show-inheritance: - geos_posp.processing.geosLogReaderFunctions module ------------------------------------------------------ @@ -20,22 +11,6 @@ geos_posp.processing.geosLogReaderFunctions module :undoc-members: :show-inheritance: -geos_posp.processing.MohrCircle module ------------------------------------------- - -.. automodule:: geos_posp.processing.MohrCircle - :members: - :undoc-members: - :show-inheritance: - -geos_posp.processing.MohrCoulomb module -------------------------------------------- - -.. automodule:: geos_posp.processing.MohrCoulomb - :members: - :undoc-members: - :show-inheritance: - geos_posp.processing.multiblockInpectorTreeFunctions module --------------------------------------------------------------- diff --git a/docs/index.rst b/docs/index.rst index f05ca861b..c14a1db81 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -92,4 +92,6 @@ Packages geos-xml-tools + geos-xml-viewer + pygeos-tools diff --git a/geos-geomechanics/src/geos/geomechanics/model/MohrCircle.py b/geos-geomechanics/src/geos/geomechanics/model/MohrCircle.py index 2e7237677..f1abab3c5 100644 --- a/geos-geomechanics/src/geos/geomechanics/model/MohrCircle.py +++ b/geos-geomechanics/src/geos/geomechanics/model/MohrCircle.py @@ -5,7 +5,7 @@ import numpy.typing as npt from typing_extensions import Self -from geos_posp.processing.geomechanicsCalculatorFunctions import ( +from geos.geomechanics.processing.geomechanicsCalculatorFunctions import ( computeStressPrincipalComponentsFromStressVector, ) __doc__ = """ @@ -38,6 +38,7 @@ p1, p2, p3 :float = mohrCircle.getPrincipalComponents() radius :float = mohrCircle.getCircleRadius() center :float = mohrCircle.getCircleCenter() + """ diff --git a/geos-geomechanics/src/geos/geomechanics/processing/geomechanicsCalculatorFunctions.py b/geos-geomechanics/src/geos/geomechanics/processing/geomechanicsCalculatorFunctions.py index 174c17267..ab01621bf 100644 --- a/geos-geomechanics/src/geos/geomechanics/processing/geomechanicsCalculatorFunctions.py +++ b/geos-geomechanics/src/geos/geomechanics/processing/geomechanicsCalculatorFunctions.py @@ -5,7 +5,7 @@ import numpy as np import numpy.typing as npt -from geos_posp.processing.MohrCoulomb import MohrCoulomb +from geos.geomechanics.model.MohrCoulomb import MohrCoulomb from geos.utils.algebraFunctions import getAttributeMatrixFromVector from geos.utils.PhysicalConstants import ( EPSILON, ) diff --git a/geos-posp/src/PVplugins/PVGeosLogReader.py b/geos-posp/src/PVplugins/PVGeosLogReader.py index 15f596271..c218659b7 100644 --- a/geos-posp/src/PVplugins/PVGeosLogReader.py +++ b/geos-posp/src/PVplugins/PVGeosLogReader.py @@ -54,12 +54,11 @@ from vtkmodules.vtkCommonDataModel import vtkTable __doc__ = """ -GeosLogRePVGeosLogReaderader is a Paraview plugin that allows to read Geos output log. +PVGeosLogReader is a Paraview plugin that allows to read Geos output log. Input is a file and output is a vtkTable containing log information. ..WARNING:: - The reader is compliant with GEOS log before commit version #9365098. For more recent version, use the csv or hdf5 export options from GEOS. diff --git a/geos-posp/src/geos_posp/filters/GeosBlockMerge.py b/geos-posp/src/geos_posp/filters/GeosBlockMerge.py index cf87c650b..e9f953e12 100644 --- a/geos-posp/src/geos_posp/filters/GeosBlockMerge.py +++ b/geos-posp/src/geos_posp/filters/GeosBlockMerge.py @@ -425,9 +425,9 @@ def convertFaultsToSurfaces( self: Self ) -> bool: def convertBlockToSurface( self: Self, block: vtkUnstructuredGrid ) -> vtkPolyData: """Convert vtkUnstructuredGrid to a surface vtkPolyData. - ..WARNING: work only with triangulated surfaces + .. WARNING:: work only with triangulated surfaces - TODO: need to convert quadrangular to triangulated surfaces first + .. TODO:: need to convert quadrangular to triangulated surfaces first Args: diff --git a/geos-xml-tools/src/geos/xml_tools/regex_tools.py b/geos-xml-tools/src/geos/xml_tools/regex_tools.py index cf4c27de6..d51262d3b 100644 --- a/geos-xml-tools/src/geos/xml_tools/regex_tools.py +++ b/geos-xml-tools/src/geos/xml_tools/regex_tools.py @@ -12,10 +12,10 @@ units | 9.81[m**2/s], 1.0 [bbl/day] | Matches entire unit string units_b | m, bbl, day | Matches unit names symbolic | `1 + 2.34e5*2` | Matches the entire symbolic string -sanitize | | Removes any residual characters before - | | evaluating symbolic expressions +sanitize | | Removes any residual characters before evaluating symbolic expressions strip_trailing | 3.0000, 5.150050 | Removes unnecessary float strings strip_trailing_b| 3.0000e0, 1.23e0 | Removes unnecessary float strings + """ patterns: Dict[ str, str ] = { diff --git a/geos-xml-viewer/src/PVplugins/__init__.py b/geos-xml-viewer/src/PVPlugins/__init__.py similarity index 100% rename from geos-xml-viewer/src/PVplugins/__init__.py rename to geos-xml-viewer/src/PVPlugins/__init__.py diff --git a/geos-xml-viewer/src/PVplugins/deckReader.py b/geos-xml-viewer/src/PVPlugins/deckReader.py similarity index 95% rename from geos-xml-viewer/src/PVplugins/deckReader.py rename to geos-xml-viewer/src/PVPlugins/deckReader.py index 239634577..abe1ec473 100644 --- a/geos-xml-viewer/src/PVplugins/deckReader.py +++ b/geos-xml-viewer/src/PVPlugins/deckReader.py @@ -8,6 +8,10 @@ from vtkmodules.vtkCommonCore import vtkInformation, vtkInformationVector from vtkmodules.vtkCommonDataModel import vtkPartitionedDataSetCollection +__doc__ = """ +PVGeosDeckReader is a Paraview plugin to load and create mesh objects from GEOS xml input file. +""" + paraview_plugin_version = "0.1.0" diff --git a/geos-xml-viewer/src/PVplugins/geostkParaviewPlugin.py b/geos-xml-viewer/src/PVPlugins/geostkParaviewPlugin.py similarity index 100% rename from geos-xml-viewer/src/PVplugins/geostkParaviewPlugin.py rename to geos-xml-viewer/src/PVPlugins/geostkParaviewPlugin.py diff --git a/geos-xml-viewer/src/PVplugins/py.typed b/geos-xml-viewer/src/PVPlugins/py.typed similarity index 100% rename from geos-xml-viewer/src/PVplugins/py.typed rename to geos-xml-viewer/src/PVPlugins/py.typed diff --git a/geos-xml-viewer/src/geos_xml_viewer/algorithms/deck.py b/geos-xml-viewer/src/geos_xml_viewer/algorithms/deck.py index e0339248a..caae88221 100644 --- a/geos-xml-viewer/src/geos_xml_viewer/algorithms/deck.py +++ b/geos-xml-viewer/src/geos_xml_viewer/algorithms/deck.py @@ -373,7 +373,7 @@ def _read_vtk_data_repository( if path.suffix in CLASS_READERS: try: Reader = CLASS_READERS[ path.suffix ] - except KeyError as err: + except KeyError: # raise ValueError( # f"`read` does not support a file with the {path.suffix} extension" # ) from err @@ -457,7 +457,7 @@ def _read_vtk_data_repository( elif path.suffix in COMPOSITE_DATA_READERS: try: Reader = COMPOSITE_DATA_READERS[ path.suffix ] - except KeyError as err: + except KeyError: # raise ValueError( # f"`read` does not support a file with the {path.suffix} extension" # ) from err @@ -760,7 +760,6 @@ def format_xml_level( close_tag_newline (bool): option to place close tag on a separate line include_namespace (bool): option to include the xml namespace in the output """ - # Handle comments if node.tag is ElementTree.Comment: output.write( "\n%s" % ( indent * level, node.text ) ) diff --git a/geos-xml-viewer/src/geos_xml_viewer/bin/exporter.py b/geos-xml-viewer/src/geos_xml_viewer/bin/exporter.py index 0eef35691..2aad9feb3 100644 --- a/geos-xml-viewer/src/geos_xml_viewer/bin/exporter.py +++ b/geos-xml-viewer/src/geos_xml_viewer/bin/exporter.py @@ -64,7 +64,7 @@ def parsing() -> argparse.ArgumentParser: def main( args: argparse.Namespace ) -> None: - """Main function that reads the xml file and writes a PartiotionedDataSetCollection file. + """Main function that reads the xml file and writes a PartionedDataSetCollection file. Args: args (argparse.Namespace): list of arguments diff --git a/geos-xml-viewer/src/geos_xml_viewer/bin/modifier.py b/geos-xml-viewer/src/geos_xml_viewer/bin/modifier.py index e5ab576d3..70fb34e7b 100644 --- a/geos-xml-viewer/src/geos_xml_viewer/bin/modifier.py +++ b/geos-xml-viewer/src/geos_xml_viewer/bin/modifier.py @@ -5,9 +5,11 @@ import argparse from pathlib import PurePath -import vtkmodules.all as vtk from geos_xml_viewer.filters.geosDeckReader import GeosDeckReader +from vtkmodules.vtkIOXML import vtkXMLPartitionedDataSetCollectionReader +from vtkmodules.vtkCommonDataModel import vtkDataAssembly + def valid_file( param: str ) -> str: ext: str = PurePath( param ).suffix @@ -60,18 +62,18 @@ def main( args: argparse.Namespace ) -> None: reader.Update() pdsc_xml = reader.GetOutputDataObject( 0 ) - vtpc = vtk.vtkXMLPartitionedDataSetCollectionReader() + vtpc = vtkXMLPartitionedDataSetCollectionReader() vtpc.SetFileName( args.vtpc ) vtpc.Update() pdsc_file = vtpc.GetOutput() # look for xml root node name and wells node id - assembly_xml: vtk.vtkDataAssembly = pdsc_xml.GetDataAssembly() + assembly_xml: vtkDataAssembly = pdsc_xml.GetDataAssembly() root_name_xml: str = assembly_xml.GetNodeName( assembly_xml.GetRootNode() ) wells_xml = assembly_xml.GetFirstNodeByPath( "//" + root_name_xml + "/Wells" ) # look for vtpc root node name and wells node id - assembly_file: vtk.vtkDataAssembly = pdsc_file.GetDataAssembly() + assembly_file: vtkDataAssembly = pdsc_file.GetDataAssembly() wells_file = assembly_file.GetFirstNodeByPath( "//" + root_name_xml + "/Wells" ) print( "assembly from vtpc file: ", wells_file ) @@ -89,7 +91,7 @@ def main( args: argparse.Namespace ) -> None: print( assembly_file ) - writer = vtk.vtkXMLPartitionedDataSetCollectionWriter() + writer = vtkXMLPartitionedDataSetCollectionWriter() writer.SetInputData( pdsc_file ) writer.SetFileName( args.outputName ) writer.Write() diff --git a/geos-xml-viewer/src/geos_xml_viewer/bin/splitter.py b/geos-xml-viewer/src/geos_xml_viewer/bin/splitter.py index 24f42ad8a..75cc015d8 100644 --- a/geos-xml-viewer/src/geos_xml_viewer/bin/splitter.py +++ b/geos-xml-viewer/src/geos_xml_viewer/bin/splitter.py @@ -5,7 +5,7 @@ import argparse from pathlib import PurePath -from geos_xml_viewer.algorithms.deck import SimulationDeck, read, format_xml +from geos_xml_viewer.algorithms.deck import SimulationDeck, read from lxml import etree as ElementTree # type: ignore[import-untyped] diff --git a/geos-xml-viewer/src/geos_xml_viewer/bin/viewer.py b/geos-xml-viewer/src/geos_xml_viewer/bin/viewer.py index 5a8e41499..e694a8d73 100644 --- a/geos-xml-viewer/src/geos_xml_viewer/bin/viewer.py +++ b/geos-xml-viewer/src/geos_xml_viewer/bin/viewer.py @@ -8,7 +8,13 @@ import colorcet as cc # type: ignore[import-untyped] import pyvista as pv -import vtkmodules.all as vtk + +from vtkmodules.vtkIOXML import vtkXMLPartitionedDataSetCollectionReader +from vtkmodules.vtkCommonCore import vtkIdList +from vtkmodules.vtkCommonDataModel import vtkDataAssembly, vtkPartitionedDataSetCollection, vtkStaticCellLocator +from vtkmodules.vtkRenderingCore import vtkActor +from vtkmodules.vtkFiltersCore import vtkExtractCells + from geos_xml_viewer.filters.geosDeckReader import GeosDeckReader from geos_xml_viewer.geos.models.schema import Problem from xsdata.formats.dataclass.context import XmlContext @@ -151,7 +157,7 @@ def update_clip( self, normal: tuple[ float ], origin: tuple[ float ] ) -> None: class SetVisibilityCallback: """Helper callback to keep a reference to the actor being modified.""" - def __init__( self, actor: vtk.vtkActor ) -> None: + def __init__( self, actor: vtkActor ) -> None: self.actor = actor def __call__( self, state: bool ) -> None: @@ -162,9 +168,9 @@ class SetVisibilitiesCallback: """Helper callback to keep a reference to the actor being modified.""" def __init__( self ) -> None: - self.actors: list[ vtk.vtkActor ] = [] + self.actors: list[ vtkActor ] = [] - def add_actor( self, actor: vtk.vtkActor ) -> None: + def add_actor( self, actor: vtkActor ) -> None: self.actors.append( actor ) def update_visibility( self, state: bool ) -> None: @@ -207,10 +213,10 @@ def find_surfaces( xmlFile: str ) -> list[ str ]: def main( args: argparse.Namespace ) -> None: start_time = time.monotonic() - pdsc: vtk.vtkPartitionedDataSetCollection + pdsc: vtkPartitionedDataSetCollection if args.vtpcFilepath != "": - reader = vtk.vtkXMLPartitionedDataSetCollectionReader() + reader = vtkXMLPartitionedDataSetCollectionReader() reader.SetFileName( args.vtpcFilepath ) reader.Update() pdsc = reader.GetOutput() @@ -224,7 +230,7 @@ def main( args: argparse.Namespace ) -> None: read_time = time.monotonic() print( "time elapsed reading files: ", timedelta( seconds=read_time - start_time ) ) - assembly: vtk.vtkDataAssembly = pdsc.GetDataAssembly() + assembly: vtkDataAssembly = pdsc.GetDataAssembly() root_name: str = assembly.GetNodeName( assembly.GetRootNode() ) surfaces_used = find_surfaces( args.xmlFilepath ) @@ -405,7 +411,7 @@ def main( args: argparse.Namespace ) -> None: border_size=1, ) - my_cell_locator = vtk.vtkStaticCellLocator() + my_cell_locator = vtkStaticCellLocator() my_cell_locator.SetDataSet( region_engine.input ) my_cell_locator.AutomaticOn() my_cell_locator.SetNumberOfCellsPerNode( 20 ) @@ -421,9 +427,9 @@ def main( args: argparse.Namespace ) -> None: # render cell containing perforation cell_id = my_cell_locator.FindCell( m.center ) if cell_id != -1: - id_list = vtk.vtkIdList() + id_list = vtkIdList() id_list.InsertNextId( cell_id ) - extract = vtk.vtkExtractCells() + extract = vtkExtractCells() extract.SetInputDataObject( region_engine.input ) extract.SetCellList( id_list ) extract.Update() diff --git a/geos-xml-viewer/src/geos_xml_viewer/filters/geosDeckReader.py b/geos-xml-viewer/src/geos_xml_viewer/filters/geosDeckReader.py index 0cd73cabe..38c7c86b8 100644 --- a/geos-xml-viewer/src/geos_xml_viewer/filters/geosDeckReader.py +++ b/geos-xml-viewer/src/geos_xml_viewer/filters/geosDeckReader.py @@ -3,7 +3,8 @@ # SPDX-FileContributor: Lionel Untereiner from typing_extensions import Self -import vtkmodules.all as vtk +from vtkmodules.vtkCommonCore import vtkInformation, vtkInformationVector +from vtkmodules.vtkCommonDataModel import vtkPartitionedDataSetCollection from vtkmodules.util.vtkAlgorithm import VTKPythonAlgorithmBase from geos_xml_viewer.algorithms.deck import SimulationDeck, build_model, read @@ -53,9 +54,9 @@ def GetAttributeName( self: Self ) -> str: def RequestData( self: Self, - request: vtk.vtkInformation, - inInfoVec: vtk.vtkInformationVector, - outInfoVec: vtk.vtkInformationVector, + request: vtkInformation, + inInfoVec: vtkInformationVector, + outInfoVec: vtkInformationVector, ) -> int: """RequestData function of the vtk pipeline. @@ -68,9 +69,9 @@ def RequestData( int: Returns 1 if the pipeline is successful """ self.__simulationDeck = read( self.__filename ) - opt = vtk.vtkPartitionedDataSetCollection.GetData( outInfoVec ) + opt = vtkPartitionedDataSetCollection.GetData( outInfoVec ) - output = vtk.vtkPartitionedDataSetCollection() + output = vtkPartitionedDataSetCollection() build_model( self.__simulationDeck, output, self.__attributeName ) opt.ShallowCopy( output )