Skip to content
Merged
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
84 changes: 42 additions & 42 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@
# This file is autogenerated by pip-compile with Python 3.12
# by the following command:
#
# pip-compile --all-extras --cert=None --client-cert=None --index-url=None --output-file=requirements.txt --pip-args=None requirements.in
# pip-compile --all-extras --output-file=requirements.txt requirements.in
#
aiohappyeyeballs==2.6.1
# via aiohttp
aiohttp==3.12.15
aiohttp==3.13.2
# via wslink
aiosignal==1.4.0
# via aiohttp
attrs==25.3.0
attrs==25.4.0
# via aiohttp
certifi==2025.8.3
certifi==2025.11.12
# via
# netcdf4
# requests
cfgv==3.4.0
cfgv==3.5.0
# via pre-commit
cftime==1.6.4.post1
cftime==1.6.5
# via netcdf4
charset-normalizer==3.4.3
charset-normalizer==3.4.4
# via requests
contourpy==1.3.3
# via matplotlib
Expand All @@ -30,25 +30,25 @@ deprecation==2.1.0
# via rapidyaml
distlib==0.4.0
# via virtualenv
filelock==3.19.1
filelock==3.20.0
# via virtualenv
fonttools==4.60.0
fonttools==4.60.1
# via matplotlib
fourcipp==1.18.0
fourcipp==1.39.0
# via -r requirements.in
frozenlist==1.7.0
frozenlist==1.8.0
# via
# aiohttp
# aiosignal
identify==2.6.14
identify==2.6.15
# via pre-commit
idna==3.10
idna==3.11
# via
# requests
# yarl
iniconfig==2.1.0
iniconfig==2.3.0
# via pytest
jsonschema-rs==0.33.0
jsonschema-rs==0.37.1
# via fourcipp
kiwisolver==1.4.9
# via matplotlib
Expand All @@ -60,7 +60,7 @@ loguru==0.7.3
# lnmmeshio
markdown-it-py==4.0.0
# via rich
matplotlib==3.10.6
matplotlib==3.10.7
# via
# pyvista
# vtk
Expand All @@ -70,21 +70,21 @@ meshio==5.3.5
# via lnmmeshio
more-itertools==10.8.0
# via trame-server
msgpack==1.1.1
msgpack==1.1.2
# via wslink
multidict==6.6.4
multidict==6.7.0
# via
# aiohttp
# yarl
narwhals==2.5.0
narwhals==2.12.0
# via plotly
netcdf4==1.7.2
netcdf4==1.7.3
# via -r requirements.in
nodeenv==1.9.1
# via pre-commit
numexpr==2.13.0
numexpr==2.14.1
# via -r requirements.in
numpy==2.3.3
numpy==2.3.5
# via
# -r requirements.in
# cftime
Expand All @@ -104,27 +104,27 @@ packaging==25.0
# plotly
# pooch
# pytest
pandas==2.3.2
pandas==2.3.3
# via -r requirements.in
pillow==11.3.0
pillow==12.0.0
# via
# matplotlib
# pyvista
platformdirs==4.4.0
platformdirs==4.5.0
# via
# pooch
# virtualenv
plotly==6.3.0
plotly==6.5.0
# via
# -r requirements.in
# trame-plotly
pluggy==1.6.0
# via pytest
pooch==1.8.2
# via pyvista
pre-commit==4.3.0
pre-commit==4.5.0
# via -r requirements.in
propcache==0.3.2
propcache==0.4.1
# via
# aiohttp
# yarl
Expand All @@ -134,7 +134,7 @@ pygments==2.19.2
# rich
pyparsing==3.2.5
# via matplotlib
pytest==8.4.2
pytest==9.0.1
# via -r requirements.in
python-dateutil==2.9.0.post0
# via
Expand All @@ -144,30 +144,30 @@ python-utils==3.9.1
# via lnmmeshio
pytz==2025.2
# via pandas
pyvista==0.46.3
pyvista==0.46.4
# via -r requirements.in
pyyaml==6.0.2
pyyaml==6.0.3
# via
# lnmmeshio
# pre-commit
# trame
rapidyaml==0.9.0
rapidyaml==0.10.0
# via fourcipp
regex==2025.9.18
regex==2025.11.3
# via fourcipp
requests==2.32.5
# via pooch
rich==14.1.0
rich==14.2.0
# via meshio
scooby==0.10.2
scooby==0.11.0
# via pyvista
six==1.17.0
# via python-dateutil
tqdm==4.66.5
# via lnmmeshio
trame==3.12.0
# via -r requirements.in
trame-client==3.10.4
trame-client==3.11.2
# via
# trame
# trame-components
Expand All @@ -182,11 +182,11 @@ trame-components==2.5.0
# via -r requirements.in
trame-plotly==3.1.0
# via -r requirements.in
trame-server==3.6.1
trame-server==3.8.1
# via trame
trame-vtk==2.9.1
trame-vtk==2.10.0
# via -r requirements.in
trame-vuetify==3.0.3
trame-vuetify==3.1.0
# via -r requirements.in
typing-extensions==4.15.0
# via
Expand All @@ -197,15 +197,15 @@ tzdata==2025.2
# via pandas
urllib3==2.5.0
# via requests
virtualenv==20.34.0
virtualenv==20.35.4
# via pre-commit
vtk==9.4.2
# via
# -r requirements.in
# pyvista
wslink==2.4.0
wslink==2.5.0
# via
# trame
# trame-server
yarl==1.20.1
yarl==1.22.0
# via aiohttp
33 changes: 16 additions & 17 deletions src/fourc_webviewer/fourc_webserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

import numpy as np
import pyvista as pv
import yaml
from fourcipp import CONFIG
from fourcipp.fourc_input import FourCInput, ValidationError
from loguru import logger
from trame.app import get_server
from trame.decorators import TrameApp, change, controller

Expand All @@ -30,18 +30,16 @@
from fourc_webviewer.python_utils import (
convert_string2number,
dict_leaves_to_number_if_schema,
dict_number_leaves_to_string,
find_value_recursively,
parse_validation_error_text,
smart_string2number_cast,
)
from fourc_webviewer.read_geometry_from_file import (
FourCGeometry,
)

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

# always set pyvista to plot off screen with Trame
pv.OFF_SCREEN = True
Expand Down Expand Up @@ -124,6 +122,7 @@ def __init__(
fourc_geometry = FourCGeometry(
fourc_yaml_file=fourc_yaml_file,
temp_dir=Path(self._server_vars["temp_dir_object"].name),
first_render=True,
)
self.state.vtu_path = fourc_geometry.vtu_file_path

Expand Down Expand Up @@ -274,8 +273,10 @@ def init_pyvista_render_objects(self):

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

# read problem mesh
problem_mesh = pv.read(self.state.vtu_path)
# get problem mesh

# save problem mesh as actor
self._actors["problem_mesh"] = self._server_vars["render_window"].add_mesh(
problem_mesh, color="bisque", opacity=0.2, render=False
)
Expand All @@ -285,6 +286,7 @@ def init_pyvista_render_objects(self):
for material in self.state.materials_section.keys():
# get meshes of materials
master_mat_ind = self.determine_master_mat_ind_for_material(material)

self._actors["material_meshes"][material] = self._server_vars[
"render_window"
].add_mesh(
Expand All @@ -305,11 +307,11 @@ def init_pyvista_render_objects(self):
self._actors["dc_geometry_entities"] = {}
# get nodes of the selected condition geometries + entities
for dc_entity in all_dc_entities:
points = problem_mesh.threshold(
value=1.0,
scalars=f"d{dc_entity['geometry_type'].lower()}{dc_entity['entity'].replace('E', '')}",
preference="point",
).points
# get mesh points associated with design condition
condition_array_name = f"d{dc_entity['geometry_type'].lower()}{dc_entity['entity'].replace('E', '')}"
points = problem_mesh.points[
np.where(problem_mesh.point_data[condition_array_name] == 1)[0], :
]

if points.size:
pts = pv.PolyData(points)
Expand Down Expand Up @@ -449,7 +451,7 @@ def init_general_sections_state_and_server_vars(self):
].sections.items():
if (
not any(substr in section_name for substr in substr_to_exclude)
and not section_name in sect_to_exclude
and section_name not in sect_to_exclude
): # account for sections to be excluded as defined above
# check if the current section is "SOLVER<number>"
if re.match("^SOLVER [0-9]+", section_name): # yes
Expand Down Expand Up @@ -898,7 +900,9 @@ def init_funct_state_and_server_vars(self):

else:
# warning that this function item is not known
print(f"Unknown function item {item_data} for funct {funct_name}!")
logger.warning(
f"Unknown function item {item_data} for funct {funct_name}!"
)

# we don't enable visualization
item_data["VISUALIZATION"] = False
Expand Down Expand Up @@ -1175,11 +1179,6 @@ def change_selected_material(self, selected_material, **kwargs):
# we need to select the material region based on the newly selected
# material (if we are not in an initial rendering scenario)
if self._server_vars["render_count"]["change_selected_material"] > 0:
# first get the master material id
master_mat_id = self.determine_master_mat_ind_for_material(
selected_material
)

# update plotter / render objects
self.update_pyvista_render_objects()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import numexpr as ne
import numpy as np
import plotly.express as px
from loguru import logger

from fourc_webviewer.input_file_utils.io_utils import (
get_variable_data_by_name_in_funct_item,
Expand Down Expand Up @@ -261,6 +262,8 @@ def construct_funct_string_from_variable_data(

case _:
# warning that this variable type is not yet supported for visualization
print(f"Variable with {variable_data} not supported for visualization!")
logger.warning(
f"Variable with {variable_data} not supported for visualization!"
)

return funct_string
10 changes: 8 additions & 2 deletions src/fourc_webviewer/input_file_utils/io_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from pathlib import Path

from fourcipp.fourc_input import FourCInput
from loguru import logger

from fourc_webviewer.python_utils import flatten_list

Expand Down Expand Up @@ -39,7 +40,7 @@ def read_fourc_yaml_file(fourc_yaml_file):
# validate 4C yaml file
fourc_yaml_content.validate()
except Exception as exc:
print(exc) # currently, we throw the exception as terminal output
logger.error(exc) # currently, we throw the exception as terminal output
return (FourCInput({}), [], 0, 0, False)

with open(fourc_yaml_file, "r") as input_file:
Expand Down Expand Up @@ -78,7 +79,7 @@ def write_fourc_yaml_file(fourc_yaml_content, new_fourc_yaml_file):
try:
fourc_yaml_content.validate()
except Exception as exc:
print(exc) # currently, we throw the exception as terminal output
logger.error(exc) # currently, we throw the exception as terminal output
return False

# check if the output file suffix is supported
Expand Down Expand Up @@ -251,6 +252,11 @@ def mat_specifiers():
"VISCOPLAST_LAW_ID",
"FIBER_READER_ID",
"STR_TENS_ID",
"MATIDSCONST",
"MATIDMIXTURERULE",
"GROWTH_STRATEGY",
"FIBER_MATERIAL_ID",
"PRESTRESS_STRATEGY",
]


Expand Down
Loading
Loading