Skip to content

Commit c9fa2e2

Browse files
committed
Merge remote-tracking branch 'origin/zzqbranch'
2 parents cb5b33c + c4fd823 commit c9fa2e2

File tree

6 files changed

+47
-19
lines changed

6 files changed

+47
-19
lines changed

examples/ICFD/icfd_free_convection_flow.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
2-
Thermal flow
3-
============
2+
Free convection flow
3+
====================
44
55
This example shows a simple ICFD forced-convection input deck with a coarse mesh.
66
The executable file for LS-DYNA is `` ls-dyna_smp_d_R13.1_138-g8429c8a10f_winx64_ifort190.exe``.

pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ classifiers = [
2828
dependencies = ["ansys-dpf-core>=0.7.2",
2929
"ansys-api-dyna==0.3.6",
3030
"ansys-platform-instancemanagement~=1.0",
31+
"pyvista==0.43.4",
3132
]
3233

3334
[project.optional-dependencies]
3435
tests = [
35-
"pyvista==0.43.4",
3636
"matplotlib==3.8.3",
3737
"numpy==1.26.4",
3838
"pytest==8.1.1",
@@ -49,7 +49,6 @@ doc = [
4949
"matplotlib==3.8.3",
5050
"imageio==2.34.0",
5151
"imageio-ffmpeg==0.4.9",
52-
"pyvista==0.43.4",
5352
"numpydoc==1.6.0",
5453
"Sphinx==7.2.6",
5554
"sphinx-autobuild==2024.2.4",

src/ansys/dyna/core/pre/dynabase.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,14 @@ def get_data(self) -> List:
274274
return None
275275

276276

277+
class ParameterType(Enum):
278+
"""Contains the parameter types."""
279+
280+
R = 1
281+
I = 2
282+
C = 3
283+
284+
277285
class DynaBase:
278286
"""Contains methods for creating a general LS-DYNA keyword."""
279287

src/ansys/dyna/core/pre/graphics/graphics.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import numpy as np
77
import pyvista as pv
8-
from pyvista.plotting.plotting import Plotter
8+
from pyvista.plotting import Plotter
99
import vtk
1010

1111
import ansys.dyna.core.pre as pre
@@ -172,7 +172,7 @@ class Graphics(object):
172172
Whether to use the Trame visualizer. The default is ``False``.
173173
"""
174174

175-
def __init__(self, model: pre.Model, use_trame: bool = False):
175+
def __init__(self, model: pre.Model, use_trame: bool = False, view_position: str = "xy"):
176176
"""Initialize graphics."""
177177
self._model = model
178178
self._display_data = {}
@@ -199,6 +199,7 @@ def __init__(self, model: pre.Model, use_trame: bool = False):
199199
self._viewLeftBt: vtk.vtkButtonWidget = None
200200
self._sphinx_build = defaults.get_sphinx_build()
201201
self._use_trame = use_trame
202+
self._view_position = view_position
202203
self._init_velocity_data = []
203204
self._bdy_spc = []
204205
self._actor_init_velocity = None
@@ -631,12 +632,17 @@ def __draw_parts(self, parts: List = [], update: bool = False, spline: bool = Fa
631632
def _show_selector(self):
632633
"""Chooses between using Trame or Python visualizer."""
633634
if self._use_trame: # pragma: no cover
635+
pv.set_jupyter_backend("server")
634636
visualizer = TrameVisualizer()
635637
visualizer.set_scene(self._plotter)
636638
visualizer.show()
637639
else:
638-
self._plotter.camera_position = "xy"
639-
self._plotter.show()
640+
if self._view_position in ["xy", "xz", "yx", "yz", "zx", "zy"]:
641+
pos = self._view_position
642+
else:
643+
pos = "xy"
644+
self._plotter.camera_position = pos
645+
self._plotter.show(jupyter_backend="static")
640646

641647
def __update_bt_icons(self):
642648
"""Update the icons on display."""
@@ -835,7 +841,7 @@ def add_to_plotter(self, plotter: Plotter):
835841
if self._type is DisplayMeshType.FACE:
836842
surf = pv.PolyData(self._vertices, self._facet_list)
837843
fcolor = np.array(self.get_face_color())
838-
colors = np.tile(fcolor, (surf.n_faces, 1))
844+
colors = np.tile(fcolor, (surf.n_cells, 1))
839845
surf["colors"] = colors
840846
surf.disp_mesh = self
841847
self._poly_data = surf
@@ -847,7 +853,7 @@ def add_to_plotter(self, plotter: Plotter):
847853
elif self._type is DisplayMeshType.BEAM:
848854
surf = pv.PolyData(self._vertices, lines=self._facet_list)
849855
fcolor = np.array(self.get_face_color())
850-
colors = np.tile(fcolor, (surf.n_faces, 1))
856+
colors = np.tile(fcolor, (surf.n_cells, 1))
851857
surf["colors"] = colors
852858
surf.disp_mesh = self
853859
self._poly_data = surf
@@ -861,7 +867,7 @@ def add_to_plotter(self, plotter: Plotter):
861867
):
862868
surf = self._mesh
863869
fcolor = np.array(self.get_face_color())
864-
colors = np.tile(fcolor, (surf.n_faces, 1))
870+
colors = np.tile(fcolor, (surf.n_cells, 1))
865871
surf["colors"] = colors
866872
surf.disp_mesh = self
867873
self._poly_data = surf
@@ -968,5 +974,5 @@ def set_color_by_type(self, type: ColorByType):
968974
if self._type == DisplayMeshType.FACE:
969975
if self._poly_data != None:
970976
fcolor = np.array(self.get_face_color())
971-
colors = np.tile(fcolor, (self._poly_data.n_faces, 1))
977+
colors = np.tile(fcolor, (self._poly_data.n_cells, 1))
972978
self._poly_data["colors"] = colors

src/ansys/dyna/core/pre/graphics/trame_gui.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
try:
33
from pyvista.trame.ui import plotter_ui
44
from trame.app import get_server
5-
from trame.ui.vuetify import SinglePageLayout
5+
from trame.ui.vuetify3 import SinglePageLayout
6+
from trame.widgets import vuetify3
67

78
_HAS_TRAME = True
89

@@ -18,7 +19,7 @@ def __init__(self) -> None:
1819
if not _HAS_TRAME: # pragma: no cover
1920
raise ModuleNotFoundError("The package 'pyvista[trame]' is required to use this function.")
2021

21-
self.server = get_server()
22+
self.server = get_server(client_type="vue3")
2223
self.state, self.ctrl = self.server.state, self.server.controller
2324

2425
def set_scene(self, plotter):
@@ -31,16 +32,17 @@ def set_scene(self, plotter):
3132
plotter : pv.Plotter
3233
PyVista plotter to render the mesh.
3334
"""
34-
self.state.trame__title = "PyPrime Viewer"
35+
self.state.trame__title = "PyDYNA Viewer"
3536

3637
with SinglePageLayout(self.server) as layout:
3738
layout.icon.click = self.ctrl.view_reset_camera
38-
layout.title.set_text("PyPrime")
39+
layout.title.set_text("PyDYNA")
3940

4041
with layout.content:
41-
# Use PyVista UI template for Plotters
42-
view = plotter_ui(plotter)
43-
self.ctrl.view_update = view.update
42+
with vuetify3.VContainer(fluid=True, classes="pa-0 fill-height"):
43+
# Use PyVista UI template for Plotters
44+
view = plotter_ui(plotter)
45+
self.ctrl.view_update = view.update
4446

4547
# hide footer with trame watermark
4648
layout.footer.hide()

src/ansys/dyna/core/pre/launcher.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import os
44
import socket
55
import subprocess
6+
import sys
67
import threading
78
from time import sleep
89
from zipfile import ZipFile
@@ -74,6 +75,17 @@ def port_in_use(port, host=LOCALHOST):
7475
return True
7576

7677

78+
def get_virtualenv_path():
79+
"""Get the virtual environment path."""
80+
81+
python_executable_path = sys.executable
82+
if hasattr(sys, "real_prefix"):
83+
virtual_env_path = sys.prefix
84+
else:
85+
virtual_env_path = os.path.dirname(python_executable_path)
86+
return virtual_env_path
87+
88+
7789
def launch_grpc(port=DYNAPRE_DEFAULT_PORT, ip=LOCALHOST, server_path="") -> tuple: # pragma: no cover
7890
"""
7991
Launch the pre service locally in gRPC mode.
@@ -123,6 +135,7 @@ def launch_grpc(port=DYNAPRE_DEFAULT_PORT, ip=LOCALHOST, server_path="") -> tupl
123135
# threadserver.run()
124136
# threadserver.setDaemon(True)
125137
# threadserver.start()
138+
# env_path = get_virtualenv_path()
126139
process = subprocess.Popen("python kwserver.py", cwd=server_path, shell=True)
127140
waittime = 0
128141
while not DynaSolution.grpc_local_server_on():

0 commit comments

Comments
 (0)