Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion geos-trame/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ dependencies = [
"trame-components==2.4.2",
"trame-gantt==0.1.5",
"mpld3<0.5.11",
"xsdata==24.5",
"xsdata[cli]>24.5",
"xsdata-pydantic[lxml]==24.5",
"pyvista==0.45.2",
"dpath==2.2.0",
Expand Down
6 changes: 3 additions & 3 deletions geos-trame/src/geos/trame/app/deck/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from geos.trame.app.geosTrameException import GeosTrameException
from geos.trame.app.io.xml_parser import XMLParser
from geos.trame.app.utils.file_utils import normalize_path
from geos.trame.schema_generated.schema_mod import Problem
from geos.trame.schema_generated.schema_mod import ProblemType


class DeckFile( object ):
Expand All @@ -30,7 +30,7 @@ def __init__( self, filename: str, **kwargs: Any ) -> None:

self.inspect_tree: dict[ Any, Any ] | None = None
self.pb_dict: dict[ str, Any ] | None = None
self.problem: Problem | None = None
self.problem: ProblemType | None = None
self.xml_parser: XMLParser | None = None
self.root_node = None
self.filename = normalize_path( filename )
Expand Down Expand Up @@ -79,7 +79,7 @@ def open_deck_file( self, filename: str ) -> None:
)
parser = XmlParser( context=context, config=ParserConfig() )
try:
self.problem = parser.parse( simulation_deck, Problem )
self.problem = parser.parse( simulation_deck, ProblemType )
except ElementTree.XMLSyntaxError as e:
msg = "Failed to parse input file %s:\n%s\n" % ( filename, e )
raise GeosTrameException( msg ) from e
Expand Down
22 changes: 11 additions & 11 deletions geos-trame/src/geos/trame/app/deck/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from geos.trame.app.deck.file import DeckFile
from geos.trame.app.geosTrameException import GeosTrameException
from geos.trame.schema_generated.schema_mod import Problem, Included, File, Functions
from geos.trame.schema_generated.schema_mod import ProblemType, IncludedType, FileType, FunctionsType
from geos.trame.app.utils.file_utils import normalize_path, format_xml


Expand Down Expand Up @@ -100,14 +100,14 @@ def decode( self, path: str ) -> BaseModel | None:
return decoder.decode( data[ 0 ] )

@staticmethod
def decode_data( data: dict ) -> Problem:
def decode_data( data: dict ) -> ProblemType:
"""Convert a data to a xml serializable file."""
context = XmlContext(
element_name_generator=text.pascal_case,
attribute_name_generator=text.camel_case,
)
decoder = DictDecoder( context=context, config=ParserConfig() )
node: Problem = decoder.decode( data )
node: ProblemType = decoder.decode( data )
return node

@staticmethod
Expand Down Expand Up @@ -144,7 +144,7 @@ def timeline( self ) -> list[ dict ] | None:

return timeline

def plots( self ) -> list[ Functions ]:
def plots( self ) -> list[ FunctionsType ]:
"""Get the functions in the current problem."""
assert self.input_file is not None and self.input_file.problem is not None
return self.input_file.problem.functions
Expand All @@ -157,8 +157,8 @@ def write_files( self ) -> None:
files = self._split( pb )

for filepath, content in files.items():
model_loaded: Problem = DeckTree.decode_data( content )
model_with_changes: Problem = self._apply_changed_properties( model_loaded )
model_loaded: ProblemType = DeckTree.decode_data( content )
model_with_changes: ProblemType = self._apply_changed_properties( model_loaded )

assert ( self.input_file is not None and self.input_file.xml_parser is not None )
if self.input_file.xml_parser.contains_include_files():
Expand All @@ -178,8 +178,8 @@ def write_files( self ) -> None:
self._ctrl.on_add_success( title="File saved", message=f"File {basename} has been saved." )

@staticmethod
def _append_include_file( model: Problem, included_file_path: str ) -> None:
"""Append an Included object which follows this structure according to the documentation.
def _append_include_file( model: ProblemType, included_file_path: str ) -> None:
"""Append an IncludedType object which follows this structure according to the documentation.

<Included>
<File name="./included_file.xml" />
Expand All @@ -192,8 +192,8 @@ def _append_include_file( model: Problem, included_file_path: str ) -> None:
if len( included_file_path ) == 0:
return

includedTag = Included()
includedTag.file.append( File( name=DeckTree._append_id( included_file_path ) ) )
includedTag = IncludedType()
includedTag.file.append( FileType( name=DeckTree._append_id( included_file_path ) ) )

model.included.append( includedTag )

Expand Down Expand Up @@ -235,7 +235,7 @@ def _convert_to_snake_case( content: str ) -> str:
"""
return "".join( [ "_" + char.lower() if char.isupper() else char for char in content ] ).lstrip( "_" )

def _apply_changed_properties( self, model: Problem ) -> Problem:
def _apply_changed_properties( self, model: ProblemType ) -> ProblemType:
"""Retrieves all edited 'properties' from the simput_manager and apply it to a given model."""
manager = get_simput_manager( self._sm_id )
modified_proxy_ids: set[ str ] = manager.proxymanager.dirty_proxy_data
Expand Down
30 changes: 15 additions & 15 deletions geos-trame/src/geos/trame/app/io/data_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
from geos.trame.app.ui.viewer.wellViewer import WellViewer
from geos.trame.app.utils.pv_utils import read_unstructured_grid, split_vector_arrays
from geos.trame.schema_generated.schema_mod import (
Vtkmesh,
Vtkwell,
Perforation,
InternalWell,
VtkmeshType,
VtkwellType,
PerforationType,
InternalWellType,
)


Expand Down Expand Up @@ -44,7 +44,7 @@ def load_vtkmesh_from_id( self, node_id: str ) -> None:
"""Load the data at the given id if none is already loaded."""
if self.region_viewer.input.number_of_cells == 0:
active_block = self.source.decode( node_id )
if isinstance( active_block, Vtkmesh ):
if isinstance( active_block, VtkmeshType ):
self._read_mesh( active_block )

def _update_object_state( self, object_state: tuple[ str, bool ], **_: dict ) -> None:
Expand All @@ -56,10 +56,10 @@ def _update_object_state( self, object_state: tuple[ str, bool ], **_: dict ) ->

active_block = self.source.decode( path )

if isinstance( active_block, Vtkmesh ):
if isinstance( active_block, VtkmeshType ):
self._update_vtkmesh( active_block, show_obj )

if isinstance( active_block, Vtkwell ):
if isinstance( active_block, VtkwellType ):
if self.region_viewer.input.number_of_cells == 0 and show_obj:
self.ctrl.on_add_warning(
"Can't display " + active_block.name,
Expand All @@ -69,7 +69,7 @@ def _update_object_state( self, object_state: tuple[ str, bool ], **_: dict ) ->

self._update_vtkwell( active_block, path, show_obj )

if isinstance( active_block, InternalWell ):
if isinstance( active_block, InternalWellType ):
if self.region_viewer.input.number_of_cells == 0 and show_obj:
self.ctrl.on_add_warning(
"Can't display " + active_block.name,
Expand All @@ -79,7 +79,7 @@ def _update_object_state( self, object_state: tuple[ str, bool ], **_: dict ) ->

self._update_internalwell( active_block, path, show_obj )

if ( isinstance( active_block, Perforation ) and self.well_viewer.get_number_of_wells() == 0 and show_obj ):
if ( isinstance( active_block, PerforationType ) and self.well_viewer.get_number_of_wells() == 0 and show_obj ):
self.ctrl.on_add_warning(
"Can't display " + active_block.name,
"Please display a well before creating a perforation",
Expand All @@ -88,21 +88,21 @@ def _update_object_state( self, object_state: tuple[ str, bool ], **_: dict ) ->

self.ctrl.update_viewer( active_block, path, show_obj )

def _update_vtkmesh( self, mesh: Vtkmesh, show: bool ) -> None:
def _update_vtkmesh( self, mesh: VtkmeshType, show: bool ) -> None:
if not show:
self.region_viewer.reset()
return

self._read_mesh( mesh )

def _read_mesh( self, mesh: Vtkmesh ) -> None:
def _read_mesh( self, mesh: VtkmeshType ) -> None:
unstructured_grid = read_unstructured_grid( self.source.get_abs_path( mesh.file ) )
split_vector_arrays( unstructured_grid )

unstructured_grid.set_active_scalars( unstructured_grid.cell_data.keys()[ 0 ] )
self.region_viewer.add_mesh( unstructured_grid )

def _update_vtkwell( self, well: Vtkwell, path: str, show: bool ) -> None:
def _update_vtkwell( self, well: VtkwellType, path: str, show: bool ) -> None:
if not show:
self.well_viewer.remove( path )
return
Expand All @@ -112,8 +112,8 @@ def _update_vtkwell( self, well: Vtkwell, path: str, show: bool ) -> None:
raise GeosTrameException( f"Expected PolyData, got {type(well_polydata).__name__}" )
self.well_viewer.add_mesh( well_polydata, path )

def _update_internalwell( self, well: InternalWell, path: str, show: bool ) -> None:
"""Used to control the visibility of the InternalWell.
def _update_internalwell( self, well: InternalWellType, path: str, show: bool ) -> None:
"""Used to control the visibility of the InternalWellType.

This method will create the mesh if it doesn't exist.
"""
Expand All @@ -134,7 +134,7 @@ def _update_internalwell( self, well: InternalWell, path: str, show: bool ) -> N

@staticmethod
def __parse_polyline_property( polyline_property: str, dtype: Type[ Any ] ) -> np.ndarray:
"""Internal method used to parse and convert a property, such as polyline_node_coords, from an InternalWell.
"""Internal method used to parse and convert a property, such as polyline_node_coords, from an InternalWellType.

This string always follow this for :
"{ { 800, 1450, 395.646 }, { 800, 1450, -554.354 } }"
Expand Down
4 changes: 2 additions & 2 deletions geos-trame/src/geos/trame/app/ui/inspector.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from geos.trame.app.data_types.tree_node import TreeNode
from geos.trame.app.deck.tree import DeckTree
from geos.trame.app.utils.dict_utils import iterate_nested_dict
from geos.trame.schema_generated.schema_mod import Problem
from geos.trame.schema_generated.schema_mod import ProblemType

vuetify.enable_lab()

Expand Down Expand Up @@ -113,7 +113,7 @@ def source( self ) -> dict | None:
# TODO
# v should be a proxy like the one in paraview simple
# maybe it can be Any of schema_mod (e.g. Problem)
def _set_source( self, v: Problem | None ) -> None:
def _set_source( self, v: ProblemType | None ) -> None:

# TODO replace this snippet
from xsdata.formats.dataclass.serializers.config import SerializerConfig
Expand Down
6 changes: 3 additions & 3 deletions geos-trame/src/geos/trame/app/ui/viewer/boxViewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# SPDX-FileContributor: Lucas Givord - Kitware
import pyvista as pv

from geos.trame.schema_generated.schema_mod import Box
from geos.trame.schema_generated.schema_mod import BoxType

import re

Expand All @@ -14,11 +14,11 @@ class BoxViewer:
This mesh is represented in GEOS with a Box.
"""

def __init__( self, mesh: pv.UnstructuredGrid, box: Box ) -> None:
def __init__( self, mesh: pv.UnstructuredGrid, box: BoxType ) -> None:
"""Initialize the BoxViewer with a mesh and a box."""
self._mesh: pv.UnstructuredGrid = mesh

self._box: Box = box
self._box: BoxType = box
self._box_polydata: pv.PolyData = None
self._box_polydata_actor: pv.Actor = None

Expand Down
38 changes: 19 additions & 19 deletions geos-trame/src/geos/trame/app/ui/viewer/viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from geos.trame.app.ui.viewer.perforationViewer import PerforationViewer
from geos.trame.app.ui.viewer.regionViewer import RegionViewer
from geos.trame.app.ui.viewer.wellViewer import WellViewer
from geos.trame.schema_generated.schema_mod import Box, Vtkmesh, Vtkwell, InternalWell, Perforation
from geos.trame.schema_generated.schema_mod import BoxType, VtkmeshType, VtkwellType, InternalWellType, PerforationType

pv.OFF_SCREEN = True

Expand All @@ -32,17 +32,17 @@ def __init__(
"""Deck representing the 3D View using PyVista.

This view can show:
- Vtkmesh,
- Vtkwell,
- Perforation,
- InternalWell
- Box
- VtkmeshType,
- VtkwellType,
- PerforationType,
- InternalWellType
- BoxType

Everything is handle in the method 'update_viewer()' which is trigger when the
'state.object_state' changed (see DeckTree).

This View handle widgets, such as clip widget or slider to control Wells or
Perforation settings.
PerforationType settings.
"""
super().__init__( **kwargs )

Expand Down Expand Up @@ -126,23 +126,23 @@ def rendering_menu_extra_items( self ) -> None:
def update_viewer( self, active_block: BaseModel, path: str, show_obj: bool ) -> None:
"""Add from path the dataset given by the user.

Supported data type is: Vtkwell, Vtkmesh, InternalWell, Perforation, Box.
Supported data type is: VtkwellType, VtkmeshType, InternalWellType, PerforationType, BoxType.

object_state : array used to store path to the data and if we want to show it or not.
"""
if isinstance( active_block, Vtkmesh ):
if isinstance( active_block, VtkmeshType ):
self._update_vtkmesh( show_obj )

if isinstance( active_block, Vtkwell ):
if isinstance( active_block, VtkwellType ):
self._update_vtkwell( path, show_obj )

if isinstance( active_block, InternalWell ):
if isinstance( active_block, InternalWellType ):
self._update_internalwell( path, show_obj )

if isinstance( active_block, Perforation ):
if isinstance( active_block, PerforationType ):
self._update_perforation( active_block, show_obj, path )

if isinstance( active_block, Box ):
if isinstance( active_block, BoxType ):
self._update_box( active_block, show_obj )

# when data is added in the pv.Plotter, we need to refresh the scene to update
Expand Down Expand Up @@ -220,7 +220,7 @@ def _get_perforation_size( self ) -> float | None:
return None

def _update_internalwell( self, path: str, show: bool ) -> None:
"""Used to control the visibility of the InternalWell.
"""Used to control the visibility of the InternalWellType.

This method will create the mesh if it doesn't exist.
"""
Expand All @@ -235,7 +235,7 @@ def _update_internalwell( self, path: str, show: bool ) -> None:
self.ctrl.view_update()

def _update_vtkwell( self, path: str, show: bool ) -> None:
"""Used to control the visibility of the Vtkwell.
"""Used to control the visibility of the VtkwellType.

This method will create the mesh if it doesn't exist.
"""
Expand Down Expand Up @@ -273,7 +273,7 @@ def _update_actor_array( self, **_: Any ) -> None:
self.ctrl.view_update()

def _update_vtkmesh( self, show: bool ) -> None:
"""Used to control the visibility of the Vtkmesh.
"""Used to control the visibility of the VtkmeshType.

This method will create the mesh if it doesn't exist.

Expand All @@ -298,7 +298,7 @@ def _update_vtkmesh( self, show: bool ) -> None:
tubing=False,
outline_translation=False )

def _update_perforation( self, perforation: Perforation, show: bool, path: str ) -> None:
def _update_perforation( self, perforation: PerforationType, show: bool, path: str ) -> None:
"""Generate VTK dataset from a perforation."""
if not show:
if path in self._perforations:
Expand Down Expand Up @@ -355,7 +355,7 @@ def _add_perforation( self, distance_from_head: float, path: str ) -> None:

self._perforations[ path ] = saved_perforation

def _update_box( self, active_block: Box, show_obj: bool ) -> None:
def _update_box( self, active_block: BoxType, show_obj: bool ) -> None:
"""Generate and display a Box and inner cell(s) from the mesh."""
if self.region_engine.input.number_of_cells == 0 and show_obj:
self.ctrl.on_add_warning(
Expand All @@ -375,7 +375,7 @@ def _update_box( self, active_block: Box, show_obj: bool ) -> None:
self._make_mesh_transparent( False )
return

box: Box = active_block
box: BoxType = active_block
self.box_engine[ active_block.name ] = BoxViewer( self.region_engine.input, box )

box_polydata: pv.PolyData = self.box_engine[ active_block.name ].get_box_polydata()
Expand Down
2 changes: 1 addition & 1 deletion geos-trame/src/geos/trame/app/ui/viewer/wellViewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class WellViewer:
def __init__( self, size: float, amplification: float ) -> None:
"""WellViewer stores all Well used in the pv.Plotter().

A Well in GEOS could a InternalWell or a Vtkwell.
A Well in GEOS could a InternalWellType or a VtkwellType.
"""
self._wells: list[ Well ] = []
self._wells_actors: list[ WellActor ] = []
Expand Down
Loading