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
8e95d031
Commit
8e95d031
authored
5 years ago
by
EXT Jean-Matthieu Etancelin
Browse files
Options
Downloads
Patches
Plain Diff
Add generic dump function for IO_Params.
parent
2bfbe81d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!16
MPI operators
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
hysop/tools/io_utils.py
+17
-10
17 additions, 10 deletions
hysop/tools/io_utils.py
with
17 additions
and
10 deletions
hysop/tools/io_utils.py
+
17
−
10
View file @
8e95d031
...
...
@@ -49,8 +49,8 @@ class IO(object):
@requires_cmd
(
'
stat
'
)
def
get_fs_type
(
path
):
cmd
=
[
'
stat
'
,
'
-f
'
,
'
-c
'
,
'
%T
'
,
path
]
fs_type
=
''
if
mpi
.
main_rank
==
0
:
fs_type
=
''
if
mpi
.
main_rank
==
0
:
fs_type
=
subprocess
.
check_output
(
cmd
)
fs_type
=
mpi
.
main_comm
.
bcast
(
fs_type
,
root
=
0
)
return
fs_type
.
replace
(
'
\n
'
,
''
)
...
...
@@ -151,7 +151,7 @@ class IO(object):
raise
RuntimeError
(
msg
)
if
not
os
.
path
.
exists
(
cpath
):
try
:
if
mpi
.
main_rank
==
0
:
if
mpi
.
main_rank
==
0
:
os
.
makedirs
(
cpath
)
except
IOError
:
pass
...
...
@@ -232,7 +232,7 @@ class IO(object):
class
IOParams
(
namedtuple
(
"
IOParams
"
,
[
'
filename
'
,
'
filepath
'
,
'
frequency
'
,
'
fileformat
'
,
'
dump_times_fp32
'
,
'
dump_times_fp64
'
,
'
dump_tstart
'
,
'
dump_tend
'
,
'
dump_tstart
'
,
'
dump_tend
'
,
'
dump_func
'
,
'
io_leader
'
,
'
visu_leader
'
,
'
with_last
'
,
'
enable_ram_fs
'
,
'
force_ram_fs
'
,
'
dump_is_temporary
'
,
'
postprocess_dump
'
,
...
...
@@ -254,8 +254,10 @@ class IOParams(namedtuple("IOParams", ['filename', 'filepath',
Extra dump times that should be used to dump in addition to frequency (double precision)
dump_tstart: float
Start to dump at given time. Defaults to -np.inf (no time constraints).
dump_end: float
dump_
t
end: float
Stop to dump at given time. Defaults to +np.inf (no time constraints).
dump_func: function
Generic function to compute the should_dump result.
with_last: boolean
should dump when iteration is last one
io_leader : int
...
...
@@ -290,7 +292,7 @@ class IOParams(namedtuple("IOParams", ['filename', 'filepath',
"""
def
__new__
(
cls
,
filename
,
filepath
=
None
,
frequency
=
1
,
fileformat
=
None
,
dump_times
=
None
,
dump_tstart
=
None
,
dump_tend
=
None
,
dump_times
=
None
,
dump_tstart
=
None
,
dump_tend
=
None
,
dump_func
=
None
,
io_leader
=
0
,
visu_leader
=
0
,
with_last
=
False
,
enable_ram_fs
=
False
,
force_ram_fs
=
False
,
dump_is_temporary
=
False
,
postprocess_dump
=
None
,
...
...
@@ -316,7 +318,9 @@ class IOParams(namedtuple("IOParams", ['filename', 'filepath',
check_instance
(
dump_is_temporary
,
bool
)
check_instance
(
postprocess_dump
,
str
,
allow_none
=
True
)
check_instance
(
hdf5_disable_compression
,
bool
)
if
dump_func
:
assert
callable
(
dump_func
),
"
given function must be callable
"
assert
dump_func
.
func_code
.
co_argcount
,
"
given function must take one arg (as simulation object)
"
frequency
=
int
(
frequency
)
dump_tstart
=
float
(
dump_tstart
)
dump_tend
=
float
(
dump_tend
)
...
...
@@ -378,13 +382,15 @@ class IOParams(namedtuple("IOParams", ['filename', 'filepath',
return
super
(
IOParams
,
cls
).
__new__
(
cls
,
filename
,
filepath
,
frequency
,
fileformat
,
dump_times_fp32
,
dump_times_fp64
,
dump_tstart
,
dump_tend
,
dump_tstart
,
dump_tend
,
dump_func
,
io_leader
,
visu_leader
,
with_last
,
enable_ram_fs
,
force_ram_fs
,
dump_is_temporary
,
postprocess_dump
,
hdf5_disable_compression
,
disk_filepath
,
kwds
)
def
should_dump
(
self
,
simulation
):
if
self
.
dump_func
is
not
None
:
return
self
.
dump_func
(
simulation
)
frequency
=
self
.
frequency
t
=
simulation
.
t
()
dump
=
(
frequency
>=
0
)
and
(
self
.
with_last
and
simulation
.
_next_is_last
)
...
...
@@ -403,7 +409,7 @@ class IOParams(namedtuple("IOParams", ['filename', 'filepath',
def
clone
(
self
,
**
kwds
):
keys
=
(
'
filename
'
,
'
frequency
'
,
'
fileformat
'
,
'
dump_times
'
,
'
dump_tstart
'
,
'
dump_tend
'
,
'
dump_times
'
,
'
dump_tstart
'
,
'
dump_tend
'
,
'
dump_func
'
,
'
io_leader
'
,
'
visu_leader
'
,
'
with_last
'
,
'
enable_ram_fs
'
,
'
force_ram_fs
'
,
'
dump_is_temporary
'
,
'
postprocess_dump
'
,
...
...
@@ -441,6 +447,7 @@ fileformat: {}
frequency: {}
dump_times: {}
dump_tstart: {}
dump_func: {}
dump_tend: {}
io_leader: {}
visu_leader: {}
...
...
@@ -451,7 +458,7 @@ post_process: {}
hdf5_no_compr: {}
extra_kwds: {}
'''
.
format
(
self
.
filename
,
self
.
filepath
,
self
.
fileformat
,
self
.
frequency
,
self
.
dump_times
,
self
.
dump_tstart
,
self
.
dump_tend
,
self
.
frequency
,
self
.
dump_times
,
self
.
dump_tstart
,
self
.
dump_tend
,
self
.
dump_func
,
self
.
io_leader
,
self
.
visu_leader
,
self
.
enable_ram_fs
,
self
.
force_ram_fs
,
self
.
dump_is_temporary
,
...
...
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