Commit 50950bb0 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Add new function to decide on recursion with in a sub_pair task. Makes sure...

Add new function to decide on recursion with in a sub_pair task. Makes sure all recursion tests are identical.
parent d7346105
...@@ -1316,6 +1316,19 @@ int cell_is_drift_needed(struct cell *c, const struct engine *e) { ...@@ -1316,6 +1316,19 @@ int cell_is_drift_needed(struct cell *c, const struct engine *e) {
return 0; return 0;
} }
/**
* @brief Can a task recurse to a lower level based on the staus of the particles
* in the cell.
*
* @param c The #cell.
*/
int cell_can_recurse_in_pair_task(const struct cell *c) {
return c->split &&
(2.f * kernel_gamma * space_stretch * (c->h_max_old + c->dx_max_old) <
c->dmin);
}
/** /**
* @brief Traverse a sub-cell task and activate the sort tasks along the way. * @brief Traverse a sub-cell task and activate the sort tasks along the way.
*/ */
...@@ -1353,13 +1366,8 @@ void cell_activate_subcell_tasks(struct cell *ci, struct cell *cj, ...@@ -1353,13 +1366,8 @@ void cell_activate_subcell_tasks(struct cell *ci, struct cell *cj,
} }
/* Otherwise, pair interation, recurse? */ /* Otherwise, pair interation, recurse? */
else if (ci->split && cj->split && else if (cell_can_recurse_in_pair_task(ci) &&
2.f * kernel_gamma * space_stretch * cell_can_recurse_in_pair_task(cj)) {
(ci->h_max_old + ci->dx_max_old) <
ci->dmin &&
2.f * kernel_gamma * space_stretch *
(cj->h_max_old + cj->dx_max_old) <
cj->dmin) {
/* Get the type of pair if not specified explicitly. */ /* Get the type of pair if not specified explicitly. */
double shift[3]; double shift[3];
......
...@@ -388,5 +388,5 @@ void cell_check_timesteps(struct cell *c); ...@@ -388,5 +388,5 @@ void cell_check_timesteps(struct cell *c);
void cell_store_pre_drift_values(struct cell *c); void cell_store_pre_drift_values(struct cell *c);
void cell_activate_subcell_tasks(struct cell *ci, struct cell *cj, void cell_activate_subcell_tasks(struct cell *ci, struct cell *cj,
struct scheduler *s); struct scheduler *s);
int cell_can_recurse_in_pair_task(const struct cell *c);
#endif /* SWIFT_CELL_H */ #endif /* SWIFT_CELL_H */
...@@ -2096,11 +2096,7 @@ void DOSUB_PAIR1(struct runner *r, struct cell *ci, struct cell *cj, int sid, ...@@ -2096,11 +2096,7 @@ void DOSUB_PAIR1(struct runner *r, struct cell *ci, struct cell *cj, int sid,
sid = space_getsid(s, &ci, &cj, shift); sid = space_getsid(s, &ci, &cj, shift);
/* Recurse? */ /* Recurse? */
if (ci->split && cj->split && if (cell_can_recurse_in_pair_task(ci) && cell_can_recurse_in_pair_task(cj)) {
2.f * kernel_gamma * space_stretch * (ci->h_max_old + ci->dx_max_old) <
ci->dmin &&
2.f * kernel_gamma * space_stretch * (cj->h_max_old + cj->dx_max_old) <
cj->dmin) {
/* Different types of flags. */ /* Different types of flags. */
switch (sid) { switch (sid) {
...@@ -2395,11 +2391,7 @@ void DOSUB_PAIR2(struct runner *r, struct cell *ci, struct cell *cj, int sid, ...@@ -2395,11 +2391,7 @@ void DOSUB_PAIR2(struct runner *r, struct cell *ci, struct cell *cj, int sid,
sid = space_getsid(s, &ci, &cj, shift); sid = space_getsid(s, &ci, &cj, shift);
/* Recurse? */ /* Recurse? */
if (ci->split && cj->split && if (cell_can_recurse_in_pair_task(ci) && cell_can_recurse_in_pair_task(cj)) {
2.f * kernel_gamma * space_stretch * (ci->h_max_old + ci->dx_max_old) <
ci->dmin &&
2.f * kernel_gamma * space_stretch * (cj->h_max_old + cj->dx_max_old) <
cj->dmin) {
/* Different types of flags. */ /* Different types of flags. */
switch (sid) { switch (sid) {
...@@ -2706,11 +2698,8 @@ void DOSUB_SUBSET(struct runner *r, struct cell *ci, struct part *parts, ...@@ -2706,11 +2698,8 @@ void DOSUB_SUBSET(struct runner *r, struct cell *ci, struct part *parts,
else { else {
/* Recurse? */ /* Recurse? */
if (ci->split && cj->split && if (cell_can_recurse_in_pair_task(ci) &&
2.f * kernel_gamma * space_stretch * (ci->h_max_old + ci->dx_max_old) < cell_can_recurse_in_pair_task(cj)) {
ci->dmin &&
2.f * kernel_gamma * space_stretch * (cj->h_max_old + cj->dx_max_old) <
cj->dmin) {
/* Get the type of pair if not specified explicitly. */ /* Get the type of pair if not specified explicitly. */
double shift[3] = {0.0, 0.0, 0.0}; double shift[3] = {0.0, 0.0, 0.0};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment