Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
OGSTools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ogs
OpenGeoSys Tools
OGSTools
Commits
d7abda65
Commit
d7abda65
authored
1 year ago
by
Florian Zill
Browse files
Options
Downloads
Patches
Plain Diff
[meshlib] introducing typechecked
parent
bd16d9f8
No related branches found
No related tags found
1 merge request
!134
MeshSeries aggregation function
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
ogstools/meshlib/boundary_subset.py
+3
-10
3 additions, 10 deletions
ogstools/meshlib/boundary_subset.py
ogstools/meshlib/data_processing.py
+2
-7
2 additions, 7 deletions
ogstools/meshlib/data_processing.py
pyproject.toml
+1
-0
1 addition, 0 deletions
pyproject.toml
with
6 additions
and
17 deletions
ogstools/meshlib/boundary_subset.py
+
3
−
10
View file @
d7abda65
...
...
@@ -5,6 +5,7 @@ from typing import Union
import
numpy
as
np
import
pyvista
as
pv
from
ogs
import
cli
from
typeguard
import
typechecked
class
Surface
:
...
...
@@ -19,11 +20,8 @@ class Surface:
def
material_id
(
self
)
->
int
:
return
self
.
_material_id
def
__init__
(
self
,
input
:
Union
[
Path
,
pv
.
DataSet
],
material_id
:
int
,
):
@typechecked
def
__init__
(
self
,
input
:
Union
[
Path
,
pv
.
DataSet
],
material_id
:
int
):
"""
Initialize a surface mesh. Either from pyvista or from a file.
"""
self
.
_material_id
=
material_id
...
...
@@ -37,11 +35,6 @@ class Surface:
self
.
mesh
=
input
self
.
filename
=
Path
(
tempfile
.
mkstemp
(
"
.vtu
"
,
"
surface
"
)[
1
])
pv
.
save_meshio
(
self
.
filename
,
self
.
mesh
,
file_format
=
"
vtu
"
)
else
:
msg
=
"
{} given, must be either Path or pyvista Dataset.
"
.
format
(
self
.
filename
)
raise
ValueError
(
msg
)
self
.
mesh
.
cell_data
[
"
MaterialIDs
"
]
=
(
np
.
ones
(
self
.
mesh
.
n_cells
)
*
self
.
material_id
...
...
This diff is collapsed.
Click to expand it.
ogstools/meshlib/data_processing.py
+
2
−
7
View file @
d7abda65
...
...
@@ -3,6 +3,7 @@ from typing import Optional, Union
import
numpy
as
np
import
pyvista
as
pv
from
typeguard
import
typechecked
from
ogstools.propertylib
import
Property
...
...
@@ -85,7 +86,7 @@ def difference_pairwise(
)
# TODO: let this also return meshes and a property
@typechecked
def
difference_matrix
(
meshes_1
:
Union
[
list
,
np
.
ndarray
],
meshes_2
:
Optional
[
Union
[
list
,
np
.
ndarray
]]
=
None
,
...
...
@@ -104,13 +105,7 @@ def difference_matrix(
or all datasets between meshes_1 and meshes_2 for all possible
combinations.
"""
if
not
isinstance
(
meshes_1
,
(
list
,
np
.
ndarray
)):
msg
=
"
mesh1 is neither of type list nor np.ndarray
"
# type: ignore[unreachable]
raise
TypeError
(
msg
)
meshes_1
=
np
.
asarray
(
meshes_1
).
flatten
()
if
not
isinstance
(
meshes_2
,
(
list
,
np
.
ndarray
))
and
meshes_2
is
not
None
:
msg
=
"
mesh2 is neither of type list nor np.ndarray.
"
# type: ignore[unreachable]
raise
TypeError
(
msg
)
if
meshes_2
is
None
:
meshes_2
=
meshes_1
.
copy
()
meshes_2
=
np
.
asarray
(
meshes_2
).
flatten
()
...
...
This diff is collapsed.
Click to expand it.
pyproject.toml
+
1
−
0
View file @
d7abda65
...
...
@@ -26,6 +26,7 @@ dependencies = [
"ogs>
=
6.5
.
1
.dev
0
",
"ogs6py>
=
0.370
",
"tqdm>
=
4.60
",
"typeguard>
=
4.0
.
0
",
"VTUinterface>
=
0.704
",
]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment