-
Notifications
You must be signed in to change notification settings - Fork 250
Fix getbc not passing extra args for discrete BC functions #4816
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
base: main
Are you sure you want to change the base?
Changes from 5 commits
fcdecfb
9bbebb8
899aba5
f100b7e
5fc0ff0
027aa8f
099c081
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,21 +5,23 @@ A wrapper for boundary condition functions with optional parameters. | |
| When `parameters=nothing`, the boundary condition `func` is called with the signature | ||
|
|
||
| ``` | ||
| func(i, j, grid, clock, model_fields) | ||
| func(i, j, grid, clock, model_fields, args...) | ||
| ``` | ||
|
|
||
| where `i, j` are the indices along the boundary, | ||
| where `grid` is `model.grid`, `clock.time` is the current simulation time and | ||
| `clock.iteration` is the current model iteration, and | ||
| `model_fields` is a `NamedTuple` with `u, v, w`, the fields in `model.tracers`, | ||
| and the fields in `model.diffusivity_fields`, each of which is an `OffsetArray`s (or `NamedTuple`s | ||
| of `OffsetArray`s depending on the turbulence closure) of field data. | ||
| `grid` is `model.grid`, | ||
| `model_fields` is a `NamedTuple` with `u, v, w`, the fields in `model.tracers` or | ||
| the fields in `model.diffusivity_fields`, each of which is an `OffsetArray`s (or `NamedTuple`s | ||
| of `OffsetArray`s depending on the turbulence closure) of field data, | ||
| and `args` are any additional arguments passed to `getbc`. | ||
| Note also that `clock.time` is the current simulation time and `clock.iteration` is the current model | ||
| iteration. | ||
|
|
||
| When `parameters` is not `nothing`, the boundary condition `func` is called with | ||
| the signature | ||
|
|
||
| ``` | ||
| func(i, j, grid, clock, model_fields, parameters) | ||
| func(i, j, grid, clock, model_fields, parameters, args...) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wrt to the above comment, this docstring indeed would be misleading for any model that chooses to use arguments other than There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if such models are developed we may want to replace this with a comment that the function signature should refer to the model documentation. |
||
| ``` | ||
|
|
||
| *Note* that the index `end` does *not* access the final physical grid point of | ||
|
|
@@ -34,17 +36,17 @@ end | |
| const UnparameterizedDBF = DiscreteBoundaryFunction{<:Nothing} | ||
|
|
||
| @inline getbc(condition::UnparameterizedDBF, i::Integer, j::Integer, grid::AbstractGrid, clock, model_fields, args...) = | ||
| condition.func(i, j, grid, clock, model_fields) | ||
| condition.func(i, j, grid, clock, model_fields, args...) | ||
|
|
||
| @inline getbc(condition::DiscreteBoundaryFunction, i::Integer, j::Integer, grid::AbstractGrid, clock, model_fields, args...) = | ||
| condition.func(i, j, grid, clock, model_fields, condition.parameters) | ||
| condition.func(i, j, grid, clock, model_fields, condition.parameters, args...) | ||
|
|
||
| # 3D function for immersed boundary conditions | ||
| @inline getbc(condition::UnparameterizedDBF, i::Integer, j::Integer, k::Integer, grid::AbstractGrid, clock, model_fields, args...) = | ||
| condition.func(i, j, k, grid, clock, model_fields) | ||
| condition.func(i, j, k, grid, clock, model_fields, args...) | ||
|
|
||
| @inline getbc(condition::DiscreteBoundaryFunction, i::Integer, j::Integer, k::Integer, grid::AbstractGrid, clock, model_fields, args...) = | ||
| condition.func(i, j, k, grid, clock, model_fields, condition.parameters) | ||
| condition.func(i, j, k, grid, clock, model_fields, condition.parameters, args...) | ||
|
|
||
| # Don't re-convert DiscreteBoundaryFunctions passed to BoundaryCondition constructor | ||
| BoundaryCondition(Classification::DataType, condition::DiscreteBoundaryFunction) = BoundaryCondition(Classification(), condition) | ||
|
|
||
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 suggest keeping the original behavior so that future model developers can support more arguments?
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.
Unless we can articulate why removing this aspect of the code design is undesirable.
Uh oh!
There was an error while loading. Please reload this page.
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.
If we want this, we need to pass the args... to the continuous boundary function, which is not the original behavior. If we want to support more arguments, there is some structural work to be done on the
ContinuousBoundaryFunctionsto make sure that field dependencies do not conflict with the extra arguments passed to thegetbc.It might be easier to allow this only for a
DiscreteBoundaryFunction.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.
Here, we want to have a generic
args...so that a model implementation can pass additional arguments intofill_halo_regions!(which then are propagated intogetbc). However, havingargs...does not imply thatContinuousBoundaryFunctionhas to support interpreting it.ContinuousBoundaryFunctioncan have an interface which only utilizes the first two argumentsclock, model_fieldsand discards the rest. Then the extraargs...are only used byDiscreteBoundaryFunction.