Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SWIFTsim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
SWIFT
SWIFTsim
Commits
3a17de8b
Commit
3a17de8b
authored
9 years ago
by
Matthieu Schaller
Browse files
Options
Downloads
Patches
Plain Diff
New function to compute the (integer) time of the next snapshot dump
parent
a35351c4
No related branches found
No related tags found
1 merge request
!159
Timed outputs
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/engine.c
+27
-0
27 additions, 0 deletions
src/engine.c
src/engine.h
+2
-0
2 additions, 0 deletions
src/engine.h
with
29 additions
and
0 deletions
src/engine.c
+
27
−
0
View file @
3a17de8b
...
...
@@ -2340,6 +2340,7 @@ void engine_dump_snapshot(struct engine *e, struct UnitSystem *us,
struct
clocks_time
time1
,
time2
;
clocks_gettime
(
&
time1
);
/* Dump... */
#if defined(WITH_MPI)
#if defined(HAVE_PARALLEL_HDF5)
write_output_parallel
(
e
,
baseName
,
us
,
myrank
,
nr_nodes
,
MPI_COMM_WORLD
,
...
...
@@ -2356,6 +2357,9 @@ void engine_dump_snapshot(struct engine *e, struct UnitSystem *us,
if
(
e
->
verbose
)
message
(
"writing particle properties took %.3f %s."
,
(
float
)
clocks_diff
(
&
time1
,
&
time2
),
clocks_getunit
());
/* ... and find the next output time */
engine_compute_next_snapshot_time
(
e
);
}
#if defined(HAVE_LIBNUMA) && defined(_GNU_SOURCE)
...
...
@@ -2426,6 +2430,7 @@ void engine_init(struct engine *e, struct space *s,
parser_get_param_double
(
params
,
"Snapshots:time_first"
);
e
->
deltaTimeSnapshot
=
parser_get_param_double
(
params
,
"Snapshots:delta_time"
);
e
->
ti_nextSnapshot
=
0
;
e
->
dt_min
=
parser_get_param_double
(
params
,
"TimeIntegration:dt_min"
);
e
->
dt_max
=
parser_get_param_double
(
params
,
"TimeIntegration:dt_max"
);
e
->
file_stats
=
NULL
;
...
...
@@ -2716,3 +2721,25 @@ void engine_print_policy(struct engine *e) {
fflush
(
stdout
);
#endif
}
/**
* @brief Computes the next time (on the time line) for a dump
*
* @param e The #engine.
*/
void
engine_compute_next_snapshot_time
(
struct
engine
*
e
)
{
for
(
double
time
=
e
->
timeFirstSnapshot
;
time
<
e
->
timeEnd
;
time
+=
e
->
deltaTimeSnapshot
)
{
/* Output time on the integer timeline */
e
->
ti_nextSnapshot
=
(
time
-
e
->
timeBegin
)
/
e
->
timeBase
;
if
(
e
->
ti_nextSnapshot
>
e
->
ti_current
)
break
;
}
/* Be nice, talk... */
const
float
next_snapshot_time
=
e
->
ti_nextSnapshot
*
e
->
timeBase
+
e
->
timeBegin
;
if
(
e
->
verbose
)
message
(
"Next output time set to t=%f"
,
next_snapshot_time
);
}
This diff is collapsed.
Click to expand it.
src/engine.h
+
2
−
0
View file @
3a17de8b
...
...
@@ -134,6 +134,7 @@ struct engine {
/* Snapshot times */
double
timeFirstSnapshot
;
double
deltaTimeSnapshot
;
int
ti_nextSnapshot
;
/* File for statistics */
FILE
*
file_stats
;
...
...
@@ -185,6 +186,7 @@ struct engine {
/* Function prototypes. */
void
engine_barrier
(
struct
engine
*
e
,
int
tid
);
void
engine_compute_next_snapshot_time
(
struct
engine
*
e
);
void
engine_dump_snapshot
(
struct
engine
*
e
,
struct
UnitSystem
*
us
,
const
char
*
baseName
);
void
engine_init
(
struct
engine
*
e
,
struct
space
*
s
,
...
...
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