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
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
Max Bittens
ogstools
Commits
f30f05cc
Commit
f30f05cc
authored
1 year ago
by
Julian Heinze
Browse files
Options
Downloads
Patches
Plain Diff
cleanup if-statements
parent
f9c93a6c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ogstools/fe2vtu/_cli.py
+53
-69
53 additions, 69 deletions
ogstools/fe2vtu/_cli.py
with
53 additions
and
69 deletions
ogstools/fe2vtu/_cli.py
+
53
−
69
View file @
f30f05cc
...
...
@@ -71,73 +71,57 @@ def cli():
mesh
=
get_geo_mesh
(
doc
)
if
args
.
case
==
"
geometry
"
or
args
.
case
==
"
geo_surface
"
:
if
args
.
case
==
"
geo_surface
"
:
# surface
surf
=
mesh
.
extract_surface
()
pv
.
save_meshio
(
args
.
output
,
surf
,
file_format
=
"
vtu
"
)
# log feflow version
log
.
info
(
"
The surface of the input mesh has been successfully converted.
"
)
else
:
pv
.
save_meshio
(
args
.
output
,
mesh
,
file_format
=
"
vtu
"
)
log
.
info
(
"
The geometry of the input mesh has been successfully converted.
"
)
elif
args
.
case
==
"
properties
"
or
args
.
case
==
"
properties_surface
"
:
if
"
properties
"
in
args
.
case
:
update_geo_mesh
(
mesh
,
doc
)
if
args
.
case
==
"
properties_surface
"
:
surf
=
mesh
.
extract_surface
()
pv
.
save_meshio
(
args
.
output
,
surf
,
file_format
=
"
vtu
"
)
log
.
info
(
"
The surface with properties of the input mesh have been successfully converted.
"
)
else
:
pv
.
save_meshio
(
args
.
output
,
mesh
,
file_format
=
"
vtu
"
)
log
.
info
(
"
The input mesh has been successfully converted.
"
)
if
args
.
BC
==
"
BC
"
:
BC_mesh
=
mesh
.
copy
()
for
cd
in
[
cell_data
for
cell_data
in
BC_mesh
.
cell_data
if
cell_data
not
in
[
"
P_SOUF
"
,
"
P_IOFLOW
"
]
]:
BC_mesh
.
cell_data
.
remove
(
cd
)
# Only cell data are needed
BC_mesh
.
point_data
.
clear
()
# get the topsurface since there are the cells of interest
topsurf
=
get_specific_surface
(
BC_mesh
.
extract_surface
(),
lambda
normals
:
normals
[:,
2
]
>
0
)
topsurf
.
save
(
"
topsurface_
"
+
args
.
output
)
# create the xml-file
write_xml
(
"
topsurface_
"
+
args
.
output
,
"
Neumann
"
,
topsurf
.
cell_data
,
"
MeshElement
"
,
)
# remove all the point data that are not of interest
for
point_data
in
mesh
.
point_data
:
if
not
all
([
"
_BC_
"
in
point_data
]):
mesh
.
point_data
.
remove
(
point_data
)
# Only selected point data is needed -> clear all cell data
mesh
.
cell_data
.
clear
()
# remove all points with point data that are of "nan"-value
for
point_data
in
mesh
.
point_data
:
filtered_points
=
mesh
.
extract_points
(
[
not
np
.
isnan
(
x
)
for
x
in
mesh
[
point_data
]],
include_cells
=
False
,
)
# Only "BULK_NODE_ID" can be read by ogs
filtered_points
.
rename_array
(
"
vtkOriginalPointIds
"
,
"
BULK_NODE_ID
"
)
filtered_points
.
save
(
point_data
+
"
.vtu
"
)
# create the xml-file
write_xml
(
""
,
"
Dirichlet
"
,
filtered_points
.
point_data
,
"
MeshNode
"
)
mesh
=
mesh
.
extract_surface
()
if
"
surface
"
in
args
.
case
else
mesh
msg
=
{
"
geo_surface
"
:
"
surface
"
,
"
geometry
"
:
"
geometry
"
,
"
properties_surface
"
:
"
surface with properties
"
,
"
properties
"
:
""
,
}
pv
.
save_meshio
(
args
.
output
,
mesh
,
file_format
=
"
vtu
"
)
log
.
info
(
"
The %s of the input mesh has been successfully converted.
"
,
msg
[
args
.
case
],
)
if
"
properties
"
not
in
args
.
case
or
args
.
BC
!=
"
BC
"
:
return
BC_mesh
=
mesh
.
copy
()
for
cd
in
[
cell_data
for
cell_data
in
BC_mesh
.
cell_data
if
cell_data
not
in
[
"
P_SOUF
"
,
"
P_IOFLOW
"
]
]:
BC_mesh
.
cell_data
.
remove
(
cd
)
# Only cell data are needed
BC_mesh
.
point_data
.
clear
()
# get the topsurface since there are the cells of interest
topsurf
=
get_specific_surface
(
BC_mesh
.
extract_surface
(),
lambda
normals
:
normals
[:,
2
]
>
0
)
topsurf
.
save
(
"
topsurface_
"
+
args
.
output
)
# create the xml-file
write_xml
(
"
topsurface_
"
+
args
.
output
,
"
Neumann
"
,
topsurf
.
cell_data
,
"
MeshElement
"
,
)
# remove all the point data that are not of interest
for
point_data
in
mesh
.
point_data
:
if
not
all
([
"
_BC_
"
in
point_data
]):
mesh
.
point_data
.
remove
(
point_data
)
# Only selected point data is needed -> clear all cell data
mesh
.
cell_data
.
clear
()
# remove all points with point data that are of "nan"-value
for
point_data
in
mesh
.
point_data
:
filtered_points
=
mesh
.
extract_points
(
[
not
np
.
isnan
(
x
)
for
x
in
mesh
[
point_data
]],
include_cells
=
False
,
)
# Only "BULK_NODE_ID" can be read by ogs
filtered_points
.
rename_array
(
"
vtkOriginalPointIds
"
,
"
BULK_NODE_ID
"
)
filtered_points
.
save
(
point_data
+
"
.vtu
"
)
# create the xml-file
write_xml
(
""
,
"
Dirichlet
"
,
filtered_points
.
point_data
,
"
MeshNode
"
)
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