Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TOUGH2 Visualization
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
jarunanp
TOUGH2 Visualization
Commits
d74c7598
Commit
d74c7598
authored
5 years ago
by
jarunanp
Browse files
Options
Downloads
Patches
Plain Diff
add file converter and config file
parent
8210a4ad
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
config.yaml
+5
-0
5 additions, 0 deletions
config.yaml
results_to_vtk.py
+85
-0
85 additions, 0 deletions
results_to_vtk.py
with
90 additions
and
0 deletions
config.yaml
0 → 100644
+
5
−
0
View file @
d74c7598
filename_in
:
"
/home/jarunanp/work/geg/19_04_Justin_Paraview/Production_openBC/Results/openBC_prod_10yr.csv"
filename_out
:
"
/home/jarunanp/work/geg/19_04_Justin_Paraview/output/openBC_prod_10yr.vtk"
npoint_d1
:
80
npoint_d2
:
40
npoint_d3
:
15
This diff is collapsed.
Click to expand it.
results_to_vtk.py
0 → 100644
+
85
−
0
View file @
d74c7598
import
os
import
sys
import
numpy
as
np
import
yaml
def
read_config_file
(
filename
):
"""
read input values
"""
print
(
"
... reading an input file
"
,
filename
)
with
open
(
filename
,
"
r
"
)
as
f
:
config
=
yaml
.
load
(
f
)
return
config
def
read_results
(
config
):
"""
read mesh and results
"""
print
(
"
... reading a result file
"
,
config
[
"
filename_in
"
])
# Open the file and read data
with
open
(
config
[
"
filename_in
"
],
"
r
"
)
as
f
:
data
=
f
.
readlines
()
header
=
data
.
pop
(
0
)
header
=
header
.
replace
(
'
\"
'
,
''
)
header
=
header
.
replace
(
'
'
,
''
)
header
=
header
.
strip
().
split
(
"
,
"
)
header
.
pop
(
0
)
header
.
pop
(
0
)
header
.
pop
(
0
)
nresults
=
len
(
header
)
print
(
header
,
nresults
)
results
=
{}
for
i
in
range
(
nresults
):
key
=
header
[
i
]
results
[
key
]
=
[]
npoint_d1
=
config
[
"
npoint_d1
"
]
npoint_d2
=
config
[
"
npoint_d2
"
]
npoint_d3
=
config
[
"
npoint_d3
"
]
npoints
=
npoint_d1
*
npoint_d2
*
npoint_d3
#
ncell_d1
=
npoint_d1
-
1
ncell_d2
=
npoint_d2
-
1
ncell_d3
=
npoint_d3
-
1
ncells
=
ncell_d1
*
ncell_d2
*
ncell_d3
# Write output
with
open
(
config
[
"
filename_out
"
],
"
w
"
)
as
g
:
g
.
write
(
"
# vtk DataFile Version 2.0
\n
"
)
g
.
write
(
"
Mesh data
\n
"
)
g
.
write
(
"
ASCII
\n
"
)
g
.
write
(
"
DATASET STRUCTURED_GRID
\n
"
)
g
.
write
(
"
DIMENSIONS {:d} {:d} {:d}
\n
"
.
format
(
npoint_d1
,
npoint_d2
,
npoint_d3
))
g
.
write
(
"
POINTS {:d} double
\n
"
.
format
(
npoints
))
# Loop over all data lines
for
line
in
data
:
line
=
line
.
replace
(
'
NAN
'
,
'
0.0
'
)
values
=
line
.
strip
().
split
(
"
,
"
)
x
=
values
[
0
]
y
=
values
[
1
]
z
=
values
[
2
]
g
.
write
(
"
{} {} {}
\n
"
.
format
(
x
,
y
,
z
))
# store results to arrays
for
i
in
range
(
nresults
):
key
=
header
[
i
]
results
[
key
].
append
(
values
[
i
+
3
])
# Write data
g
.
write
(
"
POINT_DATA {:d}
\n
"
.
format
(
npoints
))
g
.
write
(
"
FIELD FieldData {:d}
\n
"
.
format
(
nresults
))
for
i
in
range
(
nresults
):
key
=
header
[
i
]
results_data
=
results
[
key
]
g
.
write
(
"
{} 1 {:d} float
\n
"
.
format
(
key
,
npoints
))
for
value
in
results_data
:
g
.
write
(
"
{}
"
.
format
(
value
))
g
.
write
(
"
\n
"
)
if
__name__
==
"
__main__
"
:
# read config file
config
=
read_config_file
(
"
config.yaml
"
)
# read result file
read_results
(
config
)
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