Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
fossils
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review 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
Boman Romain
fossils
Commits
49dcdbbd
Commit
49dcdbbd
authored
2 years ago
by
Boman Romain
Browse files
Options
Downloads
Patches
Plain Diff
save also .vtp
parent
a92b7cf1
No related branches found
No related tags found
No related merge requests found
Pipeline
#10130
passed
2 years ago
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
convert.py
+51
-8
51 additions, 8 deletions
convert.py
with
51 additions
and
8 deletions
convert.py
+
51
−
8
View file @
49dcdbbd
...
...
@@ -21,13 +21,24 @@ import numpy as np
import
fossils
fossils
.
setup_pythonpath
()
# - parameters
testcase
=
'
models_Panthera_pardus_Panthera_pardus_RC_30
'
fieldname
=
'
smooth_stress_zz.msh
'
use_custom_range
=
True
vmin
=
-
30.
# <= use custom range (panthera)
vmax
=
30.
testcase
=
'
models_dolicorhynchops_dolicorhynchops_10k
'
fieldname
=
'
smooth_stress_zz.msh
'
use_custom_range
=
False
# ======================================================================
# folder = os.path.join('workspace', \
# 'models_dolicorhynchops_dolicorhynchops_10k')
folder
=
os
.
path
.
join
(
'
workspace
'
,
\
'
models_Panthera_pardus_Panthera_pardus_RC_30
'
)
folder
=
os
.
path
.
join
(
'
workspace
'
,
testcase
)
meshfile
=
os
.
path
.
join
(
folder
,
'
mesh.msh
'
)
datafile
=
os
.
path
.
join
(
folder
,
'
smooth_stress_zz.msh
'
)
# <= values for colours
datafile
=
os
.
path
.
join
(
folder
,
fieldname
)
# <= values for colours
# load mesh and result file into Gmsh
gmsh
.
initialize
()
...
...
@@ -65,11 +76,9 @@ npts = points.GetNumberOfPoints()
# print(f'npts={npts}')
# print(f'len(data)={len(data)}')
vmin
=
np
.
min
(
data
)
# <= use real full range (dolico)
vmax
=
np
.
max
(
data
)
vmin
=
-
30.
# <= use custom range (panthera)
vmax
=
30.
if
not
use_custom_range
:
vmin
=
np
.
min
(
data
)
# <= use real full range (dolico)
vmax
=
np
.
max
(
data
)
# print(f'vmin={vmin}')
# print(f'vmax={vmax}')
...
...
@@ -93,7 +102,41 @@ writer.SetArrayName("Colors")
writer
.
SetInputConnection
(
bfilter
.
GetOutputPort
())
writer
.
Write
()
# ==============================================================================
# ----- export .vtk with a single nodal field
# read exported mesh
reader
=
vtk
.
vtkUnstructuredGridReader
()
reader
.
SetFileName
(
tmp_file
)
reader
.
Update
()
ugrid
=
reader
.
GetOutput
()
darray
=
vtk
.
vtkDoubleArray
()
darray
.
SetNumberOfComponents
(
1
)
darray
.
SetName
(
"
sigzz
"
)
ugrid
.
GetPointData
().
AddArray
(
darray
)
ugrid
.
GetPointData
().
SetActiveScalars
(
"
sigzz
"
)
for
i
,
v
in
enumerate
(
data
):
if
v
>
vmax
:
v
=
vmax
# saturate
if
v
<
vmin
:
v
=
vmin
darray
.
InsertValue
(
i
,
v
)
# extract mesh boundary
bfilter
=
vtk
.
vtkGeometryFilter
()
bfilter
.
SetInputConnection
(
reader
.
GetOutputPort
())
writer
=
vtk
.
vtkXMLPolyDataWriter
()
writer
.
SetInputConnection
(
bfilter
.
GetOutputPort
())
writer
.
SetFileName
(
'
philippe.vtp
'
)
writer
.
Write
()
# ===========================================================
# clean tmp file
os
.
remove
(
tmp_file
)
print
(
'
done.
'
)
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