Commit a34aa63f authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Add the capability to deal with more than one output between two time-steps.

parent 0f6ff35e
......@@ -23,7 +23,7 @@ TimeIntegration:
Snapshots:
basename: box # Common part of the name of output files
time_first: 0. # Time of the first output (in internal units)
delta_time: 1.04 # Time difference between consecutive outputs (in internal units)
delta_time: 1.001 # Time difference between consecutive outputs (in internal units)
scale_factor_first: 0.00991
compression: 4
......
......@@ -4856,6 +4856,15 @@ void engine_step(struct engine *e) {
#endif
}
/**
* @brief Check whether any kind of i/o has to be performed during this
* step.
*
* This includes snapshots, stats and halo finder. We also handle the case
* of multiple outputs between two steps.
*
* @param e The #engine.
*/
void engine_check_for_dumps(struct engine *e) {
/* Save some statistics ? */
......@@ -4882,52 +4891,85 @@ void engine_check_for_dumps(struct engine *e) {
timebin_t max_active_bin = e->max_active_bin;
double time = e->time;
/* Write some form of output */
if (dump_snapshot && save_stats) {
while (save_stats || dump_snapshot || run_stf) {
/* If both, need to figure out which one occurs first */
if (e->ti_next_stats == e->ti_next_snapshot) {
/* Write some form of output */
if (dump_snapshot && save_stats) {
/* Let's fake that we are at the common dump time */
e->ti_current = e->ti_next_snapshot;
e->max_active_bin = 0;
if (!(e->policy & engine_policy_cosmology))
e->time = e->ti_next_snapshot * e->time_base + e->time_begin;
/* If both, need to figure out which one occurs first */
if (e->ti_next_stats == e->ti_next_snapshot) {
/* Drift everyone */
engine_drift_all(e);
/* Let's fake that we are at the common dump time */
e->ti_current = e->ti_next_snapshot;
e->max_active_bin = 0;
if (!(e->policy & engine_policy_cosmology))
e->time = e->ti_next_snapshot * e->time_base + e->time_begin;
/* Dump everything */
engine_print_stats(e);
engine_dump_snapshot(e);
/* Drift everyone */
engine_drift_all(e);
} else if (e->ti_next_stats < e->ti_next_snapshot) {
/* Dump everything */
engine_print_stats(e);
engine_dump_snapshot(e);
/* Let's fake that we are at the stats dump time */
e->ti_current = e->ti_next_stats;
e->max_active_bin = 0;
if (!(e->policy & engine_policy_cosmology))
e->time = e->ti_next_stats * e->time_base + e->time_begin;
} else if (e->ti_next_stats < e->ti_next_snapshot) {
/* Drift everyone */
engine_drift_all(e);
/* Let's fake that we are at the stats dump time */
e->ti_current = e->ti_next_stats;
e->max_active_bin = 0;
if (!(e->policy & engine_policy_cosmology))
e->time = e->ti_next_stats * e->time_base + e->time_begin;
/* Dump stats */
engine_print_stats(e);
/* Drift everyone */
engine_drift_all(e);
/* Let's fake that we are at the snapshot dump time */
e->ti_current = e->ti_next_snapshot;
e->max_active_bin = 0;
if (!(e->policy & engine_policy_cosmology))
e->time = e->ti_next_snapshot * e->time_base + e->time_begin;
/* Dump stats */
engine_print_stats(e);
/* Drift everyone */
engine_drift_all(e);
/* Let's fake that we are at the snapshot dump time */
e->ti_current = e->ti_next_snapshot;
e->max_active_bin = 0;
if (!(e->policy & engine_policy_cosmology))
e->time = e->ti_next_snapshot * e->time_base + e->time_begin;
/* Dump snapshot */
engine_dump_snapshot(e);
/* Drift everyone */
engine_drift_all(e);
} else if (e->ti_next_stats > e->ti_next_snapshot) {
/* Dump snapshot */
engine_dump_snapshot(e);
} else if (e->ti_next_stats > e->ti_next_snapshot) {
/* Let's fake that we are at the snapshot dump time */
e->ti_current = e->ti_next_snapshot;
e->max_active_bin = 0;
if (!(e->policy & engine_policy_cosmology))
e->time = e->ti_next_snapshot * e->time_base + e->time_begin;
/* Drift everyone */
engine_drift_all(e);
/* Dump snapshot */
engine_dump_snapshot(e);
/* Let's fake that we are at the stats dump time */
e->ti_current = e->ti_next_stats;
e->max_active_bin = 0;
if (!(e->policy & engine_policy_cosmology))
e->time = e->ti_next_stats * e->time_base + e->time_begin;
/* Drift everyone */
engine_drift_all(e);
/* Dump stats */
engine_print_stats(e);
}
/* Let's compute the time of the next outputs */
engine_compute_next_snapshot_time(e);
engine_compute_next_statistics_time(e);
} else if (dump_snapshot) {
/* Let's fake that we are at the snapshot dump time */
e->ti_current = e->ti_next_snapshot;
......@@ -4938,9 +4980,14 @@ void engine_check_for_dumps(struct engine *e) {
/* Drift everyone */
engine_drift_all(e);
/* Dump snapshot */
/* Dump... */
engine_dump_snapshot(e);
/* ... and find the next output time */
engine_compute_next_snapshot_time(e);
} else if (save_stats) {
/* Let's fake that we are at the stats dump time */
e->ti_current = e->ti_next_stats;
e->max_active_bin = 0;
......@@ -4950,61 +4997,50 @@ void engine_check_for_dumps(struct engine *e) {
/* Drift everyone */
engine_drift_all(e);
/* Dump stats */
/* Dump */
engine_print_stats(e);
}
/* Let's compute the time of the next outputs */
engine_compute_next_snapshot_time(e);
engine_compute_next_statistics_time(e);
} else if (dump_snapshot) {
/* Let's fake that we are at the snapshot dump time */
e->ti_current = e->ti_next_snapshot;
e->max_active_bin = 0;
if (!(e->policy & engine_policy_cosmology))
e->time = e->ti_next_snapshot * e->time_base + e->time_begin;
/* Drift everyone */
engine_drift_all(e);
/* Dump... */
engine_dump_snapshot(e);
/* ... and find the next output time */
engine_compute_next_snapshot_time(e);
} else if (save_stats) {
/* Let's fake that we are at the stats dump time */
e->ti_current = e->ti_next_stats;
e->max_active_bin = 0;
if (!(e->policy & engine_policy_cosmology))
e->time = e->ti_next_stats * e->time_base + e->time_begin;
/* Drift everyone */
engine_drift_all(e);
/* Dump */
engine_print_stats(e);
/* and move on */
engine_compute_next_statistics_time(e);
}
/* and move on */
engine_compute_next_statistics_time(e);
}
/* Perform structure finding? */
if (run_stf) {
/* Perform structure finding? */
if (run_stf) {
// MATTHIEU: Add a drift_all here. And check the order with the order i/o
// options.
// MATTHIEU: Add a drift_all here. And check the order with the order i/o
// options.
#ifdef HAVE_VELOCIRAPTOR
velociraptor_init(e);
velociraptor_invoke(e);
velociraptor_init(e);
velociraptor_invoke(e);
/* ... and find the next output time */
if (e->stf_output_freq_format == TIME) engine_compute_next_stf_time(e);
/* ... and find the next output time */
if (e->stf_output_freq_format == TIME) engine_compute_next_stf_time(e);
#endif
}
/* We need to see whether whether we are in the pathological case
* where there can be another dump before the next step. */
/* Save some statistics ? */
save_stats = 0;
if (e->ti_end_min > e->ti_next_stats && e->ti_next_stats > 0)
save_stats = 1;
/* Do we want a snapshot? */
dump_snapshot = 0;
if (e->ti_end_min > e->ti_next_snapshot && e->ti_next_snapshot > 0)
dump_snapshot = 1;
/* Do we want to perform structure finding? */
run_stf = 0;
if ((e->policy & engine_policy_structure_finding)) {
if (e->stf_output_freq_format == STEPS && e->step % e->deltaStepSTF == 0)
run_stf = 1;
else if (e->stf_output_freq_format == TIME &&
e->ti_end_min > e->ti_nextSTF && e->ti_nextSTF > 0)
run_stf = 1;
}
}
/* Restore the information we stored */
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment