Commit 552bac04 authored by Folkert Nobels's avatar Folkert Nobels
Browse files

Code formatting

parent 917403e3
......@@ -3119,8 +3119,8 @@ void engine_step(struct engine *e) {
#endif
/* Write the star formation information to the file */
if (e->policy & engine_policy_star_formation) {
star_formation_logger_write_to_log_file(e->sfh_logger,e->time, e->cosmology->a, e->cosmology->z,
e->sfh);
star_formation_logger_write_to_log_file(
e->sfh_logger, e->time, e->cosmology->a, e->cosmology->z, e->sfh);
}
if (!e->restarting)
......@@ -3379,7 +3379,7 @@ void engine_check_for_dumps(struct engine *e) {
#endif
}
/* Dump... */
/* Dump... */
#ifdef WITH_LOGGER
/* Write a file containing the offsets in the particle logger. */
engine_dump_index(e);
......@@ -4344,11 +4344,13 @@ void engine_init(struct engine *e, struct space *s, struct swift_params *params,
if (e->policy & engine_policy_star_formation) {
const int buffersize = 300;
char SFH_logger_fileName[buffersize];
snprintf(SFH_logger_fileName, buffersize, "%s_SFH_logger.txt", e->snapshot_base_name);
snprintf(SFH_logger_fileName, buffersize, "%s_SFH_logger.txt",
e->snapshot_base_name);
e->sfh_logger = fopen(SFH_logger_fileName, "w");
star_formation_logger_init_log_file(e->sfh_logger, e->internal_units, e->physical_constants);
star_formation_logger_init_log_file(e->sfh_logger, e->internal_units,
e->physical_constants);
}
#if defined(WITH_LOGGER)
......
......@@ -644,8 +644,7 @@ void runner_do_star_formation(struct runner *r, struct cell *c, int timer) {
dt_star);
/* Add the SFR and SFR*dt to the SFH struct of this cell */
star_formation_logger_log_active_part(p, xp, &c->stars.sfh,
dt_star);
star_formation_logger_log_active_part(p, xp, &c->stars.sfh, dt_star);
/* Are we forming a star particle from this SF rate? */
if (star_formation_should_convert_to_star(p, xp, sf_props, e,
......@@ -1471,10 +1470,10 @@ void runner_do_ghost(struct runner *r, struct cell *c, int timer) {
if (((p->h >= hydro_h_max) && (f < 0.f)) ||
((p->h <= hydro_h_min) && (f > 0.f))) {
/* We have a particle whose smoothing length is already set (wants
* to be larger but has already hit the maximum OR wants to be
* smaller but has already reached the minimum). So, just tidy up as
* if the smoothing length had converged correctly */
/* We have a particle whose smoothing length is already set (wants
* to be larger but has already hit the maximum OR wants to be
* smaller but has already reached the minimum). So, just tidy up as
* if the smoothing length had converged correctly */
#ifdef EXTRA_HYDRO_LOOP
......@@ -1619,7 +1618,7 @@ void runner_do_ghost(struct runner *r, struct cell *c, int timer) {
}
}
/* We now have a particle whose smoothing length has converged */
/* We now have a particle whose smoothing length has converged */
#ifdef EXTRA_HYDRO_LOOP
......
......@@ -754,7 +754,7 @@ void space_allocate_extras(struct space *s, int verbose) {
s->gparts[i].id_or_neg_offset = -1;
}
/* Put the spare particles in their correct cell */
/* Put the spare particles in their correct cell */
#ifdef WITH_MPI
error("Need to do this correctly over MPI for only the local cells.");
#endif
......@@ -843,7 +843,7 @@ void space_allocate_extras(struct space *s, int verbose) {
s->parts[i].id = -1;
}
/* Put the spare particles in their correct cell */
/* Put the spare particles in their correct cell */
#ifdef WITH_MPI
error("Need to do this correctly over MPI for only the local cells.");
#endif
......@@ -922,7 +922,7 @@ void space_allocate_extras(struct space *s, int verbose) {
s->sparts[i].id = -42;
}
/* Put the spare particles in their correct cell */
/* Put the spare particles in their correct cell */
#ifdef WITH_MPI
error("Need to do this correctly over MPI for only the local cells.");
#endif
......@@ -2777,7 +2777,7 @@ void space_split_recursive(struct space *s, struct cell *c,
ti_stars_end_min = min(ti_stars_end_min, cp->stars.ti_end_min);
ti_stars_end_max = min(ti_stars_end_max, cp->stars.ti_end_max);
ti_stars_beg_max = min(ti_stars_beg_max, cp->stars.ti_beg_max);
star_formation_logger_assign(c,&cp->stars.sfh);
star_formation_logger_assign(c, &cp->stars.sfh);
/* Increase the depth */
if (cp->maxdepth > maxdepth) maxdepth = cp->maxdepth;
......@@ -2918,7 +2918,8 @@ void space_split_recursive(struct space *s, struct cell *c,
hydro_time_bin_max = max(hydro_time_bin_max, parts[k].time_bin);
h_max = max(h_max, parts[k].h);
/* Collect SFR from the particles after rebuilt */
star_formation_logger_log_inactive_part(&parts[k], &xparts[k], &c->stars.sfh);
star_formation_logger_log_inactive_part(&parts[k], &xparts[k],
&c->stars.sfh);
}
/* xparts: Reset x_diff */
......
......@@ -199,7 +199,9 @@ INLINE static void star_formation_logger_write_to_log_file(
* @param us The current internal system of units.
* @param phys_const Physical constants in internal units
*/
INLINE static void star_formation_logger_init_log_file(FILE *fp, const struct unit_system* restrict us, const struct phys_const* phys_const) {
INLINE static void star_formation_logger_init_log_file(
FILE *fp, const struct unit_system *restrict us,
const struct phys_const *phys_const) {
/* Write some general text to the logger file */
fprintf(fp, "# Star Formation History Logger file\n");
......@@ -207,24 +209,35 @@ INLINE static void star_formation_logger_init_log_file(FILE *fp, const struct un
fprintf(fp, "# The units are all given in internal physical units!\n");
fprintf(fp, "#\n");
fprintf(fp, "# (1) Time\n");
fprintf(fp, "# Unit = %e seconds\n",us->UnitTime_in_cgs);
fprintf(fp, "# Unit = %e yr or %e Myr\n", 1.f/phys_const->const_year, 1.f/phys_const->const_year/1e6);
fprintf(fp, "# Unit = %e seconds\n", us->UnitTime_in_cgs);
fprintf(fp, "# Unit = %e yr or %e Myr\n", 1.f / phys_const->const_year,
1.f / phys_const->const_year / 1e6);
fprintf(fp, "# (2) Scale factor (no unit)\n");
fprintf(fp, "# (3) Redshift (no unit)\n");
fprintf(fp, "# (4) Total mass stars formed at current time\n");
fprintf(fp, "# Unit = %e gram\n",us->UnitMass_in_cgs);
fprintf(fp, "# Unit = %e solar mass\n",1.f/phys_const->const_solar_mass);
fprintf(fp, "# Unit = %e gram\n", us->UnitMass_in_cgs);
fprintf(fp, "# Unit = %e solar mass\n",
1.f / phys_const->const_solar_mass);
fprintf(fp, "# (5) The total SFR of all the active particles\n");
fprintf(fp, "# Unit = %e gram/s\n",us->UnitMass_in_cgs/us->UnitTime_in_cgs);
fprintf(fp, "# Unit = %e Msol/yr\n",phys_const->const_year/phys_const->const_solar_mass);
fprintf(fp, "# (6) The active star formation rate (SFR) times their time steps\n");
fprintf(fp, "# Unit = %e gram\n",us->UnitMass_in_cgs);
fprintf(fp, "# Unit = %e solar mass\n",1.f/phys_const->const_solar_mass);
fprintf(fp, "# Unit = %e gram/s\n",
us->UnitMass_in_cgs / us->UnitTime_in_cgs);
fprintf(fp, "# Unit = %e Msol/yr\n",
phys_const->const_year / phys_const->const_solar_mass);
fprintf(
fp,
"# (6) The active star formation rate (SFR) times their time steps\n");
fprintf(fp, "# Unit = %e gram\n", us->UnitMass_in_cgs);
fprintf(fp, "# Unit = %e solar mass\n",
1.f / phys_const->const_solar_mass);
fprintf(fp, "# (7) The total SFR of all the particles in the simulation\n");
fprintf(fp, "# Unit = %e gram/s\n",us->UnitMass_in_cgs/us->UnitTime_in_cgs);
fprintf(fp, "# Unit = %e Msol/yr\n",phys_const->const_year/phys_const->const_solar_mass);
fprintf(fp, "# Unit = %e gram/s\n",
us->UnitMass_in_cgs / us->UnitTime_in_cgs);
fprintf(fp, "# Unit = %e Msol/yr\n",
phys_const->const_year / phys_const->const_solar_mass);
fprintf(fp, "#\n");
fprintf(fp, "# NOTE: As a consistency check (4) and (6) need to have a cumulative summation\n");
fprintf(fp,
"# NOTE: As a consistency check (4) and (6) need to have a "
"cumulative summation\n");
fprintf(fp, "# that is very close to each other.\n");
fprintf(fp, "#\n");
fprintf(fp,
......
......@@ -120,7 +120,9 @@ INLINE static void star_formation_logger_write_to_log_file(
* @param us The current internal system of units.
* @param phys_const Physical constants in internal units
*/
INLINE static void star_formation_logger_init_log_file(FILE *fp, const struct unit_system* restrict us, const struct phys_const* phys_const) {}
INLINE static void star_formation_logger_init_log_file(
FILE *fp, const struct unit_system *restrict us,
const struct phys_const *phys_const) {}
/**
* @brief Add the SFR tracer to the total active SFR of this cell
......
......@@ -120,7 +120,9 @@ INLINE static void star_formation_logger_write_to_log_file(
* @param us The current internal system of units.
* @param phys_const Physical constants in internal units
*/
INLINE static void star_formation_logger_init_log_file(FILE *fp, const struct unit_system* restrict us, const struct phys_const* phys_const) {}
INLINE static void star_formation_logger_init_log_file(
FILE *fp, const struct unit_system *restrict us,
const struct phys_const *phys_const) {}
/**
* @brief Add the SFR tracer to the total active SFR of this cell
......
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