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

Removed nested function in engine_init_particles()

parent 29ba1972
...@@ -545,3 +545,26 @@ void cell_split(struct cell *c) { ...@@ -545,3 +545,26 @@ void cell_split(struct cell *c) {
for (k = 0; k < gcount; k++) for (k = 0; k < gcount; k++)
if (gparts[k].id > 0) gparts[k].part->gpart = &gparts[k]; if (gparts[k].id > 0) gparts[k].part->gpart = &gparts[k];
} }
/**
* @brief Initialises all particles to a valid state even if the ICs were stupid
*
* @param c Cell to act upon
* @param data Unused parameter
*/
void cell_init_parts(struct cell *c, void *data) {
struct part *p = c->parts;
struct xpart *xp = c->xparts;
for(int i=0; i<c->count; ++i) {
p[i].t_begin = 0.;
p[i].t_end = 0.;
p[i].rho = -1.;
xp[i].v_full[0] = p[i].v[0];
xp[i].v_full[1] = p[i].v[1];
xp[i].v_full[2] = p[i].v[2];
}
c->t_end_min = 0.;
}
...@@ -169,5 +169,6 @@ int cell_pack(struct cell *c, struct pcell *pc); ...@@ -169,5 +169,6 @@ int cell_pack(struct cell *c, struct pcell *pc);
int cell_unpack(struct pcell *pc, struct cell *c, struct space *s); int cell_unpack(struct pcell *pc, struct cell *c, struct space *s);
int cell_getsize(struct cell *c); int cell_getsize(struct cell *c);
int cell_link(struct cell *c, struct part *parts); int cell_link(struct cell *c, struct part *parts);
void cell_init_parts(struct cell *c, void *data);
#endif /* SWIFT_CELL_H */ #endif /* SWIFT_CELL_H */
...@@ -1849,41 +1849,10 @@ void engine_init_particles(struct engine *e) { ...@@ -1849,41 +1849,10 @@ void engine_init_particles(struct engine *e) {
//engine_print(e); //engine_print(e);
//fflush(stdout);
//message("Engine prepared");
/* Nested functions are not standard C. Please extract. */
/* Make sure all particles are ready to go */ /* Make sure all particles are ready to go */
void initParts(struct part * p, struct xpart * xp, struct cell * c) { /* i.e. clean-up any stupid state in the ICs */
p->t_begin = 0.;
p->t_end = 0.;
p->rho = -1.;
xp->v_full[0] = p->v[0];
xp->v_full[1] = p->v[1];
xp->v_full[2] = p->v[2];
c->t_end_min = 0.;
}
message("Initialising particles"); message("Initialising particles");
space_map_parts_xparts(s, initParts); space_map_cells_pre(s, 1, cell_init_parts, NULL);
/* Now everybody should have sensible smoothing length */
void printParts(struct part * p, struct xpart * xp, struct cell * c) {
if (p->id == 1000)
message("id=%lld h=%f rho=%f t_begin=%f t_end=%f", p->id, p->h, p->rho,
p->t_begin, p->t_end);
}
// space_map_parts_xparts(s, printParts);
void printCells(struct part * p, struct xpart * xp, struct cell * c) {
if (c->super != NULL && 0)
message(
"c->t_end_min=%f c->t_end_max=%f c->super=%p sort=%p ghost=%p "
"kick=%p",
c->t_end_min, c->t_end_max, c->super, c->sorts, c->ghost, c->kick);
}
// space_map_parts_xparts(s, printCells);
/* Now do a density calculation */ /* Now do a density calculation */
TIMER_TIC; TIMER_TIC;
...@@ -1895,10 +1864,6 @@ void engine_init_particles(struct engine *e) { ...@@ -1895,10 +1864,6 @@ void engine_init_particles(struct engine *e) {
TIMER_TOC(timer_runners); TIMER_TOC(timer_runners);
// space_map_parts_xparts(s, printParts);
printf("\n\n");
/* Ready to go */ /* Ready to go */
e->step = -1; e->step = -1;
} }
......
...@@ -849,7 +849,6 @@ void space_map_parts(struct space *s, ...@@ -849,7 +849,6 @@ void space_map_parts(struct space *s,
* *
* @param c The #cell we are working in. * @param c The #cell we are working in.
* @param fun Function pointer to apply on the cells. * @param fun Function pointer to apply on the cells.
* @param data Data passed to the function fun.
*/ */
static void rec_map_parts_xparts(struct cell *c, static void rec_map_parts_xparts(struct cell *c,
......
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