Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
dumux
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
dumux-repositories
dumux
Commits
94226bd7
Commit
94226bd7
authored
8 years ago
by
Thomas Fetzer
Browse files
Options
Downloads
Patches
Plain Diff
[bin] Add postprocessing folder and two pvpython scripts
parent
d0cf5fce
No related branches found
No related tags found
1 merge request
!160
Cleanup/binfolder
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bin/postprocessing/extractLineData.py
+67
-0
67 additions, 0 deletions
bin/postprocessing/extractLineData.py
bin/postprocessing/extractPointDataOverTime.py
+86
-0
86 additions, 0 deletions
bin/postprocessing/extractPointDataOverTime.py
with
153 additions
and
0 deletions
bin/postprocessing/extractLineData.py
0 → 100644
+
67
−
0
View file @
94226bd7
import
argparse
import
csv
import
sys
import
os
# parse arguments
parser
=
argparse
.
ArgumentParser
(
prog
=
'
pvpython
'
+
sys
.
argv
[
0
],
description
=
'
Extract data from the paraview plotOverLine filter.
'
)
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'
-i
'
,
'
--inputDirectory
'
,
help
=
"
Directory in which the .vtu are located
"
)
parser
.
add_argument
(
'
-f
'
,
'
--files
'
,
nargs
=
'
+
'
,
required
=
True
,
help
=
"
vtu files to be processed
"
)
parser
.
add_argument
(
'
-o
'
,
'
--outputDirectory
'
,
help
=
"
Directory to which the data files are written
"
)
parser
.
add_argument
(
'
-p1
'
,
'
--point1
'
,
type
=
float
,
nargs
=
3
,
required
=
True
,
help
=
'
Coordinates of the first point (in 3D)
'
)
parser
.
add_argument
(
'
-p2
'
,
'
--point2
'
,
type
=
float
,
nargs
=
3
,
required
=
True
,
help
=
'
Coordinates of the second point (in 3D)
'
)
parser
.
add_argument
(
'
-r
'
,
'
--resolution
'
,
type
=
int
,
default
=
1000
,
help
=
'
Resolution of the line (number of data points written to data file)
'
)
parser
.
add_argument
(
'
-v
'
,
'
--verbosity
'
,
type
=
int
,
default
=
2
,
help
=
'
Verbosity of the output. 1 = print progress. 2 = print data columns
'
)
args
=
vars
(
parser
.
parse_args
())
from
paraview.simple
import
*
# import locations
inDirectory
=
args
[
'
inputDirectory
'
]
outDirectory
=
args
[
'
outputDirectory
'
]
if
not
inDirectory
==
''
:
inDirectory
+=
'
/
'
if
not
outDirectory
==
''
:
outDirectory
+=
'
/
'
if
not
os
.
path
.
exists
(
outDirectory
):
os
.
makedirs
(
outDirectory
)
# loop over all vtk files
counter
=
1
for
curFile
in
args
[
'
files
'
]:
# print progress to command line
fileWithoutPath
=
os
.
path
.
basename
(
curFile
)
basename
=
os
.
path
.
splitext
(
fileWithoutPath
)[
0
]
if
args
[
'
verbosity
'
]
==
1
:
print
(
"
Processing file ({}/{}): {}
"
.
format
(
counter
,
len
(
args
[
'
files
'
]),
fileWithoutPath
))
counter
+=
1
# load vtk file
vtkFile
=
XMLUnstructuredGridReader
(
FileName
=
inDirectory
+
curFile
)
SetActiveSource
(
vtkFile
)
# apply and configure PlotOverLine filter
plotOverLine
=
PlotOverLine
(
Source
=
"
High Resolution Line Source
"
)
plotOverLine
.
Source
.
Resolution
=
args
[
'
resolution
'
]
plotOverLine
.
Source
.
Point1
=
args
[
'
point1
'
]
plotOverLine
.
Source
.
Point2
=
args
[
'
point2
'
]
# write output to csv writer
csvFile
=
outDirectory
+
basename
+
'
.csv
'
writer
=
CreateWriter
(
csvFile
,
plotOverLine
)
writer
.
UpdatePipeline
()
# print the parameters and the column numbers
if
args
[
'
verbosity
'
]
==
2
:
with
open
(
csvFile
)
as
f
:
print
csvFile
reader
=
csv
.
reader
(
f
)
paramList
=
list
(
reader
)
paramCounter
=
1
for
param
in
paramList
[
0
]:
print
"
%-2i %s
"
%
(
paramCounter
,
param
)
paramCounter
+=
1
This diff is collapsed.
Click to expand it.
bin/postprocessing/extractPointDataOverTime.py
0 → 100644
+
86
−
0
View file @
94226bd7
import
argparse
import
csv
import
fileinput
import
os
import
sys
# parse arguments
parser
=
argparse
.
ArgumentParser
(
prog
=
'
pvpython
'
+
sys
.
argv
[
0
],
description
=
'
Extract data from the paraview probeLocation and plotOverTime filters.
'
)
parser
.
add_argument
(
'
-i
'
,
'
--inputDirectory
'
,
help
=
"
Directory in which the pvd file is located
"
)
parser
.
add_argument
(
'
-f
'
,
'
--files
'
,
nargs
=
'
+
'
,
required
=
True
,
help
=
"
pvd files to be processed
"
)
parser
.
add_argument
(
'
-o
'
,
'
--outputDirectory
'
,
help
=
"
Directory to which the .csv files are written
"
)
parser
.
add_argument
(
'
-p
'
,
'
--point
'
,
type
=
float
,
nargs
=
3
,
required
=
True
,
help
=
'
Coordinates of the probed point (in 3D)
'
)
parser
.
add_argument
(
'
-v
'
,
'
--verbosity
'
,
type
=
int
,
default
=
2
,
help
=
'
Verbosity of the output. 1 = print progress. 2 = print data columns
'
)
args
=
vars
(
parser
.
parse_args
())
from
paraview.simple
import
*
# import locations
inDirectory
=
args
[
'
inputDirectory
'
]
outDirectory
=
args
[
'
outputDirectory
'
]
if
not
inDirectory
==
''
:
inDirectory
+=
'
/
'
if
not
outDirectory
==
''
:
outDirectory
+=
'
/
'
if
not
os
.
path
.
exists
(
outDirectory
):
os
.
makedirs
(
outDirectory
)
# loop over all pvd files
counter
=
1
for
curFile
in
args
[
'
files
'
]:
# print progress to command line
fileWithoutPath
=
os
.
path
.
basename
(
curFile
)
basename
=
os
.
path
.
splitext
(
fileWithoutPath
)[
0
]
if
args
[
'
verbosity
'
]
==
1
:
print
(
"
Processing file ({}/{}): {}
"
.
format
(
counter
,
len
(
args
[
'
files
'
]),
inDirectory
+
curFile
))
counter
+=
1
# load pvd file
pvdFile
=
PVDReader
(
FileName
=
inDirectory
+
curFile
)
# Extract Point and Probe at a location
selectionSource
=
IDSelectionSource
(
ContainingCells
=
0
,
InsideOut
=
False
,
FieldType
=
'
POINT
'
,
IDs
=
0
)
ExtractSelection
=
ExtractSelection
(
Selection
=
selectionSource
,
Input
=
pvdFile
)
ExtractSelection
.
UpdatePipeline
()
selectionData
=
servermanager
.
Fetch
(
ExtractSelection
)
probeLocation
=
ProbeLocation
()
probeLocation
.
Input
=
pvdFile
pointSource
=
probeLocation
.
ProbeType
pointSource
.
Center
.
SetData
(
args
[
'
point
'
])
probeLocation
.
UpdatePipeline
()
# Parse the extracted source and plot over time
selectionSourceprobeLocationation
=
IDSelectionSource
(
ContainingCells
=
0
,
InsideOut
=
False
,
FieldType
=
'
POINT
'
,
IDs
=
[
0
,
0
]
)
plotSelectionOverTime
=
PlotSelectionOverTime
(
OnlyReportSelectionStatistics
=
False
)
plotSelectionOverTime
.
Selection
=
selectionSourceprobeLocationation
plotSelectionOverTime
.
Input
=
probeLocation
# write output to csv writer
csvFile
=
outDirectory
+
basename
+
'
.csv
'
writer
=
CreateWriter
(
csvFile
,
plotSelectionOverTime
)
writer
.
UpdatePipeline
()
# print the parameters and the column numbers
if
args
[
'
verbosity
'
]
==
2
:
with
open
(
outDirectory
+
basename
+
'
0.csv
'
)
as
file
:
print
outDirectory
+
basename
+
'
.csv
'
reader
=
csv
.
reader
(
file
)
paramList
=
list
(
reader
)
paramCounter
=
1
for
param
in
paramList
[
0
]:
print
"
%-2i %s
"
%
(
paramCounter
,
param
)
paramCounter
+=
1
# create a proper csv file with semicolons as separators
f
=
open
(
outDirectory
+
basename
+
'
0.csv
'
,
'
r
'
)
filedata
=
f
.
read
()
f
.
close
()
os
.
remove
(
outDirectory
+
basename
+
'
0.csv
'
)
newdata
=
filedata
.
replace
(
'
,
'
,
'
;
'
)
f
=
open
(
csvFile
,
'
w
'
)
f
.
write
(
newdata
)
f
.
close
()
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