Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogs-utils
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
ogs-utils
Commits
df9fd0a0
Commit
df9fd0a0
authored
7 years ago
by
Tom Fischer
Browse files
Options
Downloads
Patches
Plain Diff
Add another, more flexible script for merging data arrays.
parent
f6aae985
No related branches found
No related tags found
1 merge request
!3
Add another, more flexible script for merging data arrays.
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
post/merge-scalar-data-arrays/README.md
+4
-1
4 additions, 1 deletion
post/merge-scalar-data-arrays/README.md
post/merge-scalar-data-arrays/mergeDataArraysIntoOne.py
+62
-0
62 additions, 0 deletions
post/merge-scalar-data-arrays/mergeDataArraysIntoOne.py
with
66 additions
and
1 deletion
post/merge-scalar-data-arrays/README.md
+
4
−
1
View file @
df9fd0a0
# Merge two scalar data arrays
Th
is
script takes two scalar nodal fields from a vtu file and combines them to a
Th
e
script
'mergeDataArrays'
takes two scalar nodal fields from a vtu file and combines them to a
two-component vector field.
The script 'mergeDataArraysIntoOne' takes arbitrary number of scalar fields from
a vtu file and uses them as the components of a vector field that will be
created.
This diff is collapsed.
Click to expand it.
post/merge-scalar-data-arrays/mergeDataArraysIntoOne.py
0 → 100755
+
62
−
0
View file @
df9fd0a0
#
# \copyright
# Copyright (c) 2012-2017, OpenGeoSys Community (http://www.opengeosys.org)
# Distributed under a Modified BSD License.
# See accompanying file LICENSE.txt or
# http://www.opengeosys.org/project/license
#
#!/usr/bin/env python2
from
vtk
import
*
from
sys
import
argv
,
exit
if
len
(
argv
)
<
5
:
print
"
Usage:
"
,
argv
[
0
],
"
input.vtu scalar_array1 ... name_for_new_array output.vtu
"
exit
(
1
)
input_file
=
argv
[
1
]
output_file
=
argv
[
len
(
argv
)
-
1
]
print
(
"
Reading from
"
,
input_file
)
print
(
"
Writing to
"
,
output_file
)
r
=
vtkXMLUnstructuredGridReader
()
r
.
SetFileName
(
input_file
)
r
.
Update
()
m
=
r
.
GetOutput
()
cell_data
=
m
.
GetCellData
()
tensor_arrays
=
[]
number_of_components
=
len
(
argv
)
-
4
number_of_tuples
=
cell_data
.
GetArray
(
argv
[(
2
)]).
GetNumberOfTuples
()
for
i
in
range
(
0
,
number_of_components
):
tensor_arrays
.
append
(
cell_data
.
GetArray
(
argv
[(
i
)
+
2
]))
new_array
=
vtkDoubleArray
()
new_array
.
SetNumberOfComponents
(
number_of_components
)
new_array
.
SetNumberOfTuples
((
number_of_tuples
))
new_array
.
SetName
(
argv
[
len
(
argv
)
-
2
])
print
"
copy the particular cell data arrays to the cell data array
"
,
argv
[(
len
(
argv
)
-
2
)]
for
i
in
range
(
0
,
number_of_components
):
new_array
.
CopyComponent
(
i
,
tensor_arrays
[
i
],
0
)
print
"
add
"
,
argv
[(
len
(
argv
)
-
2
)],
"
to the data arrays
"
cell_data
.
AddArray
(
new_array
)
print
"
remove the not needed cell data arrays
"
for
i
in
range
(
0
,
number_of_components
):
print
"
remove the not needed cell data array
"
,
argv
[(
i
)
+
2
]
cell_data
.
RemoveArray
(
argv
[(
i
)
+
2
])
print
"
write result to file
"
w
=
vtkXMLUnstructuredGridWriter
()
w
.
SetFileName
(
output_file
)
w
.
SetInputData
(
m
)
w
.
SetDataModeToAscii
()
w
.
SetCompressorTypeToNone
()
w
.
Update
()
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