diff --git a/src/zoom_proxy.c b/src/zoom_proxy.c index 6f94382dee142973b212f3f0afd8299393104f1f..9cd134dab1531a3261026760bf6257430fcaa561 100644 --- a/src/zoom_proxy.c +++ b/src/zoom_proxy.c @@ -57,7 +57,7 @@ int find_proxy_type(struct cell *ci, struct cell *cj, struct engine *e, const double theta_crit = e->gravity_properties->theta_crit; const double max_mesh_dist = e->mesh->r_cut_max; const double max_mesh_dist2 = max_mesh_dist * max_mesh_dist; - + int proxy_type = 0; /* In the hydro case, only care about direct neighbours of the same @@ -65,8 +65,7 @@ int find_proxy_type(struct cell *ci, struct cell *cj, struct engine *e, if (with_hydro && ci->type == zoom && ci->type == cj->type) { /* Check for direct neighbours without periodic BC */ - if (is_adjacent) - proxy_type |= (int)proxy_cell_type_hydro; + if (is_adjacent) proxy_type |= (int)proxy_cell_type_hydro; } /* In the gravity case, check distances using the MAC. */ @@ -80,20 +79,20 @@ int find_proxy_type(struct cell *ci, struct cell *cj, struct engine *e, We then can decide whether we are too close for an M2L interaction and hence require a proxy as this pair of cells cannot rely on just an M2L calculation. */ - + /* Minimal distance between any two points in the cells. */ const double min_dist_CoM2 = cell_min_dist2(ci, cj, periodic, dim); - + /* Are we beyond the distance where the truncated forces are 0 * but not too far such that M2L can be used? */ if (periodic) { - + if ((min_dist_CoM2 < max_mesh_dist2) && !(4. * r_max * r_max < theta_crit * theta_crit * min_dist_CoM2)) proxy_type |= (int)proxy_cell_type_gravity; - + } else { - + if (!(4. * r_max * r_max < theta_crit * theta_crit * min_dist_CoM2)) { proxy_type |= (int)proxy_cell_type_gravity; } @@ -118,66 +117,66 @@ void add_proxy(struct cell *ci, struct cell *cj, struct engine *e, /* Add to proxies? */ if (ci->nodeID == nodeID && cj->nodeID != nodeID) { - + /* Do we already have a relationship with this node? */ int proxy_id = e->proxy_ind[cj->nodeID]; if (proxy_id < 0) { if (e->nr_proxies == engine_maxproxies) error("Maximum number of proxies exceeded."); - + /* Ok, start a new proxy for this pair of nodes */ - proxy_init(&proxies[e->nr_proxies], nodeID, - cj->nodeID); - + proxy_init(&proxies[e->nr_proxies], nodeID, cj->nodeID); + /* Store the information */ e->proxy_ind[cj->nodeID] = e->nr_proxies; proxy_id = e->nr_proxies; e->nr_proxies += 1; - + /* Check the maximal proxy limit */ if ((size_t)proxy_id > 8 * sizeof(long long)) - error("Created more than %zd proxies. cell.mpi.sendto will " - "overflow.", - 8 * sizeof(long long)); + error( + "Created more than %zd proxies. cell.mpi.sendto will " + "overflow.", + 8 * sizeof(long long)); } - + /* Add the cell to the proxy */ proxy_addcell_in(&proxies[proxy_id], cj, proxy_type); proxy_addcell_out(&proxies[proxy_id], ci, proxy_type); - + /* Store info about where to send the cell */ ci->mpi.sendto |= (1ULL << proxy_id); } - + /* Same for the symmetric case? */ if (cj->nodeID == nodeID && ci->nodeID != nodeID) { - + /* Do we already have a relationship with this node? */ int proxy_id = e->proxy_ind[ci->nodeID]; if (proxy_id < 0) { if (e->nr_proxies == engine_maxproxies) error("Maximum number of proxies exceeded."); - + /* Ok, start a new proxy for this pair of nodes */ - proxy_init(&proxies[e->nr_proxies], e->nodeID, - ci->nodeID); - + proxy_init(&proxies[e->nr_proxies], e->nodeID, ci->nodeID); + /* Store the information */ e->proxy_ind[ci->nodeID] = e->nr_proxies; proxy_id = e->nr_proxies; e->nr_proxies += 1; - + /* Check the maximal proxy limit */ if ((size_t)proxy_id > 8 * sizeof(long long)) - error("Created more than %zd proxies. cell.mpi.sendto will " - "overflow.", - 8 * sizeof(long long)); + error( + "Created more than %zd proxies. cell.mpi.sendto will " + "overflow.", + 8 * sizeof(long long)); } - + /* Add the cell to the proxy */ proxy_addcell_in(&proxies[proxy_id], ci, proxy_type); proxy_addcell_out(&proxies[proxy_id], cj, proxy_type); - + /* Store info about where to send the cell */ cj->mpi.sendto |= (1ULL << proxy_id); } @@ -194,8 +193,8 @@ void add_proxy(struct cell *ci, struct cell *cj, struct engine *e, * @param proxy_type What sort of proxy is this? */ void get_void_proxy(struct cell *c, struct cell *void_c, struct space *s, - struct proxy *proxies, const int nodeID, - double void_rmax, double zoom_rmax) { + struct proxy *proxies, const int nodeID, double void_rmax, + double zoom_rmax) { /* How many zoom cells? */ int nr_zoom_cells = s->zoom_props->nr_zoom_cells; @@ -214,15 +213,14 @@ void get_void_proxy(struct cell *c, struct cell *void_c, struct space *s, /* What type of proxy do we need? * (proxy_cell_type_none if no proxy needed). */ int proxy_type = - find_proxy_type(zoom_cj, c, s->e, 0 /*is_adjacent*/, - void_rmax + zoom_rmax, s->dim, s->periodic); + find_proxy_type(zoom_cj, c, s->e, 0 /*is_adjacent*/, + void_rmax + zoom_rmax, s->dim, s->periodic); /* Abort if not in range at all */ if (proxy_type == proxy_cell_type_none) return; /* Make the proxies. */ add_proxy(zoom_cj, c, s->e, proxies, nodeID, proxy_type); - } } #endif @@ -264,7 +262,7 @@ void engine_makeproxies_with_zoom_region(struct engine *e) { const int periodic = s->periodic; /* Set up cell offsets. */ - const int bkg_offset = s->zoom_props->bkg_cell_offset ; + const int bkg_offset = s->zoom_props->bkg_cell_offset; const int buff_offset = s->zoom_props->buffer_cell_offset; /* Set up some width and distance variables. */ @@ -341,7 +339,8 @@ void engine_makeproxies_with_zoom_region(struct engine *e) { if (e->verbose) message( "Looking for proxies up to %d top-level background cells away " - "(delta_m=%d delta_p=%d)", delta_cells, delta_m, delta_p); + "(delta_m=%d delta_p=%d)", + delta_cells, delta_m, delta_p); /* Loop over each cell in the space. */ for (int i = 0; i < cdim[0]; i++) { @@ -390,9 +389,9 @@ void engine_makeproxies_with_zoom_region(struct engine *e) { /* What type of proxy do we need? * (proxy_cell_type_none if no proxy needed). */ int proxy_type = find_proxy_type( - ci, cj, e, - (abs(i - iii) <= 1 && abs(j - jjj) <= 1 && abs(k - kkk) <= 1), - 2 * r_max_bkg, dim, periodic); + ci, cj, e, + (abs(i - iii) <= 1 && abs(j - jjj) <= 1 && abs(k - kkk) <= 1), + 2 * r_max_bkg, dim, periodic); /* Abort if not in range at all */ if (proxy_type == proxy_cell_type_none) continue; @@ -434,10 +433,6 @@ void engine_makeproxies_with_zoom_region(struct engine *e) { /* Get the cell. */ struct cell *cj = &cells[cjd]; - /* Skip itself. */ - if (cj->subtype == void_cell) - continue; - /* Avoid completely local and foreign pairs */ if ((zoom_ci->nodeID == nodeID && cj->nodeID == nodeID) || (zoom_ci->nodeID != nodeID && cj->nodeID != nodeID)) @@ -445,10 +440,9 @@ void engine_makeproxies_with_zoom_region(struct engine *e) { /* What type of proxy do we need? * (proxy_cell_type_none if no proxy needed). */ - int proxy_type = find_proxy_type(zoom_ci, cj, e, - 0 /*is_adjacent*/, - r_max_zoom + r_max_bkg, - dim, periodic); + int proxy_type = + find_proxy_type(zoom_ci, cj, e, 0 /*is_adjacent*/, + r_max_zoom + r_max_bkg, dim, periodic); /* Abort if not in range at all */ if (proxy_type == proxy_cell_type_none) continue; @@ -471,8 +465,7 @@ void engine_makeproxies_with_zoom_region(struct engine *e) { struct cell *buff_ci = &cells[buff_cid]; /* Skip void cells. */ - if (buff_ci->subtype == void_cell) - continue; + if (buff_ci->subtype == void_cell) continue; /* Loop over all the background neighbours in range. */ for (int ii = -delta_m; ii <= delta_p; ii++) { @@ -494,10 +487,6 @@ void engine_makeproxies_with_zoom_region(struct engine *e) { /* Get the cell. */ struct cell *cj = &cells[cjd]; - /* Skip itself. */ - if (cj->subtype == empty) - continue; - /* Avoid completely local and foreign pairs */ if ((buff_ci->nodeID == nodeID && cj->nodeID == nodeID) || (buff_ci->nodeID != nodeID && cj->nodeID != nodeID)) @@ -505,10 +494,9 @@ void engine_makeproxies_with_zoom_region(struct engine *e) { /* What type of proxy do we need? * (proxy_cell_type_none if no proxy needed). */ - int proxy_type = find_proxy_type(buff_ci, cj, e, - 0 /*is_adjacent*/, - r_max_buff + r_max_bkg, - dim, periodic); + int proxy_type = + find_proxy_type(buff_ci, cj, e, 0 /*is_adjacent*/, + r_max_buff + r_max_bkg, dim, periodic); /* Abort if not in range at all */ if (proxy_type == proxy_cell_type_none) continue; @@ -554,7 +542,8 @@ void engine_makeproxies_with_zoom_region(struct engine *e) { if (e->verbose) message( "Looking for proxies up to %d top-level buffer cells away " - "(delta_m=%d delta_p=%d)", delta_cells, delta_m, delta_p); + "(delta_m=%d delta_p=%d)", + delta_cells, delta_m, delta_p); /* Loop over each cell in the space. */ for (int i = 0; i < cdim[0]; i++) { @@ -601,17 +590,17 @@ void engine_makeproxies_with_zoom_region(struct engine *e) { /* What type of proxy do we need? * (proxy_cell_type_none if no proxy needed). */ - int proxy_type = find_proxy_type( - ci, cj, e, - (abs(i - iii) <= 1 && abs(j - jjj) <= 1 && abs(k - kkk) <= 1), - 2 * r_max_buff, dim, periodic); + int proxy_type = + find_proxy_type(ci, cj, e, + (abs(i - iii) <= 1 && abs(j - jjj) <= 1 && + abs(k - kkk) <= 1), + 2 * r_max_buff, dim, periodic); /* Abort if not in range at all */ if (proxy_type == proxy_cell_type_none) continue; /* Make the proxies. */ add_proxy(ci, cj, e, proxies, nodeID, proxy_type); - } } } @@ -639,15 +628,12 @@ void engine_makeproxies_with_zoom_region(struct engine *e) { if (kkk < 0 || kkk >= cdim[2]) continue; /* Get the cell ID. */ - const int cjd = cell_getid(cdim, iii, jjj, kkk) + buff_offset; + const int cjd = + cell_getid(cdim, iii, jjj, kkk) + buff_offset; /* Get the cell. */ struct cell *cj = &cells[cjd]; - /* Skip itself. */ - if (cj->subtype == void_cell) - continue; - /* Avoid completely local and foreign pairs */ if ((zoom_ci->nodeID == nodeID && cj->nodeID == nodeID) || (zoom_ci->nodeID != nodeID && cj->nodeID != nodeID)) @@ -655,10 +641,9 @@ void engine_makeproxies_with_zoom_region(struct engine *e) { /* What type of proxy do we need? * (proxy_cell_type_none if no proxy needed). */ - int proxy_type = find_proxy_type(zoom_ci, cj, e, - 0 /*is_adjacent*/, - r_max_zoom + r_max_buff, - dim, periodic); + int proxy_type = + find_proxy_type(zoom_ci, cj, e, 0 /*is_adjacent*/, + r_max_zoom + r_max_buff, dim, periodic); /* Abort if not in range at all */ if (proxy_type == proxy_cell_type_none) continue; @@ -745,9 +730,9 @@ void engine_makeproxies_with_zoom_region(struct engine *e) { /* What type of proxy do we need? * (proxy_cell_type_none if no proxy needed). */ int proxy_type = find_proxy_type( - ci, cj, e, - (abs(i - iii) <= 1 && abs(j - jjj) <= 1 && abs(k - kkk) <= 1), - 2 * r_max_zoom, dim, periodic); + ci, cj, e, + (abs(i - iii) <= 1 && abs(j - jjj) <= 1 && abs(k - kkk) <= 1), + 2 * r_max_zoom, dim, periodic); /* Abort if not in range at all */ if (proxy_type == proxy_cell_type_none) continue; @@ -772,4 +757,3 @@ void engine_makeproxies_with_zoom_region(struct engine *e) { error("SWIFT was not compiled with MPI support."); #endif } -