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

Add support for SetDivergence to DivergenceF2C #1593

Merged
merged 1 commit into from
Jan 17, 2024
Merged

Conversation

dennisYatunin
Copy link
Member

This PR fixes a bug in ClimaAtmos related to the advection of precipitation.

Advection is implemented using the DivergenceF2C operator, and, at the bottom cell center, we need to enforce a zero-divergence boundary condition for precipitation. We initially implemented this using SetDivergence, but this is not supported for DivergenceF2C and was ignored due to the following fallback method in finitedifference.jl:

boundary_width(::DivergenceF2C, ::AbstractBoundaryCondition) = 0

This PR adds support for SetDivergence to DivergenceF2C, as well as its operator matrix. It also includes a new unit test for these additions.

  • Code follows the style guidelines OR N/A.
  • Unit tests are included OR N/A.
  • Code is exercised in an integration test OR N/A.
  • Documentation has been added/updated OR N/A.

@dennisYatunin
Copy link
Member Author

@simonbyrne Do you think it would be a good idea to get rid of the AbstractBoundaryCondition fallback methods for boundary_width in the future? They could potentially lead to more silent bugs like this if we keep them around.

@simonbyrne
Copy link
Member

@simonbyrne Do you think it would be a good idea to get rid of the AbstractBoundaryCondition fallback methods for boundary_width in the future? They could potentially lead to more silent bugs like this if we keep them around.

What's the bug?

@simonbyrne
Copy link
Member

Is it #1212?

@szy21
Copy link
Member

szy21 commented Jan 17, 2024

No, it's here: This line doesn't give an error when SetDivergence is not defined. It just ignores the boundary condition.

@dennisYatunin dennisYatunin merged commit 0577f72 into main Jan 17, 2024
16 checks passed
@dennisYatunin dennisYatunin deleted the dy/set_divergence branch January 17, 2024 18:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants