view src/SbpOperators/boundaryops/normal_derivative.jl @ 1354:150313ed2cae

Merge refactor/grids (missed delete of a note) Changes from previous merge: * `EquidistantGrid` is now only a 1D thing. * Higher dimensions are supported through `TensorGrid`. * The old behavior of `EquidistantGrid` has been moved to the function `equidistant_grid`. * Grids embedded in higher dimensions are now supported through tensor products with `ZeroDimGrid`s. * Vector valued grid functions are now supported and the default element type is `SVector`. * Grids are now expected to support Julia's indexing and iteration interface. * `eval_on` can be called with both `f(x,y,...)` and `f(x̄)`.
author Jonatan Werpers <jonatan@werpers.com>
date Sat, 20 May 2023 14:19:20 +0200
parents 08f06bfacd5c
children f4dc17cfafce
line wrap: on
line source

"""
    normal_derivative(g, stencil_set::StencilSet, boundary)
    normal_derivative(g::TensorGrid, stencil_set::StencilSet, boundary::TensorGridBoundary)
    normal_derivative(g::EquidistantGrid, stencil_set::StencilSet, boundary)

Creates the normal derivative boundary operator `d` as a `LazyTensor`

`d` computes the normal derivative at `boundary` of a grid function on `g` using the
'd1' stencil in `stencil_set`. `d'` is the prolongation of the normal
derivative of a grid function to the whole of `g` using the same stencil. On a
one-dimensional grid, `d` is a `BoundaryOperator`. On a multi-dimensional
grid, `d` is the inflation of a `BoundaryOperator`.

See also: [`BoundaryOperator`](@ref), [`LazyTensors.inflate`](@ref).
"""
function normal_derivative end


function normal_derivative(g::TensorGrid, stencil_set::StencilSet, boundary::TensorGridBoundary)
    op = normal_derivative(g.grids[grid_id(boundary)], stencil_set, boundary_id(boundary))
    return LazyTensors.inflate(op, size(g), grid_id(boundary))
end

function normal_derivative(g::EquidistantGrid, stencil_set::StencilSet, boundary)
    closure_stencil = parse_stencil(stencil_set["d1"]["closure"])
    h_inv = inverse_spacing(g)

    scaled_stencil = scale(closure_stencil,h_inv)
    return BoundaryOperator(g, scaled_stencil, boundary)
end