When sorting the hydro particles, only recurse if we need to.
4 unresolved threads
4 unresolved threads
@nnrw56 is that what you had in mind?
Merge request reports
Activity
933 933 /* Allocate memory for sorting. */ 934 934 cell_malloc_hydro_sorts(c, flags); 935 935 936 /* Does this cell have any progeny? */ 936 /* Shall we recurse to a lower level? */ 937 int recurse = 0; 937 938 if (c->split) { 939 for (int k = 0; k < 8; k++) { 933 933 /* Allocate memory for sorting. */ 934 934 cell_malloc_hydro_sorts(c, flags); 935 935 936 /* Does this cell have any progeny? */ 936 /* Shall we recurse to a lower level? */ 937 int recurse = 0; 937 938 if (c->split) { 939 for (int k = 0; k < 8; k++) { 940 941 const struct cell *cp = c->progeny[k]; 942 943 if (cp != NULL && cp->hydro.count > 0) { /* Are there any parts? */ 944 945 const int do_sub_sort = cell_get_flag(cp, cell_flag_do_hydro_sub_sort); 946 947 if (cp->hydro.requires_sorts || /* Do they need sorting? */ 937 938 if (c->split) { 939 for (int k = 0; k < 8; k++) { 940 941 const struct cell *cp = c->progeny[k]; 942 943 if (cp != NULL && cp->hydro.count > 0) { /* Are there any parts? */ 944 945 const int do_sub_sort = cell_get_flag(cp, cell_flag_do_hydro_sub_sort); 946 947 if (cp->hydro.requires_sorts || /* Do they need sorting? */ 948 (cp->hydro.do_sort | flags) || /* Are we forcing a sort? */ 949 do_sub_sort) { /* Do we want a sort at a lower level? */ 950 951 /* Ok, recurse */ 952 recurse = 1; 953 break; 935 935 936 /* Does this cell have any progeny? */ 936 /* Shall we recurse to a lower level? */ 937 int recurse = 0; 937 938 if (c->split) { 939 for (int k = 0; k < 8; k++) { 940 941 const struct cell *cp = c->progeny[k]; 942 943 if (cp != NULL && cp->hydro.count > 0) { /* Are there any parts? */ 944 945 const int do_sub_sort = cell_get_flag(cp, cell_flag_do_hydro_sub_sort); 946 947 if (cp->hydro.requires_sorts || /* Do they need sorting? */ 948 (cp->hydro.do_sort | flags) || /* Are we forcing a sort? */ 949 do_sub_sort) { /* Do we want a sort at a lower level? */ This looks right in spirit, but I'm not 100% sure about the details, mainly because it's probably been more than a year since I last touched this code...
IIRC,
do_hydro_sub_sort
propagates upwards, so if any cell sets it, so do all its parents. Would it be sufficient to just check for that flag? Or is there some use-case I'm missing?
Please register or sign in to reply