Skip to content

Unable to use continuous function with ValueBoundaryCondition #4702

@bgroenks96

Description

@bgroenks96

Hi guys,

Thanks for all of your outstanding work on Oceananigans, really happy to be working with you :)

For unit testing in our land model, I would like to be able to apply a simple periodic upper boundary condition to the temperature field. I figured this would be possible with ValueBoundaryCondition(f) where f is the function. This works fine for FluxBoudnaryCondition, as indicated in the docs. However, with ValueBoundaryCondition, I get an error. Here is the MWE:

using Oceananigans
using Oceananigans.BoundaryConditions: FieldBoundaryConditions, ValueBoundaryCondition, NoFluxBoundaryCondition, fill_halo_regions!

f(x, z, t) = sin(2π*t)
bc = ValueBoundaryCondition(f)
grid = RectilinearGrid(CPU(), size=(1,10), x=(0,1), z=(0,1), topology=(Periodic,Flat,Bounded))
field_bc = FieldBoundaryConditions(grid, (Center, Center, Nothing), top=bc, bottom=NoFluxBoundaryCondition())
field = CenterField(grid, boundary_conditions=field_bc)
fill_halo_regions!(field)

Error:

ERROR: MethodError: objects of type Oceananigans.BoundaryConditions.ContinuousBoundaryFunction{Nothing, Nothing, Nothing, Nothing, typeof(f), Nothing, Tuple{}, Nothing, Nothing} are not callable
Stacktrace:
  [1] getbc
    @ ~/.julia/packages/Oceananigans/bKiml/src/BoundaryConditions/boundary_condition.jl:113 [inlined]
  [2] getbc
    @ ~/.julia/packages/Oceananigans/bKiml/src/BoundaryConditions/boundary_condition.jl:112 [inlined]
  [3] right_gradient
    @ ~/.julia/packages/Oceananigans/bKiml/src/BoundaryConditions/fill_halo_regions_value_gradient.jl:13 [inlined]

@glwagner mentioned that regularize_field_boundary_conditions might fix this, but it didn't seem to work when I tried it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions