Fixing warning#1044
Conversation
daavid00
commented
Jun 22, 2026
|
jenkins build this please |
| EdgeWeightType weWeight = 0; | ||
| for (int edge=0; edge<grid.numFaces(); ++edge) { | ||
| // assumes that transmissibility is positive (too obvious to leave an assert) | ||
| const auto& addend = graph.transmissibility(edge); |
There was a problem hiding this comment.
I am not sure how big these transmissibilities can get, but from the point of view of what is computed here, I think is better to do the whole computation on the original type which is always double and cast to the target type when using the value.
That has several advantages:
- Avoid explicit template instantiations for each used type which is more maintainable. This will avoid linker error if someone needs to cast to another type later on.
- On values that are very small for each edge,
doublewill have a better truncation than the currently used types which arefloatandint. Small values (e.g., 0.4 for integers) truncate to zero prematurely, which I'd imagine is not desirable. - The current implementation is this way because adding on a saturated integer wraps around (e.g., the correct form even made into the standard), which is would lead to errors. With a floating point type, saturation is automatic.
There was a problem hiding this comment.
The transmissibilities should not get big enough to reach the limit of float or int. In CombinedGridWellGraph the transmissibility is multiplied by 1e18 because of metis which operates on integers and values are shifted from decimals. Thus metis is at higher risk of reaching the limit but I would be very surprised if it happened.
There was a problem hiding this comment.
@michal-toth I see, the scaling makes sense for metis.
TBH, this looks a bit confusing to me. How I understand it, the scaled value is the edge weight, not a transmissibility. However, there is another method that computes the edgeWeight. Should't the transmissibility simply return whatever the transmissibility vector contains, and let the edgeWeight perform the actual scaling? Or is there an specific reason why not to use edgeWeight in this function? At least, that's what I would expect when reading this function documentation.
|
jenkins build this please |
|
jenkins build this please |