@@ -310,17 +310,29 @@ __global__ void buildPatchContactMapping(deme::bodyID_t* curr_idPatchA,
310310 // Note: encodeType preserves the order, so arrays are sorted by (A, B) lexicographically
311311 // For matching, we need to normalize to (min, max) since the same physical contact
312312 // could have different A/B ordering between timesteps
313- deme::bodyID_t curr_min = (curr_A < curr_B) ? curr_A : curr_B;
314- deme::bodyID_t curr_max = (curr_A < curr_B) ? curr_B : curr_A;
313+ deme::bodyID_t curr_min, curr_max;
314+ if (curr_A < curr_B) {
315+ curr_min = curr_A;
316+ curr_max = curr_B;
317+ } else {
318+ curr_min = curr_B;
319+ curr_max = curr_A;
320+ }
315321
316322 left = type_start;
317323 right = type_end;
318324 while (left < right) {
319325 size_t mid = left + (right - left) / 2 ;
320326 deme::bodyID_t prev_A = prev_idPatchA[mid];
321327 deme::bodyID_t prev_B = prev_idPatchB[mid];
322- deme::bodyID_t prev_min = (prev_A < prev_B) ? prev_A : prev_B;
323- deme::bodyID_t prev_max = (prev_A < prev_B) ? prev_B : prev_A;
328+ deme::bodyID_t prev_min, prev_max;
329+ if (prev_A < prev_B) {
330+ prev_min = prev_A;
331+ prev_max = prev_B;
332+ } else {
333+ prev_min = prev_B;
334+ prev_max = prev_A;
335+ }
324336
325337 // Compare (min, max) pairs lexicographically to find matching physical contact
326338 if (prev_min < curr_min || (prev_min == curr_min && prev_max < curr_max)) {
@@ -334,8 +346,14 @@ __global__ void buildPatchContactMapping(deme::bodyID_t* curr_idPatchA,
334346 if (left < type_end) {
335347 deme::bodyID_t prev_A = prev_idPatchA[left];
336348 deme::bodyID_t prev_B = prev_idPatchB[left];
337- deme::bodyID_t prev_min = (prev_A < prev_B) ? prev_A : prev_B;
338- deme::bodyID_t prev_max = (prev_A < prev_B) ? prev_B : prev_A;
349+ deme::bodyID_t prev_min, prev_max;
350+ if (prev_A < prev_B) {
351+ prev_min = prev_A;
352+ prev_max = prev_B;
353+ } else {
354+ prev_min = prev_B;
355+ prev_max = prev_A;
356+ }
339357 if (prev_min == curr_min && prev_max == curr_max) {
340358 my_partner = left;
341359 }
0 commit comments