-
Notifications
You must be signed in to change notification settings - Fork 217
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
Fix BoundaryAdjacentMean
#4189
base: main
Are you sure you want to change the base?
Fix BoundaryAdjacentMean
#4189
Conversation
src/Models/boundary_mean.jl
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we call this boundary_adjacent_mean
to match the type name?
src/Models/boundary_mean.jl
Outdated
flux_field :: FF | ||
value :: BV | ||
struct BoundaryAdjacentMean{NI, BV} | ||
boundary_normal_integral :: NI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so the idea is that we compute an integral first and then divide by area to get the mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the type doesn't say anything about "normal" and I think this works on scalars right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good point, I guess boundary_parallel_integral
is more accurate? boundary normal integal is actually wrong
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think merely integral
is enough. The name of the type is "boundary adjacent mean". If we compute the mean by first taking the integral and dividing by area, then integral
combined with the name of the type give you what yo uneed to know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first rule is "do no harm"
import Oceananigans.BoundaryConditions: update_boundary_condition! | ||
|
||
""" | ||
BoundaryAdjacentMean |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the function signature is missing arguments
An = boundary_normal_area(val_side, grid) | ||
|
||
# get the total flux | ||
sum!(bam.boundary_parallel_integral, (@at (Face, Center, Center) u) * An) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few comments:
- It might be nicer to preform this operation --- that way users can look at it, and potentially verify its correctness.
- Why don't we use
Average
here? sum!
is incorrect if the grid is stretched, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean to return the operation and let the user do it?
I can't exactly remember how I ended up with this design but I think I did it this was so that we don't have to allocate a new average field (since you can't do in place averaging right?)
And I think sum is correct since it is multiplied by the area right?
new{NI, BV}(boundary_parallel_integral, value) | ||
end | ||
|
||
@inline (bam::BoundaryAdjacentMean)(args...) = bam.value[] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just noticed this. I would offer that this code is surprising and hard to understand.
I'm no longer sure that we need the type A disadvantage is that we need to use However, there are some significant advantages:
|
I think the reason I ended up with this was to avoid using |
Ok, so we have to decide which is best: adopt complication of |
Addresses concerns in #4183 and bug