Skip to content

Add indefinite integral / antiderivative operator to Oceanostics #150

@tomchor

Description

@tomchor

I think Oceananigans doesn't have an indifinite integral operator, only definite integrals. Ideally we'd do it in a way that can be plugged into KernelFunctionOperator, but I suspect that this isn't possible to be the fact that you need to unroll loops. For example, here's a (downwards) buoyancy integration used to calculate the hydrostatic pressure in Ocenanigans:

https://github.com/CliMA/Oceananigans.jl/blob/fa5e280115f619d01a460f012328bd7e6d253b38/src/Models/NonhydrostaticModels/update_hydrostatic_pressure.jl#L4-L18

The basic form (assuming a direct integration of buoyancy) is something like:

@kernel function antiderivative!(B, grid, buoyancy)
    i, j = @index(Global, NTuple)

    @inbounds B[i, j, grid.Nz] = buoyancy[i, j, grid.Nz+1] * Δzᶜᶜᶠ(i, j, grid.Nz+1, grid)

    @unroll for k in grid.Nz-1 : -1 : 1
        @inbounds B[i, j, k] = B[i, j, k+1] - buoyancy[i, j, k+1] * Δzᶜᶜᶠ(i, j, k+1, grid)
    end
end

Not sure how to best implement this here, but it would be useful. Maybe it's easier to just do these calculations on the CPU?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions