Commit 3d63d354 authored by Loic Hausammann's avatar Loic Hausammann
Browse files

Update cell.h with required modifications

parent 9470da94
...@@ -1096,10 +1096,10 @@ int main(int argc, char *argv[]) { ...@@ -1096,10 +1096,10 @@ int main(int argc, char *argv[]) {
? e.sched.tasks[l].cj->hydro.count ? e.sched.tasks[l].cj->hydro.count
: 0, : 0,
(e.sched.tasks[l].ci != NULL) (e.sched.tasks[l].ci != NULL)
? e.sched.tasks[l].ci->grav.gcount ? e.sched.tasks[l].ci->grav.count
: 0, : 0,
(e.sched.tasks[l].cj != NULL) (e.sched.tasks[l].cj != NULL)
? e.sched.tasks[l].cj->grav.gcount ? e.sched.tasks[l].cj->grav.count
: 0, : 0,
e.sched.tasks[l].flags, e.sched.tasks[l].sid); e.sched.tasks[l].flags, e.sched.tasks[l].sid);
} }
...@@ -1134,9 +1134,9 @@ int main(int argc, char *argv[]) { ...@@ -1134,9 +1134,9 @@ int main(int argc, char *argv[]) {
(e.sched.tasks[l].cj == NULL) ? 0 (e.sched.tasks[l].cj == NULL) ? 0
: e.sched.tasks[l].cj->hydro.count, : e.sched.tasks[l].cj->hydro.count,
(e.sched.tasks[l].ci == NULL) ? 0 (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 == NULL) ? 0
: e.sched.tasks[l].cj->grav.gcount, : e.sched.tasks[l].cj->grav.count,
e.sched.tasks[l].sid); e.sched.tasks[l].sid);
} }
} }
......
...@@ -39,15 +39,16 @@ __attribute__((always_inline)) INLINE static int cell_are_part_drifted( ...@@ -39,15 +39,16 @@ __attribute__((always_inline)) INLINE static int cell_are_part_drifted(
const struct cell *c, const struct engine *e) { const struct cell *c, const struct engine *e) {
#ifdef SWIFT_DEBUG_CHECKS #ifdef SWIFT_DEBUG_CHECKS
if (c->hydro.ti_old > e->ti_current) if (c->hydro.ti_old_part > e->ti_current)
error( 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)", "and e->ti_current=%lld (t=%e, a=%e)",
c->hydro.ti_old, c->hydro.ti_old * e->time_base, e->ti_current, c->hydro.ti_old_part, c->hydro.ti_old_part * e->time_base,
e->ti_current * e->time_base, e->cosmology->a); e->ti_current, e->ti_current * e->time_base, e->cosmology->a);
#endif #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( ...@@ -62,15 +63,15 @@ __attribute__((always_inline)) INLINE static int cell_are_gpart_drifted(
const struct cell *c, const struct engine *e) { const struct cell *c, const struct engine *e) {
#ifdef SWIFT_DEBUG_CHECKS #ifdef SWIFT_DEBUG_CHECKS
if (c->grav.ti_old_gpart > e->ti_current) if (c->grav.ti_old_part > e->ti_current)
error( 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=%lld (t=%e) "
"and e->ti_current=%lld (t=%e)", "and e->ti_current=%lld (t=%e)",
c->grav.ti_old_gpart, c->grav.ti_old_gpart * e->time_base, c->grav.ti_old_part, c->grav.ti_old_part * e->time_base, e->ti_current,
e->ti_current, e->ti_current * e->time_base); e->ti_current * e->time_base);
#endif #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 ? */ /* Are cells / particles active for regular tasks ? */
......
...@@ -278,7 +278,7 @@ __attribute__((always_inline)) INLINE void cache_read_particles_subset( ...@@ -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 /* 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 * interact. We use values of the same magnitude (but negative!) as the real
* particles to avoid overflow problems. */ * 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), const float pos_padded[3] = {-(2. * ci->width[0] + max_dx),
-(2. * ci->width[1] + max_dx), -(2. * ci->width[1] + max_dx),
-(2. * ci->width[2] + max_dx)}; -(2. * ci->width[2] + max_dx)};
...@@ -326,7 +326,7 @@ __attribute__((always_inline)) INLINE void cache_read_particles_subset( ...@@ -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 /* 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 * interact. We use values of the same magnitude (but negative!) as the real
* particles to avoid overflow problems. */ * 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), const float pos_padded[3] = {-(2. * ci->width[0] + max_dx),
-(2. * ci->width[1] + max_dx), -(2. * ci->width[1] + max_dx),
-(2. * ci->width[2] + max_dx)}; -(2. * ci->width[2] + max_dx)};
...@@ -491,11 +491,14 @@ __attribute__((always_inline)) INLINE void cache_read_two_partial_cells_sorted( ...@@ -491,11 +491,14 @@ __attribute__((always_inline)) INLINE void cache_read_two_partial_cells_sorted(
#ifdef SWIFT_DEBUG_CHECKS #ifdef SWIFT_DEBUG_CHECKS
const float shift_threshold_x = 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 = 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 = 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. */ /* Make sure that particle positions have been shifted correctly. */
for (int i = 0; i < ci_cache_count; i++) { for (int i = 0; i < ci_cache_count; i++) {
...@@ -529,7 +532,7 @@ __attribute__((always_inline)) INLINE void cache_read_two_partial_cells_sorted( ...@@ -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 /* 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 * interact. We use values of the same magnitude (but negative!) as the real
* particles to avoid overflow problems. */ * 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), const float pos_padded[3] = {-(2. * ci->width[0] + max_dx),
-(2. * ci->width[1] + max_dx), -(2. * ci->width[1] + max_dx),
-(2. * ci->width[2] + max_dx)}; -(2. * ci->width[2] + max_dx)};
...@@ -723,7 +726,7 @@ cache_read_two_partial_cells_sorted_force( ...@@ -723,7 +726,7 @@ cache_read_two_partial_cells_sorted_force(
/* Pad cache with fake particles that exist outside the cell so will not /* 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 * interact. We use values of the same magnitude (but negative!) as the real
* particles to avoid overflow problems. */ * 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), const float pos_padded[3] = {-(2. * ci->width[0] + max_dx),
-(2. * ci->width[1] + max_dx), -(2. * ci->width[1] + max_dx),
-(2. * ci->width[2] + max_dx)}; -(2. * ci->width[2] + max_dx)};
......
This diff is collapsed.
...@@ -93,7 +93,7 @@ struct pcell { ...@@ -93,7 +93,7 @@ struct pcell {
integertime_t ti_beg_max; integertime_t ti_beg_max;
/*! Integer time of the last drift of the #part in this cell */ /*! 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. */ /*! Number of #part in this cell. */
int count; int count;
...@@ -128,21 +128,26 @@ struct pcell { ...@@ -128,21 +128,26 @@ struct pcell {
integertime_t ti_beg_max; integertime_t ti_beg_max;
/*! Integer time of the last drift of the #gpart in this cell */ /*! 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 */ /*! Integer time of the last drift of the #multipole in this cell */
integertime_t ti_old_multipole; integertime_t ti_old_multipole;
/*! Number of #gpart in this cell. */ /*! Number of #gpart in this cell. */
int gcount; int count;
} grav; } grav;
/*! Relative indices of the cell's progeny. */ /*! Stars variables */
int progeny[8]; struct {
/*! Number of #spart in this cell. */ /*! Number of #spart in this cell. */
int scount; int count;
} stars;
/*! Relative indices of the cell's progeny. */
int progeny[8];
#ifdef SWIFT_DEBUG_CHECKS #ifdef SWIFT_DEBUG_CHECKS
/* Cell ID (for debugging) */ /* Cell ID (for debugging) */
...@@ -166,7 +171,7 @@ struct pcell_step { ...@@ -166,7 +171,7 @@ struct pcell_step {
integertime_t ti_end_max; integertime_t ti_end_max;
/*! Maximal distance any #part has travelled since last rebuild */ /*! Maximal distance any #part has travelled since last rebuild */
float dx_max; float dx_max_part;
} hydro; } hydro;
...@@ -178,7 +183,12 @@ struct pcell_step { ...@@ -178,7 +183,12 @@ struct pcell_step {
/*! Minimal integer end-of-timestep in this cell (gravity) */ /*! Minimal integer end-of-timestep in this cell (gravity) */
integertime_t ti_end_max; integertime_t ti_end_max;
} grav; } grav;
/*! Stars variables */
struct {
} stars;
}; };
/** /**
...@@ -197,9 +207,6 @@ struct cell { ...@@ -197,9 +207,6 @@ struct cell {
/*! Linking pointer for "memory management". */ /*! Linking pointer for "memory management". */
struct cell *next; struct cell *next;
/*! Pointer to the #spart data. */
struct spart *sparts;
/*! Pointers to the next level of cells. */ /*! Pointers to the next level of cells. */
struct cell *progeny[8]; struct cell *progeny[8];
...@@ -226,10 +233,10 @@ struct cell { ...@@ -226,10 +233,10 @@ struct cell {
struct cell *super; struct cell *super;
/*! Last (integer) time the cell's part were drifted forward in time. */ /*! 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. */ /*! 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. */ /*! Maximum particle movement in this cell since the last sort. */
float dx_max_sort; float dx_max_sort;
...@@ -259,12 +266,12 @@ struct cell { ...@@ -259,12 +266,12 @@ struct cell {
/*! Is the #part data of this cell being used in a sub-cell? */ /*! Is the #part data of this cell being used in a sub-cell? */
int hold; 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. */ /*! Values of h_max before the drifts, used for sub-cell tasks. */
float h_max_old; 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. */ /*! Values of dx_max_sort before the drifts, used for sub-cell tasks. */
float dx_max_sort_old; float dx_max_sort_old;
...@@ -319,27 +326,6 @@ struct cell { ...@@ -319,27 +326,6 @@ struct cell {
/*! Task for cooling */ /*! Task for cooling */
struct task *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 #ifdef SWIFT_DEBUG_CHECKS
/*! Last (integer) time the cell's sort arrays were updated. */ /*! Last (integer) time the cell's sort arrays were updated. */
...@@ -353,7 +339,7 @@ struct cell { ...@@ -353,7 +339,7 @@ struct cell {
struct { struct {
/*! Pointer to the #gpart data. */ /*! Pointer to the #gpart data. */
struct gpart *gparts; struct gpart *parts;
/*! This cell's multipole. */ /*! This cell's multipole. */
struct gravity_tensors *multipole; struct gravity_tensors *multipole;
...@@ -373,25 +359,25 @@ struct cell { ...@@ -373,25 +359,25 @@ struct cell {
integertime_t ti_beg_max; integertime_t ti_beg_max;
/*! Last (integer) time the cell's gpart were drifted forward in time. */ /*! 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. */ /*! Last (integer) time the cell's multipole was drifted forward in time. */
integertime_t ti_old_multipole; integertime_t ti_old_multipole;
/*! Nr of #gpart in this cell. */ /*! Nr of #gpart in this cell. */
int gcount; int count;
/*! Spin lock for various uses (#gpart case). */ /*! Spin lock for various uses (#gpart case). */
swift_lock_type glock; swift_lock_type plock;
/*! Spin lock for various uses (#multipole case). */ /*! Spin lock for various uses (#multipole case). */
swift_lock_type mlock; swift_lock_type mlock;
/*! Number of #gpart updated in this cell. */ /*! 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? */ /*! 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? */ /*! Is the #multipole data of this cell being used in a sub-cell? */
int mhold; int mhold;
...@@ -403,7 +389,7 @@ struct cell { ...@@ -403,7 +389,7 @@ struct cell {
char do_sub_drift; char do_sub_drift;
/*! The drift task for gparts */ /*! The drift task for gparts */
struct task *drift_gpart; struct task *drift;
/*! Linked list of the tasks computing this cell's gravity forces. */ /*! Linked list of the tasks computing this cell's gravity forces. */
struct link *grav; struct link *grav;
...@@ -432,45 +418,74 @@ struct cell { ...@@ -432,45 +418,74 @@ struct cell {
/*! Number of M-M tasks that are associated with this cell. */ /*! Number of M-M tasks that are associated with this cell. */
short int nr_mm_tasks; short int nr_mm_tasks;
#ifdef WITH_MPI
/* Task receiving gpart data. */
struct task *recv;
/* Linked list for sending gpart data. */
struct link *send;
#endif
} grav; } grav;
/*! The first kick task */ /*! Stars variables */
struct task *kick1; struct {
/*! The second kick task */ /*! Pointer to the #spart data. */
struct task *kick2; struct spart *parts;
/*! The task to compute time-steps */ /*! Nr of #spart in this cell. */
struct task *timestep; int count;
/*! Dependency implicit task for the star ghost (in->ghost->out)*/ /*! Dependency implicit task for the star ghost (in->ghost->out)*/
struct task *stars_ghost_in; struct task *ghost_in;
/*! Dependency implicit task for the star ghost (in->ghost->out)*/ /*! Dependency implicit task for the star ghost (in->ghost->out)*/
struct task *stars_ghost_out; struct task *ghost_out;
/*! The star ghost task itself */ /*! The star ghost task itself */
struct task *stars_ghost; struct task *ghost;
/*! Linked list of the tasks computing this cell's star density. */ /*! Linked list of the tasks computing this cell's star density. */
struct link *stars_density; struct link *density;
/*! Task for source terms */ /*! Number of #spart updated in this cell. */
struct task *sourceterms; int updated;
/*! Is the #spart data of this cell being used in a sub-cell? */
int hold;
/*! Spin lock for various uses (#spart case). */
swift_lock_type lock;
} stars;
#ifdef WITH_MPI #ifdef WITH_MPI
/*! MPI variables */ /*! MPI variables */
struct { 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). */ /* Task receiving data (time-step). */
struct task *recv_ti; struct task *recv_ti;
...@@ -492,27 +507,27 @@ struct cell { ...@@ -492,27 +507,27 @@ struct cell {
} mpi; } mpi;
#endif #endif
/*! Minimum dimension, i.e. smallest edge of this cell (min(width)). */ /*! The first kick task */
float dmin; struct task *kick1;
/*! Nr of #spart in this cell. */ /*! The second kick task */
int scount; struct task *kick2;
/*! Spin lock for various uses (#spart case). */ /*! The task to compute time-steps */
swift_lock_type slock; 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. */ /*! ID of the previous owner, e.g. runner. */
int owner; int owner;
/*! Number of #spart updated in this cell. */
int s_updated;
/*! ID of the node this cell lives on. */ /*! ID of the node this cell lives on. */
int nodeID; 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. */ /*! Number of tasks that are associated with this cell. */
short int nr_tasks; short int nr_tasks;
...@@ -622,7 +637,7 @@ cell_can_recurse_in_pair_hydro_task(const struct cell *c) { ...@@ -622,7 +637,7 @@ cell_can_recurse_in_pair_hydro_task(const struct cell *c) {
/* smaller than the sub-cell sizes ? */ /* smaller than the sub-cell sizes ? */
/* Note: We use the _old values as these might have been updated by a drift */ /* 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 + 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( ...@@ -766,7 +781,7 @@ __attribute__((always_inline)) INLINE static int cell_need_rebuild_for_pair(
/* moved larger than the cell size ? */ /* moved larger than the cell size ? */
/* Note ci->dmin == cj->dmin */ /* Note ci->dmin == cj->dmin */
return (kernel_gamma * max(ci->hydro.h_max, cj->hydro.h_max) + 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); cj->dmin);
} }
......
...@@ -274,8 +274,8 @@ int checkCellhdxmax(const struct cell *c, int *depth) { ...@@ -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]); message("location: %f %f %f", c->loc[0], c->loc[1], c->loc[2]);
result = 0; result = 0;
} }
if (c->hydro.dx_max != dx_max) { if (c->hydro.dx_max_part != dx_max) {
message("%d Inconsistent dx_max: %f != %f", *depth, c->hydro.dx_max, message("%d Inconsistent dx_max: %f != %f", *depth, c->hydro.dx_max_part,
dx_max); dx_max);
message("location: %f %f %f", c->loc[0], c->loc[1], c->loc[2]); message("location: %f %f %f", c->loc[0], c->loc[1], c->loc[2]);
result = 0; result = 0;
...@@ -317,13 +317,13 @@ static void dumpCells_map(struct cell *c, void *data) { ...@@ -317,13 +317,13 @@ static void dumpCells_map(struct cell *c, void *data) {
#endif #endif
/* Only cells with particles are dumped. */