diff --git a/examples/main.c b/examples/main.c index 9117d18d69edc3a6fd3bbf968b53ea36ea36e822..116d422c9adae14d4b14ec4467378c65a53aa0da 100644 --- a/examples/main.c +++ b/examples/main.c @@ -1096,10 +1096,10 @@ int main(int argc, char *argv[]) { ? e.sched.tasks[l].cj->hydro.count : 0, (e.sched.tasks[l].ci != NULL) - ? e.sched.tasks[l].ci->grav.gcount + ? e.sched.tasks[l].ci->grav.count : 0, (e.sched.tasks[l].cj != NULL) - ? e.sched.tasks[l].cj->grav.gcount + ? e.sched.tasks[l].cj->grav.count : 0, e.sched.tasks[l].flags, e.sched.tasks[l].sid); } @@ -1134,9 +1134,9 @@ int main(int argc, char *argv[]) { (e.sched.tasks[l].cj == NULL) ? 0 : e.sched.tasks[l].cj->hydro.count, (e.sched.tasks[l].ci == NULL) ? 0 - : e.sched.tasks[l].ci->grav.gcount, + : e.sched.tasks[l].ci->grav.count, (e.sched.tasks[l].cj == NULL) ? 0 - : e.sched.tasks[l].cj->grav.gcount, + : e.sched.tasks[l].cj->grav.count, e.sched.tasks[l].sid); } } diff --git a/src/active.h b/src/active.h index 24382c4a5b4d9431061d862fc0a1112d2afc7dad..deaf37f276822c2620151d2de24789d5a2a1ce52 100644 --- a/src/active.h +++ b/src/active.h @@ -39,15 +39,16 @@ __attribute__((always_inline)) INLINE static int cell_are_part_drifted( const struct cell *c, const struct engine *e) { #ifdef SWIFT_DEBUG_CHECKS - if (c->hydro.ti_old > e->ti_current) + if (c->hydro.ti_old_part > e->ti_current) error( - "Cell has been drifted too far forward in time! c->ti_old=%lld (t=%e) " + "Cell has been drifted too far forward in time! c->ti_old_part=%lld " + "(t=%e) " "and e->ti_current=%lld (t=%e, a=%e)", - c->hydro.ti_old, c->hydro.ti_old * e->time_base, e->ti_current, - e->ti_current * e->time_base, e->cosmology->a); + c->hydro.ti_old_part, c->hydro.ti_old_part * e->time_base, + e->ti_current, e->ti_current * e->time_base, e->cosmology->a); #endif - return (c->hydro.ti_old == e->ti_current); + return (c->hydro.ti_old_part == e->ti_current); } /** @@ -62,15 +63,15 @@ __attribute__((always_inline)) INLINE static int cell_are_gpart_drifted( const struct cell *c, const struct engine *e) { #ifdef SWIFT_DEBUG_CHECKS - if (c->grav.ti_old_gpart > e->ti_current) + if (c->grav.ti_old_part > e->ti_current) error( "Cell has been drifted too far forward in time! c->ti_old=%lld (t=%e) " "and e->ti_current=%lld (t=%e)", - c->grav.ti_old_gpart, c->grav.ti_old_gpart * e->time_base, - e->ti_current, e->ti_current * e->time_base); + c->grav.ti_old_part, c->grav.ti_old_part * e->time_base, e->ti_current, + e->ti_current * e->time_base); #endif - return (c->grav.ti_old_gpart == e->ti_current); + return (c->grav.ti_old_part == e->ti_current); } /* Are cells / particles active for regular tasks ? */ diff --git a/src/cache.h b/src/cache.h index 1a1e6210843dbe4418111f518a04cf6d764aa090..77f933cc54e7549ef55b7e7503b9797524413713 100644 --- a/src/cache.h +++ b/src/cache.h @@ -278,7 +278,7 @@ __attribute__((always_inline)) INLINE void cache_read_particles_subset( /* Pad cache with fake particles that exist outside the cell so will not * interact. We use values of the same magnitude (but negative!) as the real * particles to avoid overflow problems. */ - const double max_dx = ci->hydro.dx_max; + const double max_dx = ci->hydro.dx_max_part; const float pos_padded[3] = {-(2. * ci->width[0] + max_dx), -(2. * ci->width[1] + max_dx), -(2. * ci->width[2] + max_dx)}; @@ -326,7 +326,7 @@ __attribute__((always_inline)) INLINE void cache_read_particles_subset( /* Pad cache with fake particles that exist outside the cell so will not * interact. We use values of the same magnitude (but negative!) as the real * particles to avoid overflow problems. */ - const double max_dx = ci->hydro.dx_max; + const double max_dx = ci->hydro.dx_max_part; const float pos_padded[3] = {-(2. * ci->width[0] + max_dx), -(2. * ci->width[1] + max_dx), -(2. * ci->width[2] + max_dx)}; @@ -491,11 +491,14 @@ __attribute__((always_inline)) INLINE void cache_read_two_partial_cells_sorted( #ifdef SWIFT_DEBUG_CHECKS const float shift_threshold_x = - 2. * ci->width[0] + 2. * max(ci->hydro.dx_max, cj->hydro.dx_max); + 2. * ci->width[0] + + 2. * max(ci->hydro.dx_max_part, cj->hydro.dx_max_part); const float shift_threshold_y = - 2. * ci->width[1] + 2. * max(ci->hydro.dx_max, cj->hydro.dx_max); + 2. * ci->width[1] + + 2. * max(ci->hydro.dx_max_part, cj->hydro.dx_max_part); const float shift_threshold_z = - 2. * ci->width[2] + 2. * max(ci->hydro.dx_max, cj->hydro.dx_max); + 2. * ci->width[2] + + 2. * max(ci->hydro.dx_max_part, cj->hydro.dx_max_part); /* Make sure that particle positions have been shifted correctly. */ for (int i = 0; i < ci_cache_count; i++) { @@ -529,7 +532,7 @@ __attribute__((always_inline)) INLINE void cache_read_two_partial_cells_sorted( /* Pad cache with fake particles that exist outside the cell so will not * interact. We use values of the same magnitude (but negative!) as the real * particles to avoid overflow problems. */ - const double max_dx = max(ci->hydro.dx_max, cj->hydro.dx_max); + const double max_dx = max(ci->hydro.dx_max_part, cj->hydro.dx_max_part); const float pos_padded[3] = {-(2. * ci->width[0] + max_dx), -(2. * ci->width[1] + max_dx), -(2. * ci->width[2] + max_dx)}; @@ -723,7 +726,7 @@ cache_read_two_partial_cells_sorted_force( /* Pad cache with fake particles that exist outside the cell so will not * interact. We use values of the same magnitude (but negative!) as the real * particles to avoid overflow problems. */ - const double max_dx = max(ci->hydro.dx_max, cj->hydro.dx_max); + const double max_dx = max(ci->hydro.dx_max_part, cj->hydro.dx_max_part); const float pos_padded[3] = {-(2. * ci->width[0] + max_dx), -(2. * ci->width[1] + max_dx), -(2. * ci->width[2] + max_dx)}; diff --git a/src/cell.c b/src/cell.c index 14c2c1c0ee707383802f534a2641f865500d141d..2f5dd3db170357e8bdd90daf645d640f3bf6110f 100644 --- a/src/cell.c +++ b/src/cell.c @@ -122,7 +122,7 @@ int cell_link_parts(struct cell *c, struct part *parts) { */ int cell_link_gparts(struct cell *c, struct gpart *gparts) { - c->grav.gparts = gparts; + c->grav.parts = gparts; /* Fill the progeny recursively, depth-first. */ if (c->split) { @@ -134,7 +134,7 @@ int cell_link_gparts(struct cell *c, struct gpart *gparts) { } /* Return the total number of linked particles. */ - return c->grav.gcount; + return c->grav.count; } /** @@ -147,7 +147,7 @@ int cell_link_gparts(struct cell *c, struct gpart *gparts) { */ int cell_link_sparts(struct cell *c, struct spart *sparts) { - c->sparts = sparts; + c->stars.parts = sparts; /* Fill the progeny recursively, depth-first. */ if (c->split) { @@ -159,7 +159,7 @@ int cell_link_sparts(struct cell *c, struct spart *sparts) { } /* Return the total number of linked particles. */ - return c->scount; + return c->stars.count; } /** @@ -184,12 +184,12 @@ int cell_pack(struct cell *restrict c, struct pcell *restrict pc, pc->hydro.ti_end_max = c->hydro.ti_end_max; pc->grav.ti_end_min = c->grav.ti_end_min; pc->grav.ti_end_max = c->grav.ti_end_max; - pc->hydro.ti_old = c->hydro.ti_old; - pc->grav.ti_old_gpart = c->grav.ti_old_gpart; + pc->hydro.ti_old_part = c->hydro.ti_old_part; + pc->grav.ti_old_part = c->grav.ti_old_part; pc->grav.ti_old_multipole = c->grav.ti_old_multipole; pc->hydro.count = c->hydro.count; - pc->grav.gcount = c->grav.gcount; - pc->scount = c->scount; + pc->grav.count = c->grav.count; + pc->stars.count = c->stars.count; /* Copy the Multipole related information */ if (with_gravity) { @@ -286,12 +286,12 @@ int cell_unpack(struct pcell *restrict pc, struct cell *restrict c, c->hydro.ti_end_max = pc->hydro.ti_end_max; c->grav.ti_end_min = pc->grav.ti_end_min; c->grav.ti_end_max = pc->grav.ti_end_max; - c->hydro.ti_old = pc->hydro.ti_old; - c->grav.ti_old_gpart = pc->grav.ti_old_gpart; + c->hydro.ti_old_part = pc->hydro.ti_old_part; + c->grav.ti_old_part = pc->grav.ti_old_part; c->grav.ti_old_multipole = pc->grav.ti_old_multipole; c->hydro.count = pc->hydro.count; - c->grav.gcount = pc->grav.gcount; - c->scount = pc->scount; + c->grav.count = pc->grav.count; + c->stars.count = pc->stars.count; #ifdef SWIFT_DEBUG_CHECKS c->cellID = pc->cellID; #endif @@ -321,8 +321,8 @@ int cell_unpack(struct pcell *restrict pc, struct cell *restrict c, struct cell *temp; space_getcells(s, 1, &temp); temp->hydro.count = 0; - temp->grav.gcount = 0; - temp->scount = 0; + temp->grav.count = 0; + temp->stars.count = 0; temp->loc[0] = c->loc[0]; temp->loc[1] = c->loc[1]; temp->loc[2] = c->loc[2]; @@ -335,7 +335,7 @@ int cell_unpack(struct pcell *restrict pc, struct cell *restrict c, if (k & 1) temp->loc[2] += temp->width[2]; temp->depth = c->depth + 1; temp->split = 0; - temp->hydro.dx_max = 0.f; + temp->hydro.dx_max_part = 0.f; temp->hydro.dx_max_sort = 0.f; temp->nodeID = c->nodeID; temp->parent = c; @@ -409,7 +409,7 @@ int cell_pack_end_step(struct cell *restrict c, pcells[0].hydro.ti_end_max = c->hydro.ti_end_max; pcells[0].grav.ti_end_min = c->grav.ti_end_min; pcells[0].grav.ti_end_max = c->grav.ti_end_max; - pcells[0].hydro.dx_max = c->hydro.dx_max; + pcells[0].hydro.dx_max_part = c->hydro.dx_max_part; /* Fill in the progeny, depth-first recursion. */ int count = 1; @@ -445,7 +445,7 @@ int cell_unpack_end_step(struct cell *restrict c, c->hydro.ti_end_max = pcells[0].hydro.ti_end_max; c->grav.ti_end_min = pcells[0].grav.ti_end_min; c->grav.ti_end_max = pcells[0].grav.ti_end_max; - c->hydro.dx_max = pcells[0].hydro.dx_max; + c->hydro.dx_max_part = pcells[0].hydro.dx_max_part; /* Fill in the progeny, depth-first recursion. */ int count = 1; @@ -603,16 +603,16 @@ int cell_glocktree(struct cell *c) { TIMER_TIC /* First of all, try to lock this cell. */ - if (c->grav.ghold || lock_trylock(&c->grav.glock) != 0) { + if (c->grav.phold || lock_trylock(&c->grav.plock) != 0) { TIMER_TOC(timer_locktree); return 1; } /* Did somebody hold this cell in the meantime? */ - if (c->grav.ghold) { + if (c->grav.phold) { /* Unlock this cell. */ - if (lock_unlock(&c->grav.glock) != 0) error("Failed to unlock cell."); + if (lock_unlock(&c->grav.plock) != 0) error("Failed to unlock cell."); /* Admit defeat. */ TIMER_TOC(timer_locktree); @@ -624,13 +624,13 @@ int cell_glocktree(struct cell *c) { for (finger = c->parent; finger != NULL; finger = finger->parent) { /* Lock this cell. */ - if (lock_trylock(&finger->grav.glock) != 0) break; + if (lock_trylock(&finger->grav.plock) != 0) break; /* Increment the hold. */ - atomic_inc(&finger->grav.ghold); + atomic_inc(&finger->grav.phold); /* Unlock the cell. */ - if (lock_unlock(&finger->grav.glock) != 0) error("Failed to unlock cell."); + if (lock_unlock(&finger->grav.plock) != 0) error("Failed to unlock cell."); } /* If we reached the top of the tree, we're done. */ @@ -645,10 +645,10 @@ int cell_glocktree(struct cell *c) { /* Undo the holds up to finger. */ for (struct cell *finger2 = c->parent; finger2 != finger; finger2 = finger2->parent) - atomic_dec(&finger2->grav.ghold); + atomic_dec(&finger2->grav.phold); /* Unlock this cell. */ - if (lock_unlock(&c->grav.glock) != 0) error("Failed to unlock cell."); + if (lock_unlock(&c->grav.plock) != 0) error("Failed to unlock cell."); /* Admit defeat. */ TIMER_TOC(timer_locktree); @@ -731,16 +731,16 @@ int cell_slocktree(struct cell *c) { TIMER_TIC /* First of all, try to lock this cell. */ - if (c->shold || lock_trylock(&c->slock) != 0) { + if (c->stars.hold || lock_trylock(&c->stars.lock) != 0) { TIMER_TOC(timer_locktree); return 1; } /* Did somebody hold this cell in the meantime? */ - if (c->shold) { + if (c->stars.hold) { /* Unlock this cell. */ - if (lock_unlock(&c->slock) != 0) error("Failed to unlock cell."); + if (lock_unlock(&c->stars.lock) != 0) error("Failed to unlock cell."); /* Admit defeat. */ TIMER_TOC(timer_locktree); @@ -752,13 +752,13 @@ int cell_slocktree(struct cell *c) { for (finger = c->parent; finger != NULL; finger = finger->parent) { /* Lock this cell. */ - if (lock_trylock(&finger->slock) != 0) break; + if (lock_trylock(&finger->stars.lock) != 0) break; /* Increment the hold. */ - atomic_inc(&finger->shold); + atomic_inc(&finger->stars.hold); /* Unlock the cell. */ - if (lock_unlock(&finger->slock) != 0) error("Failed to unlock cell."); + if (lock_unlock(&finger->stars.lock) != 0) error("Failed to unlock cell."); } /* If we reached the top of the tree, we're done. */ @@ -773,10 +773,10 @@ int cell_slocktree(struct cell *c) { /* Undo the holds up to finger. */ for (struct cell *finger2 = c->parent; finger2 != finger; finger2 = finger2->parent) - atomic_dec(&finger2->shold); + atomic_dec(&finger2->stars.hold); /* Unlock this cell. */ - if (lock_unlock(&c->slock) != 0) error("Failed to unlock cell."); + if (lock_unlock(&c->stars.lock) != 0) error("Failed to unlock cell."); /* Admit defeat. */ TIMER_TOC(timer_locktree); @@ -813,11 +813,11 @@ void cell_gunlocktree(struct cell *c) { TIMER_TIC /* First of all, try to unlock this cell. */ - if (lock_unlock(&c->grav.glock) != 0) error("Failed to unlock cell."); + if (lock_unlock(&c->grav.plock) != 0) error("Failed to unlock cell."); /* Climb up the tree and unhold the parents. */ for (struct cell *finger = c->parent; finger != NULL; finger = finger->parent) - atomic_dec(&finger->grav.ghold); + atomic_dec(&finger->grav.phold); TIMER_TOC(timer_locktree); } @@ -851,11 +851,11 @@ void cell_sunlocktree(struct cell *c) { TIMER_TIC /* First of all, try to unlock this cell. */ - if (lock_unlock(&c->slock) != 0) error("Failed to unlock cell."); + if (lock_unlock(&c->stars.lock) != 0) error("Failed to unlock cell."); /* Climb up the tree and unhold the parents. */ for (struct cell *finger = c->parent; finger != NULL; finger = finger->parent) - atomic_dec(&finger->shold); + atomic_dec(&finger->stars.hold); TIMER_TOC(timer_locktree); } @@ -867,23 +867,24 @@ void cell_sunlocktree(struct cell *c) { * @param parts_offset Offset of the cell parts array relative to the * space's parts array, i.e. c->hydro.parts - s->parts. * @param sparts_offset Offset of the cell sparts array relative to the - * space's sparts array, i.e. c->sparts - s->sparts. - * @param buff A buffer with at least max(c->hydro.count, c->grav.gcount) + * space's sparts array, i.e. c->stars.parts - s->stars.parts. + * @param buff A buffer with at least max(c->hydro.count, c->grav.count) * entries, used for sorting indices. - * @param sbuff A buffer with at least max(c->scount, c->grav.gcount) entries, - * used for sorting indices for the sparts. - * @param gbuff A buffer with at least max(c->hydro.count, c->grav.gcount) + * @param sbuff A buffer with at least max(c->stars.count, c->grav.count) + * entries, used for sorting indices for the sparts. + * @param gbuff A buffer with at least max(c->hydro.count, c->grav.count) * entries, used for sorting indices for the gparts. */ void cell_split(struct cell *c, ptrdiff_t parts_offset, ptrdiff_t sparts_offset, struct cell_buff *buff, struct cell_buff *sbuff, struct cell_buff *gbuff) { - const int count = c->hydro.count, gcount = c->grav.gcount, scount = c->scount; + const int count = c->hydro.count, gcount = c->grav.count, + scount = c->stars.count; struct part *parts = c->hydro.parts; struct xpart *xparts = c->hydro.xparts; - struct gpart *gparts = c->grav.gparts; - struct spart *sparts = c->sparts; + struct gpart *gparts = c->grav.parts; + struct spart *sparts = c->stars.parts; const double pivot[3] = {c->loc[0] + c->width[0] / 2, c->loc[1] + c->width[1] / 2, c->loc[2] + c->width[2] / 2}; @@ -1075,8 +1076,8 @@ void cell_split(struct cell *c, ptrdiff_t parts_offset, ptrdiff_t sparts_offset, /* Store the counts and offsets. */ for (int k = 0; k < 8; k++) { - c->progeny[k]->scount = bucket_count[k]; - c->progeny[k]->sparts = &c->sparts[bucket_offset[k]]; + c->progeny[k]->stars.count = bucket_count[k]; + c->progeny[k]->stars.parts = &c->stars.parts[bucket_offset[k]]; } /* Finally, do the same song and dance for the gparts. */ @@ -1137,8 +1138,8 @@ void cell_split(struct cell *c, ptrdiff_t parts_offset, ptrdiff_t sparts_offset, /* Store the counts and offsets. */ for (int k = 0; k < 8; k++) { - c->progeny[k]->grav.gcount = bucket_count[k]; - c->progeny[k]->grav.gparts = &c->grav.gparts[bucket_offset[k]]; + c->progeny[k]->grav.count = bucket_count[k]; + c->progeny[k]->grav.parts = &c->grav.parts[bucket_offset[k]]; } } @@ -1226,9 +1227,9 @@ void cell_check_part_drift_point(struct cell *c, void *data) { /* Only check local cells */ if (c->nodeID != engine_rank) return; - if (c->hydro.ti_old != ti_drift) + if (c->hydro.ti_old_part != ti_drift) error("Cell in an incorrect time-zone! c->hydro.ti_old=%lld ti_drift=%lld", - c->hydro.ti_old, ti_drift); + c->hydro.ti_old_part, ti_drift); for (int i = 0; i < c->hydro.count; ++i) if (c->hydro.parts[i].ti_drift != ti_drift) @@ -1257,21 +1258,21 @@ void cell_check_gpart_drift_point(struct cell *c, void *data) { /* Only check local cells */ if (c->nodeID != engine_rank) return; - if (c->grav.ti_old_gpart != ti_drift) + if (c->grav.ti_old_part != ti_drift) error( - "Cell in an incorrect time-zone! c->grav.ti_old_gpart=%lld " + "Cell in an incorrect time-zone! c->grav.ti_old_part=%lld " "ti_drift=%lld", - c->grav.ti_old_gpart, ti_drift); + c->grav.ti_old_part, ti_drift); - for (int i = 0; i < c->grav.gcount; ++i) - if (c->grav.gparts[i].ti_drift != ti_drift) + for (int i = 0; i < c->grav.count; ++i) + if (c->grav.parts[i].ti_drift != ti_drift) error("g-part in an incorrect time-zone! gp->ti_drift=%lld ti_drift=%lld", - c->grav.gparts[i].ti_drift, ti_drift); + c->grav.parts[i].ti_drift, ti_drift); - for (int i = 0; i < c->scount; ++i) - if (c->sparts[i].ti_drift != ti_drift) + for (int i = 0; i < c->stars.count; ++i) + if (c->stars.parts[i].ti_drift != ti_drift) error("s-part in an incorrect time-zone! sp->ti_drift=%lld ti_drift=%lld", - c->sparts[i].ti_drift, ti_drift); + c->stars.parts[i].ti_drift, ti_drift); #else error("Calling debugging code without debugging flag activated."); #endif @@ -1397,8 +1398,8 @@ void cell_make_multipoles(struct cell *c, integertime_t ti_current) { } else { - if (c->grav.gcount > 0) { - gravity_P2M(c->grav.multipole, c->grav.gparts, c->grav.gcount); + if (c->grav.count > 0) { + gravity_P2M(c->grav.multipole, c->grav.parts, c->grav.count); const double dx = c->grav.multipole->CoM[0] > c->loc[0] + c->width[0] * 0.5 ? c->grav.multipole->CoM[0] - c->loc[0] @@ -1489,10 +1490,10 @@ void cell_check_multipole(struct cell *c) { for (int k = 0; k < 8; k++) if (c->progeny[k] != NULL) cell_check_multipole(c->progeny[k]); - if (c->grav.gcount > 0) { + if (c->grav.count > 0) { /* Brute-force calculation */ - gravity_P2M(&ma, c->grav.gparts, c->grav.gcount); + gravity_P2M(&ma, c->grav.parts, c->grav.count); /* Now compare the multipole expansion */ if (!gravity_multipole_equal(&ma, c->grav.multipole, tolerance)) { @@ -1599,10 +1600,10 @@ void cell_activate_drift_gpart(struct cell *c, struct scheduler *s) { if this has not yet been done. */ if (c == c->grav.super) { #ifdef SWIFT_DEBUG_CHECKS - if (c->grav.drift_gpart == NULL) - error("Trying to activate un-existing c->grav.drift_gpart"); + if (c->grav.drift == NULL) + error("Trying to activate un-existing c->grav.drift"); #endif - scheduler_activate(s, c->grav.drift_gpart); + scheduler_activate(s, c->grav.drift); } else { for (struct cell *parent = c->parent; parent != NULL && !parent->grav.do_sub_drift; @@ -1610,10 +1611,10 @@ void cell_activate_drift_gpart(struct cell *c, struct scheduler *s) { parent->grav.do_sub_drift = 1; if (parent == c->grav.super) { #ifdef SWIFT_DEBUG_CHECKS - if (parent->grav.drift_gpart == NULL) - error("Trying to activate un-existing parent->grav.drift_gpart"); + if (parent->grav.drift == NULL) + error("Trying to activate un-existing parent->grav.drift"); #endif - scheduler_activate(s, parent->grav.drift_gpart); + scheduler_activate(s, parent->grav.drift); break; } } @@ -1689,10 +1690,10 @@ void cell_activate_subcell_hydro_tasks(struct cell *ci, struct cell *cj, const struct engine *e = s->space->e; /* Store the current dx_max and h_max values. */ - ci->hydro.dx_max_old = ci->hydro.dx_max; + ci->hydro.dx_max_part_old = ci->hydro.dx_max_part; ci->hydro.h_max_old = ci->hydro.h_max; if (cj != NULL) { - cj->hydro.dx_max_old = cj->hydro.dx_max; + cj->hydro.dx_max_part_old = cj->hydro.dx_max_part; cj->hydro.h_max_old = cj->hydro.h_max; } @@ -2062,7 +2063,7 @@ void cell_activate_subcell_grav_tasks(struct cell *ci, struct cell *cj, if (cj == NULL) { /* Do anything? */ - if (ci->grav.gcount == 0 || !cell_is_active_gravity(ci, e)) return; + if (ci->grav.count == 0 || !cell_is_active_gravity(ci, e)) return; /* Recurse? */ if (ci->split) { @@ -2090,7 +2091,7 @@ void cell_activate_subcell_grav_tasks(struct cell *ci, struct cell *cj, /* Anything to do here? */ if (!cell_is_active_gravity(ci, e) && !cell_is_active_gravity(cj, e)) return; - if (ci->grav.gcount == 0 || cj->grav.gcount == 0) return; + if (ci->grav.count == 0 || cj->grav.count == 0) return; /* Atomically drift the multipole in ci */ lock_lock(&ci->grav.mlock); @@ -2279,12 +2280,12 @@ int cell_unskip_hydro_tasks(struct cell *c, struct scheduler *s) { /* If the local cell is active, receive data from the foreign cell. */ if (cj_active) { - scheduler_activate(s, ci->hydro.recv_xv); + scheduler_activate(s, ci->mpi.hydro.recv_xv); if (ci_active) { - scheduler_activate(s, ci->hydro.recv_rho); + scheduler_activate(s, ci->mpi.hydro.recv_rho); #ifdef EXTRA_HYDRO_LOOP - scheduler_activate(s, ci->hydro.recv_gradient); + scheduler_activate(s, ci->mpi.hydro.recv_gradient); #endif } } @@ -2295,7 +2296,7 @@ int cell_unskip_hydro_tasks(struct cell *c, struct scheduler *s) { /* Is the foreign cell active and will need stuff from us? */ if (ci_active) { - scheduler_activate_send(s, cj->hydro.send_xv, ci_nodeID); + scheduler_activate_send(s, cj->mpi.hydro.send_xv, ci_nodeID); /* Drift the cell which will be sent; note that not all sent particles will be drifted, only those that are needed. */ @@ -2303,10 +2304,10 @@ int cell_unskip_hydro_tasks(struct cell *c, struct scheduler *s) { /* If the local cell is also active, more stuff will be needed. */ if (cj_active) { - scheduler_activate_send(s, cj->hydro.send_rho, ci_nodeID); + scheduler_activate_send(s, cj->mpi.hydro.send_rho, ci_nodeID); #ifdef EXTRA_HYDRO_LOOP - scheduler_activate_send(s, cj->hydro.send_gradient, ci_nodeID); + scheduler_activate_send(s, cj->mpi.hydro.send_gradient, ci_nodeID); #endif } } @@ -2318,12 +2319,12 @@ int cell_unskip_hydro_tasks(struct cell *c, struct scheduler *s) { /* If the local cell is active, receive data from the foreign cell. */ if (ci_active) { - scheduler_activate(s, cj->hydro.recv_xv); + scheduler_activate(s, cj->mpi.hydro.recv_xv); if (cj_active) { - scheduler_activate(s, cj->hydro.recv_rho); + scheduler_activate(s, cj->mpi.hydro.recv_rho); #ifdef EXTRA_HYDRO_LOOP - scheduler_activate(s, cj->hydro.recv_gradient); + scheduler_activate(s, cj->mpi.hydro.recv_gradient); #endif } } @@ -2334,7 +2335,7 @@ int cell_unskip_hydro_tasks(struct cell *c, struct scheduler *s) { /* Is the foreign cell active and will need stuff from us? */ if (cj_active) { - scheduler_activate_send(s, ci->hydro.send_xv, cj_nodeID); + scheduler_activate_send(s, ci->mpi.hydro.send_xv, cj_nodeID); /* Drift the cell which will be sent; note that not all sent particles will be drifted, only those that are needed. */ @@ -2343,10 +2344,10 @@ int cell_unskip_hydro_tasks(struct cell *c, struct scheduler *s) { /* If the local cell is also active, more stuff will be needed. */ if (ci_active) { - scheduler_activate_send(s, ci->hydro.send_rho, cj_nodeID); + scheduler_activate_send(s, ci->mpi.hydro.send_rho, cj_nodeID); #ifdef EXTRA_HYDRO_LOOP - scheduler_activate_send(s, ci->hydro.send_gradient, cj_nodeID); + scheduler_activate_send(s, ci->mpi.hydro.send_gradient, cj_nodeID); #endif } } @@ -2440,7 +2441,7 @@ int cell_unskip_gravity_tasks(struct cell *c, struct scheduler *s) { if (ci_nodeID != nodeID) { /* If the local cell is active, receive data from the foreign cell. */ - if (cj_active) scheduler_activate(s, ci->grav.recv); + if (cj_active) scheduler_activate(s, ci->mpi.grav.recv); /* If the foreign cell is active, we want its ti_end values. */ if (ci_active) scheduler_activate(s, ci->mpi.recv_ti); @@ -2448,7 +2449,7 @@ int cell_unskip_gravity_tasks(struct cell *c, struct scheduler *s) { /* Is the foreign cell active and will need stuff from us? */ if (ci_active) { - scheduler_activate_send(s, cj->grav.send, ci_nodeID); + scheduler_activate_send(s, cj->mpi.grav.send, ci_nodeID); /* Drift the cell which will be sent at the level at which it is sent, i.e. drift the cell specified in the send task (l->t) @@ -2462,7 +2463,7 @@ int cell_unskip_gravity_tasks(struct cell *c, struct scheduler *s) { } else if (cj_nodeID != nodeID) { /* If the local cell is active, receive data from the foreign cell. */ - if (ci_active) scheduler_activate(s, cj->grav.recv); + if (ci_active) scheduler_activate(s, cj->mpi.grav.recv); /* If the foreign cell is active, we want its ti_end values. */ if (cj_active) scheduler_activate(s, cj->mpi.recv_ti); @@ -2470,7 +2471,7 @@ int cell_unskip_gravity_tasks(struct cell *c, struct scheduler *s) { /* Is the foreign cell active and will need stuff from us? */ if (cj_active) { - scheduler_activate_send(s, ci->grav.send, cj_nodeID); + scheduler_activate_send(s, ci->mpi.grav.send, cj_nodeID); /* Drift the cell which will be sent at the level at which it is sent, i.e. drift the cell specified in the send task (l->t) @@ -2547,7 +2548,7 @@ int cell_unskip_stars_tasks(struct cell *c, struct scheduler *s) { int rebuild = 0; /* Un-skip the density tasks involved with this cell. */ - for (struct link *l = c->stars_density; l != NULL; l = l->next) { + for (struct link *l = c->stars.density; l != NULL; l = l->next) { struct task *t = l->t; struct cell *ci = t->ci; struct cell *cj = t->cj; @@ -2679,9 +2680,9 @@ int cell_unskip_stars_tasks(struct cell *c, struct scheduler *s) { /* Unskip all the other task types. */ if (c->nodeID == nodeID && cell_is_active_stars(c, e)) { - if (c->stars_ghost_in != NULL) scheduler_activate(s, c->stars_ghost_in); - if (c->stars_ghost_out != NULL) scheduler_activate(s, c->stars_ghost_out); - if (c->stars_ghost != NULL) scheduler_activate(s, c->stars_ghost); + if (c->stars.ghost_in != NULL) scheduler_activate(s, c->stars.ghost_in); + if (c->stars.ghost_out != NULL) scheduler_activate(s, c->stars.ghost_out); + if (c->stars.ghost != NULL) scheduler_activate(s, c->stars.ghost); } return rebuild; @@ -2820,7 +2821,7 @@ int cell_has_tasks(struct cell *c) { void cell_drift_part(struct cell *c, const struct engine *e, int force) { const float hydro_h_max = e->hydro_properties->h_max; - const integertime_t ti_old_part = c->hydro.ti_old; + const integertime_t ti_old_part = c->hydro.ti_old_part; const integertime_t ti_current = e->ti_current; struct part *const parts = c->hydro.parts; struct xpart *const xparts = c->hydro.xparts; @@ -2852,7 +2853,7 @@ void cell_drift_part(struct cell *c, const struct engine *e, int force) { cell_drift_part(cp, e, force); /* Update */ - dx_max = max(dx_max, cp->hydro.dx_max); + dx_max = max(dx_max, cp->hydro.dx_max_part); dx_max_sort = max(dx_max_sort, cp->hydro.dx_max_sort); cell_h_max = max(cell_h_max, cp->hydro.h_max); } @@ -2860,11 +2861,11 @@ void cell_drift_part(struct cell *c, const struct engine *e, int force) { /* Store the values */ c->hydro.h_max = cell_h_max; - c->hydro.dx_max = dx_max; + c->hydro.dx_max_part = dx_max; c->hydro.dx_max_sort = dx_max_sort; /* Update the time of the last drift */ - c->hydro.ti_old = ti_current; + c->hydro.ti_old_part = ti_current; } else if (!c->split && force && ti_current > ti_old_part) { @@ -2966,11 +2967,11 @@ void cell_drift_part(struct cell *c, const struct engine *e, int force) { /* Store the values */ c->hydro.h_max = cell_h_max; - c->hydro.dx_max = dx_max; + c->hydro.dx_max_part = dx_max; c->hydro.dx_max_sort = dx_max_sort; /* Update the time of the last drift */ - c->hydro.ti_old = ti_current; + c->hydro.ti_old_part = ti_current; } /* Clear the drift flags. */ @@ -2987,10 +2988,10 @@ void cell_drift_part(struct cell *c, const struct engine *e, int force) { */ void cell_drift_gpart(struct cell *c, const struct engine *e, int force) { - const integertime_t ti_old_gpart = c->grav.ti_old_gpart; + const integertime_t ti_old_gpart = c->grav.ti_old_part; const integertime_t ti_current = e->ti_current; - struct gpart *const gparts = c->grav.gparts; - struct spart *const sparts = c->sparts; + struct gpart *const gparts = c->grav.parts; + struct spart *const sparts = c->stars.parts; /* Drift irrespective of cell flags? */ force |= c->grav.do_drift; @@ -3017,7 +3018,7 @@ void cell_drift_gpart(struct cell *c, const struct engine *e, int force) { } /* Update the time of the last drift */ - c->grav.ti_old_gpart = ti_current; + c->grav.ti_old_part = ti_current; } else if (!c->split && force && ti_current > ti_old_gpart) { @@ -3030,7 +3031,7 @@ void cell_drift_gpart(struct cell *c, const struct engine *e, int force) { dt_drift = (ti_current - ti_old_gpart) * e->time_base; /* Loop over all the g-particles in the cell */ - const size_t nr_gparts = c->grav.gcount; + const size_t nr_gparts = c->grav.count; for (size_t k = 0; k < nr_gparts; k++) { /* Get a handle on the gpart. */ @@ -3075,7 +3076,7 @@ void cell_drift_gpart(struct cell *c, const struct engine *e, int force) { } /* Loop over all the star particles in the cell */ - const size_t nr_sparts = c->scount; + const size_t nr_sparts = c->stars.count; for (size_t k = 0; k < nr_sparts; k++) { /* Get a handle on the spart. */ @@ -3097,7 +3098,7 @@ void cell_drift_gpart(struct cell *c, const struct engine *e, int force) { } /* Update the time of the last drift */ - c->grav.ti_old_gpart = ti_current; + c->grav.ti_old_part = ti_current; } /* Clear the drift flags. */ diff --git a/src/cell.h b/src/cell.h index 8567d6d071dff7a55ae7b284989444f1127f126e..852a6e97936cf5b8755fe21e6d9e7bb899ae5312 100644 --- a/src/cell.h +++ b/src/cell.h @@ -93,7 +93,7 @@ struct pcell { integertime_t ti_beg_max; /*! Integer time of the last drift of the #part in this cell */ - integertime_t ti_old; + integertime_t ti_old_part; /*! Number of #part in this cell. */ int count; @@ -128,22 +128,27 @@ struct pcell { integertime_t ti_beg_max; /*! Integer time of the last drift of the #gpart in this cell */ - integertime_t ti_old_gpart; + integertime_t ti_old_part; /*! Integer time of the last drift of the #multipole in this cell */ integertime_t ti_old_multipole; /*! Number of #gpart in this cell. */ - int gcount; + int count; } grav; + /*! Stars variables */ + struct { + + /*! Number of #spart in this cell. */ + int count; + + } stars; + /*! Relative indices of the cell's progeny. */ int progeny[8]; - /*! Number of #spart in this cell. */ - int scount; - #ifdef SWIFT_DEBUG_CHECKS /* Cell ID (for debugging) */ int cellID; @@ -166,7 +171,7 @@ struct pcell_step { integertime_t ti_end_max; /*! Maximal distance any #part has travelled since last rebuild */ - float dx_max; + float dx_max_part; } hydro; @@ -178,7 +183,12 @@ struct pcell_step { /*! Minimal integer end-of-timestep in this cell (gravity) */ integertime_t ti_end_max; + } grav; + + /*! Stars variables */ + struct { + } stars; }; /** @@ -197,9 +207,6 @@ struct cell { /*! Linking pointer for "memory management". */ struct cell *next; - /*! Pointer to the #spart data. */ - struct spart *sparts; - /*! Pointers to the next level of cells. */ struct cell *progeny[8]; @@ -226,10 +233,10 @@ struct cell { struct cell *super; /*! Last (integer) time the cell's part were drifted forward in time. */ - integertime_t ti_old; + integertime_t ti_old_part; /*! Maximum part movement in this cell since last construction. */ - float dx_max; + float dx_max_part; /*! Maximum particle movement in this cell since the last sort. */ float dx_max_sort; @@ -259,12 +266,12 @@ struct cell { /*! Is the #part data of this cell being used in a sub-cell? */ int hold; - /*! Values of dx_max before the drifts, used for sub-cell tasks. */ - float dx_max_old; - /*! Values of h_max before the drifts, used for sub-cell tasks. */ float h_max_old; + /*! Values of dx_max before the drifts, used for sub-cell tasks. */ + float dx_max_part_old; + /*! Values of dx_max_sort before the drifts, used for sub-cell tasks. */ float dx_max_sort_old; @@ -319,27 +326,6 @@ struct cell { /*! Task for cooling */ struct task *cooling; -#ifdef WITH_MPI - /* Task receiving hydro data (positions). */ - struct task *recv_xv; - - /* Task receiving hydro data (density). */ - struct task *recv_rho; - - /* Task receiving hydro data (gradient). */ - struct task *recv_gradient; - - /* Linked list for sending hydro data (positions). */ - struct link *send_xv; - - /* Linked list for sending hydro data (density). */ - struct link *send_rho; - - /* Linked list for sending hydro data (gradient). */ - struct link *send_gradient; - -#endif - #ifdef SWIFT_DEBUG_CHECKS /*! Last (integer) time the cell's sort arrays were updated. */ @@ -353,7 +339,7 @@ struct cell { struct { /*! Pointer to the #gpart data. */ - struct gpart *gparts; + struct gpart *parts; /*! This cell's multipole. */ struct gravity_tensors *multipole; @@ -373,25 +359,25 @@ struct cell { integertime_t ti_beg_max; /*! Last (integer) time the cell's gpart were drifted forward in time. */ - integertime_t ti_old_gpart; + integertime_t ti_old_part; /*! Last (integer) time the cell's multipole was drifted forward in time. */ integertime_t ti_old_multipole; /*! Nr of #gpart in this cell. */ - int gcount; + int count; /*! Spin lock for various uses (#gpart case). */ - swift_lock_type glock; + swift_lock_type plock; /*! Spin lock for various uses (#multipole case). */ swift_lock_type mlock; /*! Number of #gpart updated in this cell. */ - int g_updated; + int updated; /*! Is the #gpart data of this cell being used in a sub-cell? */ - int ghold; + int phold; /*! Is the #multipole data of this cell being used in a sub-cell? */ int mhold; @@ -403,7 +389,7 @@ struct cell { char do_sub_drift; /*! The drift task for gparts */ - struct task *drift_gpart; + struct task *drift; /*! Linked list of the tasks computing this cell's gravity forces. */ struct link *grav; @@ -432,45 +418,74 @@ struct cell { /*! Number of M-M tasks that are associated with this cell. */ short int nr_mm_tasks; -#ifdef WITH_MPI - - /* Task receiving gpart data. */ - struct task *recv; + } grav; - /* Linked list for sending gpart data. */ - struct link *send; + /*! Stars variables */ + struct { -#endif + /*! Pointer to the #spart data. */ + struct spart *parts; - } grav; + /*! Nr of #spart in this cell. */ + int count; - /*! The first kick task */ - struct task *kick1; + /*! Dependency implicit task for the star ghost (in->ghost->out)*/ + struct task *ghost_in; - /*! The second kick task */ - struct task *kick2; + /*! Dependency implicit task for the star ghost (in->ghost->out)*/ + struct task *ghost_out; - /*! The task to compute time-steps */ - struct task *timestep; + /*! The star ghost task itself */ + struct task *ghost; - /*! Dependency implicit task for the star ghost (in->ghost->out)*/ - struct task *stars_ghost_in; + /*! Linked list of the tasks computing this cell's star density. */ + struct link *density; - /*! Dependency implicit task for the star ghost (in->ghost->out)*/ - struct task *stars_ghost_out; + /*! Number of #spart updated in this cell. */ + int updated; - /*! The star ghost task itself */ - struct task *stars_ghost; + /*! Is the #spart data of this cell being used in a sub-cell? */ + int hold; - /*! Linked list of the tasks computing this cell's star density. */ - struct link *stars_density; + /*! Spin lock for various uses (#spart case). */ + swift_lock_type lock; - /*! Task for source terms */ - struct task *sourceterms; + } stars; #ifdef WITH_MPI /*! MPI variables */ struct { + + struct { + /* Task receiving hydro data (positions). */ + struct task *recv_xv; + + /* Task receiving hydro data (density). */ + struct task *recv_rho; + + /* Task receiving hydro data (gradient). */ + struct task *recv_gradient; + + /* Linked list for sending hydro data (positions). */ + struct link *send_xv; + + /* Linked list for sending hydro data (density). */ + struct link *send_rho; + + /* Linked list for sending hydro data (gradient). */ + struct link *send_gradient; + + } hydro; + + struct { + + /* Task receiving gpart data. */ + struct task *recv; + + /* Linked list for sending gpart data. */ + struct link *send; + } grav; + /* Task receiving data (time-step). */ struct task *recv_ti; @@ -492,27 +507,27 @@ struct cell { } mpi; #endif - /*! Minimum dimension, i.e. smallest edge of this cell (min(width)). */ - float dmin; + /*! The first kick task */ + struct task *kick1; - /*! Nr of #spart in this cell. */ - int scount; + /*! The second kick task */ + struct task *kick2; - /*! Spin lock for various uses (#spart case). */ - swift_lock_type slock; + /*! The task to compute time-steps */ + struct task *timestep; + + /*! Task for source terms */ + struct task *sourceterms; + + /*! Minimum dimension, i.e. smallest edge of this cell (min(width)). */ + float dmin; /*! ID of the previous owner, e.g. runner. */ int owner; - /*! Number of #spart updated in this cell. */ - int s_updated; - /*! ID of the node this cell lives on. */ int nodeID; - /*! Is the #spart data of this cell being used in a sub-cell? */ - int shold; - /*! Number of tasks that are associated with this cell. */ short int nr_tasks; @@ -622,7 +637,7 @@ cell_can_recurse_in_pair_hydro_task(const struct cell *c) { /* smaller than the sub-cell sizes ? */ /* Note: We use the _old values as these might have been updated by a drift */ return c->split && ((kernel_gamma * c->hydro.h_max_old + - c->hydro.dx_max_old) < 0.5f * c->dmin); + c->hydro.dx_max_part_old) < 0.5f * c->dmin); } /** @@ -766,7 +781,7 @@ __attribute__((always_inline)) INLINE static int cell_need_rebuild_for_pair( /* moved larger than the cell size ? */ /* Note ci->dmin == cj->dmin */ return (kernel_gamma * max(ci->hydro.h_max, cj->hydro.h_max) + - ci->hydro.dx_max + cj->hydro.dx_max > + ci->hydro.dx_max_part + cj->hydro.dx_max_part > cj->dmin); } diff --git a/src/debug.c b/src/debug.c index 8c4a633eabf65e7c084d90ff0f6ffb9011812079..a980ef9457a31d4b36f99926a24d7bc55822670a 100644 --- a/src/debug.c +++ b/src/debug.c @@ -274,8 +274,8 @@ int checkCellhdxmax(const struct cell *c, int *depth) { message("location: %f %f %f", c->loc[0], c->loc[1], c->loc[2]); result = 0; } - if (c->hydro.dx_max != dx_max) { - message("%d Inconsistent dx_max: %f != %f", *depth, c->hydro.dx_max, + if (c->hydro.dx_max_part != dx_max) { + message("%d Inconsistent dx_max: %f != %f", *depth, c->hydro.dx_max_part, dx_max); message("location: %f %f %f", c->loc[0], c->loc[1], c->loc[2]); result = 0; @@ -317,13 +317,13 @@ static void dumpCells_map(struct cell *c, void *data) { #endif /* Only cells with particles are dumped. */ - if (c->hydro.count > 0 || c->grav.gcount > 0 || c->scount > 0) { + if (c->hydro.count > 0 || c->grav.count > 0 || c->stars.count > 0) { /* In MPI mode we may only output cells with foreign partners. * These define the edges of the partitions. */ int ismpiactive = 0; #if WITH_MPI - ismpiactive = (c->hydro.send_xv != NULL); + ismpiactive = (c->mpi.hydro.send_xv != NULL); if (mpiactive) mpiactive = ismpiactive; else @@ -351,11 +351,11 @@ static void dumpCells_map(struct cell *c, void *data) { const struct part *parts = c->hydro.parts; for (int k = 0; k < c->hydro.count; k++) if (part_is_active(&parts[k], e)) pactcount++; - struct gpart *gparts = c->grav.gparts; - for (int k = 0; k < c->grav.gcount; k++) + struct gpart *gparts = c->grav.parts; + for (int k = 0; k < c->grav.count; k++) if (gpart_is_active(&gparts[k], e)) pactcount++; - struct spart *sparts = c->sparts; - for (int k = 0; k < c->scount; k++) + struct spart *sparts = c->stars.parts; + for (int k = 0; k < c->stars.count; k++) if (spart_is_active(&sparts[k], e)) pactcount++; } @@ -363,8 +363,8 @@ static void dumpCells_map(struct cell *c, void *data) { " %6.3f %6.3f %6.3f %6.3f %6.3f %6.3f %6d %6d %6d %6d %6d %6d " "%6.1f %20lld %6d %6d %6d %6d %6d %6d %6d\n", c->loc[0], c->loc[1], c->loc[2], c->width[0], c->width[1], - c->width[2], e->step, c->hydro.count, c->grav.gcount, c->scount, - pactcount, c->depth, ntasks, c->hydro.ti_end_min, + c->width[2], e->step, c->hydro.count, c->grav.count, + c->stars.count, pactcount, c->depth, ntasks, c->hydro.ti_end_min, get_time_bin(c->hydro.ti_end_min), (c->super == c), (c->parent == NULL), cell_is_active_hydro(c, e), c->nodeID, c->nodeID == e->nodeID, ismpiactive); diff --git a/src/engine.c b/src/engine.c index 0ec042b2d7b2531b5df100b047a6aa5077f1355d..8e6d8fa20590ca3b5480c073919f31087d80e0ee 100644 --- a/src/engine.c +++ b/src/engine.c @@ -158,14 +158,14 @@ void engine_add_stars_ghosts(struct engine *e, struct cell *c, struct task *stars_ghost_out) { /* If we have reached the leaf OR have to few particles to play with*/ - if (!c->split || c->scount < engine_max_sparts_per_ghost) { + if (!c->split || c->stars.count < engine_max_sparts_per_ghost) { /* Add the ghost task and its dependencies */ struct scheduler *s = &e->sched; - c->stars_ghost = scheduler_addtask(s, task_type_stars_ghost, + c->stars.ghost = scheduler_addtask(s, task_type_stars_ghost, task_subtype_none, 0, 0, c, NULL); - scheduler_addunlock(s, stars_ghost_in, c->stars_ghost); - scheduler_addunlock(s, c->stars_ghost, stars_ghost_out); + scheduler_addunlock(s, stars_ghost_in, c->stars.ghost); + scheduler_addunlock(s, c->stars.ghost, stars_ghost_out); } else { /* Keep recursing */ for (int k = 0; k < 8; k++) @@ -348,8 +348,8 @@ void engine_make_hierarchical_tasks_gravity(struct engine *e, struct cell *c) { /* Local tasks only... */ if (c->nodeID == e->nodeID) { - c->grav.drift_gpart = scheduler_addtask(s, task_type_drift_gpart, - task_subtype_none, 0, 0, c, NULL); + c->grav.drift = scheduler_addtask(s, task_type_drift_gpart, + task_subtype_none, 0, 0, c, NULL); if (is_self_gravity) { @@ -376,7 +376,7 @@ void engine_make_hierarchical_tasks_gravity(struct engine *e, struct cell *c) { c->grav.mesh = scheduler_addtask(s, task_type_grav_mesh, task_subtype_none, 0, 0, c, NULL); - if (periodic) scheduler_addunlock(s, c->grav.drift_gpart, c->grav.mesh); + if (periodic) scheduler_addunlock(s, c->grav.drift, c->grav.mesh); if (periodic) scheduler_addunlock(s, c->grav.mesh, c->grav.down); scheduler_addunlock(s, c->grav.init, c->grav.long_range); scheduler_addunlock(s, c->grav.long_range, c->grav.down); @@ -439,13 +439,13 @@ void engine_make_hierarchical_tasks_stars(struct engine *e, struct cell *c) { if (c->nodeID == e->nodeID) { /* Generate the ghost tasks. */ - c->stars_ghost_in = + c->stars.ghost_in = scheduler_addtask(s, task_type_stars_ghost_in, task_subtype_none, 0, /* implicit = */ 1, c, NULL); - c->stars_ghost_out = + c->stars.ghost_out = scheduler_addtask(s, task_type_stars_ghost_out, task_subtype_none, 0, /* implicit = */ 1, c, NULL); - engine_add_stars_ghosts(e, c, c->stars_ghost_in, c->stars_ghost_out); + engine_add_stars_ghosts(e, c, c->stars.ghost_in, c->stars.ghost_out); } } else { /* We are above the super-cell so need to go deeper */ @@ -1439,10 +1439,10 @@ void engine_addtasks_send_hydro(struct engine *e, struct cell *ci, } /* Add them to the local cell. */ - engine_addlink(e, &ci->hydro.send_xv, t_xv); - engine_addlink(e, &ci->hydro.send_rho, t_rho); + engine_addlink(e, &ci->mpi.hydro.send_xv, t_xv); + engine_addlink(e, &ci->mpi.hydro.send_rho, t_rho); #ifdef EXTRA_HYDRO_LOOP - engine_addlink(e, &ci->hydro.send_gradient, t_gradient); + engine_addlink(e, &ci->mpi.hydro.send_gradient, t_gradient); #endif } @@ -1496,11 +1496,11 @@ void engine_addtasks_send_gravity(struct engine *e, struct cell *ci, scheduler_addunlock(s, t_grav, ci->grav.super->grav.down); /* Drift before you send */ - scheduler_addunlock(s, ci->grav.super->grav.drift_gpart, t_grav); + scheduler_addunlock(s, ci->grav.super->grav.drift, t_grav); } /* Add them to the local cell. */ - engine_addlink(e, &ci->grav.send, t_grav); + engine_addlink(e, &ci->mpi.grav.send, t_grav); } /* Recurse? */ @@ -1609,9 +1609,9 @@ void engine_addtasks_recv_hydro(struct engine *e, struct cell *c, #endif } - c->hydro.recv_xv = t_xv; - c->hydro.recv_rho = t_rho; - c->hydro.recv_gradient = t_gradient; + c->mpi.hydro.recv_xv = t_xv; + c->mpi.hydro.recv_rho = t_rho; + c->mpi.hydro.recv_gradient = t_gradient; /* Add dependencies. */ if (c->hydro.sorts != NULL) scheduler_addunlock(s, t_xv, c->hydro.sorts); @@ -1669,7 +1669,7 @@ void engine_addtasks_recv_gravity(struct engine *e, struct cell *c, c->mpi.tag, 0, c, NULL); } - c->grav.recv = t_grav; + c->mpi.grav.recv = t_grav; for (struct link *l = c->grav.grav; l != NULL; l = l->next) scheduler_addunlock(s, t_grav, l->t); @@ -1756,8 +1756,8 @@ void engine_exchange_cells(struct engine *e) { if (e->proxies[k].cells_in_type[j] & proxy_cell_type_hydro) count_parts_in += e->proxies[k].cells_in[j]->hydro.count; if (e->proxies[k].cells_in_type[j] & proxy_cell_type_gravity) - count_gparts_in += e->proxies[k].cells_in[j]->grav.gcount; - count_sparts_in += e->proxies[k].cells_in[j]->scount; + count_gparts_in += e->proxies[k].cells_in[j]->grav.count; + count_sparts_in += e->proxies[k].cells_in[j]->stars.count; } if (count_parts_in > s->size_parts_foreign) { if (s->parts_foreign != NULL) free(s->parts_foreign); @@ -1801,11 +1801,11 @@ void engine_exchange_cells(struct engine *e) { if (e->proxies[k].cells_in_type[j] & proxy_cell_type_gravity) { cell_link_gparts(e->proxies[k].cells_in[j], gparts); - gparts = &gparts[e->proxies[k].cells_in[j]->grav.gcount]; + gparts = &gparts[e->proxies[k].cells_in[j]->grav.count]; } cell_link_sparts(e->proxies[k].cells_in[j], sparts); - sparts = &sparts[e->proxies[k].cells_in[j]->scount]; + sparts = &sparts[e->proxies[k].cells_in[j]->stars.count]; } } s->nr_parts_foreign = parts - s->parts_foreign; @@ -2440,7 +2440,7 @@ void engine_make_self_gravity_tasks_mapper(void *map_data, int num_elements, struct cell *ci = &cells[cid]; /* Skip cells without gravity particles */ - if (ci->grav.gcount == 0) continue; + if (ci->grav.count == 0) continue; /* Is that cell local ? */ if (ci->nodeID != nodeID) continue; @@ -2503,7 +2503,7 @@ void engine_make_self_gravity_tasks_mapper(void *map_data, int num_elements, if (cid <= cjd && cj->nodeID == nodeID) continue; /* Skip cells without gravity particles */ - if (cj->grav.gcount == 0) continue; + if (cj->grav.count == 0) continue; /* Recover the multipole information */ const struct gravity_tensors *const multi_j = cj->grav.multipole; @@ -2579,7 +2579,7 @@ void engine_make_external_gravity_tasks(struct engine *e) { struct cell *ci = &cells[cid]; /* Skip cells without gravity particles */ - if (ci->grav.gcount == 0) continue; + if (ci->grav.count == 0) continue; /* Is that neighbour local ? */ if (ci->nodeID != nodeID) continue; @@ -2706,7 +2706,7 @@ void engine_make_starsloop_tasks_mapper(void *map_data, int num_elements, struct cell *ci = &cells[cid]; /* Skip cells without star particles */ - if (ci->scount == 0) continue; + if (ci->stars.count == 0) continue; /* If the cells is local build a self-interaction */ if (ci->nodeID == nodeID) @@ -2786,7 +2786,7 @@ void engine_count_and_link_tasks_mapper(void *map_data, int num_elements, } else if (t_subtype == task_subtype_external_grav) { engine_addlink(e, &ci->grav.grav, t); } else if (t->subtype == task_subtype_stars_density) { - engine_addlink(e, &ci->stars_density, t); + engine_addlink(e, &ci->stars.density, t); } /* Link pair tasks to cells. */ @@ -2801,8 +2801,8 @@ void engine_count_and_link_tasks_mapper(void *map_data, int num_elements, engine_addlink(e, &ci->grav.grav, t); engine_addlink(e, &cj->grav.grav, t); } else if (t->subtype == task_subtype_stars_density) { - engine_addlink(e, &ci->stars_density, t); - engine_addlink(e, &cj->stars_density, t); + engine_addlink(e, &ci->stars.density, t); + engine_addlink(e, &cj->stars.density, t); } #ifdef SWIFT_DEBUG_CHECKS else if (t_subtype == task_subtype_external_grav) { @@ -2821,7 +2821,7 @@ void engine_count_and_link_tasks_mapper(void *map_data, int num_elements, } else if (t_subtype == task_subtype_external_grav) { engine_addlink(e, &ci->grav.grav, t); } else if (t->subtype == task_subtype_stars_density) { - engine_addlink(e, &ci->stars_density, t); + engine_addlink(e, &ci->stars.density, t); } /* Link sub-pair tasks to cells. */ @@ -2836,8 +2836,8 @@ void engine_count_and_link_tasks_mapper(void *map_data, int num_elements, engine_addlink(e, &ci->grav.grav, t); engine_addlink(e, &cj->grav.grav, t); } else if (t->subtype == task_subtype_stars_density) { - engine_addlink(e, &ci->stars_density, t); - engine_addlink(e, &cj->stars_density, t); + engine_addlink(e, &ci->stars.density, t); + engine_addlink(e, &cj->stars.density, t); } #ifdef SWIFT_DEBUG_CHECKS else if (t_subtype == task_subtype_external_grav) { @@ -2902,7 +2902,7 @@ void engine_link_gravity_tasks(struct engine *e) { /* drift ---+-> gravity --> grav_down */ /* init --/ */ - scheduler_addunlock(sched, ci->grav.super->grav.drift_gpart, t); + scheduler_addunlock(sched, ci->grav.super->grav.drift, t); scheduler_addunlock(sched, ci_parent->grav.init_out, t); scheduler_addunlock(sched, t, ci_parent->grav.down_in); } @@ -2915,7 +2915,7 @@ void engine_link_gravity_tasks(struct engine *e) { #endif /* drift -----> gravity --> end_force */ - scheduler_addunlock(sched, ci->grav.super->grav.drift_gpart, t); + scheduler_addunlock(sched, ci->grav.super->grav.drift, t); scheduler_addunlock(sched, t, ci->super->hydro.end_force); } @@ -2926,7 +2926,7 @@ void engine_link_gravity_tasks(struct engine *e) { /* drift ---+-> gravity --> grav_down */ /* init --/ */ - scheduler_addunlock(sched, ci->grav.super->grav.drift_gpart, t); + scheduler_addunlock(sched, ci->grav.super->grav.drift, t); scheduler_addunlock(sched, ci_parent->grav.init_out, t); scheduler_addunlock(sched, t, ci_parent->grav.down_in); } @@ -2935,7 +2935,7 @@ void engine_link_gravity_tasks(struct engine *e) { /* drift ---+-> gravity --> grav_down */ /* init --/ */ if (ci->grav.super != cj->grav.super) /* Avoid double unlock */ - scheduler_addunlock(sched, cj->grav.super->grav.drift_gpart, t); + scheduler_addunlock(sched, cj->grav.super->grav.drift, t); if (ci_parent != cj_parent) { /* Avoid double unlock */ scheduler_addunlock(sched, cj_parent->grav.init_out, t); @@ -2952,7 +2952,7 @@ void engine_link_gravity_tasks(struct engine *e) { #endif /* drift ---+-> gravity --> grav_down */ /* init --/ */ - scheduler_addunlock(sched, ci->grav.super->grav.drift_gpart, t); + scheduler_addunlock(sched, ci->grav.super->grav.drift, t); scheduler_addunlock(sched, ci_parent->grav.init_out, t); scheduler_addunlock(sched, t, ci_parent->grav.down_in); } @@ -2966,7 +2966,7 @@ void engine_link_gravity_tasks(struct engine *e) { #endif /* drift -----> gravity --> end_force */ - scheduler_addunlock(sched, ci->grav.super->grav.drift_gpart, t); + scheduler_addunlock(sched, ci->grav.super->grav.drift, t); scheduler_addunlock(sched, t, ci->super->hydro.end_force); } @@ -2977,7 +2977,7 @@ void engine_link_gravity_tasks(struct engine *e) { /* drift ---+-> gravity --> grav_down */ /* init --/ */ - scheduler_addunlock(sched, ci->grav.super->grav.drift_gpart, t); + scheduler_addunlock(sched, ci->grav.super->grav.drift, t); scheduler_addunlock(sched, ci_parent->grav.init_out, t); scheduler_addunlock(sched, t, ci_parent->grav.down_in); } @@ -2986,7 +2986,7 @@ void engine_link_gravity_tasks(struct engine *e) { /* drift ---+-> gravity --> grav_down */ /* init --/ */ if (ci->grav.super != cj->grav.super) /* Avoid double unlock */ - scheduler_addunlock(sched, cj->grav.super->grav.drift_gpart, t); + scheduler_addunlock(sched, cj->grav.super->grav.drift, t); if (ci_parent != cj_parent) { /* Avoid double unlock */ scheduler_addunlock(sched, cj_parent->grav.init_out, t); @@ -3073,7 +3073,7 @@ static inline void engine_make_stars_loops_dependencies(struct scheduler *sched, struct task *density, struct cell *c) { /* density loop --> ghost */ - scheduler_addunlock(sched, density, c->super->stars_ghost_in); + scheduler_addunlock(sched, density, c->super->stars.ghost_in); } /** @@ -3354,11 +3354,11 @@ void engine_link_stars_tasks_mapper(void *map_data, int num_elements, /* Make the self-density tasks depend on the drifts. */ scheduler_addunlock(sched, t->ci->super->hydro.drift, t); - scheduler_addunlock(sched, t->ci->super->grav.drift_gpart, t); + scheduler_addunlock(sched, t->ci->super->grav.drift, t); /* Now, build all the dependencies for the stars */ engine_make_stars_loops_dependencies(sched, t, t->ci); - scheduler_addunlock(sched, t->ci->stars_ghost_out, + scheduler_addunlock(sched, t->ci->stars.ghost_out, t->ci->super->hydro.end_force); } @@ -3948,11 +3948,11 @@ void engine_marktasks_mapper(void *map_data, int num_elements, /* If the local cell is active, receive data from the foreign cell. */ if (cj_active_hydro) { - scheduler_activate(s, ci->hydro.recv_xv); + scheduler_activate(s, ci->mpi.hydro.recv_xv); if (ci_active_hydro) { - scheduler_activate(s, ci->hydro.recv_rho); + scheduler_activate(s, ci->mpi.hydro.recv_rho); #ifdef EXTRA_HYDRO_LOOP - scheduler_activate(s, ci->hydro.recv_gradient); + scheduler_activate(s, ci->mpi.hydro.recv_gradient); #endif } } @@ -3964,7 +3964,7 @@ void engine_marktasks_mapper(void *map_data, int num_elements, if (ci_active_hydro) { struct link *l = - scheduler_activate_send(s, cj->hydro.send_xv, ci_nodeID); + scheduler_activate_send(s, cj->mpi.hydro.send_xv, ci_nodeID); /* Drift the cell which will be sent at the level at which it is sent, i.e. drift the cell specified in the send task (l->t) @@ -3973,10 +3973,11 @@ void engine_marktasks_mapper(void *map_data, int num_elements, /* If the local cell is also active, more stuff will be needed. */ if (cj_active_hydro) { - scheduler_activate_send(s, cj->hydro.send_rho, ci_nodeID); + scheduler_activate_send(s, cj->mpi.hydro.send_rho, ci_nodeID); #ifdef EXTRA_HYDRO_LOOP - scheduler_activate_send(s, cj->hydro.send_gradient, ci_nodeID); + scheduler_activate_send(s, cj->mpi.hydro.send_gradient, + ci_nodeID); #endif } } @@ -3989,11 +3990,11 @@ void engine_marktasks_mapper(void *map_data, int num_elements, /* If the local cell is active, receive data from the foreign cell. */ if (ci_active_hydro) { - scheduler_activate(s, cj->hydro.recv_xv); + scheduler_activate(s, cj->mpi.hydro.recv_xv); if (cj_active_hydro) { - scheduler_activate(s, cj->hydro.recv_rho); + scheduler_activate(s, cj->mpi.hydro.recv_rho); #ifdef EXTRA_HYDRO_LOOP - scheduler_activate(s, cj->hydro.recv_gradient); + scheduler_activate(s, cj->mpi.hydro.recv_gradient); #endif } } @@ -4005,7 +4006,7 @@ void engine_marktasks_mapper(void *map_data, int num_elements, if (cj_active_hydro) { struct link *l = - scheduler_activate_send(s, ci->hydro.send_xv, cj_nodeID); + scheduler_activate_send(s, ci->mpi.hydro.send_xv, cj_nodeID); /* Drift the cell which will be sent at the level at which it is sent, i.e. drift the cell specified in the send task (l->t) @@ -4015,10 +4016,11 @@ void engine_marktasks_mapper(void *map_data, int num_elements, /* If the local cell is also active, more stuff will be needed. */ if (ci_active_hydro) { - scheduler_activate_send(s, ci->hydro.send_rho, cj_nodeID); + scheduler_activate_send(s, ci->mpi.hydro.send_rho, cj_nodeID); #ifdef EXTRA_HYDRO_LOOP - scheduler_activate_send(s, ci->hydro.send_gradient, cj_nodeID); + scheduler_activate_send(s, ci->mpi.hydro.send_gradient, + cj_nodeID); #endif } } @@ -4047,7 +4049,7 @@ void engine_marktasks_mapper(void *map_data, int num_elements, if (ci_nodeID != nodeID) { /* If the local cell is active, receive data from the foreign cell. */ - if (cj_active_gravity) scheduler_activate(s, ci->grav.recv); + if (cj_active_gravity) scheduler_activate(s, ci->mpi.grav.recv); /* If the foreign cell is active, we want its ti_end values. */ if (ci_active_gravity) scheduler_activate(s, ci->mpi.recv_ti); @@ -4056,7 +4058,7 @@ void engine_marktasks_mapper(void *map_data, int num_elements, if (ci_active_gravity) { struct link *l = - scheduler_activate_send(s, cj->grav.send, ci_nodeID); + scheduler_activate_send(s, cj->mpi.grav.send, ci_nodeID); /* Drift the cell which will be sent at the level at which it is sent, i.e. drift the cell specified in the send task (l->t) @@ -4071,7 +4073,7 @@ void engine_marktasks_mapper(void *map_data, int num_elements, } else if (cj_nodeID != nodeID) { /* If the local cell is active, receive data from the foreign cell. */ - if (ci_active_gravity) scheduler_activate(s, cj->grav.recv); + if (ci_active_gravity) scheduler_activate(s, cj->mpi.grav.recv); /* If the foreign cell is active, we want its ti_end values. */ if (cj_active_gravity) scheduler_activate(s, cj->mpi.recv_ti); @@ -4080,7 +4082,7 @@ void engine_marktasks_mapper(void *map_data, int num_elements, if (cj_active_gravity) { struct link *l = - scheduler_activate_send(s, ci->grav.send, cj_nodeID); + scheduler_activate_send(s, ci->mpi.grav.send, cj_nodeID); /* Drift the cell which will be sent at the level at which it is sent, i.e. drift the cell specified in the send task (l->t) @@ -4156,8 +4158,8 @@ void engine_marktasks_mapper(void *map_data, int num_elements, /* Time-step? */ else if (t_type == task_type_timestep) { t->ci->hydro.updated = 0; - t->ci->grav.g_updated = 0; - t->ci->s_updated = 0; + t->ci->grav.updated = 0; + t->ci->stars.updated = 0; if (cell_is_active_hydro(t->ci, e) || cell_is_active_gravity(t->ci, e)) scheduler_activate(s, t); } @@ -4312,7 +4314,7 @@ int engine_estimate_nr_tasks(struct engine *e) { struct cell *c = &e->s->cells_top[k]; /* Any cells with particles will have tasks (local & foreign). */ - int nparts = c->hydro.count + c->grav.gcount + c->scount; + int nparts = c->hydro.count + c->grav.count + c->stars.count; if (nparts > 0) { ntop++; ncells++; @@ -4564,7 +4566,7 @@ void engine_collect_end_of_step_recurse(struct cell *c, for (int k = 0; k < 8; k++) { struct cell *cp = c->progeny[k]; if (cp != NULL && - (cp->hydro.count > 0 || cp->grav.gcount > 0 || cp->scount > 0)) { + (cp->hydro.count > 0 || cp->grav.count > 0 || cp->stars.count > 0)) { /* Recurse */ engine_collect_end_of_step_recurse(cp, e); @@ -4579,13 +4581,13 @@ void engine_collect_end_of_step_recurse(struct cell *c, ti_gravity_beg_max = max(ti_gravity_beg_max, cp->grav.ti_beg_max); updated += cp->hydro.updated; - g_updated += cp->grav.g_updated; - s_updated += cp->s_updated; + g_updated += cp->grav.updated; + s_updated += cp->stars.updated; /* Collected, so clear for next time. */ cp->hydro.updated = 0; - cp->grav.g_updated = 0; - cp->s_updated = 0; + cp->grav.updated = 0; + cp->stars.updated = 0; } } @@ -4597,8 +4599,8 @@ void engine_collect_end_of_step_recurse(struct cell *c, c->grav.ti_end_max = ti_gravity_end_max; c->grav.ti_beg_max = ti_gravity_beg_max; c->hydro.updated = updated; - c->grav.g_updated = g_updated; - c->s_updated = s_updated; + c->grav.updated = g_updated; + c->stars.updated = s_updated; } /** @@ -4630,7 +4632,7 @@ void engine_collect_end_of_step_mapper(void *map_data, int num_elements, for (int ind = 0; ind < num_elements; ind++) { struct cell *c = &s->cells_top[local_cells[ind]]; - if (c->hydro.count > 0 || c->grav.gcount > 0 || c->scount > 0) { + if (c->hydro.count > 0 || c->grav.count > 0 || c->stars.count > 0) { /* Make the top-cells recurse */ engine_collect_end_of_step_recurse(c, e); @@ -4647,13 +4649,13 @@ void engine_collect_end_of_step_mapper(void *map_data, int num_elements, ti_gravity_beg_max = max(ti_gravity_beg_max, c->grav.ti_beg_max); updates += c->hydro.updated; - g_updates += c->grav.g_updated; - s_updates += c->s_updated; + g_updates += c->grav.updated; + s_updates += c->stars.updated; /* Collected, so clear for next time. */ c->hydro.updated = 0; - c->grav.g_updated = 0; - c->s_updated = 0; + c->grav.updated = 0; + c->stars.updated = 0; } } diff --git a/src/map.c b/src/map.c index fdc9ca1a7ada3f402613a5bdede16851d62fbded..6b693885b08e1c103faa0b1b33d53cdc996c8877 100644 --- a/src/map.c +++ b/src/map.c @@ -122,8 +122,8 @@ void map_cellcheck(struct cell *c, void *data) { } /* Loop over all gparts and check if they are in the cell. */ - for (int k = 0; k < c->grav.gcount; k++) { - struct gpart *p = &c->grav.gparts[k]; + for (int k = 0; k < c->grav.count; k++) { + struct gpart *p = &c->grav.parts[k]; if (p->x[0] < c->loc[0] || p->x[1] < c->loc[1] || p->x[2] < c->loc[2] || p->x[0] > c->loc[0] + c->width[0] || p->x[1] > c->loc[1] + c->width[1] || diff --git a/src/mesh_gravity.c b/src/mesh_gravity.c index a40fd2539b79a875656b2fe4a4dc24031f8e70eb..e7005b083c94e20f5218923e443f71464ab383e1 100644 --- a/src/mesh_gravity.c +++ b/src/mesh_gravity.c @@ -185,8 +185,8 @@ INLINE static void gpart_to_mesh_CIC(const struct gpart* gp, double* rho, int N, */ void cell_gpart_to_mesh_CIC(const struct cell* c, double* rho, int N, double fac, const double dim[3]) { - const int gcount = c->grav.gcount; - const struct gpart* gparts = c->grav.gparts; + const int gcount = c->grav.count; + const struct gpart* gparts = c->grav.parts; /* Assign all the gpart of that cell to the mesh */ for (int i = 0; i < gcount; ++i) diff --git a/src/runner.c b/src/runner.c index a623bdd2629089b63eb9719d9e67e0d8d33b2b55..08f9e780b97e592ce7b53ae6bbbcede9b78f8926 100644 --- a/src/runner.c +++ b/src/runner.c @@ -145,7 +145,7 @@ void runner_do_sourceterms(struct runner *r, struct cell *c, int timer) { */ void runner_do_stars_ghost(struct runner *r, struct cell *c, int timer) { - struct spart *restrict sparts = c->sparts; + struct spart *restrict sparts = c->stars.parts; const struct engine *e = r->e; const struct cosmology *cosmo = e->cosmology; const struct stars_props *stars_properties = e->stars_properties; @@ -168,9 +168,9 @@ void runner_do_stars_ghost(struct runner *r, struct cell *c, int timer) { /* Init the list of active particles that have to be updated. */ int *sid = NULL; - if ((sid = (int *)malloc(sizeof(int) * c->scount)) == NULL) + if ((sid = (int *)malloc(sizeof(int) * c->stars.count)) == NULL) error("Can't allocate memory for sid."); - for (int k = 0; k < c->scount; k++) + for (int k = 0; k < c->stars.count; k++) if (spart_is_active(&sparts[k], e)) { sid[scount] = k; ++scount; @@ -348,8 +348,8 @@ void runner_do_stars_ghost(struct runner *r, struct cell *c, int timer) { */ void runner_do_grav_external(struct runner *r, struct cell *c, int timer) { - struct gpart *restrict gparts = c->grav.gparts; - const int gcount = c->grav.gcount; + struct gpart *restrict gparts = c->grav.parts; + const int gcount = c->grav.count; const struct engine *e = r->e; const struct external_potential *potential = e->external_potential; const struct phys_const *constants = e->physical_constants; @@ -391,8 +391,8 @@ void runner_do_grav_external(struct runner *r, struct cell *c, int timer) { */ void runner_do_grav_mesh(struct runner *r, struct cell *c, int timer) { - struct gpart *restrict gparts = c->grav.gparts; - const int gcount = c->grav.gcount; + struct gpart *restrict gparts = c->grav.parts; + const int gcount = c->grav.count; const struct engine *e = r->e; #ifdef SWIFT_DEBUG_CHECKS @@ -1265,7 +1265,7 @@ static void runner_do_unskip_hydro(struct cell *c, struct engine *e) { static void runner_do_unskip_stars(struct cell *c, struct engine *e) { /* Ignore empty cells. */ - if (c->scount == 0) return; + if (c->stars.count == 0) return; /* Skip inactive cells. */ if (!cell_is_active_stars(c, e)) return; @@ -1294,7 +1294,7 @@ static void runner_do_unskip_stars(struct cell *c, struct engine *e) { static void runner_do_unskip_gravity(struct cell *c, struct engine *e) { /* Ignore empty cells. */ - if (c->grav.gcount == 0) return; + if (c->grav.count == 0) return; /* Skip inactive cells. */ if (!cell_is_active_gravity(c, e)) return; @@ -1391,11 +1391,11 @@ void runner_do_kick1(struct runner *r, struct cell *c, int timer) { const int with_cosmology = (e->policy & engine_policy_cosmology); struct part *restrict parts = c->hydro.parts; struct xpart *restrict xparts = c->hydro.xparts; - struct gpart *restrict gparts = c->grav.gparts; - struct spart *restrict sparts = c->sparts; + struct gpart *restrict gparts = c->grav.parts; + struct spart *restrict sparts = c->stars.parts; const int count = c->hydro.count; - const int gcount = c->grav.gcount; - const int scount = c->scount; + const int gcount = c->grav.count; + const int scount = c->stars.count; const integertime_t ti_current = e->ti_current; const double time_base = e->time_base; @@ -1564,12 +1564,12 @@ void runner_do_kick2(struct runner *r, struct cell *c, int timer) { const struct hydro_props *hydro_props = e->hydro_properties; const int with_cosmology = (e->policy & engine_policy_cosmology); const int count = c->hydro.count; - const int gcount = c->grav.gcount; - const int scount = c->scount; + const int gcount = c->grav.count; + const int scount = c->stars.count; struct part *restrict parts = c->hydro.parts; struct xpart *restrict xparts = c->hydro.xparts; - struct gpart *restrict gparts = c->grav.gparts; - struct spart *restrict sparts = c->sparts; + struct gpart *restrict gparts = c->grav.parts; + struct spart *restrict sparts = c->stars.parts; const integertime_t ti_current = e->ti_current; const double time_base = e->time_base; @@ -1738,20 +1738,20 @@ void runner_do_timestep(struct runner *r, struct cell *c, int timer) { const struct engine *e = r->e; const integertime_t ti_current = e->ti_current; const int count = c->hydro.count; - const int gcount = c->grav.gcount; - const int scount = c->scount; + const int gcount = c->grav.count; + const int scount = c->stars.count; struct part *restrict parts = c->hydro.parts; struct xpart *restrict xparts = c->hydro.xparts; - struct gpart *restrict gparts = c->grav.gparts; - struct spart *restrict sparts = c->sparts; + struct gpart *restrict gparts = c->grav.parts; + struct spart *restrict sparts = c->stars.parts; TIMER_TIC; /* Anything to do here? */ if (!cell_is_active_hydro(c, e) && !cell_is_active_gravity(c, e)) { c->hydro.updated = 0; - c->grav.g_updated = 0; - c->s_updated = 0; + c->grav.updated = 0; + c->stars.updated = 0; return; } @@ -1961,8 +1961,8 @@ void runner_do_timestep(struct runner *r, struct cell *c, int timer) { /* And aggregate */ updated += cp->hydro.updated; - g_updated += cp->grav.g_updated; - s_updated += cp->s_updated; + g_updated += cp->grav.updated; + s_updated += cp->stars.updated; ti_hydro_end_min = min(cp->hydro.ti_end_min, ti_hydro_end_min); ti_hydro_end_max = max(cp->hydro.ti_end_max, ti_hydro_end_max); ti_hydro_beg_max = max(cp->hydro.ti_beg_max, ti_hydro_beg_max); @@ -1974,8 +1974,8 @@ void runner_do_timestep(struct runner *r, struct cell *c, int timer) { /* Store the values. */ c->hydro.updated = updated; - c->grav.g_updated = g_updated; - c->s_updated = s_updated; + c->grav.updated = g_updated; + c->stars.updated = s_updated; c->hydro.ti_end_min = ti_hydro_end_min; c->hydro.ti_end_max = ti_hydro_end_max; c->hydro.ti_beg_max = ti_hydro_beg_max; @@ -2009,11 +2009,11 @@ void runner_do_end_force(struct runner *r, struct cell *c, int timer) { const struct space *s = e->s; const struct cosmology *cosmo = e->cosmology; const int count = c->hydro.count; - const int gcount = c->grav.gcount; - const int scount = c->scount; + const int gcount = c->grav.count; + const int scount = c->stars.count; struct part *restrict parts = c->hydro.parts; - struct gpart *restrict gparts = c->grav.gparts; - struct spart *restrict sparts = c->sparts; + struct gpart *restrict gparts = c->grav.parts; + struct spart *restrict sparts = c->stars.parts; const int periodic = s->periodic; const float G_newton = e->physical_constants->const_newton_G; @@ -2214,7 +2214,7 @@ void runner_do_recv_part(struct runner *r, struct cell *c, int clear_sorts, /* ... and store. */ // c->hydro.ti_end_min = ti_hydro_end_min; // c->hydro.ti_end_max = ti_hydro_end_max; - c->hydro.ti_old = ti_current; + c->hydro.ti_old_part = ti_current; c->hydro.h_max = h_max; if (timer) TIMER_TOC(timer_dorecv_part); @@ -2235,8 +2235,8 @@ void runner_do_recv_gpart(struct runner *r, struct cell *c, int timer) { #ifdef WITH_MPI - const struct gpart *restrict gparts = c->grav.gparts; - const size_t nr_gparts = c->grav.gcount; + const struct gpart *restrict gparts = c->grav.parts; + const size_t nr_gparts = c->grav.count; const integertime_t ti_current = r->e->ti_current; TIMER_TIC; @@ -2268,7 +2268,7 @@ void runner_do_recv_gpart(struct runner *r, struct cell *c, int timer) { /* Otherwise, recurse and collect. */ else { for (int k = 0; k < 8; k++) { - if (c->progeny[k] != NULL && c->progeny[k]->grav.gcount > 0) { + if (c->progeny[k] != NULL && c->progeny[k]->grav.count > 0) { runner_do_recv_gpart(r, c->progeny[k], 0); ti_gravity_end_min = min(ti_gravity_end_min, c->progeny[k]->grav.ti_end_min); @@ -2289,7 +2289,7 @@ void runner_do_recv_gpart(struct runner *r, struct cell *c, int timer) { /* ... and store. */ // c->grav.ti_end_min = ti_gravity_end_min; // c->grav.ti_end_max = ti_gravity_end_max; - c->grav.ti_old_gpart = ti_current; + c->grav.ti_old_part = ti_current; if (timer) TIMER_TOC(timer_dorecv_gpart); @@ -2309,8 +2309,8 @@ void runner_do_recv_spart(struct runner *r, struct cell *c, int timer) { #ifdef WITH_MPI - const struct spart *restrict sparts = c->sparts; - const size_t nr_sparts = c->scount; + const struct spart *restrict sparts = c->stars.parts; + const size_t nr_sparts = c->stars.count; const integertime_t ti_current = r->e->ti_current; TIMER_TIC; @@ -2342,7 +2342,7 @@ void runner_do_recv_spart(struct runner *r, struct cell *c, int timer) { /* Otherwise, recurse and collect. */ else { for (int k = 0; k < 8; k++) { - if (c->progeny[k] != NULL && c->progeny[k]->scount > 0) { + if (c->progeny[k] != NULL && c->progeny[k]->stars.count > 0) { runner_do_recv_spart(r, c->progeny[k], 0); ti_gravity_end_min = min(ti_gravity_end_min, c->progeny[k]->grav.ti_end_min); @@ -2363,7 +2363,7 @@ void runner_do_recv_spart(struct runner *r, struct cell *c, int timer) { /* ... and store. */ // c->grav.ti_end_min = ti_gravity_end_min; // c->grav.ti_end_max = ti_gravity_end_max; - c->grav.ti_old_gpart = ti_current; + c->grav.ti_old_part = ti_current; if (timer) TIMER_TOC(timer_dorecv_spart); diff --git a/src/runner_doiact.h b/src/runner_doiact.h index 361c5c1ab1f6b12334946c20e56680eeaa048ea1..74c8b210e0d0096e8a5c00ef1899e632f013dc67 100644 --- a/src/runner_doiact.h +++ b/src/runner_doiact.h @@ -925,11 +925,14 @@ void DOPAIR1(struct runner *r, struct cell *ci, struct cell *cj, const int sid, #ifdef SWIFT_DEBUG_CHECKS /* Some constants used to checks that the parts are in the right frame */ const float shift_threshold_x = - 2. * ci->width[0] + 2. * max(ci->hydro.dx_max, cj->hydro.dx_max); + 2. * ci->width[0] + + 2. * max(ci->hydro.dx_max_part, cj->hydro.dx_max_part); const float shift_threshold_y = - 2. * ci->width[1] + 2. * max(ci->hydro.dx_max, cj->hydro.dx_max); + 2. * ci->width[1] + + 2. * max(ci->hydro.dx_max_part, cj->hydro.dx_max_part); const float shift_threshold_z = - 2. * ci->width[2] + 2. * max(ci->hydro.dx_max, cj->hydro.dx_max); + 2. * ci->width[2] + + 2. * max(ci->hydro.dx_max_part, cj->hydro.dx_max_part); #endif /* SWIFT_DEBUG_CHECKS */ /* Get some other useful values. */ @@ -1230,11 +1233,14 @@ void DOPAIR2(struct runner *r, struct cell *ci, struct cell *cj, const int sid, #ifdef SWIFT_DEBUG_CHECKS /* Some constants used to checks that the parts are in the right frame */ const float shift_threshold_x = - 2. * ci->width[0] + 2. * max(ci->hydro.dx_max, cj->hydro.dx_max); + 2. * ci->width[0] + + 2. * max(ci->hydro.dx_max_part, cj->hydro.dx_max_part); const float shift_threshold_y = - 2. * ci->width[1] + 2. * max(ci->hydro.dx_max, cj->hydro.dx_max); + 2. * ci->width[1] + + 2. * max(ci->hydro.dx_max_part, cj->hydro.dx_max_part); const float shift_threshold_z = - 2. * ci->width[2] + 2. * max(ci->hydro.dx_max, cj->hydro.dx_max); + 2. * ci->width[2] + + 2. * max(ci->hydro.dx_max_part, cj->hydro.dx_max_part); #endif /* SWIFT_DEBUG_CHECKS */ /* Get some other useful values. */ diff --git a/src/runner_doiact_grav.h b/src/runner_doiact_grav.h index 1a999e21934f59774b86434e0bd6738a77603659..2fd7681ce33f0b8e442e74006b1b91b693a63eb4 100644 --- a/src/runner_doiact_grav.h +++ b/src/runner_doiact_grav.h @@ -99,8 +99,8 @@ static INLINE void runner_do_grav_down(struct runner *r, struct cell *c, if (!cell_are_gpart_drifted(c, e)) error("Un-drifted gparts"); /* Cell properties */ - struct gpart *gparts = c->grav.gparts; - const int gcount = c->grav.gcount; + struct gpart *gparts = c->grav.parts; + const int gcount = c->grav.count; const struct grav_tensor *pot = &c->grav.multipole->pot; const double CoM[3] = {c->grav.multipole->CoM[0], c->grav.multipole->CoM[1], c->grav.multipole->CoM[2]}; @@ -716,8 +716,8 @@ static INLINE void runner_dopair_grav_pp(struct runner *r, struct cell *ci, /* Start by constructing particle caches */ /* Computed the padded counts */ - const int gcount_i = ci->grav.gcount; - const int gcount_j = cj->grav.gcount; + const int gcount_i = ci->grav.count; + const int gcount_j = cj->grav.count; const int gcount_padded_i = gcount_i - (gcount_i % VEC_SIZE) + VEC_SIZE; const int gcount_padded_j = gcount_j - (gcount_j % VEC_SIZE) + VEC_SIZE; @@ -730,10 +730,10 @@ static INLINE void runner_dopair_grav_pp(struct runner *r, struct cell *ci, /* Fill the caches */ gravity_cache_populate(e->max_active_bin, allow_mpole, periodic, dim, - ci_cache, ci->grav.gparts, gcount_i, gcount_padded_i, + ci_cache, ci->grav.parts, gcount_i, gcount_padded_i, shift_i, CoM_j, rmax2_j, ci, e->gravity_properties); gravity_cache_populate(e->max_active_bin, allow_mpole, periodic, dim, - cj_cache, cj->grav.gparts, gcount_j, gcount_padded_j, + cj_cache, cj->grav.parts, gcount_j, gcount_padded_j, shift_j, CoM_i, rmax2_i, cj, e->gravity_properties); /* Can we use the Newtonian version or do we need the truncated one ? */ @@ -747,12 +747,12 @@ static INLINE void runner_dopair_grav_pp(struct runner *r, struct cell *ci, /* First the P2P */ runner_dopair_grav_pp_full(ci_cache, cj_cache, gcount_i, gcount_j, gcount_padded_j, periodic, dim, e, - ci->grav.gparts, cj->grav.gparts); + ci->grav.parts, cj->grav.parts); /* Then the M2P */ if (allow_mpole) runner_dopair_grav_pm_full(ci_cache, gcount_padded_i, CoM_j, multi_j, - periodic, dim, e, ci->grav.gparts, gcount_i, + periodic, dim, e, ci->grav.parts, gcount_i, cj); } if (cj_active && symmetric) { @@ -760,12 +760,12 @@ static INLINE void runner_dopair_grav_pp(struct runner *r, struct cell *ci, /* First the P2P */ runner_dopair_grav_pp_full(cj_cache, ci_cache, gcount_j, gcount_i, gcount_padded_i, periodic, dim, e, - cj->grav.gparts, ci->grav.gparts); + cj->grav.parts, ci->grav.parts); /* Then the M2P */ if (allow_mpole) runner_dopair_grav_pm_full(cj_cache, gcount_padded_j, CoM_i, multi_i, - periodic, dim, e, cj->grav.gparts, gcount_j, + periodic, dim, e, cj->grav.parts, gcount_j, ci); } @@ -790,26 +790,26 @@ static INLINE void runner_dopair_grav_pp(struct runner *r, struct cell *ci, /* First the (truncated) P2P */ runner_dopair_grav_pp_truncated(ci_cache, cj_cache, gcount_i, gcount_j, gcount_padded_j, dim, r_s_inv, e, - ci->grav.gparts, cj->grav.gparts); + ci->grav.parts, cj->grav.parts); /* Then the M2P */ if (allow_mpole) runner_dopair_grav_pm_truncated(ci_cache, gcount_padded_i, CoM_j, multi_j, dim, r_s_inv, e, - ci->grav.gparts, gcount_i, cj); + ci->grav.parts, gcount_i, cj); } if (cj_active && symmetric) { /* First the (truncated) P2P */ runner_dopair_grav_pp_truncated(cj_cache, ci_cache, gcount_j, gcount_i, gcount_padded_i, dim, r_s_inv, e, - cj->grav.gparts, ci->grav.gparts); + cj->grav.parts, ci->grav.parts); /* Then the M2P */ if (allow_mpole) runner_dopair_grav_pm_truncated(cj_cache, gcount_padded_j, CoM_i, multi_i, dim, r_s_inv, e, - cj->grav.gparts, gcount_j, ci); + cj->grav.parts, gcount_j, ci); } } else { @@ -822,34 +822,34 @@ static INLINE void runner_dopair_grav_pp(struct runner *r, struct cell *ci, /* First the (Newtonian) P2P */ runner_dopair_grav_pp_full(ci_cache, cj_cache, gcount_i, gcount_j, gcount_padded_j, periodic, dim, e, - ci->grav.gparts, cj->grav.gparts); + ci->grav.parts, cj->grav.parts); /* Then the M2P */ if (allow_mpole) runner_dopair_grav_pm_full(ci_cache, gcount_padded_i, CoM_j, multi_j, - periodic, dim, e, ci->grav.gparts, - gcount_i, cj); + periodic, dim, e, ci->grav.parts, gcount_i, + cj); } if (cj_active && symmetric) { /* First the (Newtonian) P2P */ runner_dopair_grav_pp_full(cj_cache, ci_cache, gcount_j, gcount_i, gcount_padded_i, periodic, dim, e, - cj->grav.gparts, ci->grav.gparts); + cj->grav.parts, ci->grav.parts); /* Then the M2P */ if (allow_mpole) runner_dopair_grav_pm_full(cj_cache, gcount_padded_j, CoM_i, multi_i, - periodic, dim, e, cj->grav.gparts, - gcount_j, ci); + periodic, dim, e, cj->grav.parts, gcount_j, + ci); } } } /* Write back to the particles */ - if (ci_active) gravity_cache_write_back(ci_cache, ci->grav.gparts, gcount_i); + if (ci_active) gravity_cache_write_back(ci_cache, ci->grav.parts, gcount_i); if (cj_active && symmetric) - gravity_cache_write_back(cj_cache, cj->grav.gparts, gcount_j); + gravity_cache_write_back(cj_cache, cj->grav.parts, gcount_j); TIMER_TOC(timer_dopair_grav_pp); } @@ -1097,7 +1097,7 @@ static INLINE void runner_doself_grav_pp(struct runner *r, struct cell *c) { TIMER_TIC; #ifdef SWIFT_DEBUG_CHECKS - if (c->grav.gcount == 0) error("Doing self gravity on an empty cell !"); + if (c->grav.count == 0) error("Doing self gravity on an empty cell !"); #endif /* Anything to do here? */ @@ -1118,7 +1118,7 @@ static INLINE void runner_doself_grav_pp(struct runner *r, struct cell *c) { c->loc[2] + 0.5 * c->width[2]}; /* Computed the padded counts */ - const int gcount = c->grav.gcount; + const int gcount = c->grav.count; const int gcount_padded = gcount - (gcount % VEC_SIZE) + VEC_SIZE; #ifdef SWIFT_DEBUG_CHECKS @@ -1128,7 +1128,7 @@ static INLINE void runner_doself_grav_pp(struct runner *r, struct cell *c) { #endif /* Fill the cache */ - gravity_cache_populate_no_mpole(e->max_active_bin, ci_cache, c->grav.gparts, + gravity_cache_populate_no_mpole(e->max_active_bin, ci_cache, c->grav.parts, gcount, gcount_padded, loc, c, e->gravity_properties); @@ -1137,7 +1137,7 @@ static INLINE void runner_doself_grav_pp(struct runner *r, struct cell *c) { /* Not periodic -> Can always use Newtonian potential */ runner_doself_grav_pp_full(ci_cache, gcount, gcount_padded, e, - c->grav.gparts); + c->grav.parts); } else { @@ -1149,18 +1149,18 @@ static INLINE void runner_doself_grav_pp(struct runner *r, struct cell *c) { /* Periodic but far-away cells must use the truncated potential */ runner_doself_grav_pp_truncated(ci_cache, gcount, gcount_padded, r_s_inv, - e, c->grav.gparts); + e, c->grav.parts); } else { /* Periodic but close-by cells can use the full Newtonian potential */ runner_doself_grav_pp_full(ci_cache, gcount, gcount_padded, e, - c->grav.gparts); + c->grav.parts); } } /* Write back to the particles */ - gravity_cache_write_back(ci_cache, c->grav.gparts, gcount); + gravity_cache_write_back(ci_cache, c->grav.parts, gcount); TIMER_TOC(timer_doself_grav_pp); } @@ -1361,7 +1361,7 @@ static INLINE void runner_dopair_recursive_grav_pm(struct runner *r, #ifdef SWIFT_DEBUG_CHECKS /* Early abort? */ - if (ci->grav.gcount == 0 || cj->grav.gcount == 0) + if (ci->grav.count == 0 || cj->grav.count == 0) error("Doing pair gravity on an empty cell !"); /* Sanity check */ @@ -1389,7 +1389,7 @@ static INLINE void runner_dopair_recursive_grav_pm(struct runner *r, struct gravity_cache *const ci_cache = &r->ci_gravity_cache; /* Computed the padded counts */ - const int gcount_i = ci->grav.gcount; + const int gcount_i = ci->grav.count; const int gcount_padded_i = gcount_i - (gcount_i % VEC_SIZE) + VEC_SIZE; #ifdef SWIFT_DEBUG_CHECKS @@ -1407,25 +1407,25 @@ static INLINE void runner_dopair_recursive_grav_pm(struct runner *r, /* Fill the cache */ gravity_cache_populate_all_mpole( - e->max_active_bin, periodic, dim, ci_cache, ci->grav.gparts, gcount_i, + e->max_active_bin, periodic, dim, ci_cache, ci->grav.parts, gcount_i, gcount_padded_i, ci, CoM_j, r_max * r_max, e->gravity_properties); /* Can we use the Newtonian version or do we need the truncated one ? */ if (!periodic) { runner_dopair_grav_pm_full(ci_cache, gcount_padded_i, CoM_j, multi_j, - periodic, dim, e, ci->grav.gparts, gcount_i, + periodic, dim, e, ci->grav.parts, gcount_i, cj); } else { runner_dopair_grav_pm_truncated(ci_cache, gcount_padded_i, CoM_j, multi_j, - dim, r_s_inv, e, ci->grav.gparts, - gcount_i, cj); + dim, r_s_inv, e, ci->grav.parts, gcount_i, + cj); } /* Write back to the particles */ - gravity_cache_write_back(ci_cache, ci->grav.gparts, gcount_i); + gravity_cache_write_back(ci_cache, ci->grav.parts, gcount_i); } } @@ -1463,8 +1463,8 @@ static INLINE void runner_dopair_recursive_grav(struct runner *r, #ifdef SWIFT_DEBUG_CHECKS - const int gcount_i = ci->grav.gcount; - const int gcount_j = cj->grav.gcount; + const int gcount_i = ci->grav.count; + const int gcount_j = cj->grav.count; /* Early abort? */ if (gcount_i == 0 || gcount_j == 0) @@ -1607,7 +1607,7 @@ static INLINE void runner_doself_recursive_grav(struct runner *r, #ifdef SWIFT_DEBUG_CHECKS /* Early abort? */ - if (c->grav.gcount == 0) error("Doing self gravity on an empty cell !"); + if (c->grav.count == 0) error("Doing self gravity on an empty cell !"); #endif TIMER_TIC; diff --git a/src/runner_doiact_stars.h b/src/runner_doiact_stars.h index c83161636456014ec92c414b17e59ddb6c3d30ba..5e656e1420134026ea6bc1d5c9c3df27887a4797 100644 --- a/src/runner_doiact_stars.h +++ b/src/runner_doiact_stars.h @@ -40,9 +40,9 @@ void runner_doself_stars_density(struct runner *r, struct cell *c, int timer) { const float a = cosmo->a; const float H = cosmo->H; - const int scount = c->scount; + const int scount = c->stars.count; const int count = c->hydro.count; - struct spart *restrict sparts = c->sparts; + struct spart *restrict sparts = c->stars.parts; struct part *restrict parts = c->hydro.parts; /* Loop over the sparts in ci. */ @@ -101,9 +101,9 @@ void runner_dosubpair_stars_density(struct runner *r, struct cell *restrict ci, /* Anything to do here? */ if (!cell_is_active_stars(ci, e) && !cell_is_active_stars(cj, e)) return; - const int scount_i = ci->scount; + const int scount_i = ci->stars.count; const int count_j = cj->hydro.count; - struct spart *restrict sparts_i = ci->sparts; + struct spart *restrict sparts_i = ci->stars.parts; struct part *restrict parts_j = cj->hydro.parts; /* Cosmological terms */ @@ -382,15 +382,16 @@ void runner_dosub_subset_stars_density(struct runner *r, struct cell *ci, if (!cell_is_active_stars(ci, e) && (cj == NULL || !cell_is_active_stars(cj, e))) return; - if (ci->scount == 0 || (cj != NULL && cj->scount == 0)) return; + if (ci->stars.count == 0 || (cj != NULL && cj->stars.count == 0)) return; /* Find out in which sub-cell of ci the parts are. */ struct cell *sub = NULL; if (ci->split) { for (int k = 0; k < 8; k++) { if (ci->progeny[k] != NULL) { - if (&sparts[ind[0]] >= &ci->progeny[k]->sparts[0] && - &sparts[ind[0]] < &ci->progeny[k]->sparts[ci->progeny[k]->scount]) { + if (&sparts[ind[0]] >= &ci->progeny[k]->stars.parts[0] && + &sparts[ind[0]] < + &ci->progeny[k]->stars.parts[ci->progeny[k]->stars.count]) { sub = ci->progeny[k]; break; } @@ -1067,7 +1068,7 @@ void runner_dosub_pair_stars_density(struct runner *r, struct cell *ci, /* Should we even bother? */ if (!cell_is_active_stars(ci, e) && !cell_is_active_stars(cj, e)) return; - if (ci->scount == 0 || cj->scount == 0) return; + if (ci->stars.count == 0 || cj->stars.count == 0) return; /* Get the type of pair if not specified explicitly. */ double shift[3]; @@ -1386,7 +1387,7 @@ void runner_dosub_self_stars_density(struct runner *r, struct cell *ci, TIMER_TIC; /* Should we even bother? */ - if (ci->scount == 0 || !cell_is_active_stars(ci, r->e)) return; + if (ci->stars.count == 0 || !cell_is_active_stars(ci, r->e)) return; /* Recurse? */ if (cell_can_recurse_in_self_stars_task(ci)) { diff --git a/src/scheduler.c b/src/scheduler.c index 851ebf7ef6e92bed998a7ed7387b11fa07167802..2ac619b8cd9b8a435922570ab0898540e4b28e31 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -884,7 +884,7 @@ static void scheduler_splittask_stars(struct task *t, struct scheduler *s) { /* Non-splittable task? */ if ((t->ci == NULL) || (t->type == task_type_pair && t->cj == NULL) || - t->ci->scount == 0 || (t->cj != NULL && t->cj->scount == 0)) { + t->ci->stars.count == 0 || (t->cj != NULL && t->cj->stars.count == 0)) { t->type = task_type_none; t->subtype = task_subtype_none; t->cj = NULL; @@ -908,7 +908,7 @@ static void scheduler_splittask_stars(struct task *t, struct scheduler *s) { if (cell_can_split_self_stars_task(ci)) { /* Make a sub? */ - if (scheduler_dosub && ci->scount < space_subsize_self_stars) { + if (scheduler_dosub && ci->stars.count < space_subsize_self_stars) { /* convert to a self-subtask. */ t->type = task_type_sub_self; @@ -924,7 +924,7 @@ static void scheduler_splittask_stars(struct task *t, struct scheduler *s) { while (ci->progeny[first_child] == NULL) first_child++; t->ci = ci->progeny[first_child]; for (int k = first_child + 1; k < 8; k++) - if (ci->progeny[k] != NULL && ci->progeny[k]->scount) + if (ci->progeny[k] != NULL && ci->progeny[k]->stars.count) scheduler_splittask_stars( scheduler_addtask(s, task_type_self, t->subtype, 0, 0, ci->progeny[k], NULL), @@ -932,9 +932,9 @@ static void scheduler_splittask_stars(struct task *t, struct scheduler *s) { /* Make a task for each pair of progeny */ for (int j = 0; j < 8; j++) - if (ci->progeny[j] != NULL && ci->progeny[j]->scount) + if (ci->progeny[j] != NULL && ci->progeny[j]->stars.count) for (int k = j + 1; k < 8; k++) - if (ci->progeny[k] != NULL && ci->progeny[k]->scount) + if (ci->progeny[k] != NULL && ci->progeny[k]->stars.count) scheduler_splittask_stars( scheduler_addtask(s, task_type_pair, t->subtype, sub_sid_flag[j][k], 0, ci->progeny[j], @@ -969,8 +969,8 @@ static void scheduler_splittask_stars(struct task *t, struct scheduler *s) { /* Replace by a single sub-task? */ if (scheduler_dosub && /* Use division to avoid integer overflow. */ - ci->scount * sid_scale[sid] < - space_subsize_pair_stars / cj->scount && + ci->stars.count * sid_scale[sid] < + space_subsize_pair_stars / cj->stars.count && !sort_is_corner(sid)) { /* Make this task a sub task. */ @@ -1319,15 +1319,15 @@ static void scheduler_splittask_stars(struct task *t, struct scheduler *s) { /* Otherwise, break it up if it is too large? */ } else if (scheduler_doforcesplit && ci->split && cj->split && - (ci->scount > space_maxsize / cj->scount)) { + (ci->stars.count > space_maxsize / cj->stars.count)) { /* Replace the current task. */ t->type = task_type_none; for (int j = 0; j < 8; j++) - if (ci->progeny[j] != NULL && ci->progeny[j]->scount) + if (ci->progeny[j] != NULL && ci->progeny[j]->stars.count) for (int k = 0; k < 8; k++) - if (cj->progeny[k] != NULL && cj->progeny[k]->scount) { + if (cj->progeny[k] != NULL && cj->progeny[k]->stars.count) { struct task *tl = scheduler_addtask(s, task_type_pair, t->subtype, 0, 0, ci->progeny[j], cj->progeny[k]); @@ -1381,7 +1381,7 @@ static void scheduler_splittask_gravity(struct task *t, struct scheduler *s) { /* Should we split this task? */ if (cell_can_split_self_gravity_task(ci)) { - if (scheduler_dosub && ci->grav.gcount < space_subsize_self_grav) { + if (scheduler_dosub && ci->grav.count < space_subsize_self_grav) { /* Otherwise, split it. */ } else { @@ -1435,8 +1435,8 @@ static void scheduler_splittask_gravity(struct task *t, struct scheduler *s) { if (cell_can_split_pair_gravity_task(ci) && cell_can_split_pair_gravity_task(cj)) { - const long long gcount_i = ci->grav.gcount; - const long long gcount_j = cj->grav.gcount; + const long long gcount_i = ci->grav.count; + const long long gcount_j = cj->grav.count; /* Replace by a single sub-task? */ if (scheduler_dosub && @@ -1823,9 +1823,9 @@ void scheduler_reweight(struct scheduler *s, int verbose) { const float count_i = (t->ci != NULL) ? t->ci->hydro.count : 0.f; const float count_j = (t->cj != NULL) ? t->cj->hydro.count : 0.f; - const float gcount_i = (t->ci != NULL) ? t->ci->grav.gcount : 0.f; - const float gcount_j = (t->cj != NULL) ? t->cj->grav.gcount : 0.f; - const float scount_i = (t->ci != NULL) ? t->ci->scount : 0.f; + const float gcount_i = (t->ci != NULL) ? t->ci->grav.count : 0.f; + const float gcount_j = (t->cj != NULL) ? t->cj->grav.count : 0.f; + const float scount_i = (t->ci != NULL) ? t->ci->stars.count : 0.f; switch (t->type) { case task_type_sort: @@ -2131,13 +2131,13 @@ void scheduler_enqueue(struct scheduler *s, struct task *t) { // t->ci->hydro.count , t->flags , t->ci->nodeID , s->nodeID ); // fflush(stdout); } else if (t->subtype == task_subtype_gpart) { - err = MPI_Irecv(t->ci->grav.gparts, t->ci->grav.gcount, - gpart_mpi_type, t->ci->nodeID, t->flags, - subtaskMPI_comms[t->subtype], &t->req); - } else if (t->subtype == task_subtype_spart) { - err = MPI_Irecv(t->ci->sparts, t->ci->scount, spart_mpi_type, + err = MPI_Irecv(t->ci->grav.parts, t->ci->grav.count, gpart_mpi_type, t->ci->nodeID, t->flags, subtaskMPI_comms[t->subtype], &t->req); + } else if (t->subtype == task_subtype_spart) { + err = MPI_Irecv(t->ci->stars.parts, t->ci->stars.count, + spart_mpi_type, t->ci->nodeID, t->flags, + subtaskMPI_comms[t->subtype], &t->req); } else if (t->subtype == task_subtype_multipole) { t->buff = (struct gravity_tensors *)malloc( sizeof(struct gravity_tensors) * t->ci->mpi.pcell_size); @@ -2187,23 +2187,23 @@ void scheduler_enqueue(struct scheduler *s, struct task *t) { // t->ci->hydro.count , t->flags , s->nodeID , t->cj->nodeID ); // fflush(stdout); } else if (t->subtype == task_subtype_gpart) { - if ((t->ci->grav.gcount * sizeof(struct gpart)) > - s->mpi_message_limit) - err = MPI_Isend(t->ci->grav.gparts, t->ci->grav.gcount, + if ((t->ci->grav.count * sizeof(struct gpart)) > s->mpi_message_limit) + err = MPI_Isend(t->ci->grav.parts, t->ci->grav.count, gpart_mpi_type, t->cj->nodeID, t->flags, subtaskMPI_comms[t->subtype], &t->req); else - err = MPI_Issend(t->ci->grav.gparts, t->ci->grav.gcount, + err = MPI_Issend(t->ci->grav.parts, t->ci->grav.count, gpart_mpi_type, t->cj->nodeID, t->flags, subtaskMPI_comms[t->subtype], &t->req); } else if (t->subtype == task_subtype_spart) { - if ((t->ci->scount * sizeof(struct spart)) > s->mpi_message_limit) - err = MPI_Isend(t->ci->sparts, t->ci->scount, spart_mpi_type, - t->cj->nodeID, t->flags, + if ((t->ci->stars.count * sizeof(struct spart)) > + s->mpi_message_limit) + err = MPI_Isend(t->ci->stars.parts, t->ci->stars.count, + spart_mpi_type, t->cj->nodeID, t->flags, subtaskMPI_comms[t->subtype], &t->req); else - err = MPI_Issend(t->ci->sparts, t->ci->scount, spart_mpi_type, - t->cj->nodeID, t->flags, + err = MPI_Issend(t->ci->stars.parts, t->ci->stars.count, + spart_mpi_type, t->cj->nodeID, t->flags, subtaskMPI_comms[t->subtype], &t->req); } else if (t->subtype == task_subtype_multipole) { t->buff = (struct gravity_tensors *)malloc( diff --git a/src/space.c b/src/space.c index 92503e99eed1cb8a2d94d692520aea733b687a33..890fa7a063109b9b47c430285655b7034f795c80 100644 --- a/src/space.c +++ b/src/space.c @@ -172,28 +172,28 @@ void space_rebuild_recycle_mapper(void *map_data, int num_elements, c->hydro.force = NULL; c->grav.grav = NULL; c->grav.mm = NULL; - c->hydro.dx_max = 0.0f; - c->hydro.dx_max = 0.0f; + c->hydro.dx_max_part = 0.0f; + c->hydro.dx_max_sort = 0.0f; c->hydro.sorted = 0; c->hydro.count = 0; - c->grav.gcount = 0; - c->scount = 0; + c->grav.count = 0; + c->stars.count = 0; c->grav.init = NULL; c->grav.init_out = NULL; c->hydro.extra_ghost = NULL; c->hydro.ghost_in = NULL; c->hydro.ghost_out = NULL; c->hydro.ghost = NULL; - c->stars_ghost_in = NULL; - c->stars_ghost_out = NULL; - c->stars_ghost = NULL; - c->stars_density = NULL; + c->stars.ghost_in = NULL; + c->stars.ghost_out = NULL; + c->stars.ghost = NULL; + c->stars.density = NULL; c->kick1 = NULL; c->kick2 = NULL; c->timestep = NULL; c->hydro.end_force = NULL; c->hydro.drift = NULL; - c->grav.drift_gpart = NULL; + c->grav.drift = NULL; c->hydro.cooling = NULL; c->sourceterms = NULL; c->grav.long_range = NULL; @@ -205,8 +205,8 @@ void space_rebuild_recycle_mapper(void *map_data, int num_elements, c->grav.super = c; c->hydro.parts = NULL; c->hydro.xparts = NULL; - c->grav.gparts = NULL; - c->sparts = NULL; + c->grav.parts = NULL; + c->stars.parts = NULL; c->hydro.do_sub_sort = 0; c->grav.do_sub_drift = 0; c->hydro.do_sub_drift = 0; @@ -226,16 +226,16 @@ void space_rebuild_recycle_mapper(void *map_data, int num_elements, #if WITH_MPI c->mpi.tag = -1; - c->hydro.recv_xv = NULL; - c->hydro.recv_rho = NULL; - c->hydro.recv_gradient = NULL; - c->grav.recv = NULL; + c->mpi.hydro.recv_xv = NULL; + c->mpi.hydro.recv_rho = NULL; + c->mpi.hydro.recv_gradient = NULL; + c->mpi.grav.recv = NULL; c->mpi.recv_ti = NULL; - c->hydro.send_xv = NULL; - c->hydro.send_rho = NULL; - c->hydro.send_gradient = NULL; - c->grav.send = NULL; + c->mpi.hydro.send_xv = NULL; + c->mpi.hydro.send_rho = NULL; + c->mpi.hydro.send_gradient = NULL; + c->mpi.grav.send = NULL; c->mpi.send_ti = NULL; #endif } @@ -429,11 +429,11 @@ void space_regrid(struct space *s, int verbose) { for (int k = 0; k < s->nr_cells; k++) { if (lock_init(&s->cells_top[k].hydro.lock) != 0) error("Failed to init spinlock for hydro."); - if (lock_init(&s->cells_top[k].grav.glock) != 0) + if (lock_init(&s->cells_top[k].grav.plock) != 0) error("Failed to init spinlock for gravity."); if (lock_init(&s->cells_top[k].grav.mlock) != 0) error("Failed to init spinlock for multipoles."); - if (lock_init(&s->cells_top[k].slock) != 0) + if (lock_init(&s->cells_top[k].stars.lock) != 0) error("Failed to init spinlock for stars."); } @@ -452,13 +452,13 @@ void space_regrid(struct space *s, int verbose) { c->dmin = dmin; c->depth = 0; c->hydro.count = 0; - c->grav.gcount = 0; - c->scount = 0; + c->grav.count = 0; + c->stars.count = 0; c->super = c; c->hydro.super = c; c->grav.super = c; - c->hydro.ti_old = ti_current; - c->grav.ti_old_gpart = ti_current; + c->hydro.ti_old_part = ti_current; + c->grav.ti_old_part = ti_current; c->grav.ti_old_multipole = ti_current; #ifdef WITH_MPI c->mpi.tag = -1; @@ -860,7 +860,7 @@ void space_rebuild(struct space *s, int verbose) { sind[nr_sparts] = s->nr_cells; // sentinel. for (size_t k = 0; k < nr_sparts; k++) { if (sind[k] < sind[k + 1]) { - cells_top[sind[k]].scount = k - last_sindex + 1; + cells_top[sind[k]].stars.count = k - last_sindex + 1; last_sindex = k + 1; } } @@ -932,7 +932,7 @@ void space_rebuild(struct space *s, int verbose) { gind[nr_gparts] = s->nr_cells; for (size_t k = 0; k < nr_gparts; k++) { if (gind[k] < gind[k + 1]) { - cells_top[gind[k]].grav.gcount = k - last_gindex + 1; + cells_top[gind[k]].grav.count = k - last_gindex + 1; last_gindex = k + 1; } } @@ -956,8 +956,8 @@ void space_rebuild(struct space *s, int verbose) { struct spart *sfinger = s->sparts; for (int k = 0; k < s->nr_cells; k++) { struct cell *restrict c = &cells_top[k]; - c->hydro.ti_old = ti_current; - c->grav.ti_old_gpart = ti_current; + c->hydro.ti_old_part = ti_current; + c->grav.ti_old_part = ti_current; c->grav.ti_old_multipole = ti_current; #ifdef SWIFT_DEBUG_CHECKS @@ -968,12 +968,12 @@ void space_rebuild(struct space *s, int verbose) { if (c->nodeID == engine_rank) { c->hydro.parts = finger; c->hydro.xparts = xfinger; - c->grav.gparts = gfinger; - c->sparts = sfinger; + c->grav.parts = gfinger; + c->stars.parts = sfinger; finger = &finger[c->hydro.count]; xfinger = &xfinger[c->hydro.count]; - gfinger = &gfinger[c->grav.gcount]; - sfinger = &sfinger[c->scount]; + gfinger = &gfinger[c->grav.count]; + sfinger = &sfinger[c->stars.count]; } } // message( "hooking up cells took %.3f %s." , @@ -1770,19 +1770,19 @@ void space_map_cells_pre(struct space *s, int full, * @param s The #space in which the cell lives. * @param c The #cell to split recursively. * @param buff A buffer for particle sorting, should be of size at least - * c->count or @c NULL. + * c->hydro.count or @c NULL. * @param sbuff A buffer for particle sorting, should be of size at least - * c->scount or @c NULL. + * c->stars.count or @c NULL. * @param gbuff A buffer for particle sorting, should be of size at least - * c->gcount or @c NULL. + * c->grav.count or @c NULL. */ void space_split_recursive(struct space *s, struct cell *c, struct cell_buff *buff, struct cell_buff *sbuff, struct cell_buff *gbuff) { const int count = c->hydro.count; - const int gcount = c->grav.gcount; - const int scount = c->scount; + const int gcount = c->grav.count; + const int scount = c->stars.count; const int with_gravity = s->gravity; const int depth = c->depth; int maxdepth = 0; @@ -1792,8 +1792,8 @@ void space_split_recursive(struct space *s, struct cell *c, integertime_t ti_gravity_end_min = max_nr_timesteps, ti_gravity_end_max = 0, ti_gravity_beg_max = 0; struct part *parts = c->hydro.parts; - struct gpart *gparts = c->grav.gparts; - struct spart *sparts = c->sparts; + struct gpart *gparts = c->grav.parts; + struct spart *sparts = c->stars.parts; struct xpart *xparts = c->hydro.xparts; struct engine *e = s->e; const integertime_t ti_current = e->ti_current; @@ -1857,10 +1857,10 @@ void space_split_recursive(struct space *s, struct cell *c, for (int k = 0; k < 8; k++) { struct cell *cp = c->progeny[k]; cp->hydro.count = 0; - cp->grav.gcount = 0; - cp->scount = 0; - cp->hydro.ti_old = c->hydro.ti_old; - cp->grav.ti_old_gpart = c->grav.ti_old_gpart; + cp->grav.count = 0; + cp->stars.count = 0; + cp->hydro.ti_old_part = c->hydro.ti_old_part; + cp->grav.ti_old_part = c->grav.ti_old_part; cp->grav.ti_old_multipole = c->grav.ti_old_multipole; cp->loc[0] = c->loc[0]; cp->loc[1] = c->loc[1]; @@ -1875,7 +1875,7 @@ void space_split_recursive(struct space *s, struct cell *c, cp->depth = c->depth + 1; cp->split = 0; cp->hydro.h_max = 0.f; - cp->hydro.dx_max = 0.f; + cp->hydro.dx_max_part = 0.f; cp->hydro.dx_max_sort = 0.f; cp->nodeID = c->nodeID; cp->parent = c; @@ -1894,8 +1894,8 @@ void space_split_recursive(struct space *s, struct cell *c, } /* Split the cell's partcle data. */ - cell_split(c, c->hydro.parts - s->parts, c->sparts - s->sparts, buff, sbuff, - gbuff); + cell_split(c, c->hydro.parts - s->parts, c->stars.parts - s->sparts, buff, + sbuff, gbuff); /* Buffers for the progenitors */ struct cell_buff *progeny_buff = buff, *progeny_gbuff = gbuff, @@ -1907,7 +1907,7 @@ void space_split_recursive(struct space *s, struct cell *c, struct cell *cp = c->progeny[k]; /* Remove any progeny with zero particles. */ - if (cp->hydro.count == 0 && cp->grav.gcount == 0 && cp->scount == 0) { + if (cp->hydro.count == 0 && cp->grav.count == 0 && cp->stars.count == 0) { space_recycle(s, cp); c->progeny[k] = NULL; @@ -1920,8 +1920,8 @@ void space_split_recursive(struct space *s, struct cell *c, /* Update the pointers in the buffers */ progeny_buff += cp->hydro.count; - progeny_gbuff += cp->grav.gcount; - progeny_sbuff += cp->scount; + progeny_gbuff += cp->grav.count; + progeny_sbuff += cp->stars.count; /* Update the cell-wide properties */ h_max = max(h_max, cp->hydro.h_max); @@ -2110,7 +2110,7 @@ void space_split_recursive(struct space *s, struct cell *c, if (s->gravity) { if (gcount > 0) { - gravity_P2M(c->grav.multipole, c->grav.gparts, c->grav.gcount); + gravity_P2M(c->grav.multipole, c->grav.parts, c->grav.count); } else { @@ -2149,10 +2149,10 @@ void space_split_recursive(struct space *s, struct cell *c, c->owner = ((c->hydro.parts - s->parts) % s->nr_parts) * s->nr_queues / s->nr_parts; else if (s->nr_sparts > 0) - c->owner = - ((c->sparts - s->sparts) % s->nr_sparts) * s->nr_queues / s->nr_sparts; + c->owner = ((c->stars.parts - s->sparts) % s->nr_sparts) * s->nr_queues / + s->nr_sparts; else if (s->nr_gparts > 0) - c->owner = ((c->grav.gparts - s->gparts) % s->nr_gparts) * s->nr_queues / + c->owner = ((c->grav.parts - s->gparts) % s->nr_gparts) * s->nr_queues / s->nr_gparts; else c->owner = 0; /* Ok, there is really nothing on this rank... */ @@ -2203,8 +2203,8 @@ void space_split_mapper(void *map_data, int num_cells, void *extra_data) { void space_recycle(struct space *s, struct cell *c) { /* Clear the cell. */ - if (lock_destroy(&c->lock) != 0 || lock_destroy(&c->glock) != 0 || - lock_destroy(&c->mlock) != 0 || lock_destroy(&c->slock) != 0) + if (lock_destroy(&c->lock) != 0 || lock_destroy(&c->grav.plock) != 0 || + lock_destroy(&c->mlock) != 0 || lock_destroy(&c->stars.lock) != 0) error("Failed to destroy spinlocks."); /* Lock the space. */ @@ -2252,8 +2252,8 @@ void space_recycle_list(struct space *s, struct cell *cell_list_begin, /* Clean up the list of cells. */ for (struct cell *c = cell_list_begin; c != NULL; c = c->next) { /* Clear the cell. */ - if (lock_destroy(&c->lock) != 0 || lock_destroy(&c->glock) != 0 || - lock_destroy(&c->mlock) != 0 || lock_destroy(&c->slock) != 0) + if (lock_destroy(&c->lock) != 0 || lock_destroy(&c->grav.plock) != 0 || + lock_destroy(&c->mlock) != 0 || lock_destroy(&c->stars.lock) != 0) error("Failed to destroy spinlocks."); /* Count this cell. */ @@ -2349,9 +2349,9 @@ void space_getcells(struct space *s, int nr_cells, struct cell **cells) { cells[j]->grav.multipole = temp; cells[j]->nodeID = -1; if (lock_init(&cells[j]->hydro.lock) != 0 || - lock_init(&cells[j]->grav.glock) != 0 || + lock_init(&cells[j]->grav.plock) != 0 || lock_init(&cells[j]->grav.mlock) != 0 || - lock_init(&cells[j]->slock) != 0) + lock_init(&cells[j]->stars.lock) != 0) error("Failed to initialize cell spinlocks."); } } diff --git a/src/task.c b/src/task.c index c3b0a42dc7fd6233359555609e4dbe097ac62bf9..61d096cd32b6bab04c33dc439d5abe721bd7369f 100644 --- a/src/task.c +++ b/src/task.c @@ -96,8 +96,8 @@ MPI_Comm subtaskMPI_comms[task_subtype_count]; } TASK_CELL_OVERLAP(part, hydro.parts, hydro.count); -TASK_CELL_OVERLAP(gpart, grav.gparts, grav.gcount); -TASK_CELL_OVERLAP(spart, sparts, scount); +TASK_CELL_OVERLAP(gpart, grav.parts, grav.count); +TASK_CELL_OVERLAP(spart, stars.parts, stars.count); /** * @brief Returns the #task_actions for a given task. @@ -160,11 +160,11 @@ __attribute__((always_inline)) INLINE static enum task_actions task_acts_on( case task_type_timestep: case task_type_send: case task_type_recv: - if (t->ci->hydro.count > 0 && t->ci->grav.gcount > 0) + if (t->ci->hydro.count > 0 && t->ci->grav.count > 0) return task_action_all; else if (t->ci->hydro.count > 0) return task_action_part; - else if (t->ci->grav.gcount > 0) + else if (t->ci->grav.count > 0) return task_action_gpart; else error("Task without particles"); @@ -247,10 +247,10 @@ float task_overlap(const struct task *restrict ta, /* Compute the union of the cell data. */ size_t size_union = 0; - if (ta->ci != NULL) size_union += ta->ci->grav.gcount; - if (ta->cj != NULL) size_union += ta->cj->grav.gcount; - if (tb->ci != NULL) size_union += tb->ci->grav.gcount; - if (tb->cj != NULL) size_union += tb->cj->grav.gcount; + if (ta->ci != NULL) size_union += ta->ci->grav.count; + if (ta->cj != NULL) size_union += ta->cj->grav.count; + if (tb->ci != NULL) size_union += tb->ci->grav.count; + if (tb->cj != NULL) size_union += tb->cj->grav.count; /* Compute the intersection of the cell data. */ const size_t size_intersect = task_cell_overlap_gpart(ta->ci, tb->ci) + @@ -266,10 +266,10 @@ float task_overlap(const struct task *restrict ta, /* Compute the union of the cell data. */ size_t size_union = 0; - if (ta->ci != NULL) size_union += ta->ci->scount; - if (ta->cj != NULL) size_union += ta->cj->scount; - if (tb->ci != NULL) size_union += tb->ci->scount; - if (tb->cj != NULL) size_union += tb->cj->scount; + if (ta->ci != NULL) size_union += ta->ci->stars.count; + if (ta->cj != NULL) size_union += ta->cj->stars.count; + if (tb->ci != NULL) size_union += tb->ci->stars.count; + if (tb->cj != NULL) size_union += tb->cj->stars.count; /* Compute the intersection of the cell data. */ const size_t size_intersect = task_cell_overlap_spart(ta->ci, tb->ci) + @@ -397,7 +397,7 @@ int task_lock(struct task *t) { case task_type_kick1: case task_type_kick2: case task_type_timestep: - if (ci->hydro.hold || ci->grav.ghold) return 0; + if (ci->hydro.hold || ci->grav.phold) return 0; if (cell_locktree(ci) != 0) return 0; if (cell_glocktree(ci) != 0) { cell_unlocktree(ci); @@ -413,7 +413,7 @@ int task_lock(struct task *t) { case task_type_drift_gpart: case task_type_grav_mesh: - if (ci->grav.ghold) return 0; + if (ci->grav.phold) return 0; if (cell_glocktree(ci) != 0) return 0; break; @@ -421,7 +421,7 @@ int task_lock(struct task *t) { case task_type_sub_self: if (subtype == task_subtype_grav) { /* Lock the gparts and the m-pole */ - if (ci->grav.ghold || ci->grav.mhold) return 0; + if (ci->grav.phold || ci->grav.mhold) return 0; if (cell_glocktree(ci) != 0) return 0; else if (cell_mlocktree(ci) != 0) { @@ -437,7 +437,7 @@ int task_lock(struct task *t) { case task_type_sub_pair: if (subtype == task_subtype_grav) { /* Lock the gparts and the m-pole in both cells */ - if (ci->grav.ghold || cj->grav.ghold) return 0; + if (ci->grav.phold || cj->grav.phold) return 0; if (cell_glocktree(ci) != 0) return 0; if (cell_glocktree(cj) != 0) { cell_gunlocktree(ci); @@ -465,7 +465,7 @@ int task_lock(struct task *t) { case task_type_grav_down: /* Lock the gparts and the m-poles */ - if (ci->grav.ghold || ci->grav.mhold) return 0; + if (ci->grav.phold || ci->grav.mhold) return 0; if (cell_glocktree(ci) != 0) return 0; else if (cell_mlocktree(ci) != 0) { diff --git a/src/tools.c b/src/tools.c index 8aa040ae17489cce912884269b0f771773a89baa..ff33afbca3fdc97ede61ff09998d8dc27bf0154b 100644 --- a/src/tools.c +++ b/src/tools.c @@ -347,8 +347,8 @@ void pairs_all_stars_density(struct runner *r, struct cell *ci, const float H = cosmo->H; /* Implements a double-for loop and checks every interaction */ - for (int i = 0; i < ci->scount; ++i) { - struct spart *spi = &ci->sparts[i]; + for (int i = 0; i < ci->stars.count; ++i) { + struct spart *spi = &ci->stars.parts[i]; float hi = spi->h; float hig2 = hi * hi * kernel_gamma2; @@ -377,9 +377,9 @@ void pairs_all_stars_density(struct runner *r, struct cell *ci, } /* Reverse double-for loop and checks every interaction */ - for (int j = 0; j < cj->scount; ++j) { + for (int j = 0; j < cj->stars.count; ++j) { - struct spart *spj = &cj->sparts[j]; + struct spart *spj = &cj->stars.parts[j]; float hj = spj->h; float hjg2 = hj * hj * kernel_gamma2; @@ -510,9 +510,9 @@ void self_all_stars_density(struct runner *r, struct cell *ci) { const float H = cosmo->H; /* Implements a double-for loop and checks every interaction */ - for (int i = 0; i < ci->scount; ++i) { + for (int i = 0; i < ci->stars.count; ++i) { - spi = &ci->sparts[i]; + spi = &ci->stars.parts[i]; hi = spi->h; hig2 = hi * hi * kernel_gamma2; diff --git a/tests/test125cells.c b/tests/test125cells.c index 8f4cd8d0daad87e335c7647f36c2daeb85d94a28..a26813ee61597c3b5c974eac2ef14b2c383328eb 100644 --- a/tests/test125cells.c +++ b/tests/test125cells.c @@ -348,8 +348,8 @@ struct cell *make_cell(size_t n, const double offset[3], double size, double h, cell->split = 0; cell->hydro.h_max = h_max; cell->hydro.count = count; - cell->grav.gcount = 0; - cell->hydro.dx_max = 0.; + cell->grav.count = 0; + cell->hydro.dx_max_part = 0.; cell->hydro.dx_max_sort = 0.; cell->width[0] = size; cell->width[1] = size; @@ -358,7 +358,7 @@ struct cell *make_cell(size_t n, const double offset[3], double size, double h, cell->loc[1] = offset[1]; cell->loc[2] = offset[2]; - cell->hydro.ti_old = 8; + cell->hydro.ti_old_part = 8; cell->hydro.ti_end_min = 8; cell->hydro.ti_end_max = 8; cell->nodeID = NODE_ID; diff --git a/tests/test27cells.c b/tests/test27cells.c index 14e74bdaf55a1bbe3722980a852c48274ef981ec..0ba724c7da8051c10bb8205f2d9ad2ecbf3753c3 100644 --- a/tests/test27cells.c +++ b/tests/test27cells.c @@ -184,7 +184,7 @@ struct cell *make_cell(size_t n, double *offset, double size, double h, cell->split = 0; cell->hydro.h_max = h_max; cell->hydro.count = count; - cell->hydro.dx_max = 0.; + cell->hydro.dx_max_part = 0.; cell->hydro.dx_max_sort = 0.; cell->width[0] = size; cell->width[1] = size; @@ -193,7 +193,7 @@ struct cell *make_cell(size_t n, double *offset, double size, double h, cell->loc[1] = offset[1]; cell->loc[2] = offset[2]; - cell->hydro.ti_old = 8; + cell->hydro.ti_old_part = 8; cell->hydro.ti_end_min = 8; cell->hydro.ti_end_max = 8; cell->nodeID = NODE_ID; diff --git a/tests/test27cellsStars.c b/tests/test27cellsStars.c index cbb5b1b0fbce5c9c94791eabc01ae154c04be38b..3875bf75b1bb315bf48acae13b9553c689416a18 100644 --- a/tests/test27cellsStars.c +++ b/tests/test27cellsStars.c @@ -116,13 +116,13 @@ struct cell *make_cell(size_t n, size_t n_stars, double *offset, double size, } /* Construct the sparts */ - if (posix_memalign((void **)&cell->sparts, spart_align, + if (posix_memalign((void **)&cell->stars.parts, spart_align, scount * sizeof(struct spart)) != 0) { error("couldn't allocate particles, no. of particles: %d", (int)scount); } - bzero(cell->sparts, scount * sizeof(struct spart)); + bzero(cell->stars.parts, scount * sizeof(struct spart)); - struct spart *spart = cell->sparts; + struct spart *spart = cell->stars.parts; for (size_t x = 0; x < n_stars; ++x) { for (size_t y = 0; y < n_stars; ++y) { for (size_t z = 0; z < n_stars; ++z) { @@ -161,8 +161,8 @@ struct cell *make_cell(size_t n, size_t n_stars, double *offset, double size, cell->split = 0; cell->hydro.h_max = h_max; cell->hydro.count = count; - cell->scount = scount; - cell->hydro.dx_max = 0.; + cell->stars.count = scount; + cell->hydro.dx_max_part = 0.; cell->hydro.dx_max_sort = 0.; cell->width[0] = size; cell->width[1] = size; @@ -171,7 +171,7 @@ struct cell *make_cell(size_t n, size_t n_stars, double *offset, double size, cell->loc[1] = offset[1]; cell->loc[2] = offset[2]; - cell->hydro.ti_old = 8; + cell->hydro.ti_old_part = 8; cell->hydro.ti_end_min = 8; cell->hydro.ti_end_max = 8; cell->grav.ti_end_min = 8; @@ -179,7 +179,7 @@ struct cell *make_cell(size_t n, size_t n_stars, double *offset, double size, cell->nodeID = NODE_ID; shuffle_particles(cell->hydro.parts, cell->hydro.count); - shuffle_sparticles(cell->sparts, cell->scount); + shuffle_sparticles(cell->stars.parts, cell->stars.count); cell->hydro.sorted = 0; for (int k = 0; k < 13; k++) cell->hydro.sort[k] = NULL; @@ -189,7 +189,7 @@ struct cell *make_cell(size_t n, size_t n_stars, double *offset, double size, void clean_up(struct cell *ci) { free(ci->hydro.parts); - free(ci->sparts); + free(ci->stars.parts); for (int k = 0; k < 13; k++) if (ci->hydro.sort[k] != NULL) free(ci->hydro.sort[k]); free(ci); @@ -199,8 +199,8 @@ void clean_up(struct cell *ci) { * @brief Initializes all particles field to be ready for a density calculation */ void zero_particle_fields(struct cell *c) { - for (int pid = 0; pid < c->scount; pid++) { - stars_init_spart(&c->sparts[pid]); + for (int pid = 0; pid < c->stars.count; pid++) { + stars_init_spart(&c->stars.parts[pid]); } } @@ -208,12 +208,12 @@ void zero_particle_fields(struct cell *c) { * @brief Ends the loop by adding the appropriate coefficients */ void end_calculation(struct cell *c, const struct cosmology *cosmo) { - for (int pid = 0; pid < c->scount; pid++) { - stars_end_density(&c->sparts[pid], cosmo); + for (int pid = 0; pid < c->stars.count; pid++) { + stars_end_density(&c->stars.parts[pid], cosmo); /* Recover the common "Neighbour number" definition */ - c->sparts[pid].density.wcount *= pow_dimension(c->sparts[pid].h); - c->sparts[pid].density.wcount *= kernel_norm; + c->stars.parts[pid].density.wcount *= pow_dimension(c->stars.parts[pid].h); + c->stars.parts[pid].density.wcount *= kernel_norm; } } @@ -231,11 +231,12 @@ void dump_particle_fields(char *fileName, struct cell *main_cell, fprintf(file, "# Main cell --------------------------------------------\n"); /* Write main cell */ - for (int pid = 0; pid < main_cell->scount; pid++) { - fprintf(file, "%6llu %10f %10f %10f %13e %13e\n", main_cell->sparts[pid].id, - main_cell->sparts[pid].x[0], main_cell->sparts[pid].x[1], - main_cell->sparts[pid].x[2], main_cell->sparts[pid].density.wcount, - main_cell->sparts[pid].density.wcount_dh); + for (int pid = 0; pid < main_cell->stars.count; pid++) { + fprintf(file, "%6llu %10f %10f %10f %13e %13e\n", + main_cell->stars.parts[pid].id, main_cell->stars.parts[pid].x[0], + main_cell->stars.parts[pid].x[1], main_cell->stars.parts[pid].x[2], + main_cell->stars.parts[pid].density.wcount, + main_cell->stars.parts[pid].density.wcount_dh); } /* Write all other cells */ @@ -249,11 +250,12 @@ void dump_particle_fields(char *fileName, struct cell *main_cell, "# Offset: [%2d %2d %2d] -----------------------------------\n", i - 1, j - 1, k - 1); - for (int pjd = 0; pjd < cj->scount; pjd++) { - fprintf(file, "%6llu %10f %10f %10f %13e %13e\n", cj->sparts[pjd].id, - cj->sparts[pjd].x[0], cj->sparts[pjd].x[1], - cj->sparts[pjd].x[2], cj->sparts[pjd].density.wcount, - cj->sparts[pjd].density.wcount_dh); + for (int pjd = 0; pjd < cj->stars.count; pjd++) { + fprintf(file, "%6llu %10f %10f %10f %13e %13e\n", + cj->stars.parts[pjd].id, cj->stars.parts[pjd].x[0], + cj->stars.parts[pjd].x[1], cj->stars.parts[pjd].x[2], + cj->stars.parts[pjd].density.wcount, + cj->stars.parts[pjd].density.wcount_dh); } } } @@ -433,10 +435,10 @@ int main(int argc, char *argv[]) { #if defined(TEST_DOSELF_SUBSET) || defined(TEST_DOPAIR_SUBSET) int *pid = NULL; int scount = 0; - if ((pid = (int *)malloc(sizeof(int) * main_cell->scount)) == NULL) + if ((pid = (int *)malloc(sizeof(int) * main_cell->stars.count)) == NULL) error("Can't allocate memory for pid."); - for (int k = 0; k < main_cell->scount; k++) - if (spart_is_active(&main_cell->sparts[k], &engine)) { + for (int k = 0; k < main_cell->stars.count; k++) + if (spart_is_active(&main_cell->stars.parts[k], &engine)) { pid[scount] = k; ++scount; } @@ -448,7 +450,7 @@ int main(int argc, char *argv[]) { const ticks sub_tic = getticks(); #ifdef TEST_DOPAIR_SUBSET - DOPAIR1_SUBSET(&runner, main_cell, main_cell->sparts, pid, scount, + DOPAIR1_SUBSET(&runner, main_cell, main_cell->stars.parts, pid, scount, cells[j]); #else DOPAIR1(&runner, main_cell, cells[j]); @@ -462,7 +464,7 @@ int main(int argc, char *argv[]) { const ticks self_tic = getticks(); #ifdef TEST_DOSELF_SUBSET - DOSELF1_SUBSET(&runner, main_cell, main_cell->sparts, pid, scount); + DOSELF1_SUBSET(&runner, main_cell, main_cell->stars.parts, pid, scount); #else DOSELF1(&runner, main_cell); #endif diff --git a/tests/testActivePair.c b/tests/testActivePair.c index 8d585611579a1d0d9885272eb17439afa931a026..a96e4f661c06b75c14fd3b96fc3d28376b0b959e 100644 --- a/tests/testActivePair.c +++ b/tests/testActivePair.c @@ -137,7 +137,7 @@ struct cell *make_cell(size_t n, double *offset, double size, double h, cell->split = 0; cell->hydro.h_max = h_max; cell->hydro.count = count; - cell->hydro.dx_max = 0.; + cell->hydro.dx_max_part = 0.; cell->hydro.dx_max_sort = 0.; cell->width[0] = size; cell->width[1] = size; @@ -146,7 +146,7 @@ struct cell *make_cell(size_t n, double *offset, double size, double h, cell->loc[1] = offset[1]; cell->loc[2] = offset[2]; - cell->hydro.ti_old = 8; + cell->hydro.ti_old_part = 8; cell->hydro.ti_end_min = 8; cell->hydro.ti_end_max = 10; cell->nodeID = NODE_ID; diff --git a/tests/testPeriodicBC.c b/tests/testPeriodicBC.c index bf1d7bafb1d8fada7834c53cf33136a6a1faaa40..e4a5a85845f92bfbecae85d9dc9453b38b9b7646 100644 --- a/tests/testPeriodicBC.c +++ b/tests/testPeriodicBC.c @@ -163,7 +163,7 @@ struct cell *make_cell(size_t n, double *offset, double size, double h, cell->split = 0; cell->hydro.h_max = h_max; cell->hydro.count = count; - cell->hydro.dx_max = 0.; + cell->hydro.dx_max_part = 0.; cell->hydro.dx_max_sort = 0.; cell->width[0] = size; cell->width[1] = size; @@ -172,7 +172,7 @@ struct cell *make_cell(size_t n, double *offset, double size, double h, cell->loc[1] = offset[1]; cell->loc[2] = offset[2]; - cell->hydro.ti_old = 8; + cell->hydro.ti_old_part = 8; cell->hydro.ti_end_min = 8; cell->hydro.ti_end_max = 8; cell->nodeID = NODE_ID; diff --git a/tests/testPotentialPair.c b/tests/testPotentialPair.c index 7fe632cf3b35b91d2dd6027750a159973eb84505..171703873d7388b36b96b130b4e54f65476a8511 100644 --- a/tests/testPotentialPair.c +++ b/tests/testPotentialPair.c @@ -149,8 +149,8 @@ int main(int argc, char *argv[]) { ci.loc[0] = 0.; ci.loc[1] = 0.; ci.loc[2] = 0.; - ci.grav.gcount = 1; - ci.grav.ti_old_gpart = 8; + ci.grav.count = 1; + ci.grav.ti_old_part = 8; ci.grav.ti_old_multipole = 8; ci.grav.ti_end_min = 8; ci.grav.ti_end_max = 8; @@ -162,8 +162,8 @@ int main(int argc, char *argv[]) { cj.loc[0] = 1.; cj.loc[1] = 0.; cj.loc[2] = 0.; - cj.grav.gcount = num_tests; - cj.grav.ti_old_gpart = 8; + cj.grav.count = num_tests; + cj.grav.ti_old_part = 8; cj.grav.ti_old_multipole = 8; cj.grav.ti_end_min = 8; cj.grav.ti_end_max = 8; @@ -181,20 +181,20 @@ int main(int argc, char *argv[]) { cj.grav.multipole->r_max = 0.1; /* Allocate the particles */ - if (posix_memalign((void **)&ci.grav.gparts, gpart_align, - ci.grav.gcount * sizeof(struct gpart)) != 0) + if (posix_memalign((void **)&ci.grav.parts, gpart_align, + ci.grav.count * sizeof(struct gpart)) != 0) error("Error allocating gparts for cell ci"); - bzero(ci.grav.gparts, ci.grav.gcount * sizeof(struct gpart)); + bzero(ci.grav.parts, ci.grav.count * sizeof(struct gpart)); - if (posix_memalign((void **)&cj.grav.gparts, gpart_align, - cj.grav.gcount * sizeof(struct gpart)) != 0) + if (posix_memalign((void **)&cj.grav.parts, gpart_align, + cj.grav.count * sizeof(struct gpart)) != 0) error("Error allocating gparts for cell ci"); - bzero(cj.grav.gparts, cj.grav.gcount * sizeof(struct gpart)); + bzero(cj.grav.parts, cj.grav.count * sizeof(struct gpart)); /* Create the mass-less test particles */ for (int n = 0; n < num_tests; ++n) { - struct gpart *gp = &cj.grav.gparts[n]; + struct gpart *gp = &cj.grav.parts[n]; gp->x[0] = 1. + (n + 1) / ((double)num_tests); gp->x[1] = 0.5; @@ -213,15 +213,15 @@ int main(int argc, char *argv[]) { /***********************************************/ /* Create the massive particle */ - ci.grav.gparts[0].x[0] = 0.; - ci.grav.gparts[0].x[1] = 0.5; - ci.grav.gparts[0].x[2] = 0.5; - ci.grav.gparts[0].mass = 1.; - ci.grav.gparts[0].time_bin = 1; - ci.grav.gparts[0].type = swift_type_dark_matter; - ci.grav.gparts[0].id_or_neg_offset = 1; + ci.grav.parts[0].x[0] = 0.; + ci.grav.parts[0].x[1] = 0.5; + ci.grav.parts[0].x[2] = 0.5; + ci.grav.parts[0].mass = 1.; + ci.grav.parts[0].time_bin = 1; + ci.grav.parts[0].type = swift_type_dark_matter; + ci.grav.parts[0].id_or_neg_offset = 1; #ifdef SWIFT_DEBUG_CHECKS - ci.grav.gparts[0].ti_drift = 8; + ci.grav.parts[0].ti_drift = 8; #endif /* Now compute the forces */ @@ -229,18 +229,18 @@ int main(int argc, char *argv[]) { /* Verify everything */ for (int n = 0; n < num_tests; ++n) { - const struct gpart *gp = &cj.grav.gparts[n]; - const struct gpart *gp2 = &ci.grav.gparts[0]; + const struct gpart *gp = &cj.grav.parts[n]; + const struct gpart *gp2 = &ci.grav.parts[0]; const double epsilon = gravity_get_softening(gp, &props); #if defined(POTENTIAL_GRAVITY) double pot_true = - potential(ci.grav.gparts[0].mass, gp->x[0] - gp2->x[0], epsilon, rlr); + potential(ci.grav.parts[0].mass, gp->x[0] - gp2->x[0], epsilon, rlr); check_value(gp->potential, pot_true, "potential"); #endif - double acc_true = acceleration(ci.grav.gparts[0].mass, gp->x[0] - gp2->x[0], - epsilon, rlr); + double acc_true = + acceleration(ci.grav.parts[0].mass, gp->x[0] - gp2->x[0], epsilon, rlr); /* message("x=%e f=%e f_true=%e pot=%e pot_true=%e", gp->x[0] - gp2->x[0], gp->a_grav[0], acc_true, gp->potential, pot_true); */ @@ -251,7 +251,7 @@ int main(int argc, char *argv[]) { message("\n\t\t P-P interactions all good\n"); /* Reset the accelerations */ - for (int n = 0; n < num_tests; ++n) gravity_init_gpart(&cj.grav.gparts[n]); + for (int n = 0; n < num_tests; ++n) gravity_init_gpart(&cj.grav.parts[n]); /**********************************/ /* Test the basic PM interactions */ @@ -260,7 +260,7 @@ int main(int argc, char *argv[]) { /* Set an opening angle that allows P-M interactions */ props.theta_crit2 = 1.; - ci.grav.gparts[0].mass = 0.; + ci.grav.parts[0].mass = 0.; ci.grav.multipole->CoM[0] = 0.; ci.grav.multipole->CoM[1] = 0.5; ci.grav.multipole->CoM[2] = 0.5; @@ -274,7 +274,7 @@ int main(int argc, char *argv[]) { /* Verify everything */ for (int n = 0; n < num_tests; ++n) { - const struct gpart *gp = &cj.grav.gparts[n]; + const struct gpart *gp = &cj.grav.parts[n]; const struct gravity_tensors *mpole = ci.grav.multipole; const double epsilon = gravity_get_softening(gp, &props); @@ -297,7 +297,7 @@ int main(int argc, char *argv[]) { #ifndef GADGET2_LONG_RANGE_CORRECTION /* Reset the accelerations */ - for (int n = 0; n < num_tests; ++n) gravity_init_gpart(&cj.grav.gparts[n]); + for (int n = 0; n < num_tests; ++n) gravity_init_gpart(&cj.grav.parts[n]); /***************************************/ /* Test the truncated PM interactions */ @@ -314,7 +314,7 @@ int main(int argc, char *argv[]) { /* Verify everything */ for (int n = 0; n < num_tests; ++n) { - const struct gpart *gp = &cj.grav.gparts[n]; + const struct gpart *gp = &cj.grav.parts[n]; const struct gravity_tensors *mpole = ci.grav.multipole; const double epsilon = gravity_get_softening(gp, &props); @@ -342,48 +342,48 @@ int main(int argc, char *argv[]) { /************************************************/ /* Reset the accelerations */ - for (int n = 0; n < num_tests; ++n) gravity_init_gpart(&cj.grav.gparts[n]); + for (int n = 0; n < num_tests; ++n) gravity_init_gpart(&cj.grav.parts[n]); #if SELF_GRAVITY_MULTIPOLE_ORDER >= 3 /* Let's make ci more interesting */ - free(ci.grav.gparts); - ci.grav.gcount = 8; - if (posix_memalign((void **)&ci.grav.gparts, gpart_align, - ci.grav.gcount * sizeof(struct gpart)) != 0) + free(ci.grav.parts); + ci.grav.count = 8; + if (posix_memalign((void **)&ci.grav.parts, gpart_align, + ci.grav.count * sizeof(struct gpart)) != 0) error("Error allocating gparts for cell ci"); - bzero(ci.grav.gparts, ci.grav.gcount * sizeof(struct gpart)); + bzero(ci.grav.parts, ci.grav.count * sizeof(struct gpart)); /* Place particles on a simple cube of side-length 0.2 */ for (int n = 0; n < 8; ++n) { if (n & 1) - ci.grav.gparts[n].x[0] = 0.0 - 0.1; + ci.grav.parts[n].x[0] = 0.0 - 0.1; else - ci.grav.gparts[n].x[0] = 0.0 + 0.1; + ci.grav.parts[n].x[0] = 0.0 + 0.1; if (n & 2) - ci.grav.gparts[n].x[1] = 0.5 - 0.1; + ci.grav.parts[n].x[1] = 0.5 - 0.1; else - ci.grav.gparts[n].x[1] = 0.5 + 0.1; + ci.grav.parts[n].x[1] = 0.5 + 0.1; if (n & 2) - ci.grav.gparts[n].x[2] = 0.5 - 0.1; + ci.grav.parts[n].x[2] = 0.5 - 0.1; else - ci.grav.gparts[n].x[2] = 0.5 + 0.1; + ci.grav.parts[n].x[2] = 0.5 + 0.1; - ci.grav.gparts[n].mass = 1. / 8.; + ci.grav.parts[n].mass = 1. / 8.; - ci.grav.gparts[n].time_bin = 1; - ci.grav.gparts[n].type = swift_type_dark_matter; - ci.grav.gparts[n].id_or_neg_offset = 1; + ci.grav.parts[n].time_bin = 1; + ci.grav.parts[n].type = swift_type_dark_matter; + ci.grav.parts[n].id_or_neg_offset = 1; #ifdef SWIFT_DEBUG_CHECKS - ci.grav.gparts[n].ti_drift = 8; + ci.grav.parts[n].ti_drift = 8; #endif } /* Now let's make a multipole out of it. */ gravity_reset(ci.grav.multipole); - gravity_P2M(ci.grav.multipole, ci.grav.gparts, ci.grav.gcount); + gravity_P2M(ci.grav.multipole, ci.grav.parts, ci.grav.count); gravity_multipole_print(&ci.grav.multipole->m_pole); @@ -392,7 +392,7 @@ int main(int argc, char *argv[]) { /* Verify everything */ for (int n = 0; n < num_tests; ++n) { - const struct gpart *gp = &cj.grav.gparts[n]; + const struct gpart *gp = &cj.grav.parts[n]; #if defined(POTENTIAL_GRAVITY) double pot_true = 0; @@ -400,7 +400,7 @@ int main(int argc, char *argv[]) { double acc_true[3] = {0., 0., 0.}; for (int i = 0; i < 8; ++i) { - const struct gpart *gp2 = &ci.grav.gparts[i]; + const struct gpart *gp2 = &ci.grav.parts[i]; const double epsilon = gravity_get_softening(gp, &props); const double dx[3] = {gp2->x[0] - gp->x[0], gp2->x[1] - gp->x[1], @@ -434,7 +434,7 @@ int main(int argc, char *argv[]) { free(ci.grav.multipole); free(cj.grav.multipole); - free(ci.grav.gparts); - free(cj.grav.gparts); + free(ci.grav.parts); + free(cj.grav.parts); return 0; } diff --git a/tests/testPotentialSelf.c b/tests/testPotentialSelf.c index b17fbf8684167a2b56554ce654b4b8176a22dd25..83775203cd46bc2b3fece54f7a7f5d1a1725c810 100644 --- a/tests/testPotentialSelf.c +++ b/tests/testPotentialSelf.c @@ -137,32 +137,32 @@ int main(int argc, char *argv[]) { c.loc[0] = 0.; c.loc[1] = 0.; c.loc[2] = 0.; - c.grav.gcount = 1 + num_tests; - c.grav.ti_old_gpart = 8; + c.grav.count = 1 + num_tests; + c.grav.ti_old_part = 8; c.grav.ti_end_min = 8; c.grav.ti_end_max = 8; - if (posix_memalign((void **)&c.grav.gparts, gpart_align, - c.grav.gcount * sizeof(struct gpart)) != 0) + if (posix_memalign((void **)&c.grav.parts, gpart_align, + c.grav.count * sizeof(struct gpart)) != 0) error("Impossible to allocate memory for the gparts."); - bzero(c.grav.gparts, c.grav.gcount * sizeof(struct gpart)); + bzero(c.grav.parts, c.grav.count * sizeof(struct gpart)); /* Create the massive particle */ - c.grav.gparts[0].x[0] = 0.; - c.grav.gparts[0].x[1] = 0.5; - c.grav.gparts[0].x[2] = 0.5; - c.grav.gparts[0].mass = 1.; - c.grav.gparts[0].time_bin = 1; - c.grav.gparts[0].type = swift_type_dark_matter; - c.grav.gparts[0].id_or_neg_offset = 1; + c.grav.parts[0].x[0] = 0.; + c.grav.parts[0].x[1] = 0.5; + c.grav.parts[0].x[2] = 0.5; + c.grav.parts[0].mass = 1.; + c.grav.parts[0].time_bin = 1; + c.grav.parts[0].type = swift_type_dark_matter; + c.grav.parts[0].id_or_neg_offset = 1; #ifdef SWIFT_DEBUG_CHECKS - c.grav.gparts[0].ti_drift = 8; + c.grav.parts[0].ti_drift = 8; #endif /* Create the mass-less particles */ for (int n = 1; n < num_tests + 1; ++n) { - struct gpart *gp = &c.grav.gparts[n]; + struct gpart *gp = &c.grav.parts[n]; gp->x[0] = n / ((double)num_tests); gp->x[1] = 0.5; @@ -181,22 +181,22 @@ int main(int argc, char *argv[]) { /* Verify everything */ for (int n = 1; n < num_tests + 1; ++n) { - const struct gpart *gp = &c.grav.gparts[n]; + const struct gpart *gp = &c.grav.parts[n]; const double epsilon = gravity_get_softening(gp, &props); #if defined(POTENTIAL_GRAVITY) - double pot_true = potential(c.grav.gparts[0].mass, gp->x[0], epsilon, rlr); + double pot_true = potential(c.grav.parts[0].mass, gp->x[0], epsilon, rlr); check_value(gp->potential, pot_true, "potential"); #endif double acc_true = - acceleration(c.grav.gparts[0].mass, gp->x[0], epsilon, rlr); + acceleration(c.grav.parts[0].mass, gp->x[0], epsilon, rlr); check_value(gp->a_grav[0], acc_true, "acceleration"); // message("x=%e f=%e f_true=%e", gp->x[0], gp->a_grav[0], acc_true); } - free(c.grav.gparts); + free(c.grav.parts); return 0; } diff --git a/tests/testSPHStep.c b/tests/testSPHStep.c index b74bf06dc206df6ad0c694c25bddf8834276b317..41694872efbfc4d9611127eb1e6324b2b0fa5500 100644 --- a/tests/testSPHStep.c +++ b/tests/testSPHStep.c @@ -70,8 +70,8 @@ struct cell *make_cell(size_t N, float cellSize, int offset[3], int id_offset) { cell->split = 0; cell->hydro.h_max = h; cell->hydro.count = count; - cell->grav.gcount = 0; - cell->hydro.dx_max = 0.; + cell->grav.count = 0; + cell->hydro.dx_max_part = 0.; cell->hydro.dx_max_sort = 0.; cell->width[0] = cellSize; cell->width[1] = cellSize;