Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
hysop
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
particle_methods
hysop
Commits
65432bfb
Commit
65432bfb
authored
11 years ago
by
Franck Pérignon
Browse files
Options
Downloads
Patches
Plain Diff
update printer for parallel output
parent
a9aff277
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
HySoP/hysop/operator/monitors/printer.py
+18
-6
18 additions, 6 deletions
HySoP/hysop/operator/monitors/printer.py
with
18 additions
and
6 deletions
HySoP/hysop/operator/monitors/printer.py
+
18
−
6
View file @
65432bfb
...
@@ -30,12 +30,12 @@ class Printer(Monitoring):
...
@@ -30,12 +30,12 @@ class Printer(Monitoring):
Monitoring
.
__init__
(
self
,
fields
,
frequency
,
name
=
"
Printer
"
)
Monitoring
.
__init__
(
self
,
fields
,
frequency
,
name
=
"
Printer
"
)
## output file name prefix
## output file name prefix
if
prefix
is
None
:
if
prefix
is
None
:
self
.
prefix
=
'
./out_
'
+
str
(
main_rank
)
self
.
prefix
=
'
./out_
'
else
:
else
:
self
.
prefix
=
prefix
+
str
(
main_rank
)
self
.
prefix
=
prefix
## Extension for filename
## Extension for filename
if
ext
is
None
:
if
ext
is
None
:
self
.
ext
=
'
.vtk
'
self
.
ext
=
''
else
:
else
:
self
.
ext
=
ext
self
.
ext
=
ext
self
.
input
=
fields
self
.
input
=
fields
...
@@ -67,8 +67,10 @@ class Printer(Monitoring):
...
@@ -67,8 +67,10 @@ class Printer(Monitoring):
def
_build_vtk_dict
(
self
):
def
_build_vtk_dict
(
self
):
"""
Build a dictionary from fields to VTK image.
"""
"""
Build a dictionary from fields to VTK image.
"""
res
=
{}
res
=
{}
for
f
in
self
.
variables
:
for
f
in
self
.
variables
:
for
df
in
f
.
discreteFields
.
values
():
for
df
in
f
.
discreteFields
.
values
():
#ind = df.topology.mesh.iCompute
if
f
.
isVector
:
if
f
.
isVector
:
for
d
in
xrange
(
len
(
df
.
data
)):
for
d
in
xrange
(
len
(
df
.
data
)):
if
len
(
df
.
data
[
d
].
shape
)
==
2
:
if
len
(
df
.
data
[
d
].
shape
)
==
2
:
...
@@ -113,12 +115,22 @@ class Printer(Monitoring):
...
@@ -113,12 +115,22 @@ class Printer(Monitoring):
except
AttributeError
:
except
AttributeError
:
pass
pass
# Set output file name
# Set output file name
filename
=
self
.
prefix
+
'
_it_
'
+
str
(
ite
)
+
self
.
ext
filename
=
self
.
prefix
+
'
iter_
'
+
str
(
ite
)
filename
+=
'
_
'
+
str
(
main_rank
)
+
self
.
ext
print
"
Print to file
"
+
filename
print
"
Print to file
"
+
filename
## VTK output \todo: Need fix in 2D, getting an IOError.
## VTK output \todo: Need fix in 2D, getting an IOError.
try
:
try
:
orig
=
self
.
variables
[
0
].
discreteFields
.
values
()[
0
].
topology
.
mesh
.
global_start
#orig = self.variables[0].discreteFields.values()[0].topology.mesh.global_start
evtk
.
imageToVTK
(
filename
,
origin
=
(
orig
[
0
],
orig
[
1
],
orig
[
2
]),
pointData
=
self
.
_build_vtk_dict
())
topo
=
self
.
variables
[
0
].
discreteFields
.
keys
()[
0
]
orig
=
tuple
([
topo
.
mesh
.
origin
[
i
]
for
i
in
xrange
(
topo
.
mesh
.
dim
)])
coords
=
topo
.
mesh
.
coords
ind
=
topo
.
mesh
.
local_start
orig
=
tuple
([
topo
.
mesh
.
coords
[
i
].
flatten
()[
ind
[
i
]]
for
i
in
xrange
(
topo
.
mesh
.
dim
)])
spacing
=
tuple
(
topo
.
mesh
.
space_step
)
evtk
.
imageToVTK
(
filename
,
origin
=
orig
,
spacing
=
spacing
,
pointData
=
self
.
_build_vtk_dict
()))
except
IOError
:
except
IOError
:
if
self
.
variables
[
0
].
domain
.
dimension
==
2
:
if
self
.
variables
[
0
].
domain
.
dimension
==
2
:
## Standard output
## Standard output
...
...
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