You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Yeah it's ugly because I was trying to have some input sanitation before creating the boundary conditions struct but BoundaryConditions(:periodic, :periodic, :rigid_lid, :free_slip) would have conflicted with the default struct constructor.
There must be some way of doing this nicely but I don't know enough Julia right now...
Should be a perfect example of a inner constructor (which I really only recommend for input sanitization and invariants checking).
struct BoundaryConditions
x_bc::Symbol
y_bc::Symbol
top_bc::Symbol
bottom_bc::Symbol
function BoundaryConditions(x_bc, y_bc, top_bc, bottom_bc)
@assert x_bc == :periodic && y_bc == :periodic "Only periodic horizontal boundary conditions are currently supported."
@assert top_bc == :rigid_lid "Only rigid lid is currently supported at the top."
@assert bottom_bc in [:no_slip, :free_slip] "Bottom boundary condition must be :no_slip or :free_slip."
new(x_bc, y_bc, top_bc, bottom_bc)
end
end
Instead of Symbols you can also use @enum, but that is a stylistic choice.
@ali-ramadhan should this line
https://github.com/ali-ramadhan/Oceananigans.jl/blob/master/src/model.jl#L25
be
boundary_conditions = _BoundaryConditions(:periodic, :periodic, :rigid_lid, :free_slip)
instead of
boundary_conditions = BoundaryConditions(:periodic, :periodic, :rigid_lid, :free_slip)
?
The text was updated successfully, but these errors were encountered: