Commit 8b036533 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Always initialise the gparts to a sensible state

parent 858df3cb
......@@ -605,6 +605,26 @@ void cell_init_parts(struct cell *c, void *data) {
c->ti_end_max = 0;
}
/**
* @brief Initialises all g-particles to a valid state even if the ICs were
*stupid
*
* @param c Cell to act upon
* @param data Unused parameter
*/
void cell_init_gparts(struct cell *c, void *data) {
struct gpart *gp = c->gparts;
const int gcount = c->gcount;
for (int i = 0; i < gcount; ++i) {
gp[i].ti_begin = 0;
gp[i].ti_end = 0;
}
c->ti_end_min = 0;
c->ti_end_max = 0;
}
/**
* @brief Converts hydro quantities to a valid state after the initial density
*calculation
......
......@@ -178,6 +178,7 @@ int cell_getsize(struct cell *c);
int cell_link_parts(struct cell *c, struct part *parts);
int cell_link_gparts(struct cell *c, struct gpart *gparts);
void cell_init_parts(struct cell *c, void *data);
void cell_init_gparts(struct cell *c, void *data);
void cell_convert_hydro(struct cell *c, void *data);
void cell_clean_links(struct cell *c, void *data);
......
......@@ -1846,7 +1846,15 @@ void engine_init_particles(struct engine *e) {
/* Make sure all particles are ready to go */
/* i.e. clean-up any stupid state in the ICs */
space_map_cells_pre(s, 1, cell_init_parts, NULL);
if ((e->policy & engine_policy_hydro) == engine_policy_hydro) {
space_map_cells_pre(s, 1, cell_init_parts, NULL);
}
if (((e->policy & engine_policy_self_gravity) ==
engine_policy_self_gravity) ||
((e->policy & engine_policy_external_gravity) ==
engine_policy_external_gravity)) {
space_map_cells_pre(s, 1, cell_init_gparts, NULL);
}
engine_prepare(e);
......
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