Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove the exact integration in cube_to_target to avoid negative weights #6854

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jsbamboo
Copy link
Contributor

@jsbamboo jsbamboo commented Dec 16, 2024

This is to fix the negative weights in cube_to_target.

In the experience of using the cube_to_target for regionally refined meshes, we encountered issues with large negative values for terr_target. This generally happened when the dx of the target mesh was comparable/smaller than the dx of the base cube.

@PeterHjortLauritzen helped us to identify the underlying reasons for the negative weights and suggested a solution. The current practice is to keep the exact integration algorithm, but never enable it—

In remamp.F90 change:
    else if (abs(yseg(1) -yseg(2))<fuzzy_width) then
to
    else if (.false.) then

Since the original version of the judgement condition is rich in semantics, the original judgement was not deleted but annotated.

@mt5555 mt5555 requested a review from whannah1 December 16, 2024 23:59
@mt5555 mt5555 self-assigned this Dec 17, 2024
@mahf708 mahf708 linked an issue Dec 17, 2024 that may be closed by this pull request
@rljacob
Copy link
Member

rljacob commented Dec 17, 2024

Can you describe what the PR does without referring to other github issues?

@jsbamboo
Copy link
Contributor Author

@rljacob thanks for the suggestion, the description has been updated

@@ -850,7 +850,8 @@ subroutine side_integral(&

if (xseg(1).EQ.xseg(2))then
slope = bignum
else if (abs(yseg(1) -yseg(2))<fuzzy_width) then
!else if (abs(yseg(1) -yseg(2))<fuzzy_width) then !remove the exact integration
Copy link
Contributor

Choose a reason for hiding this comment

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

@jsbamboo let's change the wording on the comment on both of the commented lines to something more verbose and clear, I'm thinking:
"this will enable exact integration, which was found to create problematic negative weights"

A better solution would be to just add a logical switch controlled by a flag, but I'm fine with this solution as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks! will push a commit with the first solution

@rljacob
Copy link
Member

rljacob commented Jan 9, 2025

@mt5555 is this ready?

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

Successfully merging this pull request may close these issues.

negative weights in cube_to_target
4 participants