diff --git a/examples/parameter_example.yml b/examples/parameter_example.yml index 5d03e04c6be8c34998597b687f6101099721ffe5..ddb71c594122a3e8d6ddbd7c5b73e0474b404a75 100644 --- a/examples/parameter_example.yml +++ b/examples/parameter_example.yml @@ -224,3 +224,14 @@ EAGLEChemistry: CalciumOverSilicon: 0.0941736 # Constant ratio of Calcium over Silicon abundance SulphurOverSilicon: 0.6054160 # Constant ratio of Sulphur over Silicon abundance +# Structure finding options (requires velociraptor) +StructureFinding: + config_file_name: stf_input.cfg # Name of the STF config file. + basename: ./stf # Common part of the name of output files. + output_time_format: 0 # Specifies the frequency format of structure finding. 0 for simulation steps (delta_step) and 1 for simulation time intervals (delta_time). + scale_factor_first: 0.92 # Scale-factor of the first snaphot (cosmological run) + time_first: 0.01 # Time of the first structure finding output (in internal units). + delta_step: 1000 # Time difference between consecutive structure finding outputs (in internal units) in simulation steps. + delta_time: 1.10 # Time difference between consecutive structure finding outputs (in internal units) in simulation time intervals. + output_list_on: 0 # (Optional) Enable the output list + output_list: stflist.txt # (Optional) File containing the output times (see documentation in "Parameter File" section) diff --git a/src/engine.c b/src/engine.c index f3ea1e5662269c743290de7e8aa1b0c002afd2e2..184abee389de0cf5ff21b46aef14e1b22d04d0f2 100644 --- a/src/engine.c +++ b/src/engine.c @@ -5768,6 +5768,7 @@ void engine_init(struct engine *e, struct space *s, struct swift_params *params, parser_get_param_double(params, "Snapshots:delta_time"); e->outputlist_snapshots = NULL; e->outputlist_stats = NULL; + e->outputlist_stf = NULL; e->ti_next_snapshot = 0; parser_get_param_string(params, "Snapshots:basename", e->snapshot_base_name); e->snapshot_compression = @@ -6571,6 +6572,12 @@ void engine_compute_next_statistics_time(struct engine *e) { * @param e The #engine. */ void engine_compute_next_stf_time(struct engine *e) { + /* Do outputlist file case */ + if (e->outputlist_stf) { + outputlist_read_next_time(e->outputlist_stf, e, + "stf", &e->ti_nextSTF); + return; + } /* Find upper-bound on last output */ double time_end; @@ -6646,7 +6653,17 @@ void engine_init_outputlists(struct engine *e, struct swift_params *params) { e->a_first_statistics = stats_time_first; else e->time_first_statistics = stats_time_first; - + + /* Deal with stf */ + double stf_time_first; + outputlist_init(&e->outputlist_stf, e, "StructureFinding", &e->deltaTimeSTF, + &stf_time_first); + + if (e->policy & engine_policy_cosmology) + e->a_first_stf = stf_time_first; + else + e->timeFirstSTFOutput = stats_time_first; + } /** @@ -6790,6 +6807,10 @@ void engine_clean(struct engine *e) { outputlist_clean(e->outputlist_stats); free(e->outputlist_stats); } + if (e->outputlist_stf) { + outputlist_clean(e->outputlist_stf); + free(e->outputlist_stf); + } free(e->links); free(e->cell_loc); scheduler_clean(&e->sched); @@ -6835,6 +6856,8 @@ void engine_struct_dump(struct engine *e, FILE *stream) { if (e->outputlist_snapshots) outputlist_struct_dump(e->outputlist_snapshots, stream); if (e->outputlist_stats) outputlist_struct_dump(e->outputlist_stats, stream); + if (e->outputlist_stf) + outputlist_struct_dump(e->outputlist_stf, stream); } /** @@ -6944,6 +6967,13 @@ void engine_struct_restore(struct engine *e, FILE *stream) { e->outputlist_stats = outputlist_stats; } + if (e->outputlist_stf) { + struct outputlist *outputlist_stf = + (struct outputlist *) malloc(sizeof(struct outputlist)); + outputlist_struct_restore(outputlist_stf, stream); + e->outputlist_stf = outputlist_stf; + } + /* Want to force a rebuild before using this engine. Wait to repartition.*/ e->forcerebuild = 1; e->forcerepart = 0; diff --git a/src/engine.h b/src/engine.h index 3a917882bbc19eba35e07c58903c2c95016b6f63..4604bf1ab84152b9a6aa9f1fc396bfd80d867276 100644 --- a/src/engine.h +++ b/src/engine.h @@ -214,8 +214,9 @@ struct engine { double a_first_snapshot; double time_first_snapshot; double delta_time_snapshot; + + /* Outputlist for the snapshots */ struct outputlist *outputlist_snapshots; - struct outputlist *outputlist_stats; /* Integer time of the next snapshot */ integertime_t ti_next_snapshot; @@ -233,6 +234,9 @@ struct engine { double deltaTimeSTF; int deltaStepSTF; + /* Outputlist for the structure finding */ + struct outputlist *outputlist_stf; + /* Integer time of the next stf output */ integertime_t ti_nextSTF; @@ -243,6 +247,9 @@ struct engine { double time_first_statistics; double delta_time_statistics; + /* Outputlist for the stats */ + struct outputlist *outputlist_stats; + /* Integer time of the next statistics dump */ integertime_t ti_next_stats; diff --git a/src/outputlist.c b/src/outputlist.c index 86e8aa9884f40b07ed41c57a1b7b2ac406a7bb71..d0ad000ccdb4bd731ecaa9448af912ff0be058a7 100644 --- a/src/outputlist.c +++ b/src/outputlist.c @@ -184,7 +184,15 @@ void outputlist_read_next_time(struct outputlist *t, const struct engine *e, con } } - +/** + * @brief initialize an output list + * + * @param list The output list to initialize + * @param e The #engine + * @param name The name of the section in params + * @param delta_time updated to the initial delta time + * @param time_first updated to the time of first output (scale factor or cosmic time) + */ void outputlist_init(struct outputlist **list, const struct engine *e, char* name, double *delta_time, double *time_first) { struct swift_params *params = e->parameter_file; @@ -195,7 +203,7 @@ void outputlist_init(struct outputlist **list, const struct engine *e, char* nam /* Read output on/off */ char param_name[PARSER_MAX_LINE_SIZE]; - sprintf(param_name, "%s:outputlist_on", name); + sprintf(param_name, "%s:output_list_on", name); int outputlist_on = parser_get_opt_param_int(params, param_name, 0); @@ -224,7 +232,6 @@ void outputlist_init(struct outputlist **list, const struct engine *e, char* nam } } - } /**