solidipes-solid-mech-plugin 0.0.10__tar.gz → 0.0.12__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {solidipes_solid_mech_plugin-0.0.10 → solidipes_solid_mech_plugin-0.0.12}/.gitlab-ci.yml +7 -2
- {solidipes_solid_mech_plugin-0.0.10 → solidipes_solid_mech_plugin-0.0.12}/PKG-INFO +2 -2
- {solidipes_solid_mech_plugin-0.0.10 → solidipes_solid_mech_plugin-0.0.12}/pyproject.toml +1 -1
- {solidipes_solid_mech_plugin-0.0.10 → solidipes_solid_mech_plugin-0.0.12}/solidipes_solid_mech_plugin/loaders/abaqus.py +33 -9
- {solidipes_solid_mech_plugin-0.0.10 → solidipes_solid_mech_plugin-0.0.12}/solidipes_solid_mech_plugin/loaders/meshio.py +2 -4
- {solidipes_solid_mech_plugin-0.0.10 → solidipes_solid_mech_plugin-0.0.12}/solidipes_solid_mech_plugin/loaders/pyvista_mesh.py +9 -8
- {solidipes_solid_mech_plugin-0.0.10 → solidipes_solid_mech_plugin-0.0.12}/solidipes_solid_mech_plugin/loaders/xdmf.py +2 -4
- solidipes_solid_mech_plugin-0.0.12/solidipes_solid_mech_plugin/ontologies/solidipes_solid_mech.py +47 -0
- solidipes_solid_mech_plugin-0.0.12/solidipes_solid_mech_plugin/ontologies/solidipes_solid_mech.yaml +18 -0
- {solidipes_solid_mech_plugin-0.0.10 → solidipes_solid_mech_plugin-0.0.12}/solidipes_solid_mech_plugin.egg-info/PKG-INFO +2 -2
- {solidipes_solid_mech_plugin-0.0.10 → solidipes_solid_mech_plugin-0.0.12}/solidipes_solid_mech_plugin.egg-info/SOURCES.txt +4 -0
- {solidipes_solid_mech_plugin-0.0.10 → solidipes_solid_mech_plugin-0.0.12}/solidipes_solid_mech_plugin.egg-info/requires.txt +1 -1
- {solidipes_solid_mech_plugin-0.0.10 → solidipes_solid_mech_plugin-0.0.12}/tests/assets/generate_assets.py +10 -7
- solidipes_solid_mech_plugin-0.0.12/tests/assets/pyvista_mesh_no_fields.vtu +35 -0
- {solidipes_solid_mech_plugin-0.0.10 → solidipes_solid_mech_plugin-0.0.12}/tests/conftest.py +2 -2
- solidipes_solid_mech_plugin-0.0.12/tests/test_ontologies.py +41 -0
- {solidipes_solid_mech_plugin-0.0.10 → solidipes_solid_mech_plugin-0.0.12}/uv.lock +1574 -1287
- {solidipes_solid_mech_plugin-0.0.10 → solidipes_solid_mech_plugin-0.0.12}/.flake8 +0 -0
- {solidipes_solid_mech_plugin-0.0.10 → solidipes_solid_mech_plugin-0.0.12}/.gitignore +0 -0
- {solidipes_solid_mech_plugin-0.0.10 → solidipes_solid_mech_plugin-0.0.12}/.pre-commit-config.yaml +0 -0
- {solidipes_solid_mech_plugin-0.0.10 → solidipes_solid_mech_plugin-0.0.12}/CHANGELOG.md +0 -0
- {solidipes_solid_mech_plugin-0.0.10 → solidipes_solid_mech_plugin-0.0.12}/LICENSE +0 -0
- {solidipes_solid_mech_plugin-0.0.10 → solidipes_solid_mech_plugin-0.0.12}/README.md +0 -0
- {solidipes_solid_mech_plugin-0.0.10 → solidipes_solid_mech_plugin-0.0.12}/setup.cfg +0 -0
- {solidipes_solid_mech_plugin-0.0.10 → solidipes_solid_mech_plugin-0.0.12}/solidipes_solid_mech_plugin/__init__.py +0 -0
- {solidipes_solid_mech_plugin-0.0.10 → solidipes_solid_mech_plugin-0.0.12}/solidipes_solid_mech_plugin/config.py +0 -0
- {solidipes_solid_mech_plugin-0.0.10 → solidipes_solid_mech_plugin-0.0.12}/solidipes_solid_mech_plugin/loaders/__init__.py +0 -0
- {solidipes_solid_mech_plugin-0.0.10 → solidipes_solid_mech_plugin-0.0.12}/solidipes_solid_mech_plugin/loaders/abaqus_python_code.py +0 -0
- {solidipes_solid_mech_plugin-0.0.10 → solidipes_solid_mech_plugin-0.0.12}/solidipes_solid_mech_plugin/loaders/geo_msh.py +0 -0
- {solidipes_solid_mech_plugin-0.0.10 → solidipes_solid_mech_plugin-0.0.12}/solidipes_solid_mech_plugin/loaders/geof_mesh.py +0 -0
- {solidipes_solid_mech_plugin-0.0.10 → solidipes_solid_mech_plugin-0.0.12}/solidipes_solid_mech_plugin/loaders/parse_inp.py +0 -0
- {solidipes_solid_mech_plugin-0.0.10 → solidipes_solid_mech_plugin-0.0.12}/solidipes_solid_mech_plugin/viewers/__init__.py +0 -0
- {solidipes_solid_mech_plugin-0.0.10 → solidipes_solid_mech_plugin-0.0.12}/solidipes_solid_mech_plugin/viewers/pyvista_plotter.py +0 -0
- {solidipes_solid_mech_plugin-0.0.10 → solidipes_solid_mech_plugin-0.0.12}/solidipes_solid_mech_plugin/viewers/xdmf.py +0 -0
- {solidipes_solid_mech_plugin-0.0.10 → solidipes_solid_mech_plugin-0.0.12}/solidipes_solid_mech_plugin.egg-info/dependency_links.txt +0 -0
- {solidipes_solid_mech_plugin-0.0.10 → solidipes_solid_mech_plugin-0.0.12}/solidipes_solid_mech_plugin.egg-info/entry_points.txt +0 -0
- {solidipes_solid_mech_plugin-0.0.10 → solidipes_solid_mech_plugin-0.0.12}/solidipes_solid_mech_plugin.egg-info/top_level.txt +0 -0
- {solidipes_solid_mech_plugin-0.0.10 → solidipes_solid_mech_plugin-0.0.12}/tests/assets/pyvista_mesh.vtu +0 -0
- {solidipes_solid_mech_plugin-0.0.10 → solidipes_solid_mech_plugin-0.0.12}/tests/assets/pyvista_plot.png +0 -0
- {solidipes_solid_mech_plugin-0.0.10 → solidipes_solid_mech_plugin-0.0.12}/tests/assets/test_mesh_loaded.png +0 -0
- {solidipes_solid_mech_plugin-0.0.10 → solidipes_solid_mech_plugin-0.0.12}/tests/assets/xdmf_mesh.h5 +0 -0
- {solidipes_solid_mech_plugin-0.0.10 → solidipes_solid_mech_plugin-0.0.12}/tests/assets/xdmf_mesh.xdmf +0 -0
- {solidipes_solid_mech_plugin-0.0.10 → solidipes_solid_mech_plugin-0.0.12}/tests/helpers/utils.py +0 -0
- {solidipes_solid_mech_plugin-0.0.10 → solidipes_solid_mech_plugin-0.0.12}/tests/test_load_modules.py +0 -0
- {solidipes_solid_mech_plugin-0.0.10 → solidipes_solid_mech_plugin-0.0.12}/tests/test_pyvista_mesh.py +0 -0
- {solidipes_solid_mech_plugin-0.0.10 → solidipes_solid_mech_plugin-0.0.12}/tests/test_pyvista_plotter.py +0 -0
- {solidipes_solid_mech_plugin-0.0.10 → solidipes_solid_mech_plugin-0.0.12}/tests/test_streamlit_pyvista.py +0 -0
- {solidipes_solid_mech_plugin-0.0.10 → solidipes_solid_mech_plugin-0.0.12}/tests/test_xdmf_mesh.py +0 -0
|
@@ -31,9 +31,14 @@ test:
|
|
|
31
31
|
- PYTHON_VERSION: ["3.10", "3.11"]
|
|
32
32
|
rules:
|
|
33
33
|
image: python:${PYTHON_VERSION}
|
|
34
|
+
before_script:
|
|
35
|
+
- echo "CI_COMMIT_BRANCH=${CI_COMMIT_BRANCH}"
|
|
36
|
+
- echo "CI_MERGE_REQUEST_TARGET_BRANCH_NAME=${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}"
|
|
37
|
+
- export BRANCH="${CI_COMMIT_BRANCH}${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}"
|
|
38
|
+
- if [[ -z "${BRANCH}" ]]; then echo "force branch to main"; export BRANCH="main"; fi
|
|
34
39
|
script:
|
|
35
|
-
- apt update && apt install -y --no-install-recommends firefox-esr libgl1
|
|
36
|
-
- git clone -b ${
|
|
40
|
+
- apt update && apt install -y --no-install-recommends firefox-esr libgl1 xvfb
|
|
41
|
+
- git clone -b ${BRANCH} --single-branch https://gitlab.com/solidipes/solidipes.git
|
|
37
42
|
- pip install ./solidipes
|
|
38
43
|
- pip install .[test]
|
|
39
44
|
- python3 -m pytest
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: solidipes-solid-mech-plugin
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.12
|
|
4
4
|
Summary: Plugin for Solidipes with solid mechanics components
|
|
5
5
|
Author-email: Son Pham-Ba <son.phamba@epfl.ch>, Guillaume Anciaux <guillaume.anciaux@epfl.ch>
|
|
6
6
|
License: GPL-3.0-or-later
|
|
7
7
|
Requires-Python: <3.13,>=3.10
|
|
8
8
|
Description-Content-Type: text/markdown
|
|
9
9
|
License-File: LICENSE
|
|
10
|
-
Requires-Dist: solidipes-core-plugin>=0.0.
|
|
10
|
+
Requires-Dist: solidipes-core-plugin>=0.0.40
|
|
11
11
|
Requires-Dist: ipython~=8.18.1
|
|
12
12
|
Requires-Dist: mergedeep~=1.3.4
|
|
13
13
|
Requires-Dist: meshio[all]~=5.3.5
|
|
@@ -4,6 +4,7 @@ import mergedeep
|
|
|
4
4
|
import numpy as np
|
|
5
5
|
import pandas as pd
|
|
6
6
|
import pyparsing as pp
|
|
7
|
+
from solidipes.validators.validator import add_validation_error, validator
|
|
7
8
|
from solidipes_core_plugin.loaders.code_snippet import CodeSnippet
|
|
8
9
|
|
|
9
10
|
|
|
@@ -114,13 +115,11 @@ class ParseAbaqus:
|
|
|
114
115
|
class Abaqus(CodeSnippet):
|
|
115
116
|
supported_mime_types = {"application/fem/abaqus": "inp"}
|
|
116
117
|
|
|
117
|
-
|
|
118
|
-
from solidipes_core_plugin.viewers.xml import XML
|
|
118
|
+
from solidipes_core_plugin.viewers.xml import XML
|
|
119
119
|
|
|
120
|
-
|
|
120
|
+
from ..viewers.pyvista_plotter import PyvistaPlotter
|
|
121
121
|
|
|
122
|
-
|
|
123
|
-
self.compatible_viewers[:0] = [PyvistaPlotter, XML]
|
|
122
|
+
_compatible_viewers = [PyvistaPlotter, XML]
|
|
124
123
|
|
|
125
124
|
@CodeSnippet.loadable
|
|
126
125
|
def structure(self):
|
|
@@ -131,6 +130,16 @@ class Abaqus(CodeSnippet):
|
|
|
131
130
|
except Exception as e:
|
|
132
131
|
print(e)
|
|
133
132
|
|
|
133
|
+
@validator(description="Loadable meshes")
|
|
134
|
+
def _is_mesh_loadable(self) -> bool:
|
|
135
|
+
if not self.structure:
|
|
136
|
+
add_validation_error([f"Invalid structure: {self.structure}"])
|
|
137
|
+
return False
|
|
138
|
+
if not self.meshes:
|
|
139
|
+
add_validation_error([f"Invalid meshes: {self.meshes}"])
|
|
140
|
+
return False
|
|
141
|
+
return True
|
|
142
|
+
|
|
134
143
|
@property
|
|
135
144
|
def xml(self):
|
|
136
145
|
return self.structure
|
|
@@ -170,15 +179,30 @@ class Abaqus(CodeSnippet):
|
|
|
170
179
|
import pyvista as pv
|
|
171
180
|
|
|
172
181
|
try:
|
|
173
|
-
import meshio
|
|
174
|
-
|
|
175
182
|
fname = self.file_info.path
|
|
183
|
+
import sys
|
|
184
|
+
|
|
176
185
|
from pyvista.core.utilities import from_meshio
|
|
177
186
|
|
|
178
|
-
|
|
179
|
-
|
|
187
|
+
original_exit = sys.exit
|
|
188
|
+
|
|
189
|
+
def my_exit(code):
|
|
190
|
+
raise RuntimeError(f"Meshio: sys.exit({code})")
|
|
191
|
+
|
|
192
|
+
sys.exit = my_exit
|
|
193
|
+
import meshio
|
|
194
|
+
|
|
195
|
+
_mesh = meshio.read(fname)
|
|
196
|
+
|
|
197
|
+
res = {"meshio_reader": from_meshio(_mesh)}
|
|
198
|
+
sys.exit = original_exit
|
|
199
|
+
return res
|
|
200
|
+
except Exception as e:
|
|
201
|
+
print(e)
|
|
180
202
|
pass
|
|
181
203
|
|
|
204
|
+
sys.exit = original_exit
|
|
205
|
+
|
|
182
206
|
meshes = {}
|
|
183
207
|
for p, part in enumerate(self.parts):
|
|
184
208
|
mesh = meshio.Mesh(self.nodes(p), self.elements(p))
|
|
@@ -4,11 +4,9 @@ from solidipes.loaders.file import File
|
|
|
4
4
|
class Meshio(File):
|
|
5
5
|
"""File loaded with meshio"""
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
from ..viewers.pyvista_plotter import PyvistaPlotter
|
|
7
|
+
from ..viewers.pyvista_plotter import PyvistaPlotter
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
self.compatible_viewers[:0] = [PyvistaPlotter]
|
|
9
|
+
_compatible_viewers = [PyvistaPlotter]
|
|
12
10
|
|
|
13
11
|
@File.loadable
|
|
14
12
|
def mesh(self):
|
|
@@ -48,6 +48,8 @@ def get_cell_data_from_id_or_array(func):
|
|
|
48
48
|
class PyvistaMesh(File):
|
|
49
49
|
"""Mesh file loaded with pyvista"""
|
|
50
50
|
|
|
51
|
+
from ..viewers.pyvista_plotter import PyvistaPlotter
|
|
52
|
+
|
|
51
53
|
supported_mime_types = {
|
|
52
54
|
"meshing/GMSH": "msh",
|
|
53
55
|
"meshing/StepFile": "stl",
|
|
@@ -55,12 +57,7 @@ class PyvistaMesh(File):
|
|
|
55
57
|
"meshing/AVS": "avs",
|
|
56
58
|
}
|
|
57
59
|
|
|
58
|
-
|
|
59
|
-
from ..viewers.pyvista_plotter import PyvistaPlotter
|
|
60
|
-
|
|
61
|
-
super().__init__(**kwargs)
|
|
62
|
-
#: Fully loaded pyvista mesh
|
|
63
|
-
self.compatible_viewers[:0] = [PyvistaPlotter]
|
|
60
|
+
_compatible_viewers = [PyvistaPlotter]
|
|
64
61
|
|
|
65
62
|
def copy_pyvista_data_to_collection(self):
|
|
66
63
|
"""Add pyvista data to data collection"""
|
|
@@ -87,11 +84,11 @@ class PyvistaMesh(File):
|
|
|
87
84
|
self.copy_pyvista_data_to_collection()
|
|
88
85
|
return self.pyvista_mesh
|
|
89
86
|
|
|
90
|
-
@
|
|
87
|
+
@File.rocrate_metadata
|
|
91
88
|
def point_data_names(self):
|
|
92
89
|
return self.pyvista_mesh.point_data.keys()
|
|
93
90
|
|
|
94
|
-
@
|
|
91
|
+
@File.rocrate_metadata
|
|
95
92
|
def cell_data_names(self):
|
|
96
93
|
return self.pyvista_mesh.cell_data.keys()
|
|
97
94
|
|
|
@@ -100,10 +97,12 @@ class PyvistaMesh(File):
|
|
|
100
97
|
|
|
101
98
|
def add_point_data(self, array, name):
|
|
102
99
|
self.pyvista_mesh.point_data.set_array(array, name)
|
|
100
|
+
del self._data_collection["point_data_names"]
|
|
103
101
|
self.add(name + POINT_DATA_SUFFIX, array)
|
|
104
102
|
|
|
105
103
|
def remove_point_data(self, name):
|
|
106
104
|
self.pyvista_mesh.point_data.remove(name)
|
|
105
|
+
del self._data_collection["point_data_names"]
|
|
107
106
|
self.remove(name + POINT_DATA_SUFFIX)
|
|
108
107
|
|
|
109
108
|
def get_cell_data(self, name):
|
|
@@ -111,10 +110,12 @@ class PyvistaMesh(File):
|
|
|
111
110
|
|
|
112
111
|
def add_cell_data(self, array, name):
|
|
113
112
|
self.pyvista_mesh.cell_data.set_array(array, name)
|
|
113
|
+
del self._data_collection["cell_data_names"]
|
|
114
114
|
self.add(name + CELL_DATA_SUFFIX, array)
|
|
115
115
|
|
|
116
116
|
def remove_cell_data(self, name):
|
|
117
117
|
self.pyvista_mesh.cell_data.remove(name)
|
|
118
|
+
del self._data_collection["cell_data_names"]
|
|
118
119
|
self.remove(name + CELL_DATA_SUFFIX)
|
|
119
120
|
|
|
120
121
|
@get_point_data_from_id_or_array
|
|
@@ -9,11 +9,9 @@ from solidipes_core_plugin.loaders.xml import XML
|
|
|
9
9
|
class XDMF(Sequence, XML):
|
|
10
10
|
supported_mime_types = {"mesh/XDMF": "xdmf"}
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
from ..viewers.pyvista_plotter import PyvistaPlotter
|
|
12
|
+
from ..viewers.pyvista_plotter import PyvistaPlotter
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
self.compatible_viewers[:0] = [PyvistaPlotter]
|
|
14
|
+
_compatible_viewers = [PyvistaPlotter]
|
|
17
15
|
|
|
18
16
|
def _load_hdf5_data_item(self, item):
|
|
19
17
|
if item["@Format"] == "HDF":
|
solidipes_solid_mech_plugin-0.0.12/solidipes_solid_mech_plugin/ontologies/solidipes_solid_mech.py
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
from pydantic import Field, model_validator
|
|
2
|
+
from solidipes.ontologies.solidipes import File, build_ontology_model
|
|
3
|
+
from solidipes.ontologies.solidipes import entity_classes as base_entity_classes
|
|
4
|
+
from solidipes.utils.utils import string_to_regex_pattern as regexify
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Mesh(File):
|
|
8
|
+
"""Mesh file entity."""
|
|
9
|
+
|
|
10
|
+
ontology_class: str | None = Field(
|
|
11
|
+
default=None, pattern=regexify("solidipes_solid_mech_plugin.loaders.pyvista_mesh.PyvistaMesh")
|
|
12
|
+
)
|
|
13
|
+
cell_data_names: list[str]
|
|
14
|
+
point_data_names: list[str]
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class InputMesh(Mesh):
|
|
18
|
+
"""Mesh file entity with no fields."""
|
|
19
|
+
|
|
20
|
+
cell_data_names: list[str] = Field(default_factory=list, min_length=0, max_length=0)
|
|
21
|
+
point_data_names: list[str] = Field(default_factory=list, min_length=0, max_length=0)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class OutputMesh(Mesh):
|
|
25
|
+
"""Mesh file entity with at least one field."""
|
|
26
|
+
|
|
27
|
+
cell_data_names: list[str]
|
|
28
|
+
point_data_names: list[str]
|
|
29
|
+
|
|
30
|
+
@model_validator(mode="after")
|
|
31
|
+
def _check_at_least_one_field(self):
|
|
32
|
+
if not self.cell_data_names and not self.point_data_names:
|
|
33
|
+
raise ValueError(
|
|
34
|
+
"OutputMesh requires at least one field is required in cell_data_names or point_data_names."
|
|
35
|
+
)
|
|
36
|
+
return self
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
custom_entity_classes = [
|
|
40
|
+
InputMesh,
|
|
41
|
+
OutputMesh,
|
|
42
|
+
]
|
|
43
|
+
|
|
44
|
+
entity_classes = custom_entity_classes + base_entity_classes
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
ROCrateMetadata = build_ontology_model(entity_classes)
|
solidipes_solid_mech_plugin-0.0.12/solidipes_solid_mech_plugin/ontologies/solidipes_solid_mech.yaml
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
id: https://gitlab.com/solidipes/solidipes-solid-mech-plugin/-/raw/main/solidipes_solid_mech_plugin/ontologies/solidipes_solid_mech.yaml
|
|
2
|
+
name: solidipes_solid_mech
|
|
3
|
+
prefixes:
|
|
4
|
+
solidipes: https://gitlab.com/solidipes/solidipes/-/raw/ontology-validation/solidipes/ontologies/
|
|
5
|
+
imports:
|
|
6
|
+
- solidipes:solidipes
|
|
7
|
+
default_range: string
|
|
8
|
+
|
|
9
|
+
classes:
|
|
10
|
+
MeshFile:
|
|
11
|
+
is_a: File
|
|
12
|
+
attributes:
|
|
13
|
+
has_displacement_field:
|
|
14
|
+
range: bool
|
|
15
|
+
recommended: true
|
|
16
|
+
ontology_class:
|
|
17
|
+
pattern: "^solidipes_solid_mech_plugin.loaders.pyvista_mesh.PyvistaMesh$"
|
|
18
|
+
required: true
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: solidipes-solid-mech-plugin
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.12
|
|
4
4
|
Summary: Plugin for Solidipes with solid mechanics components
|
|
5
5
|
Author-email: Son Pham-Ba <son.phamba@epfl.ch>, Guillaume Anciaux <guillaume.anciaux@epfl.ch>
|
|
6
6
|
License: GPL-3.0-or-later
|
|
7
7
|
Requires-Python: <3.13,>=3.10
|
|
8
8
|
Description-Content-Type: text/markdown
|
|
9
9
|
License-File: LICENSE
|
|
10
|
-
Requires-Dist: solidipes-core-plugin>=0.0.
|
|
10
|
+
Requires-Dist: solidipes-core-plugin>=0.0.40
|
|
11
11
|
Requires-Dist: ipython~=8.18.1
|
|
12
12
|
Requires-Dist: mergedeep~=1.3.4
|
|
13
13
|
Requires-Dist: meshio[all]~=5.3.5
|
|
@@ -24,17 +24,21 @@ solidipes_solid_mech_plugin/loaders/meshio.py
|
|
|
24
24
|
solidipes_solid_mech_plugin/loaders/parse_inp.py
|
|
25
25
|
solidipes_solid_mech_plugin/loaders/pyvista_mesh.py
|
|
26
26
|
solidipes_solid_mech_plugin/loaders/xdmf.py
|
|
27
|
+
solidipes_solid_mech_plugin/ontologies/solidipes_solid_mech.py
|
|
28
|
+
solidipes_solid_mech_plugin/ontologies/solidipes_solid_mech.yaml
|
|
27
29
|
solidipes_solid_mech_plugin/viewers/__init__.py
|
|
28
30
|
solidipes_solid_mech_plugin/viewers/pyvista_plotter.py
|
|
29
31
|
solidipes_solid_mech_plugin/viewers/xdmf.py
|
|
30
32
|
tests/conftest.py
|
|
31
33
|
tests/test_load_modules.py
|
|
34
|
+
tests/test_ontologies.py
|
|
32
35
|
tests/test_pyvista_mesh.py
|
|
33
36
|
tests/test_pyvista_plotter.py
|
|
34
37
|
tests/test_streamlit_pyvista.py
|
|
35
38
|
tests/test_xdmf_mesh.py
|
|
36
39
|
tests/assets/generate_assets.py
|
|
37
40
|
tests/assets/pyvista_mesh.vtu
|
|
41
|
+
tests/assets/pyvista_mesh_no_fields.vtu
|
|
38
42
|
tests/assets/pyvista_plot.png
|
|
39
43
|
tests/assets/test_mesh_loaded.png
|
|
40
44
|
tests/assets/xdmf_mesh.h5
|
|
@@ -6,22 +6,25 @@ def main():
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
def generate_pyvista_assets():
|
|
9
|
-
generate_vtu()
|
|
9
|
+
generate_vtu("pyvista_mesh.vtu", with_fields=True)
|
|
10
|
+
generate_vtu("pyvista_mesh_no_fields.vtu", with_fields=False)
|
|
10
11
|
generate_pyvista_plot()
|
|
11
12
|
|
|
12
13
|
|
|
13
|
-
def generate_vtu():
|
|
14
|
+
def generate_vtu(filename: str, with_fields: bool):
|
|
14
15
|
points = [[0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [0.0, 1.0, 0.0]]
|
|
15
16
|
cells = [3, 0, 1, 2]
|
|
16
17
|
cell_types = [pv.CellType.TRIANGLE]
|
|
17
18
|
|
|
18
19
|
mesh = pv.UnstructuredGrid(cells, cell_types, points)
|
|
19
|
-
mesh.point_data.set_array([1, 2, 3], "point 1D")
|
|
20
|
-
mesh.point_data.set_array(pv.pyvista_ndarray([[1, 2, 3], [4, 5, 6], [7, 8, 9]]), "point 3D")
|
|
21
|
-
mesh.cell_data.set_array([1], "cell 1D")
|
|
22
|
-
mesh.cell_data.set_array(pv.pyvista_ndarray([[1, 2, 3]]), "cell 3D")
|
|
23
20
|
|
|
24
|
-
|
|
21
|
+
if with_fields:
|
|
22
|
+
mesh.point_data.set_array([1, 2, 3], "point 1D")
|
|
23
|
+
mesh.point_data.set_array(pv.pyvista_ndarray([[1, 2, 3], [4, 5, 6], [7, 8, 9]]), "point 3D")
|
|
24
|
+
mesh.cell_data.set_array([1], "cell 1D")
|
|
25
|
+
mesh.cell_data.set_array(pv.pyvista_ndarray([[1, 2, 3]]), "cell 3D")
|
|
26
|
+
|
|
27
|
+
mesh.save(filename)
|
|
25
28
|
|
|
26
29
|
|
|
27
30
|
def generate_pyvista_plot():
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<?xml version="1.0"?>
|
|
2
|
+
<VTKFile type="UnstructuredGrid" version="0.1" byte_order="LittleEndian" header_type="UInt32" compressor="vtkZLibDataCompressor">
|
|
3
|
+
<UnstructuredGrid>
|
|
4
|
+
<Piece NumberOfPoints="3" NumberOfCells="1">
|
|
5
|
+
<PointData>
|
|
6
|
+
</PointData>
|
|
7
|
+
<CellData>
|
|
8
|
+
</CellData>
|
|
9
|
+
<Points>
|
|
10
|
+
<DataArray type="Float64" Name="Points" NumberOfComponents="3" format="binary" RangeMin="0" RangeMax="1">
|
|
11
|
+
AQAAAACAAABIAAAAEgAAAA==eJxjYMAHPtjjlUaSBwA9VgJf
|
|
12
|
+
<InformationKey name="L2_NORM_RANGE" location="vtkDataArray" length="2">
|
|
13
|
+
<Value index="0">
|
|
14
|
+
0
|
|
15
|
+
</Value>
|
|
16
|
+
<Value index="1">
|
|
17
|
+
1
|
|
18
|
+
</Value>
|
|
19
|
+
</InformationKey>
|
|
20
|
+
</DataArray>
|
|
21
|
+
</Points>
|
|
22
|
+
<Cells>
|
|
23
|
+
<DataArray type="Int64" Name="connectivity" format="binary" RangeMin="0" RangeMax="2">
|
|
24
|
+
AQAAAACAAAAYAAAAEAAAAA==eJxjYIAARijNBKUBADgABA==
|
|
25
|
+
</DataArray>
|
|
26
|
+
<DataArray type="Int64" Name="offsets" format="binary" RangeMin="3" RangeMax="3">
|
|
27
|
+
AQAAAACAAAAIAAAACwAAAA==eJxjZoAAAAAgAAQ=
|
|
28
|
+
</DataArray>
|
|
29
|
+
<DataArray type="UInt8" Name="types" format="binary" RangeMin="5" RangeMax="5">
|
|
30
|
+
AQAAAACAAAABAAAACQAAAA==eJxjBQAABgAG
|
|
31
|
+
</DataArray>
|
|
32
|
+
</Cells>
|
|
33
|
+
</Piece>
|
|
34
|
+
</UnstructuredGrid>
|
|
35
|
+
</VTKFile>
|
|
@@ -4,7 +4,7 @@ from pathlib import Path
|
|
|
4
4
|
from typing import Generator
|
|
5
5
|
|
|
6
6
|
import pytest
|
|
7
|
-
|
|
7
|
+
import solidipes as sp
|
|
8
8
|
from solidipes.scripts.init import main as init
|
|
9
9
|
|
|
10
10
|
sys.path.append(os.path.join(os.path.dirname(__file__), "helpers"))
|
|
@@ -24,7 +24,7 @@ def study_dir(tmp_path: Path) -> Generator[Path, None, None]:
|
|
|
24
24
|
|
|
25
25
|
yield tmp_path
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
sp.close_cached_metadata()
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
@pytest.fixture
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
import pytest
|
|
5
|
+
import solidipes as sp
|
|
6
|
+
import utils
|
|
7
|
+
from solidipes.validators.ontology import set_ontology_identifier
|
|
8
|
+
|
|
9
|
+
ontology_identifier = os.path.join(
|
|
10
|
+
os.path.dirname(__file__), "..", "solidipes_solid_mech_plugin", "ontologies", "solidipes_solid_mech.py"
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@pytest.fixture
|
|
15
|
+
def study_dir_custom_ontology(study_dir: Path) -> Path:
|
|
16
|
+
"""Get the study directory with the custom ontology applied."""
|
|
17
|
+
|
|
18
|
+
set_ontology_identifier(ontology_identifier)
|
|
19
|
+
return study_dir
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class TestPyvistaMeshOntology:
|
|
23
|
+
def test_input_mesh(self, study_dir_custom_ontology: Path) -> None:
|
|
24
|
+
"""Check that a mesh without fields is detected as an InputMesh."""
|
|
25
|
+
from solidipes.validators.ontology import OntologyValidator, get_global_validator
|
|
26
|
+
|
|
27
|
+
validator = get_global_validator(OntologyValidator)
|
|
28
|
+
file_path = utils.get_asset_path("pyvista_mesh_no_fields.vtu")
|
|
29
|
+
file = sp.load_file(file_path)
|
|
30
|
+
class_name = validator.ontology.get_file_class_name(file)
|
|
31
|
+
assert class_name == "InputMesh"
|
|
32
|
+
|
|
33
|
+
def test_output_mesh(self, study_dir_custom_ontology: Path) -> None:
|
|
34
|
+
"""Check that a mesh with at least one field is detected as an OutputMesh."""
|
|
35
|
+
from solidipes.validators.ontology import OntologyValidator, get_global_validator
|
|
36
|
+
|
|
37
|
+
validator = get_global_validator(OntologyValidator)
|
|
38
|
+
file_path = utils.get_asset_path("pyvista_mesh.vtu")
|
|
39
|
+
file = sp.load_file(file_path)
|
|
40
|
+
class_name = validator.ontology.get_file_class_name(file)
|
|
41
|
+
assert class_name == "OutputMesh"
|