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) {
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.
*/
......@@ -1353,13 +1366,8 @@ void cell_activate_subcell_tasks(struct cell *ci, struct cell *cj,
}
/* Otherwise, pair interation, recurse? */
else if (ci->split && cj->split &&
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) {
else if (cell_can_recurse_in_pair_task(ci) &&
cell_can_recurse_in_pair_task(cj)) {
/* Get the type of pair if not specified explicitly. */
double shift[3];
......
......@@ -388,5 +388,5 @@ void cell_check_timesteps(struct cell *c);
void cell_store_pre_drift_values(struct cell *c);
void cell_activate_subcell_tasks(struct cell *ci, struct cell *cj,
struct scheduler *s);
int cell_can_recurse_in_pair_task(const struct cell *c);
#endif /* SWIFT_CELL_H */
......@@ -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);
/* Recurse? */
if (ci->split && cj->split &&
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) {
if (cell_can_recurse_in_pair_task(ci) && cell_can_recurse_in_pair_task(cj)) {
/* Different types of flags. */
switch (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);
/* Recurse? */
if (ci->split && cj->split &&
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) {
if (cell_can_recurse_in_pair_task(ci) && cell_can_recurse_in_pair_task(cj)) {
/* Different types of flags. */
switch (sid) {
......@@ -2706,11 +2698,8 @@ void DOSUB_SUBSET(struct runner *r, struct cell *ci, struct part *parts,
else {
/* Recurse? */
if (ci->split && cj->split &&
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) {
if (cell_can_recurse_in_pair_task(ci) &&
cell_can_recurse_in_pair_task(cj)) {
/* Get the type of pair if not specified explicitly. */
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