Unfortunately I don't think there's any way to get around a compare and branch for each of them in the no wall, no reduction case, but nesting the reduce check inside the wall check at least reduces it to one if has_wall == true.  There might be a way to turn this into an algebraic expression like I suggested with this_diffusivity, but I'm not sure if it would be noticeably faster, and it would certainly be less readable.