Skip to content

Commit b2ee716

Browse files
committed
feat: enable vtu file support
- Enables external vtu file support, see new default file. This is done in the same framework as for the Exodus files. - Improves testing suite: we now test for different files with different geometry types: exo, vtu, legacy. Also, the vtu path is tested for, which more reliably verifies if the geometry of the yaml file was initialized correctly. - Improves rendering of design conditions: threshold was replaced by more reliable point filtering. Hence, only the relevant points are included, and not all cells containing these relevant points.
1 parent bb5d38a commit b2ee716

18 files changed

+25254
-765
lines changed

requirements.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ pandas
88
pyvista
99
vtk==9.4.2
1010
numpy
11-
fourcipp
11+
git+https://github.com/4C-multiphysics/fourcipp
1212
lnmmeshio>=5.6.3
1313
numexpr
1414
netCDF4

requirements.txt

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,25 @@
22
# This file is autogenerated by pip-compile with Python 3.12
33
# by the following command:
44
#
5-
# pip-compile --all-extras --cert=None --client-cert=None --index-url=None --output-file=requirements.txt --pip-args=None requirements.in
5+
# pip-compile --all-extras --output-file=requirements.txt requirements.in
66
#
77
aiohappyeyeballs==2.6.1
88
# via aiohttp
9-
aiohttp==3.12.15
9+
aiohttp==3.13.2
1010
# via wslink
1111
aiosignal==1.4.0
1212
# via aiohttp
13-
attrs==25.3.0
13+
attrs==25.4.0
1414
# via aiohttp
15-
certifi==2025.8.3
15+
certifi==2025.11.12
1616
# via
1717
# netcdf4
1818
# requests
19-
cfgv==3.4.0
19+
cfgv==3.5.0
2020
# via pre-commit
21-
cftime==1.6.4.post1
21+
cftime==1.6.5
2222
# via netcdf4
23-
charset-normalizer==3.4.3
23+
charset-normalizer==3.4.4
2424
# via requests
2525
contourpy==1.3.3
2626
# via matplotlib
@@ -30,25 +30,25 @@ deprecation==2.1.0
3030
# via rapidyaml
3131
distlib==0.4.0
3232
# via virtualenv
33-
filelock==3.19.1
33+
filelock==3.20.0
3434
# via virtualenv
35-
fonttools==4.60.0
35+
fonttools==4.60.1
3636
# via matplotlib
37-
fourcipp==1.18.0
37+
fourcipp @ git+https://github.com/4C-multiphysics/fourcipp
3838
# via -r requirements.in
39-
frozenlist==1.7.0
39+
frozenlist==1.8.0
4040
# via
4141
# aiohttp
4242
# aiosignal
43-
identify==2.6.14
43+
identify==2.6.15
4444
# via pre-commit
45-
idna==3.10
45+
idna==3.11
4646
# via
4747
# requests
4848
# yarl
49-
iniconfig==2.1.0
49+
iniconfig==2.3.0
5050
# via pytest
51-
jsonschema-rs==0.33.0
51+
jsonschema-rs==0.37.1
5252
# via fourcipp
5353
kiwisolver==1.4.9
5454
# via matplotlib
@@ -60,7 +60,7 @@ loguru==0.7.3
6060
# lnmmeshio
6161
markdown-it-py==4.0.0
6262
# via rich
63-
matplotlib==3.10.6
63+
matplotlib==3.10.7
6464
# via
6565
# pyvista
6666
# vtk
@@ -70,21 +70,21 @@ meshio==5.3.5
7070
# via lnmmeshio
7171
more-itertools==10.8.0
7272
# via trame-server
73-
msgpack==1.1.1
73+
msgpack==1.1.2
7474
# via wslink
75-
multidict==6.6.4
75+
multidict==6.7.0
7676
# via
7777
# aiohttp
7878
# yarl
79-
narwhals==2.5.0
79+
narwhals==2.12.0
8080
# via plotly
81-
netcdf4==1.7.2
81+
netcdf4==1.7.3
8282
# via -r requirements.in
8383
nodeenv==1.9.1
8484
# via pre-commit
85-
numexpr==2.13.0
85+
numexpr==2.14.1
8686
# via -r requirements.in
87-
numpy==2.3.3
87+
numpy==2.3.5
8888
# via
8989
# -r requirements.in
9090
# cftime
@@ -104,27 +104,27 @@ packaging==25.0
104104
# plotly
105105
# pooch
106106
# pytest
107-
pandas==2.3.2
107+
pandas==2.3.3
108108
# via -r requirements.in
109-
pillow==11.3.0
109+
pillow==12.0.0
110110
# via
111111
# matplotlib
112112
# pyvista
113-
platformdirs==4.4.0
113+
platformdirs==4.5.0
114114
# via
115115
# pooch
116116
# virtualenv
117-
plotly==6.3.0
117+
plotly==6.5.0
118118
# via
119119
# -r requirements.in
120120
# trame-plotly
121121
pluggy==1.6.0
122122
# via pytest
123123
pooch==1.8.2
124124
# via pyvista
125-
pre-commit==4.3.0
125+
pre-commit==4.5.0
126126
# via -r requirements.in
127-
propcache==0.3.2
127+
propcache==0.4.1
128128
# via
129129
# aiohttp
130130
# yarl
@@ -134,7 +134,7 @@ pygments==2.19.2
134134
# rich
135135
pyparsing==3.2.5
136136
# via matplotlib
137-
pytest==8.4.2
137+
pytest==9.0.1
138138
# via -r requirements.in
139139
python-dateutil==2.9.0.post0
140140
# via
@@ -144,30 +144,30 @@ python-utils==3.9.1
144144
# via lnmmeshio
145145
pytz==2025.2
146146
# via pandas
147-
pyvista==0.46.3
147+
pyvista==0.46.4
148148
# via -r requirements.in
149-
pyyaml==6.0.2
149+
pyyaml==6.0.3
150150
# via
151151
# lnmmeshio
152152
# pre-commit
153153
# trame
154-
rapidyaml==0.9.0
154+
rapidyaml==0.10.0
155155
# via fourcipp
156-
regex==2025.9.18
156+
regex==2025.11.3
157157
# via fourcipp
158158
requests==2.32.5
159159
# via pooch
160-
rich==14.1.0
160+
rich==14.2.0
161161
# via meshio
162-
scooby==0.10.2
162+
scooby==0.11.0
163163
# via pyvista
164164
six==1.17.0
165165
# via python-dateutil
166166
tqdm==4.66.5
167167
# via lnmmeshio
168168
trame==3.12.0
169169
# via -r requirements.in
170-
trame-client==3.10.4
170+
trame-client==3.11.2
171171
# via
172172
# trame
173173
# trame-components
@@ -182,11 +182,11 @@ trame-components==2.5.0
182182
# via -r requirements.in
183183
trame-plotly==3.1.0
184184
# via -r requirements.in
185-
trame-server==3.6.1
185+
trame-server==3.8.1
186186
# via trame
187-
trame-vtk==2.9.1
187+
trame-vtk==2.10.0
188188
# via -r requirements.in
189-
trame-vuetify==3.0.3
189+
trame-vuetify==3.1.0
190190
# via -r requirements.in
191191
typing-extensions==4.15.0
192192
# via
@@ -197,15 +197,15 @@ tzdata==2025.2
197197
# via pandas
198198
urllib3==2.5.0
199199
# via requests
200-
virtualenv==20.34.0
200+
virtualenv==20.35.4
201201
# via pre-commit
202202
vtk==9.4.2
203203
# via
204204
# -r requirements.in
205205
# pyvista
206-
wslink==2.4.0
206+
wslink==2.5.0
207207
# via
208208
# trame
209209
# trame-server
210-
yarl==1.20.1
210+
yarl==1.22.0
211211
# via aiohttp

src/fourc_webviewer/fourc_webserver.py

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
import numpy as np
1111
import pyvista as pv
12-
import yaml
1312
from fourcipp import CONFIG
1413
from fourcipp.fourc_input import FourCInput, ValidationError
1514
from trame.app import get_server
@@ -30,18 +29,16 @@
3029
from fourc_webviewer.python_utils import (
3130
convert_string2number,
3231
dict_leaves_to_number_if_schema,
33-
dict_number_leaves_to_string,
3432
find_value_recursively,
3533
parse_validation_error_text,
36-
smart_string2number_cast,
3734
)
3835
from fourc_webviewer.read_geometry_from_file import (
3936
FourCGeometry,
4037
)
4138

4239
# Global variable
4340
# factor which scales the spheres used to represent nodal design conditions and result descriptions with respect to the problem length scale
44-
PV_SPHERE_FRAC_SCALE = 1.0 / 45.0
41+
PV_SPHERE_FRAC_SCALE = 1.0 / 75.0
4542

4643
# always set pyvista to plot off screen with Trame
4744
pv.OFF_SCREEN = True
@@ -124,6 +121,7 @@ def __init__(
124121
fourc_geometry = FourCGeometry(
125122
fourc_yaml_file=fourc_yaml_file,
126123
temp_dir=Path(self._server_vars["temp_dir_object"].name),
124+
first_render=True,
127125
)
128126
self.state.vtu_path = fourc_geometry.vtu_file_path
129127

@@ -274,8 +272,10 @@ def init_pyvista_render_objects(self):
274272

275273
self._server_vars["render_window"].clear_actors()
276274

275+
# read problem mesh
277276
problem_mesh = pv.read(self.state.vtu_path)
278-
# get problem mesh
277+
278+
# save problem mesh as actor
279279
self._actors["problem_mesh"] = self._server_vars["render_window"].add_mesh(
280280
problem_mesh, color="bisque", opacity=0.2, render=False
281281
)
@@ -285,6 +285,7 @@ def init_pyvista_render_objects(self):
285285
for material in self.state.materials_section.keys():
286286
# get meshes of materials
287287
master_mat_ind = self.determine_master_mat_ind_for_material(material)
288+
288289
self._actors["material_meshes"][material] = self._server_vars[
289290
"render_window"
290291
].add_mesh(
@@ -305,11 +306,11 @@ def init_pyvista_render_objects(self):
305306
self._actors["dc_geometry_entities"] = {}
306307
# get nodes of the selected condition geometries + entities
307308
for dc_entity in all_dc_entities:
308-
points = problem_mesh.threshold(
309-
value=1.0,
310-
scalars=f"d{dc_entity['geometry_type'].lower()}{dc_entity['entity'].replace('E', '')}",
311-
preference="point",
312-
).points
309+
# get mesh points associated with design condition
310+
condition_array_name = f"d{dc_entity['geometry_type'].lower()}{dc_entity['entity'].replace('E', '')}"
311+
points = problem_mesh.points[
312+
np.where(problem_mesh.point_data[condition_array_name] == 1)[0], :
313+
]
313314

314315
if points.size:
315316
pts = pv.PolyData(points)
@@ -449,7 +450,7 @@ def init_general_sections_state_and_server_vars(self):
449450
].sections.items():
450451
if (
451452
not any(substr in section_name for substr in substr_to_exclude)
452-
and not section_name in sect_to_exclude
453+
and section_name not in sect_to_exclude
453454
): # account for sections to be excluded as defined above
454455
# check if the current section is "SOLVER<number>"
455456
if re.match("^SOLVER [0-9]+", section_name): # yes
@@ -1175,11 +1176,6 @@ def change_selected_material(self, selected_material, **kwargs):
11751176
# we need to select the material region based on the newly selected
11761177
# material (if we are not in an initial rendering scenario)
11771178
if self._server_vars["render_count"]["change_selected_material"] > 0:
1178-
# first get the master material id
1179-
master_mat_id = self.determine_master_mat_ind_for_material(
1180-
selected_material
1181-
)
1182-
11831179
# update plotter / render objects
11841180
self.update_pyvista_render_objects()
11851181

src/fourc_webviewer/input_file_utils/io_utils.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,11 @@ def mat_specifiers():
251251
"VISCOPLAST_LAW_ID",
252252
"FIBER_READER_ID",
253253
"STR_TENS_ID",
254+
"MATIDSCONST",
255+
"MATIDMIXTURERULE",
256+
"GROWTH_STRATEGY",
257+
"FIBER_MATERIAL_ID",
258+
"PRESTRESS_STRATEGY",
254259
]
255260

256261

0 commit comments

Comments
 (0)