Skip to content

Conversation

GitPaean
Copy link
Member

@GitPaean GitPaean commented Oct 9, 2025

A lot of code in the function getSurfaceVolume() and computeFluidProperties() are similar (probably started from the same) while became a little different with time.

In this PR, we put the common part of the two functions inside a third function calculatePhaseProperties() and reuse it.

And also, since the surface densities does not change, it is also put in a function while called once in the constructor instead of calling it again and again.

The function calculatePhaseProperties() is still long after the PR, which probably can be split to smaller functions.

@GitPaean GitPaean added the manual:irrelevant This PR is a minor fix and should not appear in the manual label Oct 9, 2025
@GitPaean
Copy link
Member Author

GitPaean commented Oct 9, 2025

jenkins build this please

@GitPaean GitPaean changed the title reducing code duplication in MultisegmentWellSegments [WIP] reducing code duplication in MultisegmentWellSegments Oct 9, 2025
@GitPaean GitPaean force-pushed the updating_segment_phase_dnesities_refactoring branch from 8ed1c13 to abba6dd Compare October 10, 2025 07:52
@GitPaean
Copy link
Member Author

jenkins build this please

@GitPaean GitPaean force-pushed the updating_segment_phase_dnesities_refactoring branch from 132d78a to 3ab2969 Compare October 10, 2025 12:31
@GitPaean GitPaean changed the title [WIP] reducing code duplication in MultisegmentWellSegments reducing code duplication in MultisegmentWellSegments Oct 10, 2025
@GitPaean GitPaean changed the title reducing code duplication in MultisegmentWellSegments reducing some code duplication in MultisegmentWellSegments Oct 10, 2025
@GitPaean GitPaean force-pushed the updating_segment_phase_dnesities_refactoring branch from 3ab2969 to de82a0b Compare October 10, 2025 12:32
by introducing the funciton computeFluidProperties() and
getSurfaceDensities().

And some small adjustment when working on the lines.

small adjustment

more small rewriting
@GitPaean
Copy link
Member Author

jenkins build this please

@GitPaean GitPaean marked this pull request as ready for review October 10, 2025 12:55
@GitPaean
Copy link
Member Author

I am marking the PR as ready for review to discuss.

@GitPaean GitPaean requested a review from bska October 10, 2025 12:56
@GitPaean GitPaean assigned akva2 and unassigned akva2 Oct 10, 2025
@GitPaean GitPaean requested a review from akva2 October 10, 2025 12:57
Copy link
Member

@bska bska left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't looked closely enough at the details to verify that this is in fact completely equivalent to the current master, but I'll assume it is for the purpose of this initial review. I really like the reduction in duplicated logic, so this is a marked improvement over the current master version. Moreover, it opens the path to further refactorings that would hopefully bring additional improvements to the readability.

Other than that, I have just one initial suggestion.

@GitPaean
Copy link
Member Author

GitPaean commented Oct 10, 2025

I haven't looked closely enough at the details to verify that this is in fact completely equivalent to the current master,

There are some small difference between the original functions getSurfaceVolume() and computeFluidProperties(), for example,

in the original getSurfaceVolume, we check the rvmax and rsmax below 0, while we did not do in the original computeFluidProperties(). Now we do it in the new function calculatePhaseProperties().

In the original getSurfaceVolume(), OpmLog::debug was used and the original computeFluidProperties() used DeferredLogger::debug(). Now we use DeferredLogger::debug() in the new function calculatePhaseProperties().

Basically, calculatePhaseProperties() unified some difference between the original functions getSurfaceVolume() and computeFluidProperties(). It changed some code slightly, while it should not cause issue.

Furthermore, when implementing calculatePhaseProperties(), I decided to clamp the rs and rv against 0.0, which should be fine.

And also, thanks for the suggestion for the private free function surfaceDensities(), I have updated the PR accordingly.

@GitPaean
Copy link
Member Author

jenkins build this please

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

manual:irrelevant This PR is a minor fix and should not appear in the manual

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants